Search in sources :

Example 76 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tesb-studio-se by Talend.

the class JavaCamelJobScriptsExportWSAction method exportAllReferenceRoutelets.

@SuppressWarnings("unchecked")
protected final void exportAllReferenceRoutelets(String routeName, ProcessItem routeProcess, Set<String> routelets) throws InvocationTargetException, InterruptedException {
    for (NodeType node : (Collection<NodeType>) routeProcess.getProcess().getNode()) {
        if (!EmfModelUtils.isComponentActive(node)) {
            continue;
        }
        final ElementParameterType routeletId = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_PROCESS.getName(), node);
        if (null != routeletId) {
            final IRepositoryNode referencedRouteletNode;
            try {
                referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType);
            // getRouteletRepositoryNode(routeletId);
            } catch (PersistenceException e) {
                throw new InvocationTargetException(e);
            }
            final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.getObject().getProperty().getItem();
            final String className = RouteJavaScriptOSGIForESBManager.getClassName(routeletProcess);
            String idSuffix = "-" + routeName;
            if (!routelets.add(className + idSuffix)) {
                continue;
            }
            String routeletVersion = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_VERSION.getName(), node).getValue();
            if (RelationshipItemBuilder.LATEST_VERSION.equals(routeletVersion)) {
                routeletVersion = referencedRouteletNode.getObject().getVersion();
            }
            final File routeletFile;
            try {
                routeletFile = File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
                new File(getTempDir()));
            } catch (IOException e) {
                throw new InvocationTargetException(e);
            }
            String routeletName = referencedRouteletNode.getObject().getLabel();
            String routeletBundleName = routeName + "_" + routeletName;
            String routeletBundleSymbolicName = routeletBundleName;
            Project project = ProjectManager.getInstance().getCurrentProject();
            if (project != null) {
                String projectName = project.getLabel();
                if (projectName != null && projectName.length() > 0) {
                    routeletBundleSymbolicName = projectName.toLowerCase() + '.' + routeletBundleSymbolicName;
                }
            }
            BundleModel routeletModel = new BundleModel(getGroupId(), routeletBundleName, getArtifactVersion(), routeletFile);
            if (featuresModel.addBundle(routeletModel)) {
                exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, bundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue());
                CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel);
                exportAllReferenceRoutelets(routeName, routeletProcess, routelets);
            }
        }
    }
}
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) ProcessItem(org.talend.core.model.properties.ProcessItem) 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) Collection(java.util.Collection) IOException(java.io.IOException) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 77 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tesb-studio-se by Talend.

the class JavaCamelJobScriptsExportWithMavenAction method getReferenceRoutlets.

private Collection<String> getReferenceRoutlets() {
    ProcessItem routeProcess = (ProcessItem) routeNode.getObject().getProperty().getItem();
    String routeName = routeNode.getObject().getProperty().getDisplayName();
    Set<String> routelets = new HashSet<>();
    try {
        exportAllReferenceRoutelets(routeName, routeProcess, routelets);
    } catch (InvocationTargetException e) {
        return new HashSet<>();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    return routelets;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) InvocationTargetException(java.lang.reflect.InvocationTargetException) HashSet(java.util.HashSet)

Example 78 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tesb-studio-se by Talend.

the class LocalESBRunContainerServiceTest method testCreateJavaProcessor.

/**
     * Test method for
     * {@link org.talend.designer.esb.runcontainer.core.LocalESBRunContainerService#createJavaProcessor(org.talend.core.model.process.IProcess, Property, boolean)}
     */
@Test
public void testCreateJavaProcessor() {
    IESBRunContainerService service = (IESBRunContainerService) GlobalServiceRegister.getDefault().getService(IESBRunContainerService.class);
    String[] esbComponents = { "tESBProviderRequest", "tRESTClient", "tRESTRequest", "tRESTResponse", "tESBConsumer", "tESBProviderFault", "tESBProviderRequest", "tESBProviderResponse" };
    for (String esbComponent : esbComponents) {
        Property property = PropertiesFactory.eINSTANCE.createProperty();
        property.setVersion("0.1");
        property.setId("property1");
        property.setLabel("ESBArtifact");
        ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
        processItem.setProperty(property);
        property.setItem(processItem);
        ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
        processItem.setProcess(process);
        NodeType node = TalendFileFactory.eINSTANCE.createNodeType();
        process.getNode().add(node);
        node.setComponentName(esbComponent);
        IComponent tESBComponent = ComponentsFactoryProvider.getInstance().get(esbComponent, ComponentCategory.CATEGORY_4_DI.getName());
        Process esbJob = new Process(property);
        Node tESBComponent_1 = new Node(tESBComponent, esbJob);
        esbJob.addNodeContainer(new NodeContainer(tESBComponent_1));
        Assert.assertNotNull(service.createJavaProcessor(esbJob, property, false));
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IESBRunContainerService(org.talend.designer.runprocess.IESBRunContainerService) ProcessItem(org.talend.core.model.properties.ProcessItem) IComponent(org.talend.core.model.components.IComponent) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 79 with ProcessItem

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

the class ProcessController method updateContextList.

/**
     * 
     * ggu Comment method "updateContextList".
     * 
     * @param processParam
     */
private void updateContextList(IElementParameter processParam) {
    if (processParam == null || (processParam.getFieldType() != EParameterFieldType.PROCESS_TYPE && processParam.getFieldType() != EParameterFieldType.ROUTE_INPUT_PROCESS_TYPE)) {
        return;
    }
    // for context type
    List<String> contextNameList = new ArrayList<String>();
    List<String> contextValueList = new ArrayList<String>();
    // for version type
    List<String> versionNameList = new ArrayList<String>();
    List<String> versionValueList = new ArrayList<String>();
    versionNameList.add(ItemCacheManager.LATEST_VERSION);
    versionValueList.add(ItemCacheManager.LATEST_VERSION);
    IElementParameter jobNameParam = processParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
    // feature 19312
    Item item = null;
    StringBuffer labels = new StringBuffer("");
    List<IRepositoryViewObject> allVersion = new ArrayList<IRepositoryViewObject>();
    final String strJobId = (String) jobNameParam.getValue();
    String[] strJobIds = strJobId.split(ProcessController.COMMA);
    for (int i = 0; i < strJobIds.length; i++) {
        String id = strJobIds[i];
        if (StringUtils.isNotEmpty(id)) {
            allVersion = ProcessorUtilities.getAllVersionObjectById(id);
            // IRepositoryObject lastVersionObject = null;
            String label = null;
            if (allVersion != null) {
                String oldVersion = null;
                for (IRepositoryViewObject obj : allVersion) {
                    String version = obj.getVersion();
                    if (oldVersion == null) {
                        oldVersion = version;
                    }
                    if (VersionUtils.compareTo(version, oldVersion) >= 0) {
                        item = obj.getProperty().getItem();
                    // lastVersionObject = obj;
                    }
                    oldVersion = version;
                    versionNameList.add(version);
                    versionValueList.add(version);
                }
                label = item.getProperty().getLabel();
                if (i > 0) {
                    labels.append(ProcessController.COMMA);
                }
                labels.append(label);
            // IPath path = RepositoryNodeUtilities.getPath(lastVersionObject);
            // if (path != null) {
            // label = path.toString() + IPath.SEPARATOR + label;
            // }
            } else {
            // FIXME TUP-5524, don't set empty, keep the id value instead.
            // final String parentName = processParam.getName() + ":"; //$NON-NLS-1$
            // if (elem != null) {
            // // can be called in multi-thread, dispose method may be already called before executing this
            // method
            //elem.setPropertyValue(parentName + jobNameParam.getName(), ""); //$NON-NLS-1$
            // }
            }
        }
    }
    jobNameParam.setLabelFromRepository(labels.toString());
    // set default context
    String defalutValue = null;
    if (item != null && item instanceof ProcessItem) {
        for (Object o : ((ProcessItem) item).getProcess().getContext()) {
            if (o instanceof ContextType) {
                ContextType context = (ContextType) o;
                contextNameList.add(context.getName());
                contextValueList.add(context.getName());
            }
        }
        defalutValue = ((ProcessItem) item).getProcess().getDefaultContext();
    }
    setProcessTypeRelatedValues(processParam, contextNameList, contextValueList, EParameterName.PROCESS_TYPE_CONTEXT.getName(), defalutValue);
    setProcessTypeRelatedValues(processParam, versionNameList, versionValueList, EParameterName.PROCESS_TYPE_VERSION.getName(), null);
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 80 with ProcessItem

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

the class ImageController method createControl.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
     */
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
    // String fileName = (String) param.getValue();
    // IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
    // String filePath = service.getPathFileName(RepositoryConstants.IMG_DIRECTORY, fileName).toPortableString();
    boolean hasScreenshots = false;
    byte[] screenshot = null;
    if (param.getElement() instanceof INode && ((INode) param.getElement()).getExternalNode() != null) {
        String componentType = ((INode) param.getElement()).getComponent().getName();
        if ("tMap".equals(componentType)) {
            IProcess process = ((INode) param.getElement()).getProcess();
            if (process instanceof IProcess2) {
                IProcess2 processtmp = (IProcess2) process;
                Item item = processtmp.getProperty().getItem();
                if (item instanceof ProcessItem) {
                    ProcessItem processItem = (ProcessItem) item;
                    screenshot = (byte[]) processItem.getProcess().getScreenshots().get(((INode) param.getElement()).getUniqueName());
                    if (screenshot != null) {
                        hasScreenshots = true;
                    }
                } else if (item instanceof JobletProcessItem) {
                    JobletProcessItem jobletItem = (JobletProcessItem) item;
                    screenshot = (byte[]) jobletItem.getJobletProcess().getScreenshots().get(((INode) param.getElement()).getUniqueName());
                    if (screenshot != null) {
                        hasScreenshots = true;
                    }
                }
            }
        }
    }
    if (hasScreenshots) {
        ImageDescriptor imageDesc = ImageUtils.createImageFromData(screenshot);
        ((INode) param.getElement()).getExternalNode().setScreenshot(imageDesc);
        // ImageDescriptor imageDesc = ((INode) param.getElement()).getExternalNode().getScreenshot();
        // File fileOrFolder = new java.io.File(filePath);
        // if (!fileOrFolder.isFile() || !fileOrFolder.canRead()) {
        // return lastControl;
        // }
        final Composite compositeImage = new Composite(subComposite, SWT.BORDER);
        final Image image = imageDesc.createImage();
        addResourceDisposeListener(compositeImage, image);
        //$NON-NLS-1$
        CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName() + " :");
        FormData formDataLabel = new FormData();
        labelLabel.setVisible(true);
        if (numInRow != 1) {
            labelLabel.setAlignment(SWT.RIGHT);
        }
        if (lastControl != null) {
            formDataLabel.left = new FormAttachment(lastControl, 0);
        } else {
            formDataLabel.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
            formDataLabel.top = new FormAttachment(0, top);
        }
        labelLabel.setLayoutData(formDataLabel);
        compositeImage.setToolTipText(param.getDisplayName());
        Point size = new Point(image.getImageData().width, image.getImageData().height);
        FormData formData = new FormData((int) (size.x * 0.8), (int) (size.y * 0.8));
        formData.top = new FormAttachment(0, top);
        formData.left = new FormAttachment(labelLabel);
        ImageData data = image.getImageData();
        compositeImage.setLayoutData(formData);
        data = data.scaledTo((int) (size.x * 0.8), (int) (size.y * 0.8));
        Image im = new Image(image.getDevice(), data);
        compositeImage.setBackgroundImage(im);
        return compositeImage;
    } else {
        return lastControl;
    }
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) FormData(org.eclipse.swt.layout.FormData) INode(org.talend.core.model.process.INode) Composite(org.eclipse.swt.widgets.Composite) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ImageData(org.eclipse.swt.graphics.ImageData) IProcess2(org.talend.core.model.process.IProcess2) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IProcess(org.talend.core.model.process.IProcess) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

ProcessItem (org.talend.core.model.properties.ProcessItem)160 PersistenceException (org.talend.commons.exception.PersistenceException)49 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)49 ArrayList (java.util.ArrayList)44 Item (org.talend.core.model.properties.Item)40 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)37 Property (org.talend.core.model.properties.Property)30 IProcess2 (org.talend.core.model.process.IProcess2)24 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)24 IProcess (org.talend.core.model.process.IProcess)23 File (java.io.File)22 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)21 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)21 ExportFileResource (org.talend.repository.documentation.ExportFileResource)21 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)21 IOException (java.io.IOException)20 INode (org.talend.core.model.process.INode)20 List (java.util.List)19 EList (org.eclipse.emf.common.util.EList)19 ProcessorException (org.talend.designer.runprocess.ProcessorException)17