use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class UIManager method removeUnsavedOutputsFromProcess.
private void removeUnsavedOutputsFromProcess() {
AbstractMapComponent abstractMapComponent = getAbstractMapperManager().getAbstractMapComponent();
IProcess process = abstractMapComponent.getProcess();
List<OutputTable> currentOutputTablesList = mapperManager.getOutputTables();
HashSet<String> currentTables = new HashSet<String>(currentOutputTablesList.size());
for (OutputTable outputTable : currentOutputTablesList) {
currentTables.add(outputTable.getName());
}
ExternalMapperData originalExternalData = (ExternalMapperData) mapperManager.getOriginalExternalData();
HashSet<String> originalTableNames = new HashSet<String>();
if (originalExternalData != null) {
List<ExternalMapperTable> originalOutputTables = originalExternalData.getOutputTables();
for (ExternalMapperTable outputTable : originalOutputTables) {
originalTableNames.add(outputTable.getName());
}
}
for (String currentTable : currentTables) {
if (!originalTableNames.contains(currentTable)) {
process.removeUniqueConnectionName(currentTable);
}
}
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class ChangeValuesFromRepository method execute.
@SuppressWarnings("unchecked")
@Override
public void execute() {
// Force redraw of Commponents propoerties
elem.setPropertyValue(updataComponentParamName, new Boolean(true));
boolean allowAutoSwitch = true;
IElementParameter elemParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
if (elemParam != null) {
// add for TDI-8053
elemParam.setValue(Boolean.FALSE);
allowAutoSwitch = (Boolean) elemParam.getValue();
}
if (!allowAutoSwitch && (elem instanceof Node)) {
// force the autoSwitch to true if the schema is empty and if the
// query is not set.
Node node = (Node) elem;
boolean isSchemaEmpty = false;
if (node.getMetadataList().size() > 0) {
isSchemaEmpty = node.getMetadataList().get(0).getListColumns().size() == 0;
} else {
isSchemaEmpty = true;
}
for (IElementParameter curParam : node.getElementParameters()) {
if (curParam.getFieldType().equals(EParameterFieldType.MEMO_SQL)) {
if (curParam.getDefaultValues().size() > 0) {
}
}
}
if (isSchemaEmpty) {
allowAutoSwitch = true;
}
if (((INode) elem).getComponent().getName().equals("tWebService")) {
//$NON-NLS-1$
allowAutoSwitch = true;
}
}
if (propertyName.split(":")[1].equals(propertyTypeName)) {
//$NON-NLS-1$
elem.setPropertyValue(propertyName, value);
if (allowAutoSwitch) {
// Update spark mode to YARN_CLIENT if repository
if (elem instanceof IProcess) {
if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(((IProcess) elem).getComponentsType()) || ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(((IProcess) elem).getComponentsType())) {
if (EmfComponent.REPOSITORY.equals(value)) {
IElementParameter sparkLocalParam = ((IProcess) elem).getElementParameter(HadoopConstants.SPARK_LOCAL_MODE);
IElementParameter sparkParam = ((IProcess) elem).getElementParameter(HadoopConstants.SPARK_MODE);
if (sparkLocalParam != null && (Boolean) (sparkLocalParam.getValue())) {
sparkLocalParam.setValue(false);
}
if (sparkParam != null && !HadoopConstants.SPARK_MODE_YARN_CLIENT.equals(sparkParam.getValue())) {
sparkParam.setValue(HadoopConstants.SPARK_MODE_YARN_CLIENT);
}
}
}
}
setOtherProperties();
}
} else {
oldMetadata = (String) elem.getPropertyValue(propertyName);
elem.setPropertyValue(propertyName, value);
if (allowAutoSwitch) {
setOtherProperties();
}
}
String propertyParamName = null;
if (elem.getElementParameter(propertyName).getParentParameter() != null) {
IElementParameter param = elem.getElementParameter(propertyName).getParentParameter();
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
propertyParamName = param.getName();
}
}
if (propertyName.split(":")[1].equals(propertyTypeName) && (EmfComponent.BUILTIN.equals(value))) {
//$NON-NLS-1$
for (IElementParameter param : elem.getElementParameters()) {
if (param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(propertyParamName)) {
continue;
}
boolean paramFlag = JobSettingsConstants.isExtraParameter(param.getName());
//$NON-NLS-1$
boolean extraFlag = JobSettingsConstants.isExtraParameter(propertyName.split(":")[0]);
if (paramFlag == extraFlag) {
// for memo sql
if (param.getFieldType() == EParameterFieldType.MEMO_SQL) {
IElementParameter querystoreParam = elem.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE, param.getCategory());
if (querystoreParam != null) {
Map<String, IElementParameter> childParam = querystoreParam.getChildParameters();
if (childParam != null) {
IElementParameter queryTypeParam = childParam.get(EParameterName.QUERYSTORE_TYPE.getName());
if (queryTypeParam != null && EmfComponent.REPOSITORY.equals(queryTypeParam.getValue())) {
continue;
}
}
}
}
if (param.getRepositoryValue() != null) {
param.setReadOnly(false);
// for job settings extra.(feature 2710)
param.setRepositoryValueUsed(false);
}
}
}
} else {
oldValues.clear();
List<ComponentProperties> componentProperties = null;
IGenericWizardService wizardService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
}
if (wizardService != null && wizardService.isGenericConnection(connection)) {
componentProperties = wizardService.getAllComponentProperties(connection, null);
}
IElementParameter propertyParam = elem.getElementParameter(propertyName);
List<IElementParameter> elementParameters = new ArrayList<>(elem.getElementParameters());
for (IElementParameter param : elementParameters) {
String repositoryValue = param.getRepositoryValue();
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
continue;
}
boolean isGenericRepositoryValue = RepositoryToComponentProperty.isGenericRepositoryValue(connection, componentProperties, param.getName());
if (repositoryValue == null && isGenericRepositoryValue) {
repositoryValue = param.getName();
param.setRepositoryValue(repositoryValue);
param.setRepositoryValueUsed(true);
}
if (repositoryValue == null || param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(propertyParamName)) {
continue;
}
String componentName = elem instanceof INode ? (((INode) elem).getComponent().getName()) : null;
boolean b = elem instanceof INode && (//$NON-NLS-1$
((INode) elem).getComponent().getName().equals("tHL7Input") || //$NON-NLS-1$
((INode) elem).getComponent().getName().equals("tAdvancedFileOutputXML") || ((INode) elem).getComponent().getName().equals("tMDMOutput") || ((INode) elem).getComponent().getName().equals("tWebService") || ((INode) elem).getComponent().getName().equals("tCreateTable") || //$NON-NLS-1$
((INode) elem).getComponent().getName().equals("tWriteJSONField"));
if ((//$NON-NLS-1$
"TYPE".equals(repositoryValue) || (isGenericRepositoryValue || param.isShow(elem.getElementParameters())) || b) && (!param.getName().equals(propertyTypeName))) {
if (param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(propertyParamName)) {
continue;
}
Object objectValue = null;
if (connection instanceof XmlFileConnection && this.dragAndDropAction == true && repositoryValue.equals("FILE_PATH") && reOpenXSDBool == true) {
objectValue = RepositoryToComponentProperty.getXmlAndXSDFileValue((XmlFileConnection) connection, repositoryValue);
} else if (connection instanceof SalesforceSchemaConnection && "MODULENAME".equals(repositoryValue)) {
//$NON-NLS-1$
if (this.moduleUnit != null) {
objectValue = moduleUnit.getModuleName();
} else {
objectValue = null;
}
} else // module which was the last one be retrived
if (connection instanceof SalesforceSchemaConnection && "CUSTOM_MODULE_NAME".equals(repositoryValue)) {
//$NON-NLS-1$
if (this.moduleUnit != null) {
objectValue = moduleUnit.getModuleName();
} else {
objectValue = null;
}
} else if (connection instanceof MDMConnection) {
if (table == null) {
IMetadataTable metaTable = null;
if (((Node) elem).getMetadataList().size() > 0) {
metaTable = ((Node) elem).getMetadataList().get(0);
}
objectValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, metaTable);
} else {
objectValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, table);
}
} else if (connection instanceof WSDLSchemaConnection && "USE_PROXY".equals(repositoryValue)) {
//$NON-NLS-1$
objectValue = ((WSDLSchemaConnection) connection).isUseProxy();
} else {
IMetadataTable metaTable = table;
if (metaTable == null && elem instanceof Node) {
INodeConnector conn = ((Node) elem).getConnectorFromType(EConnectionType.FLOW_MAIN);
if (conn != null && conn.getMaxLinkOutput() == 1) {
metaTable = ((Node) elem).getMetadataFromConnector(conn.getName());
}
}
objectValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, metaTable, componentName);
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IJsonFileService.class)) {
IJsonFileService jsonService = (IJsonFileService) GlobalServiceRegister.getDefault().getService(IJsonFileService.class);
boolean paramChanged = jsonService.changeFilePathFromRepository(connection, param, elem, objectValue);
if (paramChanged) {
continue;
}
}
if (objectValue != null) {
oldValues.put(param.getName(), param.getValue());
if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("TYPE")) {
//$NON-NLS-1$
String dbVersion = "";
if (connection instanceof DatabaseConnection) {
dbVersion = ((DatabaseConnection) connection).getDbVersionString();
}
boolean found = false;
String[] list = param.getListRepositoryItems();
for (int i = 0; (i < list.length) && (!found); i++) {
if (objectValue.equals(list[i])) {
found = true;
elem.setPropertyValue(param.getName(), param.getListItemsValue()[i]);
}
}
IElementParameter elementParameter = null;
IElementParameter elementParameter2 = null;
if (EParameterName.DB_TYPE.getName().equals(param.getName())) {
elementParameter = elem.getElementParameter(EParameterName.DB_VERSION.getName());
elementParameter2 = elem.getElementParameter(EParameterName.SCHEMA_DB.getName());
} else {
elementParameter = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName()));
elementParameter2 = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName()));
}
String dbType = "";
if (param.getValue() != null) {
int indexOfItemFromList = param.getIndexOfItemFromList(param.getValue().toString());
if (indexOfItemFromList != -1) {
dbType = param.getListItemsDisplayCodeName()[indexOfItemFromList];
}
}
// Some DB not need fill the schema parameter for the JobSetting View "Extra" ,"Stats&Logs"
if (elementParameter2 != null && !elementParameter2.isShow(elem.getElementParameters()) && !elementParameter2.getValue().equals("")) {
elementParameter2.setValue("");
}
if (StatsAndLogsConstants.JDBC.equals(dbType)) {
IElementParameter dbNameParm = elem.getElementParameter(EParameterName.DBNAME.getName());
if (dbNameParm != null) {
dbNameParm.setValue("");
}
} else {
IElementParameter rulParam = elem.getElementParameter(EParameterName.URL.getName());
if (rulParam != null) {
rulParam.setValue("");
}
IElementParameter classParam = elem.getElementParameter(EParameterName.DRIVER_CLASS.getName());
if (classParam != null) {
classParam.setValue("");
}
IElementParameter jarParam = elem.getElementParameter(EParameterName.DRIVER_JAR.getName());
if (jarParam != null) {
jarParam.setValue(new ArrayList<Map<String, Object>>());
}
}
JobSettingVersionUtil.setDbVersion(elementParameter, dbVersion, false);
DesignerUtilities.setSchemaDB(elementParameter2, param.getValue());
} else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("FRAMEWORK_TYPE")) {
//$NON-NLS-1$
String[] list = param.getListItemsDisplayName();
for (int i = 0; i < list.length; i++) {
if (objectValue.equals(list[i])) {
elem.setPropertyValue(param.getName(), param.getListItemsValue()[i]);
}
}
} else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("EDI_VERSION")) {
String[] list = param.getListItemsDisplayName();
for (String element : list) {
if (objectValue.toString().toUpperCase().equals(element)) {
elem.setPropertyValue(param.getName(), objectValue);
}
}
} else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("DRIVER")) {
String[] list = param.getListItemsDisplayCodeName();
for (String element : list) {
if (objectValue.toString().toUpperCase().equals(element)) {
elem.setPropertyValue(param.getName(), objectValue);
}
}
} else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("CONNECTION_MODE")) {
//$NON-NLS-1$
if (!objectValue.equals(param.getValue())) {
//$NON-NLS-1$
PropertyChangeCommand cmd = new PropertyChangeCommand(elem, "CONNECTION_MODE", objectValue);
cmd.execute();
}
} else {
if (repositoryValue.equals("ENCODING")) {
//$NON-NLS-1$
IElementParameter paramEncoding = param.getChildParameters().get(EParameterName.ENCODING_TYPE.getName());
if (connection instanceof FTPConnection) {
if (((FTPConnection) connection).getEcoding() != null) {
paramEncoding.setValue(((FTPConnection) connection).getEcoding());
} else {
paramEncoding.setValue(EmfComponent.ENCODING_TYPE_CUSTOM);
}
} else {
if (objectValue instanceof String) {
String str = TalendTextUtils.removeQuotes((String) objectValue);
if (str.equals(EmfComponent.ENCODING_TYPE_UTF_8)) {
paramEncoding.setValue(EmfComponent.ENCODING_TYPE_UTF_8);
} else if (str.equals(EmfComponent.ENCODING_TYPE_ISO_8859_15)) {
paramEncoding.setValue(EmfComponent.ENCODING_TYPE_ISO_8859_15);
} else {
paramEncoding.setValue(EmfComponent.ENCODING_TYPE_CUSTOM);
// paramEncoding.setRepositoryValueUsed(true);
}
}
}
} else if (repositoryValue.equals("CSV_OPTION")) {
//$NON-NLS-1$
setOtherProperties();
}
if (repositoryValue.equals("MODULENAME")) {
//$NON-NLS-1$
List list = new ArrayList();
Object[] listItemsValue = elem.getElementParameter("MODULENAME").getListItemsValue();
for (Object element : listItemsValue) {
list.add(element);
}
if (list != null && !list.contains(objectValue)) {
//$NON-NLS-1$
objectValue = "CustomModule";
}
}
// hywang add for excel 2007
if (repositoryValue.equals(EParameterName.FILE_PATH.getName())) {
String filePath = "";
if (connection.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
if (contextItem != null) {
String selectedContext = contextItem.getDefaultContext();
final ContextType contextTypeByName = ContextUtils.getContextTypeByName(contextItem, selectedContext, true);
filePath = ConnectionContextHelper.getOriginalValue(contextTypeByName, objectValue.toString());
}
} else {
filePath = TalendTextUtils.removeQuotes(objectValue.toString());
}
boolean versionCheckFor2007 = false;
if (filePath != null && filePath.endsWith(".xlsx")) {
versionCheckFor2007 = true;
}
if (elem.getElementParameter("VERSION_2007") != null) {
elem.setPropertyValue("VERSION_2007", versionCheckFor2007);
}
}
if (param.getFieldType().equals(EParameterFieldType.FILE)) {
if (objectValue != null) {
objectValue = objectValue.toString().replace("\\", "/");
}
}
elem.setPropertyValue(param.getName(), objectValue);
}
param.setRepositoryValueUsed(true);
} else if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getRepositoryValue().equals("XML_MAPPING")) {
//$NON-NLS-1$
List<Map<String, Object>> table = (List<Map<String, Object>>) elem.getPropertyValue(param.getName());
if (((Node) elem).getMetadataList().size() > 0) {
IMetadataTable metaTable = ((Node) elem).getMetadataList().get(0);
//$NON-NLS-1$
RepositoryToComponentProperty.getTableXmlFileValue(//$NON-NLS-1$
connection, //$NON-NLS-1$
"XML_MAPPING", //$NON-NLS-1$
param, table, metaTable);
param.setRepositoryValueUsed(true);
}
} else if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getRepositoryValue().equals("WSDL_PARAMS") && connection != null) {
//$NON-NLS-1$
List<Map<String, Object>> table = (List<Map<String, Object>>) elem.getPropertyValue(param.getName());
table.clear();
ArrayList parameters = ((WSDLSchemaConnection) connection).getParameters();
if (parameters != null) {
for (Object object : parameters) {
Map<String, Object> map2 = new HashMap<String, Object>();
//$NON-NLS-1$
map2.put("VALUE", TalendTextUtils.addQuotes(object.toString()));
table.add(map2);
}
}
param.setRepositoryValueUsed(true);
} else if (param.getFieldType().equals(EParameterFieldType.TEXT) && "XPATH_QUERY".equals(param.getRepositoryValue())) {
//$NON-NLS-1$
param.setRepositoryValueUsed(true);
} else {
// For SAP
String paramName = param.getName();
if ("SAP_PROPERTIES".equals(paramName) || "MAPPING_INPUT".equals(paramName) || // INPUT_PARAMS should be MAPPING_INPUT,bug16426
"SAP_FUNCTION".equals(paramName) || "OUTPUT_PARAMS".equals(paramName) || "SAP_ITERATE_OUT_TYPE".equals(paramName) || "SAP_ITERATE_OUT_TABLENAME".equals(paramName)) {
SAPParametersUtils.retrieveSAPParams(elem, connection, param, getSapFunctionLabel());
}
if ("GATEWAYSERVICE".equals(paramName) || "PROGRAMID".equals(paramName) || "FORMAT_XML".equals(paramName) || "FILE_IDOC_XML".equals(paramName) || "FORMAT_HTML".equals(paramName) || "FILE_IDOC_HTML".equals(paramName)) {
SAPParametersUtils.getSAPIDocParams(elem, connection, param, getSapIDocLabel());
}
}
if (param.isRepositoryValueUsed()) {
if (("GENERATION_MODE").equals(param.getName())) {
param.setReadOnly(true);
} else {
param.setReadOnly(false);
}
}
}
}
// (bug 5198)
IElementParameter parentParameter = propertyParam.getParentParameter();
if (parentParameter != null) {
IElementParameter param = parentParameter.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (param != null && propertyParam == param) {
// avoid to process twice.
ConnectionItem connItem = UpdateRepositoryUtils.getConnectionItemByItemId((String) param.getValue());
if (connItem != null) {
if (elem instanceof Node) {
ConnectionContextHelper.addContextForNodeParameter((Node) elem, connItem, ignoreContextMode);
} else if (elem instanceof Process) {
ConnectionContextHelper.addContextForProcessParameter((Process) elem, connItem, param.getCategory(), ignoreContextMode);
}
}
}
}
}
toUpdate = false;
// change AS400 value
for (IElementParameter curParam : elem.getElementParameters()) {
if (curParam.getFieldType().equals(EParameterFieldType.AS400_CHECK)) {
setOtherProperties();
}
// change the HL7 Version
if (connection instanceof HL7Connection) {
if (curParam.getName().equals("HL7_VER")) {
String hl7VersionString = connection.getVersion();
if (hl7VersionString != null) {
hl7VersionString = hl7VersionString.replace(".", "");
curParam.setValue(hl7VersionString);
}
}
}
setDefaultValues(curParam, elem);
}
if (elem instanceof Node) {
// Xstream Cdc Type Mode
boolean isXstreamCdcTypeMode = false;
if (connection != null && connection instanceof DatabaseConnection) {
String cdcTypeMode = ((DatabaseConnection) connection).getCdcTypeMode();
if (CDCTypeMode.XSTREAM_MODE == CDCTypeMode.indexOf(cdcTypeMode)) {
isXstreamCdcTypeMode = true;
}
}
if (isXstreamCdcTypeMode && ((Node) elem).getComponent().getName().equals("tOracleCDC")) {
//$NON-NLS-1$
IMetadataTable table = ((Node) elem).getMetadataList().get(0);
IElementParameter schemaParam = elem.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
schemaParam.setValueToDefault(elem.getElementParameters());
table.setListColumns((((IMetadataTable) schemaParam.getValue()).clone(true)).getListColumns());
}
((Process) ((Node) elem).getProcess()).checkProcess();
// Added TDQ-11688 show regex when "built-in"
ITDQPatternService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
}
if (service != null && service.isSinglePatternNode(elem)) {
IElementParameter regexParameter = ((Node) elem).getElementParameter("PATTERN_REGEX");
if (regexParameter != null) {
regexParameter.setShow(EmfComponent.BUILTIN.equals(this.value));
}
}
}
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class PropertiesTableEditorView method createColumns.
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#createColumns(org.talend.commons.ui
* .swt.tableviewer.TableViewerCreator, org.eclipse.swt.widgets.Table)
*/
@SuppressWarnings("unchecked")
@Override
protected void createColumns(final TableViewerCreator<B> tableViewerCreator, final Table table) {
// there's two lists of values, one that will be in the table
// and the other will be stored as the current value in the property
// there is two lists because of the undo / redo capabilities
PropertiesTableEditorModel model = getModel();
TalendProposalProvider processProposalProvider = new TalendProposalProvider(model.getProcess());
String[] titles = model.getTitles();
final Object[] itemsValue = model.getItemsValue();
final String[] items = model.getItems();
// final Element elem = model.getElement();
final IElementParameter param = model.getElemParameter();
final IElement element = model.getElement();
for (int i = 0; i < titles.length; i++) {
final int curCol = i;
final IElementParameter currentParam = (IElementParameter) itemsValue[i];
// if all is empty, show it always.
boolean toDisplay = currentParam.isShow(currentParam.getShowIf(), currentParam.getNotShowIf(), element.getElementParameters());
if (!toDisplay) {
List<Map<String, Object>> fullTable = (List<Map<String, Object>>) param.getValue();
for (int curLine = 0; curLine < fullTable.size(); curLine++) {
((ElementParameter) currentParam).setCurrentRow(curLine);
if (currentParam.isShow(element.getElementParameters())) {
toDisplay = true;
break;
}
}
}
if (toDisplay) {
final TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle(titles[i]);
column.setModifiable(true);
column.setMinimumWidth(100);
column.setWeight(20);
switch(currentParam.getFieldType()) {
case CONTEXT_PARAM_NAME_LIST:
case CLOSED_LIST:
case LOOKUP_COLUMN_LIST:
case COLUMN_LIST:
case CONNECTION_LIST:
case DBTYPE_LIST:
case COMPONENT_LIST:
case PREV_COLUMN_LIST:
final ComboBoxCellEditor cellEditor = new ComboBoxCellEditor(table, currentParam.getListItemsDisplayName());
final IElementParameter copyOfTmpParam = currentParam;
((CCombo) cellEditor.getControl()).setEditable(false);
((CCombo) cellEditor.getControl()).setEnabled(!(param.isRepositoryValueUsed() || param.isReadOnly() || currentParam.isReadOnly()));
column.setCellEditor(cellEditor, new CellEditorValueAdapter() {
@Override
public String getColumnText(CellEditor cellEditor, Object bean, Object cellEditorValue) {
return (String) cellEditorValue;
}
@Override
public Object getOriginalTypedValue(CellEditor cellEditor, Object cellEditorTypedValue) {
Object returnedValue = null;
if (cellEditorTypedValue != null && cellEditorTypedValue instanceof Integer) {
int index = (Integer) cellEditorTypedValue;
String[] namesSet = ((CCombo) cellEditor.getControl()).getItems();
if (namesSet.length > 0 && index > -1 && index < namesSet.length) {
returnedValue = namesSet[index];
} else {
returnedValue = null;
}
} else {
returnedValue = null;
}
return returnedValue;
}
;
@Override
public Object getCellEditorTypedValue(CellEditor cellEditor, Object originalTypedValue) {
CCombo combo = (CCombo) cellEditor.getControl();
int rowNumber = ((Table) combo.getParent()).getSelectionIndex();
String[] listToDisplay = getItemsToDisplay(element, copyOfTmpParam, rowNumber);
if (!Arrays.equals(listToDisplay, ((ComboBoxCellEditor) cellEditor).getItems())) {
((ComboBoxCellEditor) cellEditor).setItems(listToDisplay);
}
Object returnedValue = 0;
if (originalTypedValue != null) {
String[] namesSet = listToDisplay;
for (int j = 0; j < namesSet.length; j++) {
if (namesSet[j].equals(originalTypedValue)) {
returnedValue = j;
break;
}
}
}
return returnedValue;
}
;
});
break;
case OPENED_LIST:
final EditableComboBoxCellEditor editCellEditor = new EditableComboBoxCellEditor(table, currentParam.getListItemsDisplayName());
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String oldValue = null;
if (editCellEditor != null) {
if (!(editCellEditor.getValue() instanceof String)) {
return;
}
oldValue = (String) editCellEditor.getValue();
}
String[] columnItems = null;
if (table.getSelection() != null && table.getSelection().length > 0) {
TableItem tableItem = table.getSelection()[0];
if (tableItem.getData() instanceof Map) {
Map map = (Map) tableItem.getData();
if (currentParam.getFilter() != null && map.get(currentParam.getFilter()) instanceof String) {
String value = (String) map.get(currentParam.getFilter());
if (element instanceof Node) {
List<IConnection> listConnection = (List<IConnection>) ((Node) element).getInputs();
for (IConnection con : listConnection) {
if (con.getName().equals(value)) {
List<IMetadataColumn> columns = con.getMetadataTable().getListColumns();
columnItems = new String[columns.size()];
for (int i = 0; i < columns.size(); i++) {
columnItems[i] = columns.get(i).getLabel();
}
if (editCellEditor != null) {
List<String> ret = new ArrayList<String>();
for (String columnItem : columnItems) {
ret.add(columnItem);
}
for (int i = 0; i < currentParam.getListItemsDisplayName().length; i++) {
ret.add(currentParam.getListItemsDisplayName()[i]);
}
editCellEditor.setItems(ret.toArray(new String[0]));
editCellEditor.setValue(oldValue);
}
}
}
}
}
}
}
}
});
column.setCellEditor(editCellEditor);
break;
case MODULE_LIST:
column.setModifiable((!param.isRepositoryValueUsed()) && (!param.isReadOnly()) && (!currentParam.isReadOnly()));
ModuleListCellEditor moduleEditor = new ModuleListCellEditor(table, currentParam, param);
moduleEditor.setTableEditorView(this);
column.setCellEditor(moduleEditor);
break;
case COLOR:
column.setModifiable((!param.isRepositoryValueUsed()) && (!param.isReadOnly()) && (!currentParam.isReadOnly()));
// column.setDisplayedValue("");
column.setLabelProvider(null);
column.setCellEditor(new ColorCellEditor(table) {
@Override
protected void doSetValue(Object value) {
if (value instanceof String) {
super.doSetValue(ColorUtils.stringToRGB((String) value));
} else {
super.doSetValue(value);
}
}
@Override
protected void updateContents(Object value) {
if (value != null) {
if (value instanceof String) {
super.updateContents(ColorUtils.stringToRGB((String) value));
} else {
super.updateContents(value);
}
}
}
});
column.setColorProvider(new IColumnColorProvider() {
@Override
public Color getBackgroundColor(Object bean) {
Object value = ((Map<String, Object>) bean).get(items[curCol]);
if (value == null || (!(value instanceof String))) {
return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
}
return new Color(null, ColorUtils.stringToRGB((String) value));
}
@Override
public Color getForegroundColor(Object bean) {
return null;
}
});
break;
case CHECK:
column.setModifiable((!param.isRepositoryValueUsed()) && (!param.isReadOnly()) && (!currentParam.isReadOnly()));
CheckColumnSelectionListener tableColumnSelectionListener = new CheckColumnSelectionListener(column, tableViewerCreator, currentParam);
if (!currentParam.isReadOnly()) {
column.setTableColumnSelectionListener(tableColumnSelectionListener);
}
column.setTableEditorContent(new CheckboxTableEditorContent());
Boolean curValue = (Boolean) currentParam.getValue();
if (curValue == null) {
curValue = Boolean.FALSE;
}
tableColumnSelectionListener.setChecked(curValue.booleanValue());
if (curValue.booleanValue()) {
column.setImageHeader(ImageProvider.getImage(EImage.CHECKED_ICON));
} else {
column.setImageHeader(ImageProvider.getImage(EImage.UNCHECKED_ICON));
}
//$NON-NLS-1$
column.setDisplayedValue("");
break;
case SCHEMA_TYPE:
case SCHEMA_REFERENCE:
column.setModifiable((!param.isRepositoryValueUsed()) && (!param.isReadOnly()) && (!currentParam.isReadOnly()));
final INode node = (INode) element;
// List<IMetadataTable> tables = node.getMetadataList();
// if (isEBCDICNode(node)) { // ebcdic
column.setLabelProvider(new IColumnLabelProvider() {
@Override
public String getLabel(Object bean) {
if (bean instanceof Map) {
Map<String, Object> valueMap = (Map<String, Object>) bean;
String value = (String) valueMap.get(IEbcdicConstant.FIELD_SCHEMA);
if (value != null && !"".equals(value)) {
//$NON-NLS-1$
IMetadataTable metadataTable = MetadataToolHelper.getMetadataTableFromNodeTableName(node, value);
if (metadataTable != null) {
if (isEBCDICNode(node)) {
if (isRepositorySchemaLine(node, valueMap)) {
//$NON-NLS-1$ //$NON-NLS-2$
return "Repository (" + metadataTable.getTableName() + ")";
} else {
//$NON-NLS-1$ //$NON-NLS-2$
return "Built-In (" + metadataTable.getTableName() + ")";
}
} else {
return metadataTable.getTableName();
}
} else {
return value;
}
}
}
//$NON-NLS-1$
return "";
}
});
// } else {
// column.setLabelProvider(null);
// }
SchemaCellEditor schemaEditor = new SchemaCellEditor(table, node);
schemaEditor.setTableEditorView(this);
column.setCellEditor(schemaEditor);
break;
case SAP_SCHEMA_TYPE:
column.setModifiable((!param.isRepositoryValueUsed()) && (!param.isReadOnly()) && (!currentParam.isReadOnly()));
final INode sapNode = (INode) element;
column.setLabelProvider(new IColumnLabelProvider() {
@Override
public String getLabel(Object bean) {
if (bean instanceof Map) {
Map<String, Object> valueMap = (Map<String, Object>) bean;
String value = (String) valueMap.get(IEbcdicConstant.FIELD_SCHEMA);
if (value != null && !"".equals(value)) {
//$NON-NLS-1$
IMetadataTable metadataTable = MetadataToolHelper.getMetadataTableFromNodeTableName(sapNode, value);
if (metadataTable != null) {
if (isEBCDICNode(sapNode)) {
if (isRepositorySchemaLine(sapNode, valueMap)) {
//$NON-NLS-1$ //$NON-NLS-2$
return "Repository (" + metadataTable.getTableName() + ")";
} else {
//$NON-NLS-1$ //$NON-NLS-2$
return "Built-In (" + metadataTable.getTableName() + ")";
}
} else if (isSAPNode(sapNode)) {
Object type = valueMap.get(ISAPConstant.TYPE);
if (type instanceof Integer) {
return "";
}
if (type.toString().equals(SINGLE) || type.toString().equals(STRUCTURE)) {
List<IMetadataColumn> columns = metadataTable.getListColumns(true);
StringBuffer values = new StringBuffer();
values.append(metadataTable.getTableName() + ":");
if (metadataTable.getListColumns(true).size() > 0) {
for (IMetadataColumn column : columns) {
values.append(column.getDefault() + ",");
}
String ret = values.toString();
return ret.substring(0, ret.length() - 1);
}
} else {
return metadataTable.getTableName();
}
} else {
return metadataTable.getTableName();
}
} else {
return value;
}
}
}
//$NON-NLS-1$
return "";
}
});
schemaEditor = new SchemaCellEditor(table, sapNode);
schemaEditor.setTableEditorView(this);
column.setCellEditor(schemaEditor);
break;
// hywang add for feature 6484
case RULE_TYPE:
//$NON-NLS-1$
column.setTitle("Rule");
column.setModifiable((!param.isRepositoryValueUsed()) && (!param.isReadOnly()) && (!currentParam.isReadOnly()));
final INode node1 = (INode) element;
column.setLabelProvider(new IColumnLabelProvider() {
@Override
public String getLabel(Object bean) {
if (bean instanceof Map) {
Map<String, Object> valueMap = (Map<String, Object>) bean;
String value = (String) valueMap.get(IRuleConstant.FIELD_RULE);
if (value != null && !"".equals(value)) {
//$NON-NLS-1$
IMetadataTable metadataTable = MetadataToolHelper.getMetadataTableFromNodeTableName(node1, value);
if (metadataTable != null) {
return metadataTable.getTableName();
} else {
return value;
}
}
}
//$NON-NLS-1$
return "";
}
});
RuleCellEditor ruleEditor = new RuleCellEditor(table, node1);
ruleEditor.setTableEditorView(this);
column.setCellEditor(ruleEditor);
break;
case SCHEMA_XPATH_QUERYS:
column.setModifiable((!param.isRepositoryValueUsed()) && (!param.isReadOnly()) && (!currentParam.isReadOnly()));
final INode node2 = (INode) element;
SchemaXPathQuerysCellEditor schemaXPathEditor = new SchemaXPathQuerysCellEditor(table, node2);
schemaXPathEditor.setTableEditorView(this);
column.setCellEditor(schemaXPathEditor);
break;
case MULTI_PATTERN:
column.setModifiable(true);
PatternCellEditor patternEditor = new PatternCellEditor(table, element);
patternEditor.setTableEditorView(this);
column.setCellEditor(patternEditor);
break;
case PATTERN_PROPERTY:
column.setModifiable(true);
PatternPropertyCellEditor patternPropertyEditor = new PatternPropertyCellEditor(table, element);
patternPropertyEditor.setTableEditorView(this);
column.setCellEditor(patternPropertyEditor);
break;
default:
// TEXT
TextCellEditor tcEditor = null;
if (((i == 0) && (param.isBasedOnSchema() || param.isBasedOnSubjobStarts())) || (param.isRepositoryValueUsed()) || (param.isReadOnly()) || currentParam.isReadOnly()) {
// read only cell
if (!param.getElement().isReadOnly() && (param.getName().equals("HADOOP_ADVANCED_PROPERTIES") || param.getName().equals("SPARK_ADVANCED_PROPERTIES") || param.getName().equals("HBASE_PARAMETERS"))) {
if (currentParam.isNoContextAssist()) {
tcEditor = new TextCellEditor(table);
} else {
TextCellEditorWithProposal textCellEditor = new TextCellEditorWithProposal(table, column);
textCellEditor.setContentProposalProvider(processProposalProvider);
tcEditor = textCellEditor;
}
}
} else {
// writable cell
if (currentParam.isNoContextAssist()) {
tcEditor = new TextCellEditor(table);
} else {
TextCellEditorWithProposal textCellEditor = new TextCellEditorWithProposal(table, column);
textCellEditor.setContentProposalProvider(processProposalProvider);
tcEditor = textCellEditor;
}
}
if (tcEditor != null) {
column.setCellEditor(tcEditor);
column.setModifiable((!param.isRepositoryValueUsed()) && (!param.isReadOnly()) && (!currentParam.isReadOnly()));
}
}
// for all kinds of column, check if read only or not when edit the field.
column.setColumnCellModifier(new ColumnCellModifier(column) {
@Override
public boolean canModify(Object bean) {
if (param.getName().equals("HADOOP_ADVANCED_PROPERTIES") || param.getName().equals("SPARK_ADVANCED_PROPERTIES") || param.getName().equals("HBASE_PARAMETERS")) {
boolean canModify = super.canModify(bean);
if (canModify) {
Map<String, Object> valueMap = (Map<String, Object>) bean;
List<Map<String, Object>> fullValues = (List<Map<String, Object>>) param.getValue();
((ElementParameter) currentParam).setCurrentRow(fullValues.indexOf(valueMap));
if (currentParam.isReadOnly(element.getElementParameters())) {
return false;
}
} else {
Map<String, Object> valueMap = (Map<String, Object>) bean;
if (valueMap.get("BUILDIN") != null && valueMap.get("BUILDIN").equals("TRUE")) {
return true;
} else {
return false;
}
}
return canModify;
}
boolean canModify = super.canModify(bean);
if (canModify) {
Map<String, Object> valueMap = (Map<String, Object>) bean;
List<Map<String, Object>> fullValues = (List<Map<String, Object>>) param.getValue();
((ElementParameter) currentParam).setCurrentRow(fullValues.indexOf(valueMap));
if (currentParam.isReadOnly(element.getElementParameters())) {
return false;
}
}
return canModify;
}
});
column.setColorProvider(new IColumnColorProvider<B>() {
@Override
public Color getBackgroundColor(B bean) {
Map<String, Object> valueMap = (Map<String, Object>) bean;
List<Map<String, Object>> fullValues = (List<Map<String, Object>>) param.getValue();
// hyWang add varriable index for bug 7294
int index = fullValues.indexOf(valueMap);
if (index >= 0) {
((ElementParameter) currentParam).setCurrentRow(index);
if (currentParam.isReadOnly(element.getElementParameters())) {
return AbstractMetadataTableEditorView.READONLY_CELL_BG_COLOR;
}
}
if (param.getName().equals("HADOOP_ADVANCED_PROPERTIES") || param.getName().equals("SPARK_ADVANCED_PROPERTIES") || param.getName().equals("HBASE_PARAMETERS")) {
if (valueMap.get("BUILDIN") == null || valueMap.get("BUILDIN") != null && valueMap.get("BUILDIN").equals("")) {
return Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
}
}
if (currentParam.getFieldType() == EParameterFieldType.CONTEXT_PARAM_NAME_LIST) {
Object value = ((Map<String, Object>) bean).get(items[curCol]);
boolean found = false;
Object[] items = currentParam.getListItemsValue();
for (Object item : items) {
if (item.equals(value)) {
found = true;
break;
}
}
if (!found) {
return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
}
}
return null;
}
@Override
public Color getForegroundColor(B bean) {
return null;
}
});
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<B, Object>() {
@Override
public Object get(B bean) {
Object value = ((Map<String, Object>) bean).get(items[curCol]);
if (value == null) {
//$NON-NLS-1$
return "";
}
if (itemsValue[curCol] instanceof IElementParameter) {
IElementParameter tmpParam = (IElementParameter) itemsValue[curCol];
boolean hideValue = false;
if (!tmpParam.isReadOnly()) {
if ((tmpParam.getReadOnlyIf() != null || tmpParam.getNotReadOnlyIf() != null) && tmpParam.isReadOnly(element.getElementParameters())) {
hideValue = true;
}
}
switch(tmpParam.getFieldType()) {
case CONTEXT_PARAM_NAME_LIST:
case CLOSED_LIST:
case COMPONENT_LIST:
case COLUMN_LIST:
case CONNECTION_LIST:
case LOOKUP_COLUMN_LIST:
case PREV_COLUMN_LIST:
case DBTYPE_LIST:
if (hideValue) {
//$NON-NLS-1$
return "";
}
String[] namesSet = tmpParam.getListItemsDisplayName();
if (namesSet.length == 0) {
return tmpParam.getDefaultClosedListValue();
}
if (value instanceof String) {
boolean found = false;
int index = 0;
if (currentParam.getFieldType() == EParameterFieldType.CONTEXT_PARAM_NAME_LIST) {
// if not found, won't use first(index 0) instead
index = -1;
}
Object[] items = currentParam.getListItemsValue();
for (int j = 0; j < items.length && !found; j++) {
if (items[j].equals(value)) {
found = true;
index = j;
}
}
value = new Integer(index);
}
if (value != null && ((Integer) value) >= 0) {
return namesSet[(Integer) value];
}
return null;
case OPENED_LIST:
if (hideValue) {
//$NON-NLS-1$
return "";
}
String[] listItemsValue = tmpParam.getListItemsDisplayName();
if (listItemsValue.length == 0) {
return value;
}
int index = -1;
if (value instanceof String) {
boolean found = false;
Object[] items = ((IElementParameter) itemsValue[curCol]).getListItemsValue();
for (int j = 0; j < items.length && !found; j++) {
if (items[j].equals(value)) {
found = true;
index = j;
}
}
}
Integer count = new Integer(index);
if (count >= 0) {
return listItemsValue[count];
} else if (count < 0) {
return value;
}
return value;
case CHECK:
if (hideValue) {
return false;
}
if (value instanceof String) {
return new Boolean((String) value);
}
return value;
case RADIO:
if (hideValue) {
return false;
}
if (value instanceof String) {
return new Boolean((String) value);
}
return value;
case COLOR:
if (value instanceof String) {
return ColorUtils.stringToRGB((String) value);
}
// already RGB
return value;
default:
// TEXT
if (hideValue) {
//$NON-NLS-1$
return "";
}
return value;
}
}
return value;
}
@Override
public void set(B bean, Object value) {
Object finalValue = value;
IElementParameter tmpParam = (IElementParameter) itemsValue[curCol];
// TODO should test if this parameter is contained in any other show if / not show if, etc..
boolean included = false;
for (Object object : param.getListItemsValue()) {
if (object instanceof IElementParameter) {
if (((IElementParameter) object).getShowIf() != null && ((IElementParameter) object).getShowIf().contains(tmpParam.getName())) {
included = true;
break;
}
if (((IElementParameter) object).getNotShowIf() != null && ((IElementParameter) object).getNotShowIf().contains(tmpParam.getName())) {
included = true;
break;
}
if (((IElementParameter) object).getReadOnlyIf() != null && ((IElementParameter) object).getReadOnlyIf().contains(tmpParam.getName())) {
included = true;
break;
}
if (((IElementParameter) object).getNotReadOnlyIf() != null && ((IElementParameter) object).getNotReadOnlyIf().contains(tmpParam.getName())) {
included = true;
break;
}
}
}
if (included) {
IElementParameter param = element.getElementParameter(EParameterName.UPDATE_COMPONENTS.getName());
if (param != null) {
param.setValue(Boolean.TRUE);
}
}
boolean isNeedReCheck = false;
switch(tmpParam.getFieldType()) {
case CONTEXT_PARAM_NAME_LIST:
case CLOSED_LIST:
case COLUMN_LIST:
case COMPONENT_LIST:
case CONNECTION_LIST:
case LOOKUP_COLUMN_LIST:
case PREV_COLUMN_LIST:
isNeedReCheck = true;
if (value instanceof String) {
Object[] itemNames = ((IElementParameter) itemsValue[curCol]).getListItemsDisplayName();
Object[] itemValues = ((IElementParameter) itemsValue[curCol]).getListItemsValue();
boolean found = false;
int index = 0;
for (int j = 0; j < itemNames.length && !found; j++) {
if (itemNames[j].equals(value)) {
found = true;
index = j;
}
}
if (value != null && (index >= 0)) {
finalValue = itemValues[new Integer(index)];
}
}
break;
case OPENED_LIST:
if (value instanceof String) {
Object[] itemNames = ((IElementParameter) itemsValue[curCol]).getListItemsDisplayName();
Object[] itemValues = ((IElementParameter) itemsValue[curCol]).getListItemsValue();
boolean found = false;
int index = -1;
for (int j = 0; j < itemNames.length && !found; j++) {
if (itemNames[j].equals(value)) {
found = true;
index = j;
}
}
if (value != null && (index >= 0)) {
finalValue = itemValues[new Integer(index)];
} else if (value != null && (index < 0)) {
finalValue = value;
}
}
break;
case COLOR:
if (value instanceof RGB) {
RGB rgb = (RGB) value;
//$NON-NLS-1$ //$NON-NLS-2$
finalValue = rgb.red + ";" + rgb.green + ";" + rgb.blue;
}
default:
}
((Map<String, Object>) bean).put(items[curCol], finalValue);
resetValuesIfNeeded(element, param, (Map<String, Object>) bean);
/*
* TDI-6568, in fact, no need reset the value. just want to enable
* "firePropertyChange(RETURNS_CHANGED, null, null)" in Node.
*/
if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
element.setPropertyValue(param.getName(), param.getValue());
}
if (isNeedReCheck && element instanceof Node) {
IProcess process = ((Node) element).getProcess();
if (process instanceof IProcess2) {
((IProcess2) process).checkProcess();
}
// enable to refresh component setting after change modules.
// so far, for cMessagingEndpoint (TUP-1119)
final IElementParameter copyOfTmpParam = currentParam;
if (element != null && "LIBPATH".equals(copyOfTmpParam.getName())) {
//$NON-NLS-1$
IElementParameter updateComponentsParam = element.getElementParameter(EParameterName.UPDATE_COMPONENTS.getName());
if (updateComponentsParam != null) {
updateComponentsParam.setValue(Boolean.TRUE);
}
}
}
}
});
}
}
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class UpdateCheckResult method getName.
@Override
@SuppressWarnings("unchecked")
public String getName() {
IUpdateItemType updateType = getUpdateType();
String displayName = updateType.getDisplayLabel();
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case NODE_SCHEMA:
if (getResultType() == EUpdateResult.RENAME) {
List<Object> param = (List<Object>) getParameter();
String[] oldSourceIdAndChildName = UpdateManagerUtils.getSourceIdAndChildName((String) param.get(1));
String[] newSourceIdAndChildName = UpdateManagerUtils.getSourceIdAndChildName((String) param.get(2));
String display = UpdateManagerHelper.getRenamedDisplay(oldSourceIdAndChildName[1], newSourceIdAndChildName[1]);
if (display != null) {
displayName = display;
}
} else if (getResultType() == EUpdateResult.DELETE) {
// table delete by deselect
List<Object> param = (List<Object>) getParameter();
String tableDeleted = (String) param.get(0);
EUpdateResult status = (EUpdateResult) param.get(1);
String display = getDeleteOrReloadDisplay(tableDeleted, status);
if (display != null) {
displayName = display;
}
} else if (getResultType() == EUpdateResult.RELOAD) {
// table reload by deselect and reselect
List<Object> param = (List<Object>) getParameter();
String tableReload = (String) param.get(0);
EUpdateResult status = (EUpdateResult) param.get(1);
String display = getDeleteOrReloadDisplay(tableReload, status);
if (display != null) {
displayName = display;
}
} else {
if (getUpdateObject() instanceof INode && getParameter() instanceof List && PluginChecker.isEBCDICPluginLoaded()) {
IEBCDICProviderService service = (IEBCDICProviderService) GlobalServiceRegister.getDefault().getService(IEBCDICProviderService.class);
if (service != null && service.isEbcdicNode((INode) getUpdateObject())) {
List<Object> paramObjs = (List<Object>) getParameter();
if (paramObjs.size() >= 2) {
Object schemaName = paramObjs.get(1);
if (schemaName instanceof String) {
displayName = displayName + UpdateManagerUtils.addBrackets((String) schemaName);
}
}
}
}
}
break;
case NODE_PROPERTY:
case NODE_QUERY:
case JOBLET_SCHEMA:
case NODE_VALIDATION_RULE:
break;
case JOB_PROPERTY_EXTRA:
displayName = displayName + UpdateManagerUtils.addBrackets(EComponentCategory.EXTRA.getTitle());
break;
case JOB_PROPERTY_STATS_LOGS:
displayName = displayName + UpdateManagerUtils.addBrackets(EComponentCategory.STATSANDLOGS.getTitle());
break;
case JOB_PROPERTY_HEADERFOOTER:
displayName = displayName + UpdateManagerUtils.addBrackets(EComponentCategory.HEADERFOOTER.getTitle());
break;
case CONTEXT_GROUP:
if (getUpdateObject() != null && getUpdateObject() instanceof IContext) {
displayName = ((IContext) getUpdateObject()).getName();
}
break;
case CONTEXT:
// case JOBLET_CONTEXT:
{
String display = null;
switch(getResultType()) {
case RENAME:
List<Object> param = (List<Object>) getParameter();
display = UpdateManagerHelper.getRenamedDisplay((String) param.get(1), (String) param.get(2));
break;
default:
if (getUpdateObject() instanceof Collection) {
display = UpdateManagerHelper.getCollectionsDisplay(getUpdateObject(), false);
}
break;
}
if (display != null) {
displayName = display;
}
break;
}
case JOBLET_RENAMED:
{
List<Object> param = (List<Object>) getParameter();
String display = UpdateManagerHelper.getRenamedDisplay((String) param.get(1), (String) param.get(2));
if (display != null) {
displayName = display;
}
break;
}
case RELOAD:
case JUNIT_RELOAD:
if (getParameter() != null && getParameter() instanceof PropertyChangeEvent) {
PropertyChangeEvent event = (PropertyChangeEvent) getParameter();
// reload all compoennts.
if (event.getSource() != null && !(event.getSource() instanceof IProcess)) {
displayName = updateType.getDisplayLabel();
break;
}
}
break;
default:
}
return displayName;
} else {
return UpdateManagerProviderDetector.INSTANCE.getResultName(this);
}
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class UpdateCheckResult method getCategory.
@Override
@SuppressWarnings("unchecked")
public String getCategory() {
String category = null;
if (getUpdateType() instanceof EUpdateItemType) {
switch((EUpdateItemType) getUpdateType()) {
case NODE_PROPERTY:
case NODE_SCHEMA:
case NODE_QUERY:
case NODE_VALIDATION_RULE:
case JOBLET_SCHEMA:
if (getUpdateObject() != null) {
if (getUpdateObject() instanceof Node) {
Node node = (Node) getUpdateObject();
if (node.getUniqueName().equals(node.getLabel())) {
category = node.getUniqueName();
} else {
category = node.getLabel() + UpdateManagerUtils.addBrackets(node.getUniqueName());
}
}
if (getUpdateObject() instanceof NodeType) {
NodeType node = (NodeType) getUpdateObject();
String uniqueName = null;
for (ElementParameterType param : (List<ElementParameterType>) node.getElementParameter()) {
if (EParameterName.UNIQUE_NAME.getName().equals(param.getName())) {
uniqueName = param.getValue();
break;
}
}
if (uniqueName != null) {
category = uniqueName;
}
}
}
break;
case JOB_PROPERTY_EXTRA:
case JOB_PROPERTY_STATS_LOGS:
case JOB_PROPERTY_HEADERFOOTER:
case JOB_PROPERTY_MAPREDUCE:
boolean isJoblet = false;
boolean isMR = false;
if (getUpdateObject() != null) {
if (getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
if (AbstractProcessProvider.isExtensionProcessForJoblet((IProcess) getUpdateObject())) {
isJoblet = true;
} else if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
isMR = mrProcessService.isMapReduceItem(item);
}
}
}
if (isMR) {
//
category = JobSettingsView.VIEW_NAME_BATCH;
} else if (isJoblet) {
// joblet
category = JobSettingsView.VIEW_NAME_JOBLET;
} else {
category = JobSettingsView.getViewNameLable();
}
break;
case JOB_PROPERTY_STORM:
boolean isStreaming = false;
if (getUpdateObject() != null && getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
isStreaming = streamingService.isStormItem(item);
}
}
if (isStreaming) {
//
category = JobSettingsView.VIEW_NAME_STREAMING;
} else {
category = JobSettingsView.getViewNameLable();
}
break;
case CONTEXT:
// case JOBLET_CONTEXT:
category = UpdatesConstants.CONTEXT;
break;
case CONTEXT_GROUP:
category = UpdatesConstants.CONTEXT_GROUP;
break;
case JOBLET_RENAMED:
case RELOAD:
case JUNIT_RELOAD:
if (getUpdateObject() != null && getUpdateObject() instanceof List) {
String display = UpdateManagerHelper.getCollectionsDisplay(getUpdateObject(), true);
if (display != null) {
category = display;
}
} else if (getParameter() != null && getParameter() instanceof PropertyChangeEvent) {
PropertyChangeEvent event = (PropertyChangeEvent) getParameter();
// reload all compoennts.
if (event.getSource() != null && !(event.getSource() instanceof IProcess)) {
category = UpdatesConstants.COMPONENT;
break;
}
} else {
category = UpdatesConstants.JOBLET;
}
break;
default:
}
} else {
category = UpdateManagerProviderDetector.INSTANCE.getDisplayCategory(this);
}
return category == null ? UpdatesConstants.EMPTY : category;
}
Aggregations