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);
}
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());
}
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);
}
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;
}
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.");
}
}
Aggregations