Search in sources :

Example 1 with BundleModel

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;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) BundleModel(org.talend.designer.publish.core.models.BundleModel)

Example 2 with BundleModel

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);
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProjectReference(org.talend.core.model.properties.ProjectReference) BundleModel(org.talend.designer.publish.core.models.BundleModel) IOException(java.io.IOException) Dependency(org.apache.maven.model.Dependency) InvocationTargetException(java.lang.reflect.InvocationTargetException) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Project(org.talend.core.model.general.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) ILibraryManagerService(org.talend.core.ILibraryManagerService) ProcessItem(org.talend.core.model.properties.ProcessItem) CamelRepositoryNodeType(org.talend.camel.model.CamelRepositoryNodeType) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Collection(java.util.Collection) File(java.io.File)

Example 3 with BundleModel

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();
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) ProcessItem(org.talend.core.model.properties.ProcessItem) CoreException(org.eclipse.core.runtime.CoreException) FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) BundleModel(org.talend.designer.publish.core.models.BundleModel) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with BundleModel

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)));
}
Also used : BundleModel(org.talend.designer.publish.core.models.BundleModel)

Example 5 with BundleModel

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

BundleModel (org.talend.designer.publish.core.models.BundleModel)8 ProcessItem (org.talend.core.model.properties.ProcessItem)6 IOException (java.io.IOException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 FeaturesModel (org.talend.designer.publish.core.models.FeaturesModel)4 File (java.io.File)3 IFile (org.eclipse.core.resources.IFile)3 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)3 HashSet (java.util.HashSet)2 CoreException (org.eclipse.core.runtime.CoreException)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 CamelRepositoryNodeType (org.talend.camel.model.CamelRepositoryNodeType)2 Project (org.talend.core.model.general.Project)2 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)2 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)2 ENodeType (org.talend.repository.model.IRepositoryNode.ENodeType)2 FileOutputStream (java.io.FileOutputStream)1 Collection (java.util.Collection)1