use of org.talend.repository.services.maven.ServiceMavenJavaProcessor 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