@SuppressWarnings("unchecked") protected void updateColumnList(IMetadataTable oldTable, IMetadataTable newTable) { final List<ColumnNameChanged> columnNameChanged = MetadataToolHelper.getColumnNameChanged(oldTable, newTable); if (inputNode != null) { List<IElementParameter> eps = (List<IElementParameter>) inputNode.getElementParameters(); if (eps != null) { boolean end = false; for (int i = 0; i < eps.size() && !end; i++) { IElementParameter parameter = eps.get(i); if (parameter.getFieldType() == EParameterFieldType.TABLE) { end = true; if (parameter != null) { List<Map<String, Object>> map2 = (List<Map<String, Object>>) parameter.getValue(); if (map2 != null && inputNode.getMetadataList().get(0).getListColumns().size() != map2.size()) { ColumnListController.updateColumnList(inputNode, columnNameChanged); } } } } } inputNode.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE); } node.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE); }
public static void convertVarNodesToDefineFunctions(VarTable varTable, List<INode> iNodes) { // Send back the change to the tPigLoad node if you modified the configure of define dunctions for (INode iNode : iNodes) { IElementParameter elementParameter = iNode.getElementParameter(PigMapConstants.DEFINE_FUNCTION); if (elementParameter != null && elementParameter.getValue() instanceof List) { List<Map<String, String>> defineFunctions = (List<Map<String, String>>) elementParameter.getValue(); defineFunctions.clear(); defineFunctionsAlias.clear(); for (VarNode varNode : varTable.getNodes()) { if (iNode.getUniqueName().equals(varNode.getType())) { Map<String, String> item = new HashMap<String, String>(); item.put( PigMapConstants.FUNCTION_ALIAS, TalendQuoteUtils.addQuotesIfNotExist(varNode.getName())); if (varNode.getExpression() != null) { String newString = varNode.getExpression().trim(); if (newString.length() > 0) { newString = TalendQuoteUtils.addQuotesIfNotExist(newString); } item.put(PigMapConstants.UDF_FUNCTION, newString); } else { item.put(PigMapConstants.UDF_FUNCTION, ""); // $NON-NLS-1$ } defineFunctions.add(item); String key = varNode.getName(); if (!defineFunctionsAlias.containsKey(key)) { defineFunctionsAlias.put(key, varNode.getExpression()); } } } } } }
@Override public void execute() { oldType = (String) paramEncoding.getValue(); String tempValue = newRealValue; tempValue = tempValue.replaceAll("'", ""); // $NON-NLS-1$ //$NON-NLS-2$ tempValue = tempValue.replaceAll("\"", ""); // $NON-NLS-1$ //$NON-NLS-2$ boolean newIsCustomAndoldIsNotCustom = tempValue.equals(EmfComponent.ENCODING_TYPE_CUSTOM) && !paramEncoding.getValue().equals(EmfComponent.ENCODING_TYPE_CUSTOM); boolean newIsNotCustomAndoldIsCustom = !tempValue.equals(EmfComponent.ENCODING_TYPE_CUSTOM) && paramEncoding.getValue().equals(EmfComponent.ENCODING_TYPE_CUSTOM); boolean toRefresh = false; if (fromCombo && (newIsCustomAndoldIsNotCustom || newIsNotCustomAndoldIsCustom)) { toRefresh = true; } if (ArrayUtils.contains(paramEncoding.getListItemsValue(), tempValue)) { paramEncoding.setValue(tempValue); } if (toRefresh) { getElement().setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE); if (DynamicTabbedPropertySection.getLastPropertyUsed() != null) { DynamicTabbedPropertySection.getLastPropertyUsed().refresh(); } } super.execute(); }
public static List<VarNode> convertDefineFunctionsToVarNodes( MapperManager mapperManger, List<INode> iNodes) { List<VarNode> varNodes = new ArrayList<VarNode>(); if (mapperManger != null) { PigMapComponent mapperComponent = mapperManger.getMapperComponent(); iNodesDefineFunctions.clear(); defineFunctionsAlias.clear(); checkPigLoadIfDefineFunctions(mapperComponent, iNodes); iNodesDefineFunctions.addAll(iNodes); for (INode iNode : iNodes) { IElementParameter elementParameter = iNode.getElementParameter(PigMapConstants.DEFINE_FUNCTION); if (elementParameter != null && elementParameter.getValue() instanceof List) { List<Map<String, String>> defineFunctions = (List<Map<String, String>>) elementParameter.getValue(); if (defineFunctions.size() > 0) { for (Map<String, String> item : defineFunctions) { VarNode newVarNode = PigmapFactory.eINSTANCE.createVarNode(); newVarNode.setType(iNode.getUniqueName()); newVarNode.setName(item.get(PigMapConstants.FUNCTION_ALIAS)); newVarNode.setExpression(item.get(PigMapConstants.UDF_FUNCTION)); varNodes.add(newVarNode); String key = item.get(PigMapConstants.FUNCTION_ALIAS); if (!defineFunctionsAlias.containsKey(key)) { defineFunctionsAlias.put(key, item.get(PigMapConstants.UDF_FUNCTION)); } } } } } } return varNodes; }
public static void checkPigLoadIfDefineFunctions(INode iNode, List<INode> iNodes) { if (iNode != null) { List<? extends IConnection> connections = iNode.getIncomingConnections(); for (IConnection conn : connections) { INode oriNode = conn.getSource(); if (oriNode != null) { if (oriNode.getUniqueName() != null && oriNode.getUniqueName().startsWith(PigMapConstants.TPIGLOAD_NODE)) { IElementParameter elementParameter = oriNode.getElementParameter(PigMapConstants.DEFINE_FUNCTION); if (elementParameter != null && elementParameter.getValue() instanceof List) { // we can add this direct. List<Map<String, String>> defineFunctions = (List<Map<String, String>>) elementParameter.getValue(); if (defineFunctions.size() >= 0) { iNodes.add(oriNode); } } } if (iNode.getIncomingConnections().size() > 0) { checkPigLoadIfDefineFunctions(oriNode, iNodes); } } } } }
public static Object getParameterValue(Element elem, String paramName) { IElementParameter param = elem.getElementParameter(paramName); if (param != null) { return param.getValue(); } return null; }
@Override public void undo() { if (!oldType.equals(EmfComponent.ENCODING_TYPE_CUSTOM)) { paramEncoding.setValue(oldType); paramEncoding.setShow(false); } super.undo(); }
public static boolean isRedShiftNode(INode node) { if (node != null) { IElementParameter param = node.getElementParameter(PROPERTY); if (param != null && param.getFieldType() == EParameterFieldType.PROPERTY_TYPE && IDatabaseConstant.REDSHIFT.equals(param.getRepositoryValue())) { return true; } } return false; }
public EncodingTypeChangeCommand( IElement elem, String propName, Object propValue, boolean fromCombo) { super( elem, propName, EmfComponent.ENCODING_TYPE_CUSTOM.equals(propValue) ? elem.getPropertyValue(propName) : propValue); newRealValue = (String) propValue; IElementParameter curParam = getElement().getElementParameter(getPropName()); paramEncoding = curParam.getChildParameters().get(EParameterName.ENCODING_TYPE.getName()); this.fromCombo = fromCombo; }
public static void updateModuleList(Node node) { List<ModuleNeeded> moduleNeededList = ModulesNeededProvider.getModulesNeeded(); Set<String> moduleNameList = new TreeSet<String>(); Set<String> moduleValueList = new TreeSet<String>(); for (ModuleNeeded module : moduleNeededList) { String moduleName = module.getModuleName(); moduleNameList.add(moduleName); moduleValueList.add(TalendTextUtils.addQuotes(moduleName)); } Comparator<String> comprarator = new IgnoreCaseComparator(); String[] moduleNameArray = moduleNameList.toArray(new String[0]); String[] moduleValueArray = moduleValueList.toArray(new String[0]); Arrays.sort(moduleNameArray, comprarator); Arrays.sort(moduleValueArray, comprarator); for (int i = 0; i < node.getElementParameters().size(); i++) { IElementParameter param = node.getElementParameters().get(i); if (param.getFieldType() == EParameterFieldType.MODULE_LIST) { param.setListItemsDisplayName(moduleNameArray); param.setListItemsValue(moduleValueArray); } else if (param.getFieldType() == EParameterFieldType.TABLE) { Object[] listItemsValue = param.getListItemsValue(); if (listItemsValue != null) { for (Object o : listItemsValue) { if (o instanceof IElementParameter && ((IElementParameter) o).getFieldType() == EParameterFieldType.MODULE_LIST) { ((IElementParameter) o).setListItemsDisplayName(moduleNameArray); ((IElementParameter) o).setListItemsValue(moduleValueArray); } } } } } }
/* * use to synchronize column list for output connections. */ private void syncOutputNodeColumnsList(List<ColumnNameChanged> columnNameChanged) { if (outputdataContainer == null) { return; } for (IConnection conn : node.getOutgoingConnections()) { INode targetNode = conn.getTarget(); EConnectionType connStyle = conn.getLineStyle(); if (EConnectionType.FLOW_MAIN.equals(connStyle) || EConnectionType.FLOW_MERGE.equals(connStyle) || EConnectionType.FLOW_REF.equals(connStyle)) { ColumnListController.updateColumnList(targetNode, columnNameChanged); // fix for TDI-23202 // reset value in order to call "firePropertyChange(RETURNS_CHANGED, null, null)" IElementParameter defaultMap = targetNode.getElementParameter(EParameterName.DEFAULT_MAP.getName()); if (defaultMap != null) { if ("tFlowToIterate".equals(targetNode.getComponent().getName())) { // update target properties incase any old columns are removed IElementParameter elementParameter = targetNode.getElementParameter("MAP"); if (elementParameter != null) { Object value = elementParameter.getValue(); if (value instanceof List) { for (Object obj : (List) value) { if (obj instanceof Map) { Object object = ((Map) obj).get("VALUE"); if (newOutputMetadata != null && !newOutputMetadata.getListColumns().isEmpty()) { boolean found = false; for (IMetadataColumn column : newOutputMetadata.getListColumns()) { if (column.getLabel().equals(object)) { found = true; } } if (!found) { ((Map) obj) .put("VALUE", newOutputMetadata.getListColumns().get(0).getLabel()); } } else { ((Map) obj).put("VALUE", ""); } } } } } } targetNode.setPropertyValue(EParameterName.DEFAULT_MAP.getName(), defaultMap.getValue()); } } } }
private void setDBVersionForMysql(IElementParameter dbVersionParam, String dbType) { if ("MYSQL".equals(dbType)) { String[] drivers = StatsAndLogsConstants.MYSQL_VERSION_DRIVER; // if driver is not set , set to the default boolean found = false; for (String driver : drivers) { if (driver.equals(dbVersionParam.getValue())) { found = true; } } if (!found) { dbVersionParam.setValue(drivers[0]); } } }
@Override public void refresh(IElementParameter param, boolean checkErrorsWhenViewRefreshed) { Text text = (Text) hashCurControls.get(param.getName()); if (text == null || text.isDisposed()) { return; } Object value = param.getValue(); if (value == null) { text.setText(""); // $NON-NLS-1$ } else { if (!value.equals(text.getText())) { text.setText((String) value); } } if (checkErrorsWhenViewRefreshed) { checkErrorsForPropertiesOnly(text); } }
public void init( INode node, IElementParameter schemaParam, IMetadataTable currentOutputMetadata, IMetadataTable newOutputMetadata) { this.node = node; this.schemaParam = schemaParam; if (schemaParam == null) { if (newOutputMetadata.getAttachedConnector() != null) { currentConnector = newOutputMetadata.getAttachedConnector(); } else { if (node.isELTComponent()) { currentConnector = EConnectionType.TABLE.getName(); } else { currentConnector = EConnectionType.FLOW_MAIN.getName(); } } for (IElementParameter param : node.getElementParameters()) { if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) && param.getContext().equals(currentConnector)) { this.schemaParam = param; } } } else { currentConnector = this.schemaParam.getContext(); } this.inputNode = null; this.currentInputMetadata = null; this.newInputMetadata = null; oldInputMetadata = null; this.currentOutputMetadata = currentOutputMetadata; if (this.currentOutputMetadata == null) { this.currentOutputMetadata = node.getMetadataFromConnector(currentConnector); } if (currentOutputMetadata == null && newOutputMetadata != null) { currentOutputMetadata = newOutputMetadata.clone(true); } oldOutputMetadata = this.currentOutputMetadata.clone(true); this.newOutputMetadata = newOutputMetadata.clone(true); this.newOutputMetadata.setReadOnly(this.currentOutputMetadata.isReadOnly()); initializeContainer(); setLabel(Messages.getString("ChangeMetadataCommand.changeMetadataValues")); // $NON-NLS-1$ }
public Command createCommand(SelectionEvent selectionEvent) { Set<String> elementsName; Control ctrl; elementsName = hashCurControls.keySet(); for (String name : elementsName) { Object o = hashCurControls.get(name); if (o instanceof Control) { ctrl = (Control) o; if (ctrl == null) { hashCurControls.remove(name); return null; } if (ctrl.equals(selectionEvent.getSource()) && ctrl instanceof CCombo) { boolean isDisposed = ((CCombo) ctrl).isDisposed(); if (!isDisposed && (!elem.getPropertyValue(name).equals(((CCombo) ctrl).getText()))) { String value = new String(""); // $NON-NLS-1$ for (int i = 0; i < elem.getElementParameters().size(); i++) { IElementParameter param = elem.getElementParameters().get(i); if (param.getName().equals(name)) { for (int j = 0; j < param.getListItemsValue().length; j++) { if (((CCombo) ctrl).getText().equals(param.getListItemsDisplayName()[j])) { value = (String) param.getListItemsValue()[j]; } } } } if (value.equals(elem.getPropertyValue(name))) { // same // value so // no // need to do // anything return null; } CorePlugin.getDefault().getLibrariesService().resetModulesNeeded(); return new PropertyChangeCommand(elem, name, value); } } } } return null; }
public ChangeMetadataCommand( INode node, IElementParameter schemaParam, INode inputNode, IMetadataTable currentInputMetadata, IMetadataTable newInputMetadata, IMetadataTable currentOutputMetadata, IMetadataTable newOutputMetadata) { this.node = node; this.inputNode = inputNode; this.schemaParam = schemaParam; if (schemaParam == null) { currentConnector = EConnectionType.FLOW_MAIN.getName(); for (IElementParameter param : node.getElementParameters()) { if ((param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || param.getFieldType().equals(EParameterFieldType.DCSCHEMA)) && param.getContext().equals(currentConnector)) { this.schemaParam = param; } } } else { currentConnector = this.schemaParam.getContext(); } this.currentInputMetadata = currentInputMetadata; if (currentInputMetadata != null) { oldInputMetadata = currentInputMetadata.clone(); } else { oldInputMetadata = null; } this.newInputMetadata = newInputMetadata; this.currentOutputMetadata = currentOutputMetadata; if (this.currentOutputMetadata == null) { this.currentOutputMetadata = node.getMetadataFromConnector(currentConnector); } oldOutputMetadata = this.currentOutputMetadata.clone(); this.newOutputMetadata = newOutputMetadata; initializeContainer(); setLabel(Messages.getString("ChangeMetadataCommand.changeMetadataValues")); // $NON-NLS-1$ }
@Override public void refresh(IElementParameter param, boolean check) { CCombo combo = (CCombo) hashCurControls.get(param.getName()); if (combo == null || combo.isDisposed()) { return; } updateData(); String[] curNameList = param.getListItemsDisplayName(); Object value = param.getValue(); combo.setItems(curNameList); if (value instanceof String) { combo.setText(TalendTextUtils.removeQuotes((String) value)); } if (param.isContextMode()) { Button buttonEdit = (Button) hashCurControls.get(param.getName() + BUTTON_EDIT); combo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); combo.setEnabled(false); buttonEdit.setEnabled(false); } }
/** * DOC qzhang Comment method "changeTableNameParameter". * * @param newdbTableName * @param olddbTableName * @param uniqueName * @param dbTableElementField */ private void changeTableNameParameter( String newdbTableName, String olddbTableName, String uniqueName, IElementParameter dbTableElementField) { if (dbTableElementField != null) { if (isNotSim) { newdbTableName = newdbTableName == null ? "" : newdbTableName; // $NON-NLS-1$ dbTableElementField.setValue(TalendTextUtils.addQuotes(newdbTableName)); return; } Object value = dbTableElementField.getValue(); String removeQuotes = TalendTextUtils.removeQuotes((String) value); boolean b = value == null || removeQuotes.equals(""); // $NON-NLS-1$ // add the code for table name equals uniqueName b = b || uniqueName.equals(olddbTableName); b = b || value != null && removeQuotes.toString().equals(olddbTableName); if (b) { newdbTableName = newdbTableName == null ? "" : newdbTableName; // $NON-NLS-1$ dbTableElementField.setValue(TalendTextUtils.addQuotes(newdbTableName)); } } }
@Override public void handleTableRelevantParameters( Connection connection, IElement ele, IMetadataTable metadataTable) { if (ele == null || metadataTable == null) { return; } String tableName = metadataTable.getTableName(); IElementParameter tableNameParameter = ele.getElementParameter(EHCatalogRepositoryToComponent.TABLE_NAME.getParameterName()); if (tableNameParameter != null) { tableNameParameter.setValue(getRepositoryValueOfStringType(connection, tableName)); } String partition = metadataTable.getAdditionalProperties().get(HCatalogConstants.PARTITIONS); if (StringUtils.isNotEmpty(partition)) { IElementParameter partitionParameter = ele.getElementParameter(EHCatalogRepositoryToComponent.PARTITION_NAME.getParameterName()); if (partitionParameter != null) { String partitionName = ExtractMetaDataFromHCatalog.extractPartitionNameByJsonStr(partition); if (StringUtils.isNotEmpty(partitionName)) { partitionParameter.setValue(getRepositoryValueOfStringType(connection, partitionName)); } } } }
@Override public void refresh(IElementParameter param, boolean checkErrorsWhenViewRefreshed) { IElement element = param.getElement(); if (element instanceof IProcess2) { if (findProcessProvider != null) { ImageDescriptor icon = findProcessProvider.getIcons((IProcess2) element); if (icon != null) { Image image = icon.createImage(); addResourceDisposeListener(filePathText, image); filePathText.setImage(image); } } } }
/* * (non-Javadoc) * * @see * org.talend.designer.core.ICheckNodesService#checkNode(org.talend.designer * .core.ui.editor.nodes.Node) */ public void checkNode(Node node) { if (!node.getComponent().getName().equals("cJMS")) { // $NON-NLS-1$ return; } List<? extends IElementParameter> parameters = node.getElementParameters(); for (IElementParameter param : parameters) { if (param.getFieldType() == EParameterFieldType.ROUTE_COMPONENT_TYPE) { IElementParameter idParam = param.getChildParameters().get(EParameterName.ROUTE_COMPONENT_TYPE_ID.getName()); if (idParam == null || idParam.getValue() == null || idParam.getValue().toString().isEmpty()) { String errorMessage = MessageFormat.format( CamelDesignerMessages.getString( "CheckJMSNodesService_emptyParaError") //$NON-NLS-1$ , param.getDisplayName()); Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage); } else { List<? extends INode> graphicalNodes = node.getProcess().getGraphicalNodes(); boolean has = false; for (INode n : graphicalNodes) { if (n.getUniqueName().equals(idParam.getValue())) { has = true; break; } } if (!has) { String errorMessage = MessageFormat.format( CamelDesignerMessages.getString("CheckJMSNodesService_nonExistError"), param.getDisplayName()); // $NON-NLS-1$ Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage); } } } } }
/** qzhang Comment method "setXMLMAPPING". */ protected void setXMLMAPPING() { if (getConnection() != null) { for (IElementParameter parameter : node.getElementParameters()) { if (parameter.getFieldType() == EParameterFieldType.TABLE && parameter.getRepositoryValue() != null && parameter.getRepositoryValue().equals("XML_MAPPING")) { // $NON-NLS-1$ List<Map<String, Object>> value2 = (List<Map<String, Object>>) parameter.getValue(); RepositoryToComponentProperty.getTableXMLMappingValue( getConnection(), value2, newOutputMetadata, getColumnRenameMap()); IElementParameter elementParameter = node.getElementParameter(EParameterName.PROPERTY_TYPE.getName()); if (elementParameter != null) { if (EmfComponent.BUILTIN.equals(elementParameter.getValue())) { parameter.setRepositoryValueUsed(false); } else { parameter.setRepositoryValueUsed(true); } } } } } }
/* * (non-Javadoc) * * @see * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter) */ @Override public int estimateRowSize(Composite subComposite, IElementParameter param) { if (!estimateInitialized) { DecoratedField dField = new DecoratedField( subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, new TextControlCreator()); Text text = (Text) dField.getControl(); FormData d = (FormData) text.getLayoutData(); d.height = text.getLineHeight(); text.getParent().setSize(subComposite.getSize().x, text.getLineHeight()); Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT); rowSizeByLine = text.getLineHeight(); dField.getLayoutControl().dispose(); rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine); estimateInitialized = true; } return rowSizeFixed + (rowSizeByLine * param.getNbLines()); }
private void setHCatalogRepositoryValue( HCatalogConnection connection, INode node, IElementParameter param) { if (EHCatalogRepositoryToComponent.DISTRIBUTION .getRepositoryValue() .equals(param.getRepositoryValue())) { String value = ComponentToRepositoryProperty.getParameterValue(connection, node, param); if (value != null) { connection.setDistribution(value); } } else if (EHCatalogRepositoryToComponent.HCAT_VERSION .getRepositoryValue() .equals(param.getRepositoryValue())) { String value = ComponentToRepositoryProperty.getParameterValue(connection, node, param); if (value != null) { connection.setHcatVersion(value); } } else if (EHCatalogRepositoryToComponent.TEMPLETON_HOST .getRepositoryValue() .equals(param.getRepositoryValue())) { String value = ComponentToRepositoryProperty.getParameterValue(connection, node, param); if (value != null) { connection.setHostName(value); } } else if (EHCatalogRepositoryToComponent.TEMPLETON_PORT .getRepositoryValue() .equals(param.getRepositoryValue())) { String value = ComponentToRepositoryProperty.getParameterValue(connection, node, param); if (value != null) { connection.setPort(value); } } else if (EHCatalogRepositoryToComponent.DATABASE_NAME .getRepositoryValue() .equals(param.getRepositoryValue())) { String value = ComponentToRepositoryProperty.getParameterValue(connection, node, param); if (value != null) { connection.setDatabase(value); } } else if (EHCatalogRepositoryToComponent.USERNAME .getRepositoryValue() .equals(param.getRepositoryValue())) { String value = ComponentToRepositoryProperty.getParameterValue(connection, node, param); if (value != null) { connection.setUserName(value); } } }
public void logCompSetting() { if (log4jEnabled) { stringBuffer.append(TEXT_10); stringBuffer.append(var("log4jParamters")); stringBuffer.append(TEXT_11); stringBuffer.append(TEXT_12); stringBuffer.append(var("log4jParamters")); stringBuffer.append(TEXT_13); java.util.Set<org.talend.core.model.process.EParameterFieldType> ignoredParamsTypes = new java.util.HashSet<org.talend.core.model.process.EParameterFieldType>(); ignoredParamsTypes.addAll( java.util.Arrays.asList( org.talend.core.model.process.EParameterFieldType.SCHEMA_TYPE, org.talend.core.model.process.EParameterFieldType.LABEL, org.talend.core.model.process.EParameterFieldType.EXTERNAL, org.talend.core.model.process.EParameterFieldType.MAPPING_TYPE, org.talend.core.model.process.EParameterFieldType.IMAGE, org.talend.core.model.process.EParameterFieldType.TNS_EDITOR, org.talend.core.model.process.EParameterFieldType.WSDL2JAVA, org.talend.core.model.process.EParameterFieldType.GENERATEGRAMMARCONTROLLER, org.talend.core.model.process.EParameterFieldType .GENERATE_SURVIVORSHIP_RULES_CONTROLLER, org.talend.core.model.process.EParameterFieldType.REFRESH_REPORTS, org.talend.core.model.process.EParameterFieldType.BROWSE_REPORTS, org.talend.core.model.process.EParameterFieldType.PALO_DIM_SELECTION, org.talend.core.model.process.EParameterFieldType.GUESS_SCHEMA, org.talend.core.model.process.EParameterFieldType.MATCH_RULE_IMEX_CONTROLLER, org.talend.core.model.process.EParameterFieldType.MEMO_PERL, org.talend.core.model.process.EParameterFieldType.DBTYPE_LIST, org.talend.core.model.process.EParameterFieldType.VERSION, org.talend.core.model.process.EParameterFieldType.TECHNICAL, org.talend.core.model.process.EParameterFieldType.ICON_SELECTION, org.talend.core.model.process.EParameterFieldType.JAVA_COMMAND, org.talend.core.model.process.EParameterFieldType.TREE_TABLE, org.talend.core.model.process.EParameterFieldType.VALIDATION_RULE_TYPE, org.talend.core.model.process.EParameterFieldType.DCSCHEMA, org.talend.core.model.process.EParameterFieldType.SURVIVOR_RELATION, org.talend.core.model.process.EParameterFieldType.REST_RESPONSE_SCHEMA_TYPE)); for (org.talend.core.model.process.IElementParameter ep : org.talend.core.model.utils.NodeUtil.getDisplayedParameters(node)) { if (!ep.isLog4JEnabled() || ignoredParamsTypes.contains(ep.getFieldType())) { continue; } String name = ep.getName(); if (org.talend.core.model.process.EParameterFieldType.PASSWORD.equals( ep.getFieldType())) { String epName = "__" + name + "__"; String password = ""; if (org.talend.core.model.process.ElementParameterParser.canEncrypt(node, epName)) { password = org.talend.core.model.process.ElementParameterParser.getEncryptedValue( node, epName); } else { String passwordValue = org.talend.core.model.process.ElementParameterParser.getValue(node, epName); if (passwordValue == null || "".equals(passwordValue.trim())) { // for the value which empty passwordValue = "\"\""; } password = "******" + passwordValue + ")"; } stringBuffer.append(TEXT_14); stringBuffer.append(var("log4jParamters")); stringBuffer.append(TEXT_15); stringBuffer.append(name); stringBuffer.append(TEXT_16); stringBuffer.append(password); stringBuffer.append(TEXT_17); } else { String value = org.talend.core.model.utils.NodeUtil.getNormalizeParameterValue(node, ep); stringBuffer.append(TEXT_18); stringBuffer.append(var("log4jParamters")); stringBuffer.append(TEXT_19); stringBuffer.append(name); stringBuffer.append(TEXT_20); stringBuffer.append(value); stringBuffer.append(TEXT_21); } stringBuffer.append(TEXT_22); stringBuffer.append(var("log4jParamters")); stringBuffer.append(TEXT_23); } } debug(var("log4jParamters")); }
public static ElementParameterType getElemeterParameterType(IElementParameter param) { if (param == null) { return null; } ElementParameterType targetPramType = TalendFileFactory.eINSTANCE.createElementParameterType(); if (param.getParentParameter() != null) { targetPramType.setName( param.getParentParameter().getName() + ":" + param.getName()); // $NON-NLS-1$ } else { targetPramType.setName(param.getName()); } targetPramType.setField(param.getFieldType().getName()); targetPramType.setContextMode(param.isContextMode()); Object value = param.getValue(); if (param.getFieldType().equals(EParameterFieldType.TABLE) && value != null) { List<Map<String, Object>> tableValues = (List<Map<String, Object>>) value; for (Map<String, Object> currentLine : tableValues) { for (int i = 0; i < param.getListItemsDisplayCodeName().length; i++) { ElementValueType elementValue = TalendFileFactory.eINSTANCE.createElementValueType(); elementValue.setElementRef(param.getListItemsDisplayCodeName()[i]); Object o = currentLine.get(param.getListItemsDisplayCodeName()[i]); IElementParameter tmpParam = null; Object[] listItemsValue = param.getListItemsValue(); if (listItemsValue.length > i) { tmpParam = (IElementParameter) listItemsValue[i]; } String strValue = ""; // $NON-NLS-1$ if (o instanceof Integer && tmpParam != null) { if (tmpParam.getListItemsValue().length == 0) { strValue = ""; // $NON-NLS-1$ } else { strValue = (String) tmpParam.getListItemsValue()[(Integer) o]; } } else { if (o instanceof String) { strValue = (String) o; } else { if (o instanceof Boolean) { strValue = ((Boolean) o).toString(); } } } if (tmpParam != null && tmpParam.getFieldType().equals(EParameterFieldType.PASSWORD)) { elementValue.setValue(strValue, true); } else { elementValue.setValue(strValue); } // Object object = currentLine.get(param.getListItemsDisplayCodeName()[i] + IEbcdicConstant.REF_TYPE); if (object != null) { elementValue.setType((String) object); } targetPramType.getElementValue().add(elementValue); } } } else { if (value == null) { targetPramType.setValue(""); // $NON-NLS-1$ } else { if (value instanceof Boolean) { targetPramType.setValue(((Boolean) value).toString()); } else { if (value instanceof String) { targetPramType.setRawValue(value.toString()); } } } } return targetPramType; }
@Override public void addComponents(boolean forceRedraw) { if (conSchema()) { disposeChildren(); curRowSize = 0; List<? extends IElementParameter> listParam = ((Connection) elem).getSource().getElementParameters(); generator.initController(this); for (IElementParameter cur : listParam) { if ((cur.getFieldType() == EParameterFieldType.SCHEMA_TYPE) && (cur.getContext().equals(((Connection) elem).getConnectorName()))) { AbstractElementPropertySectionController contorller = generator.getController(EParameterFieldType.SCHEMA_TYPE, this); contorller.createControl(composite, cur, 0, 0, 0, null); } } FormData data = new FormData(); data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE); data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE); data.top = new FormAttachment(0, curRowSize + ITabbedPropertyConstants.VSPACE); data.width = 300; // to correct bug of table growing indefinitly IMetadataTable outputMetaTable = ((Connection) elem).getMetadataTable(); if (outputMetaTable != null) { // Composite compositeEditorView = new Composite(composite, SWT.BORDER); // compositeEditorView.setLayoutData(data); metadataTableEditor = new MetadataTableEditor( outputMetaTable, "Schema from " //$NON-NLS-1$ + ((Connection) elem).getSource().getElementName() + " output "); //$NON-NLS-1$ metadataTableEditorView = new MetadataTableEditorView( composite, SWT.NONE, metadataTableEditor, true, false, true, false); MetadataDialog.initializeMetadataTableView( metadataTableEditorView, ((Connection) elem).getSource(), outputMetaTable); metadataTableEditorView.initGraphicComponents(); metadataTableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack()); CustomTableManager.addCustomManagementToTable(metadataTableEditorView, true); Composite compositeEditorView = metadataTableEditorView.getMainComposite(); compositeEditorView.setLayoutData(data); // compositeEditorView.getParent().layout(); Table table = metadataTableEditorView.getTable(); int currentHeightEditor = table.getHeaderHeight() + outputMetaTable.getListColumns().size() * table.getItemHeight() + table.getItemHeight() + 50; curRowSize = currentHeightEditor + ITabbedPropertyConstants.VSPACE + curRowSize; } super.addComponents(forceRedraw, false); } else if (conIf()) { super.addComponents(forceRedraw); } else { disposeChildren(); } }
/* * (non-Javadoc) * * @see * org.talend.designer.core.ICheckNodesService#checkNode(org.talend.designer * .core.ui.editor.nodes.Node) */ public void checkNode(Node node) { if (!node.getComponent().getName().equals("cCXF")) { // $NON-NLS-1$ return; } IElementParameter resourceParam = node.getElementParameter(EParameterName.ROUTE_RESOURCE_TYPE_ID.getName()); IElementParameter wsdlFileParam = node.getElementParameter("WSDL_FILE"); // $NON-NLS-1$ IElementParameter serviceParam = node.getElementParameter("SERVICE_TYPE"); // $NON-NLS-1$ IElementParameter wsdlTypeParam = node.getElementParameter("WSDL_TYPE"); // $NON-NLS-1$ IElementParameter clazzParam = node.getElementParameter("SERVICE_CLASS"); // $NON-NLS-1$ // Select WSDL if (serviceParam != null && "wsdlURL".equals(serviceParam.getValue())) { // $NON-NLS-1$ // Select File if (wsdlTypeParam != null && "file".equals(wsdlTypeParam.getValue())) { // $NON-NLS-1$ // WSDL file is empty if (wsdlFileParam == null || wsdlFileParam.getValue() == null || wsdlFileParam.getValue().toString().isEmpty() || wsdlFileParam.getValue().toString().equals("\"\"")) { // $NON-NLS-1$ String errorMessage = MessageFormat.format( CamelDesignerMessages.getString("CheckCXFNodesService_emptyError") // $NON-NLS-1$ , wsdlFileParam == null ? "" : wsdlFileParam.getDisplayName()); Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage); } } // Select Repository else if (wsdlTypeParam != null && "repo".equals(wsdlTypeParam.getValue())) { // $NON-NLS-1$ // WSDL file is empty String errorMessage = ""; // $NON-NLS-1$ if (resourceParam == null || resourceParam.getValue() == null || resourceParam.getValue().toString().isEmpty()) { errorMessage = MessageFormat.format( CamelDesignerMessages.getString("CheckCXFNodesService_emptyError") // $NON-NLS-1$ , wsdlFileParam.getDisplayName()); Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage); } else { String id = (String) resourceParam.getValue(); try { IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(id); if (lastVersion == null) { errorMessage = MessageFormat.format( CamelDesignerMessages.getString( "CheckCXFNodesService_nonexistError") //$NON-NLS-1$ , wsdlFileParam.getDisplayName()); Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage); } else if (lastVersion.isDeleted()) { errorMessage = MessageFormat.format( CamelDesignerMessages.getString( "CheckCXFNodesService_removedError") //$NON-NLS-1$ , resourceParam.getDisplayName()); Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage); } } catch (PersistenceException e) { errorMessage = MessageFormat.format( CamelDesignerMessages.getString( "CheckCXFNodesService_emptyError") //$NON-NLS-1$ , wsdlFileParam.getDisplayName()); Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage); } } } } // Select Service class else if (serviceParam != null && "serviceClass".equals(serviceParam.getValue())) { // $NON-NLS-1$ // Service class is empty if (clazzParam == null || clazzParam.getValue() == null || clazzParam.getValue().toString().isEmpty()) { String errorMessage = MessageFormat.format( CamelDesignerMessages.getString("CheckCXFNodesService_emptyError") // $NON-NLS-1$ , wsdlFileParam.getDisplayName()); Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage); } } }
/** Constructs a new FileInputNode. */ public FileInputDelimitedNode( String filename, String rowSep, String fieldSep, int limitRows, int headerRows, int footerRows, String escapeChar, String textEnclosure, boolean removeEmptyRow, boolean spitRecord, String encoding, EShadowProcessType fileType) { super("tFileInputDelimited"); // $NON-NLS-1$ boolean csvoption = false; String languageName = LanguageManager.getCurrentLanguage().getName(); switch (fileType) { case FILE_DELIMITED: csvoption = false; if (languageName.equals("perl")) { // $NON-NLS-1$ int max = getColumnCount( filename, rowSep, fieldSep, limitRows, headerRows, escapeChar, textEnclosure, EShadowProcessType.FILE_DELIMITED); this.setColumnNumber(max); } else { int max = 0; try { max = FileInputDelimited.getMaxColumnCount( trimParameter(filename), trimParameter(encoding), trimParameter(StringUtils.loadConvert(fieldSep, languageName)), trimParameter(StringUtils.loadConvert(rowSep, languageName)), true, spitRecord, headerRows, limitRows); } catch (IOException e) { // e.printStackTrace(); ExceptionHandler.process(e); } if (max > 0) { this.setColumnNumber(max); } } break; case FILE_CSV: csvoption = true; if (languageName.equals("perl")) { // $NON-NLS-1$ int max = getColumnCount( filename, rowSep, fieldSep, limitRows, headerRows, escapeChar, textEnclosure, EShadowProcessType.FILE_CSV); this.setColumnNumber(max); } else { CSVFileColumnConnter cr = null; try { cr = new CSVFileColumnConnter(); cr.setSeperator( trimParameter(StringUtils.loadConvert(fieldSep, languageName)).charAt(0)); int columnCount = 0; columnCount = cr.countMaxColumnNumber( new File(TalendTextUtils.removeQuotes(filename)), limitRows); if (columnCount > 0) { this.setColumnNumber(columnCount); } } catch (UnsupportedEncodingException e) { ExceptionHandler.process(e); } catch (FileNotFoundException e) { ExceptionHandler.process(e); } catch (IOException e) { ExceptionHandler.process(e); } } break; default: break; } String[] paramNames = null; if (!csvoption) { paramNames = new String[] { "FILENAME", "ROWSEPARATOR", "FIELDSEPARATOR", "LIMIT", "HEADER", "FOOTER", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ // //$NON-NLS-6$ "ESCAPE_CHAR", "TEXT_ENCLOSURE", "REMOVE_EMPTY_ROW", "ENCODING", "CSV_OPTION", "SPLITRECORD" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ } else { paramNames = new String[] { "FILENAME", "CSVROWSEPARATOR", "FIELDSEPARATOR", "LIMIT", "HEADER", "FOOTER", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ // //$NON-NLS-6$ "ESCAPE_CHAR", "TEXT_ENCLOSURE", "REMOVE_EMPTY_ROW", "ENCODING", "CSV_OPTION", "SPLITRECORD" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ } String[] paramValues = new String[] { filename, rowSep, fieldSep, Integer.toString(limitRows), Integer.toString(headerRows), Integer.toString(footerRows), escapeChar, textEnclosure, Boolean.toString(removeEmptyRow), encoding, Boolean.toString(csvoption), Boolean.toString(spitRecord) }; IComponent component = ComponentsFactoryProvider.getInstance() .get( "tFileInputDelimited", //$NON-NLS-1$ ComponentCategory.CATEGORY_4_DI.getName()); this.setElementParameters(component.createElementParameters(this)); for (int i = 0; i < paramNames.length; i++) { if (paramValues[i] != null) { IElementParameter param = this.getElementParameter(paramNames[i]); if (param != null) { param.setValue(paramValues[i]); } } } }
public static void setParameterValue(Element elem, String paramName, Object value) { IElementParameter param = elem.getElementParameter(paramName); if (param != null) { param.setValue(value); } }