use of org.talend.core.model.repository.job.JobResource in project tdi-studio-se by Talend.
the class SpagicDeployWizardPage method finish.
/**
* The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
* is returned then the wizard will not close.
*
* @returns boolean
*/
@Override
public boolean finish() {
Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
boolean canExport = false;
for (ExportChoice choice : ExportChoice.values()) {
if (exportChoiceMap.get(choice) != null && exportChoiceMap.get(choice) instanceof Boolean && (Boolean) exportChoiceMap.get(choice)) {
canExport = true;
break;
}
}
if (!canExport) {
MessageDialog.openInformation(getContainer().getShell(), //$NON-NLS-1$
Messages.getString("SpagicDeployWizardPage.exportResourceError"), //$NON-NLS-1$
Messages.getString("SpagicDeployWizardPage.chooseResource"));
return false;
}
if (!ensureTargetIsValid()) {
return false;
}
manager = new //$NON-NLS-1$
SpagicJavaDeployManager(//$NON-NLS-1$
exportChoiceMap, //$NON-NLS-1$
contextCombo.getText(), //$NON-NLS-1$
"all", //$NON-NLS-1$
IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
String topFolder = getRootFolderName();
List<ExportFileResource> resourcesToExport = null;
try {
resourcesToExport = getExportResources();
} catch (ProcessorException e) {
MessageBoxExceptionHandler.process(e);
return false;
}
setTopFolder(resourcesToExport, topFolder);
// Save dirty editors if possible but do not stop if not all are saved
saveDirtyEditors();
// about to invoke the operation so save our state
saveWidgetValues();
// boolean ok =executeExportOperation(new ArchiveFileExportOperationFullPath(process));
// File file = createSapgicProperty();
ArchiveFileExportOperationFullPath exporterOperation = getExporterOperation(resourcesToExport);
// exportResource(topFolder, "", "", 1);
boolean ok = executeExportOperation(exporterOperation);
// path can like name/name
manager.deleteTempFiles();
ProcessorUtilities.resetExportConfig();
String projectName = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLabel();
List<JobResource> jobResources = new ArrayList<JobResource>();
for (ExportFileResource proces : process) {
try {
proces.setProcess((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(proces.getItem().getProperty()).getItem());
} catch (PersistenceException e) {
e.printStackTrace();
}
ProcessItem processItem = (ProcessItem) proces.getItem();
JobInfo jobInfo = new JobInfo(processItem, processItem.getProcess().getDefaultContext());
jobResources.add(new JobResource(projectName, jobInfo));
Set<JobInfo> jobInfos = ProcessorUtilities.getChildrenJobInfo(processItem);
for (JobInfo subjobInfo : jobInfos) {
jobResources.add(new JobResource(projectName, subjobInfo));
}
}
JobResourceManager reManager = JobResourceManager.getInstance();
for (JobResource r : jobResources) {
if (reManager.isProtected(r)) {
try {
ProcessorUtilities.generateCode(r.getJobInfo().getJobId(), r.getJobInfo().getContextName(), r.getJobInfo().getJobVersion(), false, false);
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
} else {
reManager.deleteResource(r);
}
}
return ok;
}
use of org.talend.core.model.repository.job.JobResource in project tdi-studio-se by Talend.
the class JobExportAction method generatedCodes.
/**
* DOC ggu Comment method "generatedCodes".
*
* @param version
* @param monitor
* @param processes
*/
protected boolean generatedCodes(String version, IProgressMonitor monitor, List<ExportFileResource> processes) {
String projectName = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLabel();
List<JobResource> jobResources = new ArrayList<JobResource>();
for (ExportFileResource process : processes) {
ProcessItem processItem = (ProcessItem) process.getItem();
JobInfo jobInfo = new JobInfo(processItem, processItem.getProcess().getDefaultContext(), version);
jobResources.add(new JobResource(projectName, jobInfo));
Set<JobInfo> jobInfos = ProcessorUtilities.getChildrenJobInfo(processItem);
for (JobInfo subjobInfo : jobInfos) {
jobResources.add(new JobResource(projectName, subjobInfo));
}
}
JobResourceManager reManager = JobResourceManager.getInstance();
for (JobResource r : jobResources) {
if (reManager.isProtected(r)) {
try {
ProcessorUtilities.generateCode(r.getJobInfo().getJobId(), r.getJobInfo().getContextName(), r.getJobInfo().getJobVersion(), false, false, monitor);
} catch (ProcessorException e) {
MessageBoxExceptionHandler.process(e);
return false;
}
}
}
return true;
}
Aggregations