use of org.talend.repository.services.maven.CreateMavenDataServicePom in project tesb-studio-se by Talend.
the class BuildDataServiceProvider method createPomCreator.
@Override
public IMavenPomCreator createPomCreator(Map<String, Object> parameters) {
if (parameters == null || parameters.isEmpty()) {
return null;
}
final Object processor = parameters.get(PROCESSOR);
if (processor == null || !(processor instanceof IProcessor)) {
return null;
}
final Object pomFile = parameters.get(FILE_POM);
if (pomFile == null || !(pomFile instanceof IFile)) {
return null;
}
final Object item = parameters.get(ITEM);
if (item == null || !(item instanceof Item)) {
return null;
}
Object argumentsMap = parameters.get(ARGUMENTS_MAP);
if (argumentsMap == null) {
argumentsMap = Collections.emptyMap();
}
if (!(argumentsMap instanceof Map)) {
return null;
}
Object overwrite = parameters.get(OVERWRITE_POM);
if (overwrite == null) {
overwrite = Boolean.FALSE;
}
Object assemblyFile = parameters.get(FILE_ASSEMBLY);
CreateMavenDataServicePom creator = new CreateMavenDataServicePom((IProcessor) processor, (IFile) pomFile);
creator.setArgumentsMap((Map<String, Object>) argumentsMap);
creator.setOverwrite(Boolean.parseBoolean(overwrite.toString()));
creator.setAssemblyFile((IFile) assemblyFile);
final Property itemProperty = ((Item) item).getProperty();
IPath itemLocationPath = ItemResourceUtil.getItemLocationPath(itemProperty);
IFolder objectTypeFolder = ItemResourceUtil.getObjectTypeFolder(itemProperty);
if (itemLocationPath != null && objectTypeFolder != null) {
IPath itemRelativePath = itemLocationPath.removeLastSegments(1).makeRelativeTo(objectTypeFolder.getLocation());
creator.setObjectTypeFolder(objectTypeFolder);
creator.setItemRelativePath(itemRelativePath);
}
return creator;
}
use of org.talend.repository.services.maven.CreateMavenDataServicePom 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