Search in sources :

Example 1 with ServiceMavenJavaProcessor

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;
}
Also used : ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IFile(org.eclipse.core.resources.IFile) FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) BundleModel(org.talend.designer.publish.core.models.BundleModel) CreateMavenDataServicePom(org.talend.repository.services.maven.CreateMavenDataServicePom) Manifest(java.util.jar.Manifest) FeatureModel(org.talend.designer.publish.core.models.FeatureModel) ProcessItem(org.talend.core.model.properties.ProcessItem) IESBService(org.talend.core.IESBService) FileOutputStream(java.io.FileOutputStream) ServiceMavenJavaProcessor(org.talend.repository.services.maven.ServiceMavenJavaProcessor) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

FileOutputStream (java.io.FileOutputStream)1 Manifest (java.util.jar.Manifest)1 IFile (org.eclipse.core.resources.IFile)1 IESBService (org.talend.core.IESBService)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 BundleModel (org.talend.designer.publish.core.models.BundleModel)1 FeatureModel (org.talend.designer.publish.core.models.FeatureModel)1 FeaturesModel (org.talend.designer.publish.core.models.FeaturesModel)1 CreateMavenDataServicePom (org.talend.repository.services.maven.CreateMavenDataServicePom)1 ServiceMavenJavaProcessor (org.talend.repository.services.maven.ServiceMavenJavaProcessor)1 ServiceConnection (org.talend.repository.services.model.services.ServiceConnection)1