Search in sources :

Example 96 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method dispose.

/**
     * The <code>MultiPageEditorPart</code> implementation of this <code>IWorkbenchPart</code> method disposes all
     * nested editors. Subclasses may extend.
     */
@Override
public void dispose() {
    getSite().setSelectionProvider(null);
    getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this);
    /* after the release of eclipse3.6,this parameter can't be null */
    // setInput(null);
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
    getSite().getWorkbenchWindow().getPartService().removePartListener(partListener);
    if (this.lockService != null) {
        this.lockService.unregister();
    }
    super.dispose();
    if (getProcess() != null && !getProcess().isReadOnly()) {
        if (isKeepPropertyLocked()) {
            return;
        }
        // Unlock the process :
        IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
        IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
        try {
            getProcess().getProperty().eAdapters().remove(dirtyListener);
            Property property = getProcess().getProperty();
            if (property.eResource() == null || property.getItem().eResource() == null) {
                property = repFactory.getUptodateProperty(property);
            }
            // fix for bug 12524 for db repository
            // property = repFactory.reload(property);
            JobletUtil jUtil = new JobletUtil();
            jUtil.makeSureUnlockJoblet(getProcess());
            Item item = getProcess().getProperty().getItem();
            boolean keep = jUtil.keepLockJoblet(item);
            if (keep) {
                repFactory.unlock(property.getItem());
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        } catch (LoginException e) {
            ExceptionHandler.process(e);
        }
    }
    if (processEditorInput != null) {
        processEditorInput.dispose();
        processEditorInput = null;
    }
    designerEditor = null;
    codeEditor = null;
    if (processor instanceof IJavaBreakpointListener) {
        JDIDebugModel.removeJavaBreakpointListener((IJavaBreakpointListener) processor);
    }
    processor = null;
    dirtyListener = null;
    NodeTransferDragSourceListener.getInstance().setEditPart(null);
}
Also used : JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IJavaBreakpointListener(org.eclipse.jdt.debug.core.IJavaBreakpointListener) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IRepositoryService(org.talend.repository.model.IRepositoryService) JobletUtil(org.talend.designer.core.ui.editor.jobletcontainer.JobletUtil)

Example 97 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class AbstractJobSettingsPage method saveProcess.

protected void saveProcess(IRepositoryViewObject object, boolean addContextModel, Map<String, Set<String>> contextVars, IProgressMonitor monitor) {
    Property property = object.getProperty();
    ProcessItem pItem = (ProcessItem) property.getItem();
    if (isOpenProcess(object)) {
        Process process = getProcess(openedProcessList, object);
        LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, getParameterName().getName(), Boolean.TRUE);
        exeCommand(process, command);
        //
        IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
        if (ptParam != null) {
            IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
            Object proValue = propertyElem.getValue();
            if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
                IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                String value = (String) repositoryElem.getValue();
                ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
                if (connectionItem != null) {
                    Connection connection = connectionItem.getConnection();
                    ChangeValuesFromRepository cmd = new ChangeValuesFromRepository(process, connection, addContextModel ? getRepositoryPropertyName() : getPropertyTypeName(), value);
                    cmd.ignoreContextMode(true);
                    exeCommand(process, cmd);
                }
            }
        }
        monitor.worked(100);
    } else {
        try {
            reloadFromProjectSetings(pItem, addContextModel, contextVars);
            factory.save(pItem);
            monitor.worked(100);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) LoadProjectSettingsCommand(org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) RepositoryToComponentProperty(org.talend.core.model.metadata.designerproperties.RepositoryToComponentProperty)

Example 98 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class AbstractJavaProcessor method run.

@Override
public Process run(String[] optionsParam, int statisticsPort, int tracePort, IProgressMonitor monitor, IProcessMessageManager processMessageManager) throws ProcessorException {
    if (isStandardJob()) {
        Property property = this.getProperty();
        if (property != null) {
            // use the same function with ExportModelJavaProcessor, but will do for maven
            ProcessItem processItem = (ProcessItem) property.getItem();
            if (isRunAsExport()) {
                // Step 1: Export job
                archive = buildExportZip(processItem, monitor);
                // Step 2: Deploy in local(Maybe just unpack)
                unzipFolder = unzipAndDeploy(process, archive);
                // Step 3: Run job from given folder.
                return execFrom(unzipFolder + File.separatorChar + process.getName(), Level.INFO, statisticsPort, tracePort, optionsParam);
            } else {
                // If we are not in an export mode, we still have to check whether jobs need to be re-archived or
                // not.
                String version = processItem.getProperty().getVersion();
                if (//$NON-NLS-1$
                !RelationshipItemBuilder.LATEST_VERSION.equals(version) && version != null && !"".equals(version) && !version.equals(processItem.getProperty().getVersion())) {
                    processItem = ItemCacheManager.getProcessItem(processItem.getProperty().getId(), version);
                }
                Set<ProcessItem> processItems = new HashSet<>();
                processItems.add(processItem);
                // We get the father job childs.
                Set<JobInfo> infos = ProcessorUtilities.getChildrenJobInfo(processItem);
                Iterator<JobInfo> infoIterator = infos.iterator();
                while (infoIterator.hasNext()) {
                    processItems.add(infoIterator.next().getProcessItem());
                }
                // We iterate over the job and its childs in order to re-archive them if needed.
                for (ProcessItem pi : processItems) {
                    BDJobReArchieveCreator bdRecreator = new BDJobReArchieveCreator(pi, processItem);
                    bdRecreator.create(new File(this.getTalendJavaProject().getTargetFolder().getLocation().toPortableString()), false);
                }
            }
        }
    }
    return super.run(optionsParam, statisticsPort, tracePort, monitor, processMessageManager);
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) JobInfo(org.talend.core.model.process.JobInfo) Property(org.talend.core.model.properties.Property) ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File) HashSet(java.util.HashSet) BDJobReArchieveCreator(org.talend.repository.ui.wizards.exportjob.scriptsmanager.BDJobReArchieveCreator)

Example 99 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class JavaCompilationParticipant method updateProblems.

/**
     * yzhang Comment method "updateProblems".
     */
private void updateProblems(List<IRepositoryViewObject> routineObjectList, String filePath) {
    IRunProcessService runProcessService = CorePlugin.getDefault().getRunProcessService();
    try {
        ITalendProcessJavaProject talendProcessJavaProject = runProcessService.getTalendProcessJavaProject();
        if (talendProcessJavaProject == null) {
            return;
        }
        final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        IProject javaProject = talendProcessJavaProject.getProject();
        IFile file = javaProject.getFile(filePath);
        String fileName = file.getName();
        for (IRepositoryViewObject repositoryObject : routineObjectList) {
            Property property = repositoryObject.getProperty();
            Item item = property.getItem();
            IFile currentFile = synchronizer.getFile(item);
            if (currentFile != null && fileName.equals(currentFile.getName()) && currentFile.exists()) {
                Problems.addRoutineFile(currentFile, property);
                break;
            }
        }
    } catch (SystemException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) Item(org.talend.core.model.properties.Item) IFile(org.eclipse.core.resources.IFile) SystemException(org.talend.commons.exception.SystemException) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IProject(org.eclipse.core.resources.IProject)

Example 100 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class JobTemplateViewsAndProcessUtil method getNewMockProperty.

private Property getNewMockProperty() {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    //$NON-NLS-1$
    property.setStatusCode("");
    //$NON-NLS-1$
    property.setId("ID");
    property.setLabel(DEFAULT_JOB_NAME);
    return property;
}
Also used : Property(org.talend.core.model.properties.Property)

Aggregations

Property (org.talend.core.model.properties.Property)147 PersistenceException (org.talend.commons.exception.PersistenceException)56 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)48 Item (org.talend.core.model.properties.Item)46 ProcessItem (org.talend.core.model.properties.ProcessItem)39 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)36 Node (org.talend.designer.core.ui.editor.nodes.Node)28 Process (org.talend.designer.core.ui.editor.process.Process)23 RepositoryNode (org.talend.repository.model.RepositoryNode)22 IElementParameter (org.talend.core.model.process.IElementParameter)21 ConnectionItem (org.talend.core.model.properties.ConnectionItem)21 IDynamicProperty (org.talend.core.ui.properties.tab.IDynamicProperty)21 ArrayList (java.util.ArrayList)20 Test (org.junit.Test)19 INode (org.talend.core.model.process.INode)19 IComponent (org.talend.core.model.components.IComponent)15 Connection (org.talend.core.model.metadata.builder.connection.Connection)14 IProcess2 (org.talend.core.model.process.IProcess2)14 List (java.util.List)12 IFile (org.eclipse.core.resources.IFile)12