use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class MapperManager method removeSelectedOutput.
public void removeSelectedOutput() {
DataMapTableView currentSelectedDataMapTableView = uiManager.getCurrentSelectedOutputTableView();
String append = "";
OutputTable outputTable = ((OutputTable) currentSelectedDataMapTableView.getDataMapTable());
List<DataMapTableView> relatedOutputsTableView = null;
if (outputTable.getIsJoinTableOf() == null) {
relatedOutputsTableView = uiManager.getRelatedOutputsTableView(currentSelectedDataMapTableView);
if (relatedOutputsTableView != null && !relatedOutputsTableView.isEmpty()) {
append = " and it's join table ";
for (DataMapTableView tableView : relatedOutputsTableView) {
IDataMapTable retrieveAbstractDataMapTable = this.retrieveAbstractDataMapTable(tableView);
if (retrieveAbstractDataMapTable != null) {
append = append + "'" + retrieveAbstractDataMapTable.getName() + " ' ,";
}
}
append = append.substring(0, append.length() - 1);
}
}
if (currentSelectedDataMapTableView != null) {
String tableName = currentSelectedDataMapTableView.getDataMapTable().getName();
if (MessageDialog.openConfirm(currentSelectedDataMapTableView.getShell(), //$NON-NLS-1$
Messages.getString("MapperManager.removeOutputTableTitle"), Messages.getString("MapperManager.removeOutputTableTitleMessage") + tableName + " '" + append + "?")) {
//$NON-NLS-1$ //$NON-NLS-2$
IProcess process = getAbstractMapComponent().getProcess();
uiManager.removeOutputTableView(currentSelectedDataMapTableView);
// remove join table
if (outputTable.getIsJoinTableOf() == null && relatedOutputsTableView != null) {
for (DataMapTableView view : relatedOutputsTableView) {
uiManager.removeOutputTableView(view);
process.removeUniqueConnectionName(view.getDataMapTable().getName());
}
}
uiManager.updateToolbarButtonsStates(Zone.OUTPUTS);
process.removeUniqueConnectionName(currentSelectedDataMapTableView.getDataMapTable().getName());
}
}
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class MapperManager method addOutput.
/**
* DOC amaumont Comment method "addOutput".
*/
public void addOutput() {
String joinTableName = null;
OutputTable abstractDataMapTable = null;
String name = uiManager.openNewOutputCreationDialog();
if (name == null) {
return;
}
String[] split = name.split(uiManager.NAME_SEPARATOR);
String tableName = split[0];
boolean isCreatingJoinTable = split.length == 2;
if (isCreatingJoinTable) {
joinTableName = split[1];
}
IProcess process = getAbstractMapComponent().getProcess();
OutputTable orignalOutputTable = null;
if (isCreatingJoinTable) {
orignalOutputTable = getOutputTableByName(tableName);
if (orignalOutputTable != null) {
IMetadataTable metadataTable = orignalOutputTable.getMetadataTable();
if (metadataTable != null) {
process.addUniqueConnectionName(joinTableName);
abstractDataMapTable = new OutputTable(this, metadataTable, joinTableName);
abstractDataMapTable.setIsJoinTableOf(tableName);
}
}
} else {
process.addUniqueConnectionName(tableName);
IMetadataTable metadataTable = getNewMetadataTable();
metadataTable.setTableName(tableName);
abstractDataMapTable = new OutputTable(this, metadataTable, tableName);
}
if (abstractDataMapTable == null) {
return;
}
abstractDataMapTable.initFromExternalData(null);
List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
int sizeOutputsView = outputsTablesView.size();
Control lastChild = null;
if (sizeOutputsView - 1 >= 0) {
lastChild = outputsTablesView.get(sizeOutputsView - 1);
}
TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
DataMapTableView dataMapTableView = uiManager.createNewOutputTableView(lastChild, abstractDataMapTable, tablesZoneViewOutputs);
tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
tablesZoneViewOutputs.layout();
uiManager.moveOutputScrollBarZoneToMax();
uiManager.refreshBackground(true, false);
tablesZoneViewOutputs.layout();
uiManager.selectDataMapTableView(dataMapTableView, true, false);
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class JobErrorsChecker method checkExportErrors.
public static boolean checkExportErrors(IStructuredSelection selection, boolean isJob) {
if (!selection.isEmpty()) {
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
Set<String> jobIds = new HashSet<String>();
List<RepositoryNode> nodes = selection.toList();
if (nodes.size() > 1) {
// in case it's a multiple export, only check the status of the latest job to export
for (RepositoryNode node : nodes) {
Item item = node.getObject().getProperty().getItem();
try {
IFile sourceFile = synchronizer.getFile(item);
if (sourceFile == null) {
return false;
}
// check the item has compile error when export job
boolean ret = false;
String message = null;
IMarker[] markers = sourceFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
for (IMarker marker : markers) {
Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
message = (String) marker.getAttribute(IMarker.MESSAGE);
Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
if (lineNr != null && message != null && severity != null && start != null && end != null) {
switch(severity) {
case IMarker.SEVERITY_ERROR:
ret = true;
break;
default:
break;
}
}
}
if (ret) {
if (isJob) {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_errors") + '\n' + Messages.getString("JobErrorsChecker_compile_error_content", //$NON-NLS-1$
item.getProperty().getLabel()) + '\n' + message);
} else {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + Messages.getString("CamelJobErrorsChecker_compile_error_content", //$NON-NLS-1$
item.getProperty().getLabel()) + '\n' + message);
}
}
jobIds.add(item.getProperty().getId());
Problems.addRoutineFile(sourceFile, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty().getVersion(), true);
} catch (Exception e) {
MessageBoxExceptionHandler.process(e);
return true;
}
}
} else {
// if single export (normal case), check compilation status from latest generation.
try {
checkLastGenerationHasCompilationError(true);
} catch (Exception e) {
if (CommonsPlugin.isHeadless()) {
CommonExceptionHandler.process(e);
// trace in command status.
throw new RuntimeException(e);
}
MessageBoxExceptionHandler.process(e);
return true;
}
}
for (RepositoryNode node : nodes) {
Item item = node.getObject().getProperty().getItem();
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess process = service.getProcessFromItem(item);
if (process instanceof IProcess2) {
((IProcess2) process).checkProcess();
}
}
Problems.refreshProblemTreeView();
List<Problem> errors = Problems.getProblemList().getProblemsBySeverity(ProblemStatus.ERROR);
ErrorDetailTreeBuilder builder = new ErrorDetailTreeBuilder();
List<JobErrorEntry> input = builder.createTreeInput(errors, jobIds);
try {
if (input.size() > 0) {
String label = input.get(0).getLabel();
if (isJob) {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_content", label));
} else {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_error_content", label));
}
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e);
return true;
}
}
return false;
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class MetadataToolbarEditorViewExt method createNumberRows.
private void createNumberRows() {
numRowComposite = new Composite(toolbar, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 4;
layout.marginBottom = 0;
layout.marginHeight = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
layout.marginTop = 0;
layout.marginWidth = 0;
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.CENTER;
numRowComposite.setLayout(layout);
final Label numRowLabel = new Label(numRowComposite, SWT.NONE);
//$NON-NLS-1$
numRowLabel.setText(Messages.getString("MetadataToolbarEditorViewExt.RowNum.LabelText"));
numRowText = new Text(numRowComposite, SWT.BORDER);
GridDataFactory.swtDefaults().hint(rowNumberWidth(), SWT.DEFAULT).applyTo(numRowText);
numRowText.setBackground(ColorConstants.white);
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
IProcess process = ((AbstractMultiPageTalendEditor) editor).getTalendEditor().getProcess();
TalendProposalUtils.installOn(numRowText, process);
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class JSONShadowProcess method runWithErrorOutputAsException.
/**
*
* DOC xye Comment method "runWithErrorOutputAsException".
*
* @param outputErrorAsException
* @return
* @throws ProcessorException
*/
public CsvArray runWithErrorOutputAsException(final boolean outputErrorAsException) throws ProcessorException {
IProcess talendProcess = buildProcess();
IProcessor processor = ProcessorUtilities.getProcessor(talendProcess, null);
processor.setProxyParameters(getProxyParameters());
File previousFile = outPath.toFile();
if (previousFile.exists()) {
previousFile.delete();
}
IContext context = talendProcess.getContextManager().getDefaultContext();
processor.setContext(context);
process = processor.run(IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, null);
String error = ProcessStreamTrashReader.readErrorStream(process);
if (outputErrorAsException) {
if (error != null) {
throw new ProcessorException(error);
}
} else {
if (error != null) {
log.warn(error, new ProcessorException(error));
}
}
if (!outPath.toFile().exists()) {
//$NON-NLS-1$
throw new ProcessorException(Messages.getString("ShadowProcess.notGeneratedOutputException"));
}
try {
CsvArray array = new CsvArray();
array = array.createFrom(outPath.toFile(), currentProcessEncoding);
return array;
} catch (IOException ioe) {
throw new ProcessorException(ioe);
}
}
Aggregations