Search in sources :

Example 21 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.

the class RouteJavaScriptOSGIForESBManager method collectRouteInfo.

private Map<String, Object> collectRouteInfo(ProcessItem processItem, IProcess process) {
    Map<String, Object> routeInfo = new HashMap<String, Object>();
    // route name and class name
    //$NON-NLS-1$
    routeInfo.put("name", processItem.getProperty().getLabel());
    String className = getClassName(processItem);
    String idName = className;
    String suffix = getOsgiServiceIdSuffix();
    if (suffix != null && suffix.length() > 0) {
        idName += suffix;
    }
    //$NON-NLS-1$
    routeInfo.put("className", className);
    //$NON-NLS-2$
    routeInfo.put("idName", idName);
    boolean useSAM = false;
    boolean hasCXFUsernameToken = false;
    boolean hasCXFSamlConsumer = false;
    boolean hasCXFSamlProvider = false;
    boolean hasCXFRSSamlProviderAuthz = false;
    Collection<NodeType> cSOAPs = EmfModelUtils.getComponentsByName(processItem, "cSOAP");
    boolean hasCXFComponent = !cSOAPs.isEmpty();
    cSOAPs.addAll(EmfModelUtils.getComponentsByName(processItem, "cREST"));
    if (!cSOAPs.isEmpty()) {
        Set<String> consumerNodes = new HashSet<String>();
        @SuppressWarnings("unchecked") List<ConnectionType> connections = processItem.getProcess().getConnection();
        for (ConnectionType conn : connections) {
            consumerNodes.add(conn.getTarget());
        }
        boolean isEEVersion = isStudioEEVersion();
        for (NodeType node : cSOAPs) {
            boolean nodeUseSAM = false;
            boolean nodeUseSaml = false;
            boolean nodeUseAuthz = false;
            boolean nodeUseRegistry = false;
            // http://jira.talendforge.org/browse/TESB-3850
            //$NON-NLS-1$
            String format = EmfModelUtils.computeTextElementValue("DATAFORMAT", node);
            if (!useSAM && !"RAW".equals(format)) {
                //$NON-NLS-1$
                nodeUseSAM = //$NON-NLS-1$
                EmfModelUtils.computeCheckElementValue("ENABLE_SAM", node) || //$NON-NLS-1$
                EmfModelUtils.computeCheckElementValue("SERVICE_ACTIVITY_MONITOR", node);
            }
            // security is disable in case CXF_MESSAGE or RAW dataFormat
            if (!"CXF_MESSAGE".equals(format) && !"RAW".equals(format)) {
                //$NON-NLS-1$  //$NON-NLS-2$
                if (isEEVersion && EmfModelUtils.computeCheckElementValue("ENABLE_REGISTRY", node)) {
                    //$NON-NLS-1$
                    nodeUseRegistry = true;
                    // https://jira.talendforge.org/browse/TESB-10725
                    nodeUseSAM = false;
                } else if (EmfModelUtils.computeCheckElementValue("ENABLE_SECURITY", node)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    String securityType = EmfModelUtils.computeTextElementValue("SECURITY_TYPE", node);
                    if ("USER".equals(securityType)) {
                        //$NON-NLS-1$
                        hasCXFUsernameToken = true;
                    } else if ("SAML".equals(securityType)) {
                        //$NON-NLS-1$
                        nodeUseSaml = true;
                        nodeUseAuthz = isEEVersion && EmfModelUtils.computeCheckElementValue("USE_AUTHORIZATION", node);
                    }
                }
            }
            useSAM |= nodeUseSAM;
            if (consumerNodes.contains(ElementParameterParser.getUNIQUENAME(node))) {
                hasCXFSamlConsumer |= nodeUseSaml | nodeUseRegistry;
            } else {
                hasCXFSamlProvider |= nodeUseSaml | nodeUseRegistry;
                hasCXFRSSamlProviderAuthz |= nodeUseAuthz;
            }
        }
    }
    //$NON-NLS-1$
    routeInfo.put("useSAM", useSAM);
    //$NON-NLS-1$
    routeInfo.put("hasCXFUsernameToken", hasCXFUsernameToken);
    //$NON-NLS-1$
    routeInfo.put("hasCXFSamlConsumer", hasCXFSamlConsumer);
    //$NON-NLS-1$
    routeInfo.put("hasCXFSamlProvider", hasCXFSamlProvider);
    //$NON-NLS-1$
    routeInfo.put("hasCXFRSSamlProviderAuthz", hasCXFRSSamlProviderAuthz && !hasCXFComponent);
    //$NON-NLS-1$
    routeInfo.put("hasCXFComponent", hasCXFComponent);
    // route OSGi DataSources
    //$NON-NLS-1$
    routeInfo.put("dataSources", DataSourceConfig.getAliases(process));
    //$NON-NLS-1$
    routeInfo.put("routelets", routelets);
    return routeInfo;
}
Also used : ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) HashMap(java.util.HashMap) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) HashSet(java.util.HashSet)

Example 22 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType 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 23 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.

the class CamelDesignerUtil method checkRouteInputExistInJob.

public static boolean checkRouteInputExistInJob(ProcessItem pi) {
    if (pi == null) {
        return false;
    }
    EList<?> nodes = pi.getProcess().getNode();
    Iterator<?> iterator = nodes.iterator();
    while (iterator.hasNext()) {
        Object next = iterator.next();
        if (!(next instanceof NodeType)) {
            continue;
        }
        NodeType nt = (NodeType) next;
        if (!EmfModelUtils.isComponentActive(nt) && !EmfModelUtils.computeCheckElementValue("ACTIVATE", nt)) {
            continue;
        }
        String componentName = nt.getComponentName();
        if ("tRouteInput".equals(componentName)) {
            return true;
        } else if (service != null) {
            ProcessType jobletProcess = service.getJobletProcess(nt);
            if (jobletProcess == null) {
                continue;
            }
            if (checkRouteInputExistInJoblet(jobletProcess)) {
                return true;
            }
        }
    }
    return false;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType)

Example 24 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType 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 25 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.

the class JobJavaScriptOSGIForESBManager method collectJobInfo.

private Map<String, Object> collectJobInfo(ProcessItem processItem, IProcess process) {
    // velocity template context
    Map<String, Object> jobInfo = new HashMap<String, Object>();
    String name = processItem.getProperty().getLabel();
    String className = getPackageName(processItem) + PACKAGE_SEPARATOR + name;
    boolean isTalendStepTemplate = isTalendStepTemplate(processItem);
    // job name and class name
    String jobName = name;
    if (!EmfModelUtils.getComponentsByName(processItem, "tRouteInput").isEmpty()) {
        //$NON-NLS-1$
        jobName = className;
    }
    jobInfo.put("name", jobName);
    //$NON-NLS-1$
    jobInfo.put("version", getBundleVersion());
    //$NON-NLS-1$
    jobInfo.put("className", className);
    // additional Talend job interfaces (ESB related)
    boolean isESBJob = isTalendESBJob(processItem);
    //$NON-NLS-1$
    jobInfo.put("isESBJob", isESBJob);
    //$NON-NLS-1$
    jobInfo.put("isESBJobFactory", isESBJob && isTalendESBJobFactory(processItem));
    //$NON-NLS-1$
    jobInfo.put("isTalendStepTemplate", isTalendStepTemplate);
    // job components use SAM / use SAML
    boolean useSAM = false;
    for (NodeType node : EmfModelUtils.getComponentsByName(processItem, "tRESTClient")) {
        //$NON-NLS-1$
        if (!useSAM && EmfModelUtils.computeCheckElementValue("SERVICE_ACTIVITY_MONITOR", node)) {
            //$NON-NLS-1$
            useSAM = true;
            break;
        }
    }
    //$NON-NLS-1$
    jobInfo.put("useSAM", useSAM);
    // job OSGi DataSources
    //$NON-NLS-1$
    jobInfo.put("dataSources", DataSourceConfig.getAliases(process));
    jobInfo.put("hasDestroyMethod", ERepositoryObjectType.PROCESS_MR != ERepositoryObjectType.getItemType(processItem));
    return jobInfo;
}
Also used : HashMap(java.util.HashMap) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)190 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)152 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)126 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)111 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)109 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)108 PersistenceException (org.talend.commons.exception.PersistenceException)91 ArrayList (java.util.ArrayList)24 EList (org.eclipse.emf.common.util.EList)23 ProcessItem (org.talend.core.model.properties.ProcessItem)21 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)21 List (java.util.List)20 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)18 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)17 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)13 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)13 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)13 ColumnType (org.talend.designer.core.model.utils.emf.talendfile.ColumnType)9 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)8 IOException (java.io.IOException)7