use of org.talend.designer.runprocess.ProcessorException 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.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.
the class JavaProcessorUtilitiesTest method testComputeLibrariesPathWithMissingJars.
@Test
public void testComputeLibrariesPathWithMissingJars() {
boolean headless = CommonsPlugin.isHeadless();
try {
// don't popup dialog to block ui
CommonsPlugin.setHeadless(true);
IComponent tLibraryLoadComponent = ComponentsFactoryProvider.getInstance().get("tLibraryLoad", ComponentCategory.CATEGORY_4_DI.getName());
Property property = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property.setId("property");
//$NON-NLS-1$
property.setVersion("0.1");
//$NON-NLS-1$
property.setLabel("test");
Process process = new Process(property);
Node tLibraryLoad_1 = new Node(tLibraryLoadComponent, process);
process.addNodeContainer(new NodeContainer(tLibraryLoad_1));
tLibraryLoad_1.getElementParameter("LIBRARY").setValue("computeLibrariesPath.jar");
Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
ProcessorException exception = null;
try {
JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
} catch (ProcessorException e) {
exception = e;
}
if (exception != null) {
Assert.assertTrue(exception.getMessage().contains("computeLibrariesPath.jar"));
} else {
fail("computeLibrariesPath failed for process test{tLibraryLoad},computeLibrariesPath.jar not found but no exception");
}
} finally {
CommonsPlugin.setHeadless(headless);
}
}
use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.
the class JavaProcessorUtilitiesTest method testComputeLibrariesPath.
@Test
public void testComputeLibrariesPath() {
boolean headless = CommonsPlugin.isHeadless();
try {
CommonsPlugin.setHeadless(true);
IComponent tFixedFlowComponent = ComponentsFactoryProvider.getInstance().get("tFixedFlowInput", ComponentCategory.CATEGORY_4_DI.getName());
IComponent tLogRowComponent = ComponentsFactoryProvider.getInstance().get("tLogRow", ComponentCategory.CATEGORY_4_DI.getName());
Property property = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property.setId("property");
//$NON-NLS-1$
property.setVersion("0.1");
//$NON-NLS-1$
property.setLabel("test");
Process process = new Process(property);
Node tFixedFlowInput_1 = new Node(tFixedFlowComponent, process);
createMetadataColumns(tFixedFlowInput_1.getMetadataList().get(0), 1);
Node tLogRow_1 = new Node(tLogRowComponent, process);
createMetadataColumns(tLogRow_1.getMetadataList().get(0), 1);
process.addNodeContainer(new NodeContainer(tFixedFlowInput_1));
process.addNodeContainer(new NodeContainer(tLogRow_1));
new Connection(tFixedFlowInput_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tFixedFlowInput_1", "row1", "row1", false);
Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
try {
JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
} catch (ProcessorException e) {
fail("computeLibrariesPath failed for process test{tFixedFlowInput->tLogRow}");
}
} finally {
CommonsPlugin.setHeadless(headless);
}
}
use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.
the class GuessSchemaProcess method run.
public CsvArray run() throws ProcessorException {
CsvArray array = new CsvArray();
buildProcess();
IProcessor processor = ProcessorUtilities.getProcessor(process, null);
processor.setContext(selectContext);
File previousFile = temppath.toFile();
if (previousFile.exists()) {
previousFile.delete();
}
java.lang.Process executeprocess = processor.run(IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, null);
StringBuffer buffer = new StringBuffer();
ProcessStreamTrashReaderUtil.readAndForget(executeprocess, buffer);
final String errorMessage = buffer.toString();
boolean checkError = !info.isHive() | !previousFile.exists();
if (checkError && !"".equals(buffer.toString())) {
throw new ProcessorException(errorMessage) {
private static final long serialVersionUID = 1L;
/*
* (non-Javadoc)
*
* @see java.lang.Throwable#initCause(java.lang.Throwable)
*/
@Override
public synchronized Throwable initCause(Throwable cause) {
// TODO Auto-generated method stub
return super.initCause(cause);
}
/*
* (non-Javadoc)
*
* @see java.lang.Throwable#getMessage()
*/
@Override
public String getMessage() {
StringTokenizer tokenizer = new StringTokenizer(errorMessage, "\n");
StringBuilder sqlError = new StringBuilder();
if (tokenizer.countTokens() > 2) {
tokenizer.nextToken();
sqlError.append(tokenizer.nextToken()).append("\n");
}
return sqlError.toString();
}
};
} else {
try {
array = array.createFrom(previousFile, currentProcessEncoding);
} catch (IOException ioe) {
throw new ProcessorException(ioe) {
/*
* (non-Javadoc)
*
* @see java.lang.Throwable#getMessage()
*/
@Override
public String getMessage() {
//$NON-NLS-1$ //$NON-NLS-2$
return Messages.getString("GuessSchemaController.0", System.getProperty("line.separator"));
}
};
}
}
return array;
}
use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.
the class RowGenProcessMain method runPreviewCode.
/**
* qzhang Comment method "runPreviewCode".
*/
public Process runPreviewCode() {
getProcess();
if (jobContextManager == null) {
// proc.getContextManager().setListContext(component.getProcess().getContextManager().getListContext());
proc.getContextManager().setDefaultContext(component.getProcess().getContextManager().getDefaultContext());
} else {
// proc.getContextManager().setListContext(jobContextManager.getListContext());
proc.getContextManager().setDefaultContext(jobContextManager.getDefaultContext());
}
// IContext context2 = new org.talend.core.model.context.JobContext(PREVIEW);
// if (UIManager.isJavaProject()) {
// List<IContextParameter> params = new ArrayList<IContextParameter>();
// JobContextParameter contextParameter = new JobContextParameter();
// contextParameter.setContext(context2);
// contextParameter.setName(PREVIEW);
// contextParameter.setValue(PREVIEW);
// contextParameter.setType("String");
// params.add(contextParameter);
// context2.setContextParameterList(params);
// }
// generate context files.
IProcessor contextProcessor = ProcessorUtilities.getProcessor(proc, null);
contextProcessor.setContext(proc.getContextManager().getDefaultContext());
try {
contextProcessor.cleanBeforeGenerate(TalendProcessOptionConstants.CLEAN_CONTEXTS);
contextProcessor.generateContextCode();
} catch (ProcessorException pe) {
ExceptionHandler.process(pe);
}
IProcessor processor = ProcessorUtilities.getProcessor(proc, null, proc.getContextManager().getDefaultContext());
try {
return processor.run(IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, null);
} catch (Exception e) {
ExceptionHandler.process(e);
return null;
}
}
Aggregations