use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class MapperManager method addRejectOutput.
public void addRejectOutput() {
String baseName = ERROR_REJECT;
IProcess process = getAbstractMapComponent().getProcess();
String tableName = baseName;
if (!process.checkValidConnectionName(baseName) && process instanceof IProcess2) {
final String uniqueName = ((IProcess2) process).generateUniqueConnectionName("row", baseName);
tableName = uniqueName;
((IProcess2) process).addUniqueConnectionName(uniqueName);
} else if (process instanceof IProcess2) {
tableName = baseName;
((IProcess2) process).addUniqueConnectionName(baseName);
}
IMetadataTable metadataTable = getNewMetadataTable();
metadataTable.setTableName(tableName);
MetadataColumn errorMessageCol = new MetadataColumn();
errorMessageCol.setLabel(ERROR_REJECT_MESSAGE);
errorMessageCol.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
errorMessageCol.setNullable(true);
errorMessageCol.setOriginalDbColumnName(ERROR_REJECT_MESSAGE);
errorMessageCol.setReadOnly(true);
errorMessageCol.setCustom(true);
errorMessageCol.setCustomId(0);
metadataTable.getListColumns().add(errorMessageCol);
MetadataColumn errorStackTrace = new MetadataColumn();
errorStackTrace.setLabel(ERROR_REJECT_STACK_TRACE);
errorStackTrace.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
errorStackTrace.setNullable(true);
errorStackTrace.setOriginalDbColumnName(ERROR_REJECT_STACK_TRACE);
errorStackTrace.setReadOnly(true);
errorStackTrace.setCustom(true);
errorStackTrace.setCustomId(1);
metadataTable.getListColumns().add(errorStackTrace);
OutputTable abstractDataMapTable = new OutputTable(this, metadataTable, tableName);
abstractDataMapTable.setErrorRejectTable(true);
abstractDataMapTable.initFromExternalData(null);
TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
DataMapTableView rejectDataMapTableView = uiManager.createNewOutputTableView(null, abstractDataMapTable, tablesZoneViewOutputs);
tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
int sizeList = outputsTablesView.size();
for (int i = 0; i < sizeList; i++) {
if (i + 1 < sizeList) {
FormData formData = (FormData) outputsTablesView.get(i + 1).getLayoutData();
formData.top = new FormAttachment(outputsTablesView.get(i));
}
}
CustomTableManager.addCustomManagementToTable(uiManager.getOutputMetaEditorView(), true);
tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
tablesZoneViewOutputs.layout();
uiManager.moveOutputScrollBarZoneToMax();
uiManager.refreshBackground(true, false);
uiManager.selectDataMapTableView(rejectDataMapTableView, true, false);
}
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);
}
Aggregations