Search in sources :

Example 1 with CreateMavenDataServicePom

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;
}
Also used : ServiceItem(org.talend.repository.services.model.services.ServiceItem) Item(org.talend.core.model.properties.Item) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) CreateMavenDataServicePom(org.talend.repository.services.maven.CreateMavenDataServicePom) IProcessor(org.talend.designer.runprocess.IProcessor) Map(java.util.Map) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with CreateMavenDataServicePom

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;
}
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

IFile (org.eclipse.core.resources.IFile)2 CreateMavenDataServicePom (org.talend.repository.services.maven.CreateMavenDataServicePom)2 FileOutputStream (java.io.FileOutputStream)1 Map (java.util.Map)1 Manifest (java.util.jar.Manifest)1 IFolder (org.eclipse.core.resources.IFolder)1 IPath (org.eclipse.core.runtime.IPath)1 IESBService (org.talend.core.IESBService)1 Item (org.talend.core.model.properties.Item)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 Property (org.talend.core.model.properties.Property)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 IProcessor (org.talend.designer.runprocess.IProcessor)1 ServiceMavenJavaProcessor (org.talend.repository.services.maven.ServiceMavenJavaProcessor)1 ServiceConnection (org.talend.repository.services.model.services.ServiceConnection)1 ServiceItem (org.talend.repository.services.model.services.ServiceItem)1