Search in sources :

Example 1 with BusinessProcessItem

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

the class ImportItemUtil method resetItemReference.

/**
     * 
     * cLi Comment method "resetItemReference".
     * 
     * resolve the encode some special character(bug 6252), maybe, It's not better to resolve this by manually.
     * 
     * such as, "[" is "%5B", "]" is "%5D", etc.
     */
@SuppressWarnings("unchecked")
private void resetItemReference(ItemRecord itemRecord, Resource resource) {
    Item item = itemRecord.getItem();
    EList<EObject> contents = resource.getContents();
    /*
         * ignore job. no need, because it can't be allowed input special char for name.
         */
    if (item instanceof ProcessItem) {
    // ((ProcessItem) item).setProcess((ProcessType) EcoreUtil.getObjectByType(contents,
    // TalendFilePackage.eINSTANCE
    // .getProcessType()));
    } else /*
         * ignore joblet. no need, because it can't be allowed input special char for name.
         */
    if (item instanceof JobletProcessItem) {
    // JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
    //
    // jobletProcessItem.setJobletProcess((JobletProcess) EcoreUtil.getObjectByType(contents,
    // JobletPackage.eINSTANCE
    // .getJobletProcess()));
    // jobletProcessItem
    // .setIcon((ByteArray) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getByteArray()));
    } else // connectionItem
    if (item instanceof ConnectionItem) {
        ((ConnectionItem) item).setConnection((Connection) EcoreUtil.getObjectByType(contents, ConnectionPackage.eINSTANCE.getConnection()));
    } else // context
    if (item instanceof ContextItem) {
        EList contexts = ((ContextItem) item).getContext();
        contexts.clear();
        contexts.addAll(EcoreUtil.getObjectsByType(contents, TalendFilePackage.eINSTANCE.getContextType()));
    } else // file
    if (item instanceof FileItem) {
        /*
             * ignore routine, no need, because it can't be allowed input special char for name.
             */
        if (item instanceof RoutineItem) {
            return;
        }
        FileItem fileItem = (FileItem) item;
        fileItem.setContent((ByteArray) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getByteArray()));
    } else // snippet
    if (item instanceof SnippetItem) {
        EList variables = ((SnippetItem) item).getVariables();
        variables.clear();
        variables.addAll(EcoreUtil.getObjectsByType(contents, PropertiesPackage.eINSTANCE.getSnippetVariable()));
    } else // link doc
    if (item instanceof LinkDocumentationItem) {
        ((LinkDocumentationItem) item).setLink((LinkType) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getLinkType()));
    } else // business
    if (item instanceof BusinessProcessItem) {
        BusinessProcessItem businessProcessItem = (BusinessProcessItem) item;
        businessProcessItem.setSemantic((BusinessProcess) EcoreUtil.getObjectByType(contents, BusinessPackage.eINSTANCE.getBusinessProcess()));
        businessProcessItem.setNotationHolder((NotationHolder) EcoreUtil.getObjectByType(contents, PropertiesPackage.eINSTANCE.getNotationHolder()));
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) LinkDocumentationItem(org.talend.core.model.properties.LinkDocumentationItem) RoutineItem(org.talend.core.model.properties.RoutineItem) NotationHolder(org.talend.core.model.properties.NotationHolder) ReferenceFileItem(org.talend.core.model.properties.ReferenceFileItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) SnippetItem(org.talend.core.model.properties.SnippetItem) Item(org.talend.core.model.properties.Item) LinkDocumentationItem(org.talend.core.model.properties.LinkDocumentationItem) FolderItem(org.talend.core.model.properties.FolderItem) RoutineItem(org.talend.core.model.properties.RoutineItem) TDQItem(org.talend.core.model.properties.TDQItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) FileItem(org.talend.core.model.properties.FileItem) ReferenceFileItem(org.talend.core.model.properties.ReferenceFileItem) FileItem(org.talend.core.model.properties.FileItem) SnippetItem(org.talend.core.model.properties.SnippetItem) EList(org.eclipse.emf.common.util.EList) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) InternalEObject(org.eclipse.emf.ecore.InternalEObject) EObject(org.eclipse.emf.ecore.EObject) BusinessProcess(org.talend.designer.business.model.business.BusinessProcess)

Example 2 with BusinessProcessItem

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

the class OpenExistVersionProcessWizard method getEditorInput.

protected RepositoryEditorInput getEditorInput(final Item item, final boolean readonly, final IWorkbenchPage page) throws SystemException {
    if (item instanceof ProcessItem) {
        ProcessItem processItem = (ProcessItem) item;
        return new ProcessEditorInput(processItem, true, false, readonly);
    } else if (item instanceof BusinessProcessItem) {
        BusinessProcessItem businessProcessItem = (BusinessProcessItem) item;
        IFile file = CorePlugin.getDefault().getDiagramModelService().getDiagramFileAndUpdateResource(page, businessProcessItem);
        return new RepositoryEditorInput(file, businessProcessItem);
    } else if (item instanceof RoutineItem) {
        final RoutineItem routineItem = (RoutineItem) item;
        final ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
        ITalendSynchronizer routineSynchronizer = codeGenService.createRoutineSynchronizer();
        ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        String lastVersion = factory.getLastVersion(routineItem.getProperty().getId()).getVersion();
        String curVersion = routineItem.getProperty().getVersion();
        routineSynchronizer.syncRoutine(routineItem, true, true);
        final IFile file;
        if (curVersion != null && curVersion.equals(lastVersion)) {
            file = routineSynchronizer.getFile(routineItem);
        } else {
            file = routineSynchronizer.getRoutinesFile(routineItem);
        }
        if (file != null) {
            return new RoutineEditorInput(file, routineItem);
        }
    } else if (item instanceof SQLPatternItem) {
        SQLPatternItem patternItem = (SQLPatternItem) item;
        final ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
        ISQLPatternSynchronizer SQLPatternSynchronizer = codeGenService.getSQLPatternSynchronizer();
        SQLPatternSynchronizer.syncSQLPattern(patternItem, true);
        IFile file = SQLPatternSynchronizer.getSQLPatternFile(patternItem);
        if (file != null) {
            return new RepositoryEditorInput(file, patternItem);
        }
    }
    return null;
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IFile(org.eclipse.core.resources.IFile) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ISQLPatternSynchronizer(org.talend.designer.codegen.ISQLPatternSynchronizer) RoutineItem(org.talend.core.model.properties.RoutineItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) RoutineEditorInput(org.talend.repository.ui.actions.routines.RoutineEditorInput) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem)

Example 3 with BusinessProcessItem

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

the class OpenDiagramAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    ISelection selection = getSelectedObject();
    if (selection == null) {
        return;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (obj instanceof RepositoryNode) {
        RepositoryNode repositoryNode = (RepositoryNode) obj;
        IRepositoryViewObject repositoryObject = repositoryNode.getObject();
        Property updatedProperty = null;
        if (repositoryObject instanceof RepositoryObject) {
            RepositoryViewObject abstractRepositoryObject = new RepositoryViewObject(repositoryObject.getProperty());
            updatedProperty = abstractRepositoryObject.getProperty();
        } else if (repositoryObject instanceof RepositoryViewObject) {
            updatedProperty = repositoryObject.getProperty();
        }
        if (updatedProperty != null) {
            BusinessProcessItem businessProcessItem = (BusinessProcessItem) updatedProperty.getItem();
            DiagramResourceManager diagramResourceManager = new DiagramResourceManager(getActivePage(), new NullProgressMonitor());
            IFile file = diagramResourceManager.createDiagramFile();
            diagramResourceManager.updateResource(businessProcessItem, file);
            IEditorPart part = diagramResourceManager.openEditor(businessProcessItem, file, false);
            if (part instanceof BusinessDiagramEditor) {
                ((BusinessDiagramEditor) part).setLastVersion(true);
            }
        // TDI-21143 : Studio repository view : remove all refresh call to repo view
        // IRepositoryView view = getViewPart();
        // if (view != null) {
        // view.refresh(repositoryNode);
        // }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) RepositoryObject(org.talend.core.model.repository.RepositoryObject) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) ISelection(org.eclipse.jface.viewers.ISelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 4 with BusinessProcessItem

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

the class ReadDiagramAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    if (repositoryNode == null && getSelection() != null) {
        Object firstElement = ((IStructuredSelection) getSelection()).getFirstElement();
        if (firstElement instanceof RepositoryNode) {
            repositoryNode = (RepositoryNode) firstElement;
        }
    }
    RepositoryNode node = repositoryNode;
    if (node != null) {
        IRepositoryViewObject repositoryObject = node.getObject();
        Property updatedProperty = repositoryObject.getProperty();
        if (updatedProperty != null) {
            BusinessProcessItem businessProcessItem = (BusinessProcessItem) updatedProperty.getItem();
            DiagramResourceManager diagramResourceManager = new DiagramResourceManager(getActivePage(), new NullProgressMonitor());
            IFile file = diagramResourceManager.createDiagramFile();
            diagramResourceManager.updateResource(businessProcessItem, file);
            IEditorPart part = diagramResourceManager.openEditor(businessProcessItem, file, true);
            if (part instanceof BusinessDiagramEditor) {
                ((BusinessDiagramEditor) part).setLastVersion(true);
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) Property(org.talend.core.model.properties.Property)

Example 5 with BusinessProcessItem

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

the class SaveAsBusinessModelAction method run.

@Override
public void run() {
    SaveAsBusinessModelWizard businessModelWizard = new SaveAsBusinessModelWizard(editorPart);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), businessModelWizard);
    if (dlg.open() == Window.OK) {
        try {
            BusinessProcessItem businessProcessItem = businessModelWizard.getBusinessProcessItem();
            IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(businessProcessItem.getProperty().getId(), false);
            // because step1, the fresh will unload the resource(EMF), so, assign a new one...
            businessProcessItem = (BusinessProcessItem) repositoryNode.getObject().getProperty().getItem();
            IWorkbenchPage page = getActivePage();
            DiagramResourceManager diagramResourceManager = new DiagramResourceManager(page, new NullProgressMonitor());
            IFile file = businessModelWizard.getTempFile();
            // Set readonly to false since created job will always be editable.
            RepositoryEditorInput newBusinessModelEditorInput = new RepositoryEditorInput(file, businessProcessItem);
            newBusinessModelEditorInput.setRepositoryNode(repositoryNode);
            // here really do the normal save as function
            IDocumentProvider provider = ((BusinessDiagramEditor) this.editorPart).getDocumentProvider();
            provider.aboutToChange(newBusinessModelEditorInput);
            provider.saveDocument(null, newBusinessModelEditorInput, provider.getDocument(this.editorPart.getEditorInput()), true);
            provider.changed(newBusinessModelEditorInput);
            // copy back from the *.business_diagram file to *.item file.
            // @see:BusinessDiagramEditor.doSave(IProgressMonitor progressMonitor)
            diagramResourceManager.updateFromResource(businessProcessItem, newBusinessModelEditorInput.getFile());
            // notice: here, must save it, save the item to disk, otherwise close the editor
            // without any modification, there won't save the
            // model again, so, will lost the graphic when reopen it.
            ProxyRepositoryFactory.getInstance().save(businessProcessItem);
            // close the old editor
            page.closeEditor(this.editorPart, false);
            // open the new editor, because at the same time, there will update the jobSetting/componentSetting view
            IEditorPart openEditor = page.openEditor(newBusinessModelEditorInput, BusinessDiagramEditor.ID, true);
        } catch (Exception e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Business model could not be saved" + " : " + e.getMessage());
            ExceptionHandler.process(e);
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) IEditorPart(org.eclipse.ui.IEditorPart) IDocumentProvider(org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)9 IFile (org.eclipse.core.resources.IFile)5 IEditorPart (org.eclipse.ui.IEditorPart)4 ProcessItem (org.talend.core.model.properties.ProcessItem)4 RoutineItem (org.talend.core.model.properties.RoutineItem)4 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 PartInitException (org.eclipse.ui.PartInitException)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 Item (org.talend.core.model.properties.Item)3 Property (org.talend.core.model.properties.Property)3 RepositoryEditorInput (org.talend.core.repository.ui.editor.RepositoryEditorInput)3 BusinessDiagramEditor (org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 IProject (org.eclipse.core.resources.IProject)2 EObject (org.eclipse.emf.ecore.EObject)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 LoginException (org.talend.commons.exception.LoginException)2 SystemException (org.talend.commons.exception.SystemException)2