Search in sources :

Example 1 with BDJobReArchieveCreator

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.BDJobReArchieveCreator in project tdi-studio-se by Talend.

the class AbstractJavaProcessor method run.

@Override
public Process run(String[] optionsParam, int statisticsPort, int tracePort, IProgressMonitor monitor, IProcessMessageManager processMessageManager) throws ProcessorException {
    if (isStandardJob()) {
        Property property = this.getProperty();
        if (property != null) {
            // use the same function with ExportModelJavaProcessor, but will do for maven
            ProcessItem processItem = (ProcessItem) property.getItem();
            if (isRunAsExport()) {
                // Step 1: Export job
                archive = buildExportZip(processItem, monitor);
                // Step 2: Deploy in local(Maybe just unpack)
                unzipFolder = unzipAndDeploy(process, archive);
                // Step 3: Run job from given folder.
                return execFrom(unzipFolder + File.separatorChar + process.getName(), Level.INFO, statisticsPort, tracePort, optionsParam);
            } else {
                // If we are not in an export mode, we still have to check whether jobs need to be re-archived or
                // not.
                String version = processItem.getProperty().getVersion();
                if (//$NON-NLS-1$
                !RelationshipItemBuilder.LATEST_VERSION.equals(version) && version != null && !"".equals(version) && !version.equals(processItem.getProperty().getVersion())) {
                    processItem = ItemCacheManager.getProcessItem(processItem.getProperty().getId(), version);
                }
                Set<ProcessItem> processItems = new HashSet<>();
                processItems.add(processItem);
                // We get the father job childs.
                Set<JobInfo> infos = ProcessorUtilities.getChildrenJobInfo(processItem);
                Iterator<JobInfo> infoIterator = infos.iterator();
                while (infoIterator.hasNext()) {
                    processItems.add(infoIterator.next().getProcessItem());
                }
                // We iterate over the job and its childs in order to re-archive them if needed.
                for (ProcessItem pi : processItems) {
                    BDJobReArchieveCreator bdRecreator = new BDJobReArchieveCreator(pi, processItem);
                    bdRecreator.create(new File(this.getTalendJavaProject().getTargetFolder().getLocation().toPortableString()), false);
                }
            }
        }
    }
    return super.run(optionsParam, statisticsPort, tracePort, monitor, processMessageManager);
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) JobInfo(org.talend.core.model.process.JobInfo) Property(org.talend.core.model.properties.Property) ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File) HashSet(java.util.HashSet) BDJobReArchieveCreator(org.talend.repository.ui.wizards.exportjob.scriptsmanager.BDJobReArchieveCreator)

Aggregations

File (java.io.File)1 HashSet (java.util.HashSet)1 JobInfo (org.talend.core.model.process.JobInfo)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 Property (org.talend.core.model.properties.Property)1 ZipToFile (org.talend.repository.ui.utils.ZipToFile)1 BDJobReArchieveCreator (org.talend.repository.ui.wizards.exportjob.scriptsmanager.BDJobReArchieveCreator)1