Search in sources :

Example 1 with RouteProcess

use of org.talend.camel.designer.ui.editor.RouteProcess in project tesb-studio-se by Talend.

the class CheckRouteBuilderNodeService method checkNode.

@Override
public void checkNode(Node node) {
    // TESB-7698
    IProcess process = node.getProcess();
    if (process == null || !(process instanceof RouteProcess)) {
        return;
    }
    // End TESB-7698
    checkIncomingConnections(node);
    checkSpecialComponent(node);
}
Also used : RouteProcess(org.talend.camel.designer.ui.editor.RouteProcess) IProcess(org.talend.core.model.process.IProcess)

Example 2 with RouteProcess

use of org.talend.camel.designer.ui.editor.RouteProcess in project tesb-studio-se by Talend.

the class RouteTestCaseBuildProviderTest method testCreatePomCreator.

/**
 * Test method for
 * {@link org.talend.camel.designer.build.RouteTestCaseBuildProvider#createPomCreator(java.util.Map)}.
 *
 * @throws Exception
 */
@Test
public void testCreatePomCreator() throws Exception {
    ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    String id = ProxyRepositoryFactory.getInstance().getNextId();
    property.setId(id);
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(false);
    itemState.setPath("");
    processItem.setState(itemState);
    processItem.setProperty(property);
    ProcessType processType = TalendFileFactory.eINSTANCE.createProcessType();
    processItem.setProcess(processType);
    property.setLabel("testRoute");
    property.setVersion("0.1");
    property.setItem(processItem);
    // $NON-NLS-1$ //$NON-NLS-2$
    IComponent component = ComponentsFactoryProvider.getInstance().get("cTimer", "CAMEL");
    RouteProcess process = new RouteProcess(property);
    process.setId("routeprocess");
    INode nodeTimer = new Node(component, process);
    nodeTimer.setLabel("cTimer_1");
    MavenJavaProcessor processor = new MavenJavaProcessor(process, property, true);
    processor.setContext(process.getContextManager().getDefaultContext());
    Project project = ProjectManager.getInstance().getCurrentProject();
    IProject fsProject = ResourceUtils.getProject(project);
    IPath path = new Path("poms").append("jobs").append("process").append(property.getLabel().concat("_").concat(property.getVersion()).toLowerCase()).append("temp");
    ResourceUtils.createFolder(fsProject.getFolder(path));
    path = path.append("pom.xml");
    IFile file = fsProject.getFile(path);
    String pomContent = "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n" + "  <modelVersion>4.0.0</modelVersion>\n" + "  <artifactId>esb.tooling.test</artifactId>\n" + "  <packaging>jar</packaging>\n" + "  <name>Test POM</name>\n" + "</project>";
    InputStream inputStream = new ByteArrayInputStream(pomContent.getBytes(StandardCharsets.UTF_8));
    file.delete(true, new NullProgressMonitor());
    file.create(inputStream, false, new NullProgressMonitor());
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(IBuildParametes.ITEM, processItem);
    parameters.put(IBuildPomCreatorParameters.PROCESSOR, processor);
    parameters.put(IBuildPomCreatorParameters.FILE_POM, file);
    parameters.put(IBuildPomCreatorParameters.OVERWRITE_POM, Boolean.TRUE);
    IMavenPomCreator creator = new RouteTestCaseBuildProvider().createPomCreator(parameters);
    creator.create(new NullProgressMonitor());
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RouteTestCaseBuildProvider(org.talend.camel.designer.build.RouteTestCaseBuildProvider) INode(org.talend.core.model.process.INode) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) IComponent(org.talend.core.model.components.IComponent) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IMavenPomCreator(org.talend.core.runtime.repository.build.IMavenPomCreator) IProject(org.eclipse.core.resources.IProject) IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) MavenJavaProcessor(org.talend.designer.runprocess.maven.MavenJavaProcessor) ProcessItem(org.talend.core.model.properties.ProcessItem) ByteArrayInputStream(java.io.ByteArrayInputStream) ItemState(org.talend.core.model.properties.ItemState) RouteProcess(org.talend.camel.designer.ui.editor.RouteProcess) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 3 with RouteProcess

use of org.talend.camel.designer.ui.editor.RouteProcess in project tesb-studio-se by Talend.

the class CreateMavenBundlePom method create.

/*
     * (non-Javadoc)
     *
     * @see org.talend.designer.maven.tools.creator.CreateMavenBundleTemplatePom#create(org.eclipse.core.runtime.
     * IProgressMonitor)
     */
@Override
public void create(IProgressMonitor monitor) throws Exception {
    IFile curPomFile = getPomFile();
    if (curPomFile == null) {
        return;
    }
    bundleModel = createModel();
    // patch for TESB-23953: find "tdm-lib-di-" and remove in route, only keep 'tdm-camel'
    boolean containsTdmCamelDependency = false;
    Dependency tdmDIDependency = null;
    Dependency logbackClassicDependency = null;
    Dependency logbackCoreDependency = null;
    List<Dependency> dependencies = bundleModel.getDependencies();
    for (int i = 0; i < dependencies.size(); i++) {
        String artifactId = dependencies.get(i).getArtifactId();
        if (artifactId.startsWith("tdm-lib-di-")) {
            tdmDIDependency = dependencies.get(i);
        }
        if (artifactId.startsWith("tdm-camel-")) {
            containsTdmCamelDependency = true;
        }
        if (artifactId.equals("logback-classic")) {
            logbackClassicDependency = dependencies.get(i);
        }
        if (artifactId.equals("logback-core")) {
            logbackCoreDependency = dependencies.get(i);
        }
    }
    if (containsTdmCamelDependency && tdmDIDependency != null) {
        bundleModel.getDependencies().remove(tdmDIDependency);
    }
    if (logbackClassicDependency != null) {
        bundleModel.getDependencies().remove(logbackClassicDependency);
    }
    if (logbackCoreDependency != null) {
        bundleModel.getDependencies().remove(logbackCoreDependency);
    }
    IContainer parent = curPomFile.getParent();
    Model pom = new Model();
    boolean route = "CAMEL".equals(getJobProcessor().getProcess().getComponentsType()) && ERepositoryObjectType.getType(getJobProcessor().getProperty()).equals(ERepositoryObjectType.PROCESS_ROUTE);
    Parent parentPom = new Parent();
    parentPom.setGroupId(bundleModel.getGroupId());
    parentPom.setArtifactId(bundleModel.getArtifactId() + "-Kar");
    parentPom.setVersion(bundleModel.getVersion());
    parentPom.setRelativePath("/");
    if (route) {
        RouteProcess routeProcess = (RouteProcess) getJobProcessor().getProcess();
        boolean publishAsSnapshot = BooleanUtils.toBoolean((String) routeProcess.getAdditionalProperties().get(MavenConstants.NAME_PUBLISH_AS_SNAPSHOT));
        File featurePom = new File(parent.getLocation().toOSString() + File.separator + "pom-feature.xml");
        Model featureModel = new Model();
        featureModel.setModelVersion("4.0.0");
        featureModel.setParent(parentPom);
        featureModel.setGroupId(bundleModel.getGroupId());
        featureModel.setArtifactId(bundleModel.getArtifactId() + "-feature");
        featureModel.setName(bundleModel.getName() + " Feature");
        featureModel.setVersion(bundleModel.getVersion());
        featureModel.setPackaging("pom");
        featureModel.setProperties(bundleModel.getProperties());
        featureModel.addProperty("cloud.publisher.skip", "false");
        Build featureModelBuild = new Build();
        featureModelBuild.addPlugin(addFeaturesMavenPlugin(bundleModel.getProperties().getProperty("talend.job.finalName")));
        featureModelBuild.addPlugin(addOsgiHelperMavenPlugin());
        // featureModelBuild.addPlugin(addDeployFeatureMavenPlugin(featureModel.getArtifactId(), featureModel.getVersion(), publishAsSnapshot));
        // featureModelBuild.addPlugin(addSkipDeployFeatureMavenPlugin());
        featureModelBuild.addPlugin(addSkipMavenCleanPlugin());
        featureModelBuild.addPlugin(addSkipDockerMavenPlugin());
        featureModel.setBuild(featureModelBuild);
        // featureModel.addProfile(addProfileForNexus(publishAsSnapshot, featureModel));
        PomUtil.savePom(monitor, featureModel, featurePom);
    }
    pom.setModelVersion("4.0.0");
    pom.setParent(bundleModel.getParent());
    pom.setGroupId(bundleModel.getGroupId());
    pom.setArtifactId(bundleModel.getArtifactId() + "-Kar");
    pom.setName(bundleModel.getName() + " Kar");
    pom.setVersion(bundleModel.getVersion());
    pom.setPackaging("pom");
    pom.addModule("pom-bundle.xml");
    if (route) {
        pom.addModule("pom-feature.xml");
    }
    pom.setDependencies(bundleModel.getDependencies());
    if (pom.getBuild() == null) {
        pom.setBuild(new Build());
    }
    pom.addProfile(addProfileForCloud());
    File pomBundle = new File(parent.getLocation().toOSString() + File.separator + "pom-bundle.xml");
    bundleModel.addProperty(JOB_FINAL_NAME, "${talend.job.name}-${project.version}");
    bundleModel.addProperty("cloud.publisher.skip", "true");
    bundleModel.setParent(parentPom);
    bundleModel.setName(bundleModel.getName() + " Bundle");
    if (bundleModel.getBuild() == null) {
        bundleModel.setBuild(new Build());
    }
    bundleModel.getBuild().addPlugin(addSkipDockerMavenPlugin());
    updateBundleMainfest(bundleModel);
    PomUtil.savePom(monitor, bundleModel, pomBundle);
    PomUtil.savePom(monitor, pom, curPomFile);
    parent.refreshLocal(IResource.DEPTH_ONE, monitor);
    afterCreate(monitor);
}
Also used : IFile(org.eclipse.core.resources.IFile) Parent(org.apache.maven.model.Parent) Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model) RouteProcess(org.talend.camel.designer.ui.editor.RouteProcess) Dependency(org.apache.maven.model.Dependency) IContainer(org.eclipse.core.resources.IContainer) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 4 with RouteProcess

use of org.talend.camel.designer.ui.editor.RouteProcess in project tesb-studio-se by Talend.

the class RouteProcessConvertServiceImpl method getProcessFromItem.

@Override
public IProcess getProcessFromItem(Item item, boolean loadScreenshots) {
    if (item.eClass() == CamelPropertiesPackage.Literals.CAMEL_PROCESS_ITEM) {
        RouteProcess process = new RouteProcess(item.getProperty());
        if (item instanceof CamelProcessItemImpl) {
            CamelProcessItemImpl camelProcessItemImpl = (CamelProcessItemImpl) item;
            // FIXME: revisit the duplication of information between BUILD_TYPE and
            // camelProcessItemImpl.isExportMicroService(). It is synchronized here
            // as it gets out of sync with changes to BUILD_TYPE.
            String bt = (String) item.getProperty().getAdditionalProperties().get("BUILD_TYPE");
            boolean isMS;
            if (bt == null) {
                isMS = camelProcessItemImpl.isExportMicroService();
            } else {
                isMS = bt.indexOf("MICROSERVICE") >= 0;
                if (camelProcessItemImpl.isExportMicroService() != isMS) {
                    camelProcessItemImpl.setExportMicroService(isMS);
                }
            }
            if (isMS) {
                process = new MicroServiceProcess(item.getProperty());
            }
        }
        process.loadXmlFile(loadScreenshots);
        return process;
    }
    return null;
}
Also used : CamelProcessItemImpl(org.talend.camel.core.model.camelProperties.impl.CamelProcessItemImpl) RouteProcess(org.talend.camel.designer.ui.editor.RouteProcess) MicroServiceProcess(org.talend.camel.designer.ui.editor.MicroServiceProcess)

Example 5 with RouteProcess

use of org.talend.camel.designer.ui.editor.RouteProcess in project tesb-studio-se by Talend.

the class ECamelTemplateTest method testGetTemplateURL.

/**
 * Test method for {@link org.talend.camel.designer.codegen.config.ECamelTemplate#getTemplateURL()}.
 */
@Test
public void testGetTemplateURL() {
    ECamelTemplate.CONTEXT.getTemplateURL();
    ECamelTemplate.CAMEL_SPECIALLINKS.getTemplateURL();
    ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
    Property myProperty = PropertiesFactory.eINSTANCE.createProperty();
    String id = ProxyRepositoryFactory.getInstance().getNextId();
    myProperty.setId(id);
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(false);
    itemState.setPath("");
    processItem.setState(itemState);
    processItem.setProperty(myProperty);
    myProperty.setLabel("myRoute");
    myProperty.setVersion("0.1");
    processItem.setProcess(TalendFileFactory.eINSTANCE.createProcessType());
    // $NON-NLS-1$ //$NON-NLS-2$
    IComponent component = ComponentsFactoryProvider.getInstance().get("cTimer", "CAMEL");
    RouteProcess process = new RouteProcess(myProperty);
    process.setId("routeprocess");
    INode nodeTimer = new Node(component, process);
    nodeTimer.setLabel("cTimer_1");
    CamelCodeGenerator codeGenerator = new CamelCodeGenerator(process, false, false);
    try {
        String code = codeGenerator.generateProcessCode();
    } catch (CodeGeneratorException e) {
        e.printStackTrace();
        fail("Test testGetTemplateURL() method failure.");
    }
}
Also used : INode(org.talend.core.model.process.INode) ProcessItem(org.talend.core.model.properties.ProcessItem) IComponent(org.talend.core.model.components.IComponent) CamelCodeGenerator(org.talend.camel.designer.codegen.CamelCodeGenerator) ItemState(org.talend.core.model.properties.ItemState) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) RouteProcess(org.talend.camel.designer.ui.editor.RouteProcess) CodeGeneratorException(org.talend.designer.codegen.exception.CodeGeneratorException) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Aggregations

RouteProcess (org.talend.camel.designer.ui.editor.RouteProcess)5 IFile (org.eclipse.core.resources.IFile)2 Test (org.junit.Test)2 IComponent (org.talend.core.model.components.IComponent)2 INode (org.talend.core.model.process.INode)2 ItemState (org.talend.core.model.properties.ItemState)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 Property (org.talend.core.model.properties.Property)2 Node (org.talend.designer.core.ui.editor.nodes.Node)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 Build (org.apache.maven.model.Build)1 Dependency (org.apache.maven.model.Dependency)1 Model (org.apache.maven.model.Model)1 Parent (org.apache.maven.model.Parent)1 IContainer (org.eclipse.core.resources.IContainer)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1