use of org.talend.designer.publish.core.models.BundleModel in project tdi-studio-se by Talend.
the class AbstractPublishJobAction method getFeatureModel.
private FeaturesModel getFeatureModel(File tmpJob) {
ProcessItem processItem = (ProcessItem) node.getObject().getProperty().getItem();
FeaturesModel featuresModel = new FeaturesModel(groupId, artifactName, artifactVersion);
featuresModel.setConfigName(node.getObject().getLabel());
featuresModel.setContexts(JobContextUtils.getContextsMap(processItem));
BundleModel bundleModel = new BundleModel(groupId, artifactName, artifactVersion, tmpJob);
featuresModel.addBundle(bundleModel);
return featuresModel;
}
use of org.talend.designer.publish.core.models.BundleModel 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);
}
}
}
}
use of org.talend.designer.publish.core.models.BundleModel in project tesb-studio-se by Talend.
the class OSGIJavaProcessor method generateCode.
@Override
public void generateCode(boolean statistics, boolean trace, boolean javaProperties, int option) throws ProcessorException {
super.generateCode(statistics, trace, javaProperties, option);
IProgressMonitor monitor = new NullProgressMonitor();
ProcessItem processItem = (ProcessItem) property.getItem();
FeaturesModel featuresModel = new FeaturesModel(PomIdsHelper.getJobGroupId(processItem.getProperty()), processItem.getProperty().getDisplayName(), PomIdsHelper.getJobVersion(processItem.getProperty()));
featuresModel.setConfigName(this.context.getName());
featuresModel.setContexts(JobContextUtils.getContextsMap(processItem));
BundleModel bundleModel = new BundleModel(PomIdsHelper.getJobGroupId(processItem.getProperty()), processItem.getProperty().getDisplayName(), PomIdsHelper.getJobVersion(processItem.getProperty()));
featuresModel.addBundle(bundleModel);
IFile feature = getTalendJavaProject().createSubFolder(monitor, getTalendJavaProject().getResourcesFolder(), "feature").getFile("feature.xml");
PomIdsHelper.getJobVersion(processItem.getProperty());
try {
if (feature.exists()) {
feature.setContents(featuresModel.getContent(), 0, monitor);
} else {
feature.create(featuresModel.getContent(), 0, monitor);
}
} catch (CoreException e) {
e.printStackTrace();
}
// Delete microservice launcher for OSGi type running in studio
String packageFolder = JavaResourcesHelper.getJobClassPackageFolder(property.getItem(), true);
IFolder srcFolder = getTalendJavaProject().getSrcSubFolder(null, packageFolder);
IFile app = srcFolder.getFile("App.java");
if (app.exists()) {
try {
app.delete(true, monitor);
} catch (CoreException e) {
e.printStackTrace();
}
}
IFile talendManagementWebSecurityAutoConfiguration = srcFolder.getFile("TalendManagementWebSecurityAutoConfiguration.java");
if (talendManagementWebSecurityAutoConfiguration.exists()) {
try {
talendManagementWebSecurityAutoConfiguration.delete(true, monitor);
} catch (CoreException e) {
e.printStackTrace();
}
}
}
use of org.talend.designer.publish.core.models.BundleModel in project tesb-studio-se by Talend.
the class ExportServiceAction method addControlBundle.
private void addControlBundle(FeaturesModel feature) throws IOException, CoreException {
// $NON-NLS-1$
final String artifactName = getServiceName() + "-control-bundle";
feature.addBundle(new BundleModel(getGroupId(), artifactName, getServiceVersion(), generateControlBundle(getGroupId(), artifactName)));
}
use of org.talend.designer.publish.core.models.BundleModel in project tesb-studio-se by Talend.
the class BuildDataServiceHandler method generateJobFiles.
/*
* (non-Javadoc)
*
* @see org.talend.core.runtime.process.IBuildJobHandler#generateJobFiles(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public IProcessor generateJobFiles(IProgressMonitor monitor) throws Exception {
BuildCacheManager.getInstance().clearAllCaches();
// TESB-22307
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
IESBService soapService = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
ServiceMavenJavaProcessor processor = (ServiceMavenJavaProcessor) soapService.createJavaProcessor(null, serviceItem.getProperty(), true);
IFile pomFile = AggregatorPomsHelper.getItemPomFolder(serviceItem.getProperty()).getFile(TalendMavenConstants.POM_FILE_NAME);
CreateMavenDataServicePom pom = new CreateMavenDataServicePom(processor, pomFile);
pom.create(monitor);
}
// src\main\resources\feature\feature.xml
String featureVersion = PomIdsHelper.getJobVersion(serviceItem.getProperty());
FeaturesModel features = new FeaturesModel(getGroupId(), serviceName, featureVersion);
features.setConfigName(serviceName);
features.setContexts(contextValues);
ServiceConnection connection = (ServiceConnection) serviceItem.getConnection();
String useRegistry = connection.getAdditionalInfo().get(ServiceMetadataDialog.USE_SERVICE_REGISTRY);
if (!"true".equals(useRegistry)) {
String useCorrelation = connection.getAdditionalInfo().get(ServiceMetadataDialog.USE_BUSINESS_CORRELATION);
if ("true".equals(useCorrelation)) {
features.addFeature(new FeatureModel(FeaturesModel.CORRELATION_FEATURE_NAME));
}
}
// add talend-data-mapper feature
for (IRepositoryViewObject node : nodes) {
ProcessItem processItem = (ProcessItem) node.getProperty().getItem();
if (null != EmfModelUtils.getComponentByName(processItem, "tHMap")) {
features.addFeature(new FeatureModel(FeaturesModel.TALEND_DATA_MAPPER_FEATURE_NAME));
break;
}
}
for (IRepositoryViewObject node : nodes) {
features.addBundle(new BundleModel(PomIdsHelper.getJobGroupId(node.getProperty()), serviceExportManager.getNodeLabel(node) + "-bundle", PomIdsHelper.getJobVersion(node.getProperty())));
}
// $NON-NLS-1$
final String artifactName = serviceName + "-control-bundle";
features.addBundle(new BundleModel(PomIdsHelper.getJobGroupId(serviceItem.getProperty()), artifactName, PomIdsHelper.getJobVersion(serviceItem.getProperty())));
IFile feature = talendProcessJavaProject.createSubFolder(monitor, talendProcessJavaProject.getResourcesFolder(), "feature").getFile("feature.xml");
setFileContent(features.getContent(), feature, monitor);
// resources\META-INF\MANIFEST.MF
Manifest manifest = serviceExportManager.getManifest(artifactName, featureVersion, additionalInfo);
IFile mf = talendProcessJavaProject.createSubFolder(monitor, talendProcessJavaProject.getResourcesFolder(), "META-INF").getFile("MANIFEST.MF");
// talendProcessJavaProject.getResourceSubFolder(monitor, "META-INF").getFile("MANIFEST.MF");
FileOutputStream outputStream = new FileOutputStream(mf.getLocation().toFile());
manifest.write(outputStream);
outputStream.flush();
outputStream.close();
// resources\**.wsdl
IFile wsdl = talendProcessJavaProject.getResourcesFolder().getFile(serviceWsdl.getName());
setFileContent(serviceWsdl.getContents(), wsdl, monitor);
// resources\OSGI-INF\blueprint\blueprint.xml
IFile blueprint = talendProcessJavaProject.createSubFolder(monitor, talendProcessJavaProject.getResourcesFolder(), "OSGI-INF/blueprint").getFile("blueprint.xml");
// talendProcessJavaProject.getResourceSubFolder(monitor, "OSGI-INF/blueprint").getFile("blueprint.xml");
serviceExportManager.createBlueprint(blueprint.getLocation().toFile(), ports, additionalInfo, wsdl, serviceName);
// as not only one job code generated
return null;
}
Aggregations