Search in sources :

Example 86 with NodeType

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

the class RenametParseXMLRowTotExtractXMLFieldMigrationTask method execute.

public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() == ECodeLanguage.JAVA && processType != null) {
        try {
            //$NON-NLS-1$
            IComponentFilter filter1 = new NameComponentFilter("tParseXMLRow");
            IComponentConversion changeNodeNameConversion = new IComponentConversion() {

                public void transform(NodeType node) {
                    ProcessType item = (ProcessType) node.eContainer();
                    for (Object o : item.getNode()) {
                        NodeType nt = (NodeType) o;
                        for (Object o1 : nt.getElementParameter()) {
                            ElementParameterType t = (ElementParameterType) o1;
                            String value = t.getValue();
                            if (value != null) {
                                if (value.contains("tParseXMLRow")) {
                                    //$NON-NLS-1$
                                    //$NON-NLS-1$ //$NON-NLS-2$
                                    String replaceAll = value.replaceAll("tParseXMLRow", "tExtractXMLField");
                                    t.setValue(replaceAll);
                                }
                            }
                        }
                    }
                }
            };
            // bug 22125
            ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(new RenameComponentConversion("tExtractXMLField")));
            return ExecutionResult.SUCCESS_WITH_ALERT;
        } catch (Exception e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    } else {
        return ExecutionResult.NOTHING_TO_DO;
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) RenameComponentConversion(org.talend.core.model.components.conversions.RenameComponentConversion) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 87 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 useSL = 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;
            useSL |= // $NON-NLS-1$
            EmfModelUtils.computeCheckElementValue("ENABLE_SL", node) || EmfModelUtils.computeCheckElementValue("SERVICE_LOCATOR", node);
            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("useSL", useSL);
    // $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 88 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 IRepositoryViewObject referencedRouteletNode;
            try {
                referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType);
            // getRouteletRepositoryNode(routeletId);
            } catch (PersistenceException e) {
                throw new InvocationTargetException(e);
            }
            final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.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.getVersion();
            }
            final File routeletFile;
            try {
                routeletFile = // $NON-NLS-1$
                File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, new File(getTempDir()));
                addBuildArtifact(referencedRouteletNode, "jar", routeletFile);
            } catch (IOException e) {
                throw new InvocationTargetException(e);
            }
            String routeletName = referencedRouteletNode.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;
                }
            }
            String routeletModelVersion = PomIdsHelper.getJobVersion(referencedRouteletNode.getProperty());
            String routeletModelGroupId = PomIdsHelper.getJobGroupId(referencedRouteletNode.getProperty());
            List<ProjectReference> projectReferenceList = project.getProjectReferenceList();
            // TESB-27979, if routelet is in the same project with route
            boolean inMainProject = ProjectManager.getInstance().isInMainProject(project, routeletProcess);
            // Use same Version and GroupId for routelet from route(TESB-27437, TESB-26578, TESB-22521)
            if (projectReferenceList.size() == 0 || CommonUIPlugin.isFullyHeadless() || inMainProject) {
                routeletModelVersion = getArtifactVersion();
                routeletModelGroupId = getGroupId();
            } else {
                if (StringUtils.endsWith(PomIdsHelper.getJobVersion(routeProcess.getProperty()), MavenUrlHelper.VERSION_SNAPSHOT)) {
                    routeletModelVersion = StringUtils.endsWith(routeletModelVersion, MavenUrlHelper.VERSION_SNAPSHOT) ? routeletModelVersion : routeletModelVersion + "-" + MavenUrlHelper.VERSION_SNAPSHOT;
                    ILibraryManagerService localLibraryManager = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
                    Dependency d = new Dependency();
                    d.setArtifactId(routeletBundleName);
                    d.setGroupId(routeletModelGroupId);
                    d.setVersion(routeletModelVersion);
                    localLibraryManager.deploy(routeletFile.toURI(), PomUtil.generateMvnUrl(d), new NullProgressMonitor());
                }
            }
            BundleModel routeletModel = new BundleModel(routeletModelGroupId, routeletBundleName, routeletModelVersion, routeletFile);
            if (featuresModel.addBundle(routeletModel)) {
                String routeletBundleVersion = getArtifactVersion();
                routeletBundleVersion = routeletBundleVersion.replace("-", ".");
                exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, routeletBundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue());
                CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel);
                exportAllReferenceJobs(routeName, routeletProcess);
                exportAllReferenceRoutelets(routeName, routeletProcess, routelets);
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProjectReference(org.talend.core.model.properties.ProjectReference) BundleModel(org.talend.designer.publish.core.models.BundleModel) IOException(java.io.IOException) Dependency(org.apache.maven.model.Dependency) InvocationTargetException(java.lang.reflect.InvocationTargetException) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Project(org.talend.core.model.general.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) ILibraryManagerService(org.talend.core.ILibraryManagerService) ProcessItem(org.talend.core.model.properties.ProcessItem) CamelRepositoryNodeType(org.talend.camel.model.CamelRepositoryNodeType) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Collection(java.util.Collection) File(java.io.File)

Example 89 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 || pi.getProcess() == 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 90 with NodeType

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

the class ConsumerFaultResponseMigrationTask method addMoreFaultResponseMessage.

private void addMoreFaultResponseMessage(Item item) throws PersistenceException {
    if (item instanceof ProcessItem) {
        ProcessType processType = ((ProcessItem) item).getProcess();
        for (Object o : processType.getNode()) {
            if (o instanceof NodeType) {
                NodeType currentNode = (NodeType) o;
                if ("tESBConsumer".equals(currentNode.getComponentName())) {
                    Iterator<?> iterator = currentNode.getMetadata().iterator();
                    while (iterator.hasNext()) {
                        MetadataType metadataType = (MetadataType) iterator.next();
                        if ("FAULT".equals(metadataType.getConnector())) {
                            EList<?> column = metadataType.getColumn();
                            addColumn(column, faultActor);
                            addColumn(column, faultCode);
                            addColumn(column, faultNode);
                            addColumn(column, faultRole);
                        }
                    }
                }
            }
        }
        FACTORY.save(item, true);
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProcessItem(org.talend.core.model.properties.ProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType)

Aggregations

NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)198 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)157 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)127 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)112 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)111 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)110 PersistenceException (org.talend.commons.exception.PersistenceException)93 ProcessItem (org.talend.core.model.properties.ProcessItem)25 ArrayList (java.util.ArrayList)24 EList (org.eclipse.emf.common.util.EList)23 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)21 List (java.util.List)20 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)19 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)18 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 IComponent (org.talend.core.model.components.IComponent)10 ColumnType (org.talend.designer.core.model.utils.emf.talendfile.ColumnType)9 Property (org.talend.core.model.properties.Property)8