Search in sources :

Example 71 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.

the class JobScriptsExportWizardPage method getProcessItem.

protected ProcessItem getProcessItem() {
    if ((processItem == null) && (nodes != null) && (nodes.length >= 1)) {
        IRepositoryViewObject repositoryObject = nodes[0].getObject();
        // add for bug TDI-20132
        List<IRepositoryNode> nodesChildren = nodes[0].getChildren();
        IRepositoryViewObject childObject = null;
        if ((nodesChildren != null) && (nodesChildren.size() >= 1)) {
            childObject = nodesChildren.get(0).getObject();
        }
        if (repositoryObject == null && childObject != null && childObject.getProperty().getItem() instanceof ProcessItem) {
            processItem = (ProcessItem) childObject.getProperty().getItem();
        }
        if (repositoryObject != null && repositoryObject.getProperty().getItem() instanceof ProcessItem) {
            processItem = (ProcessItem) repositoryObject.getProperty().getItem();
        } else if (repositoryObject != null && repositoryObject.getProperty().getItem() instanceof FolderItem) {
            processItem = getProcessItemIfSelectFolder(repositoryObject);
        }
    }
    return processItem;
}
Also used : FolderItem(org.talend.core.model.properties.FolderItem) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 72 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class JavaCamelJobScriptsExportWSAction method getJobRepositoryNode.

private static IRepositoryNode getJobRepositoryNode(String jobId, ERepositoryObjectType type) throws PersistenceException {
    List<IRepositoryViewObject> list = new ArrayList<>();
    List<Project> projects = ProjectManager.getInstance().getAllReferencedProjects();
    for (Project p : projects) {
        list.addAll(ProxyRepositoryFactory.getInstance().getAll(p, type));
    }
    list.addAll(ProxyRepositoryFactory.getInstance().getAll(type));
    for (IRepositoryViewObject job : list) {
        if (job.getId().equals(jobId)) {
            return new RepositoryNode(job, null, ENodeType.REPOSITORY_ELEMENT);
        }
    }
    return null;
}
Also used : Project(org.talend.core.model.general.Project) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 73 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class JavaCamelJobScriptsExportWSAction method exportAllReferenceJobs.

private void exportAllReferenceJobs(String routeName, ProcessItem routeProcess) throws InvocationTargetException, InterruptedException {
    for (NodeType cTalendJob : EmfModelUtils.getComponentsByName(routeProcess, "cTalendJob")) {
        //$NON-NLS-1$
        String jobId = null;
        String jobVersion = null;
        String jobContext = null;
        for (Object o : cTalendJob.getElementParameter()) {
            if (!(o instanceof ElementParameterType)) {
                continue;
            }
            ElementParameterType ept = (ElementParameterType) o;
            String eptName = ept.getName();
            if ("FROM_EXTERNAL_JAR".equals(eptName) && "true".equals(ept.getValue())) {
                //$NON-NLS-1$
                break;
            }
            if ("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS".equals(eptName)) {
                //$NON-NLS-1$
                jobId = ept.getValue();
            } else if ("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION".equals(eptName)) {
                //$NON-NLS-1$
                jobVersion = ept.getValue();
            } else if ("SELECTED_JOB_NAME:PROCESS_TYPE_CONTEXT".equals(eptName)) {
                //$NON-NLS-1$
                jobContext = ept.getValue();
            }
        }
        if (jobId == null || jobVersion == null) {
            continue;
        }
        IRepositoryNode referencedJobNode;
        try {
            referencedJobNode = getJobRepositoryNode(jobId, ERepositoryObjectType.PROCESS);
        } catch (PersistenceException e) {
            throw new InvocationTargetException(e);
        }
        if (RelationshipItemBuilder.LATEST_VERSION.equals(jobVersion)) {
            jobVersion = referencedJobNode.getObject().getVersion();
        }
        String jobName = referencedJobNode.getObject().getProperty().getDisplayName();
        String jobBundleName = routeName + "_" + jobName;
        String jobBundleSymbolicName = jobBundleName;
        Project project = ProjectManager.getInstance().getCurrentProject();
        if (project != null) {
            String projectName = project.getLabel();
            if (projectName != null && projectName.length() > 0) {
                jobBundleSymbolicName = projectName.toLowerCase() + '.' + jobBundleSymbolicName;
            }
        }
        File jobFile;
        try {
            jobFile = File.createTempFile("job", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
            new File(getTempDir()));
        } catch (IOException e) {
            throw new InvocationTargetException(e);
        }
        String jobArtifactVersion = getArtifactVersion();
        String jobBundleVersion = bundleVersion;
        BundleModel jobModel = new BundleModel(getGroupId(), jobBundleName, jobArtifactVersion, jobFile);
        if (featuresModel.addBundle(jobModel)) {
            exportRouteUsedJobBundle(referencedJobNode, jobFile, jobVersion, jobBundleName, jobBundleSymbolicName, jobBundleVersion, getArtifactId(), version, jobContext);
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Project(org.talend.core.model.general.Project) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) CamelRepositoryNodeType(org.talend.camel.model.CamelRepositoryNodeType) PersistenceException(org.talend.commons.exception.PersistenceException) BundleModel(org.talend.designer.publish.core.models.BundleModel) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IOException(java.io.IOException) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

IRepositoryNode (org.talend.repository.model.IRepositoryNode)73 RepositoryNode (org.talend.repository.model.RepositoryNode)24 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)13 PersistenceException (org.talend.commons.exception.PersistenceException)13 ArrayList (java.util.ArrayList)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 WizardDialog (org.eclipse.jface.wizard.WizardDialog)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorPart (org.eclipse.ui.IEditorPart)8 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)8 ISelection (org.eclipse.jface.viewers.ISelection)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)6 ProcessItem (org.talend.core.model.properties.ProcessItem)6 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)6 IPath (org.eclipse.core.runtime.IPath)5 PartInitException (org.eclipse.ui.PartInitException)5 Item (org.talend.core.model.properties.Item)5