use of com.amalto.workbench.webservices.WSTransformerContext in project tmdm-studio-se by Talend.
the class TransformerMainPage method execute.
public void execute() {
try {
service = getService();
if (service == null) {
return;
}
java.util.List<WSTransformerContextPipelinePipelineItem> items = new ArrayList<WSTransformerContextPipelinePipelineItem>();
for (Line line : cacheList) {
String variableName = line.keyValues.get(0).value;
String contentType = line.keyValues.get(1).value;
String value = line.keyValues.get(2).value;
items.add(new WSTransformerContextPipelinePipelineItem(variableName, new WSTypedContent(contentType, null, // $NON-NLS-1$
new WSByteArray(value.getBytes("utf-8")))));
}
final WSBackgroundJobPK jobPK = service.executeTransformerV2AsJob(new WSExecuteTransformerV2AsJob(new WSTransformerContext(new WSTransformerContextPipeline(items), null, new WSTransformerV2PK(transformer.getName()))));
IRunnableWithProgress progress = new IRunnableWithProgress() {
WSBackgroundJob job = null;
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
/**
****************************************
* Watch the Background Job
*****************************************
*/
try {
boolean firstTime = true;
do {
if (firstTime) {
Thread.sleep(1500L);
firstTime = false;
} else {
Thread.sleep(5000L);
}
if (monitor.isCanceled()) {
throw new InterruptedException(Messages.TransformerMainPage_UserCancel);
}
job = service.getBackgroundJob(new WSGetBackgroundJob(jobPK.getPk()));
monitor.subTask(job.getMessage());
} while (job.getStatus().equals(BackgroundJobStatusType.RUNNING) || job.getStatus().equals(BackgroundJobStatusType.SCHEDULED));
if (job.getStatus().equals(BackgroundJobStatusType.STOPPED)) {
getSite().getShell().getDisplay().syncExec(new Runnable() {
public void run() {
MessageDialog.openError(TransformerMainPage.this.getEditor().getSite().getShell(), Messages.bind(Messages.TransformerMainPage_ErrorMsg, transformer.getName()), job.getMessage());
}
});
throw new XtentisException(Messages.bind(Messages.TransformerMainPage_JobWasStoped, job.getMessage()));
}
monitor.worked(1);
monitor.done();
/**
****************************************
* Build the result console
*****************************************
*/
// Auto sorts the entries
final TreeMap pipeline = new TreeMap<String, WSExtractedContent>();
WSPipeline wsPipeline = job.getPipeline();
java.util.List<WSPipelineTypedContentEntry> entries = wsPipeline.getTypedContentEntry();
for (WSPipelineTypedContentEntry entry : entries) {
pipeline.put(entry.getOutput(), entry.getWsExtractedContent());
}
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
try {
/*
* ProcessResultsPage page = new ProcessResultsPage(editor,pipeline);
* parent.editor.addPage(page); parent.editor.setActivePage(page.getId());
*
* parent.editor.getEditorSite().getShell()
*/
// Shell shell = new Shell(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
ProcessResultsDialog dialog = new ProcessResultsDialog(getSite().getShell(), Messages.bind(Messages.TransformerMainPage_DailogTitle, sdf.format(new Date(System.currentTimeMillis()))), pipeline);
dialog.setBlockOnOpen(false);
dialog.open();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
});
} catch (Exception e1) {
log.error(e1.getMessage(), e1);
}
}
};
// fork
new ProgressMonitorDialog(TransformerMainPage.this.getSite().getWorkbenchWindow().getShell()).run(// fork
true, true, progress);
} catch (Exception e1) {
log.error(e1.getMessage(), e1);
}
}
Aggregations