private static Map<String, String> copyLine( Map<String, Object> currentLine, IElementParameter param) { Map<String, String> newLine = new HashMap<String, String>(); String[] items = param.getListItemsDisplayCodeName(); for (int i = 0; i < items.length; i++) { Object o = currentLine.get(items[i]); if (o instanceof Integer) { IElementParameter tmpParam = (IElementParameter) param.getListItemsValue()[i]; if ((((Integer) o) == -1) || (tmpParam.getListItemsValue().length == 0)) { newLine.put(items[i], ""); // $NON-NLS-1$ } else { newLine.put(items[i], (String) tmpParam.getListItemsValue()[(Integer) o]); } } else { if (o instanceof String) { if (param.getName().equals("SQLPATTERN_VALUE")) { // $NON-NLS-1$ SQLPatternItem item = SQLPatternUtils.getItemFromCompoundId(param.getElement(), ((String) o)); if (item != null) { newLine.put(items[i], new String(item.getContent().getInnerContent())); } else { newLine.put(items[i], ""); // $NON-NLS-1$ } } else if (param.getElement() != null && param.getElement() instanceof INode && ((INode) param.getElement()).getComponent().getName().equals("tWebService")) { String replacedValue = (String) o; if (items[i].equals("EXPRESSION")) { String inputRow = "row1"; List connList = ((INode) param.getElement()).getIncomingConnections(); if (connList.size() > 0) { inputRow = ((IConnection) connList.get(0)).getName(); replacedValue = replacedValue.replace("input.", inputRow + "."); } } newLine.put(items[i], replacedValue); } else { newLine.put(items[i], (String) o); } } else { if (o instanceof Boolean) { newLine.put(items[i], ((Boolean) o).toString()); } else { newLine.put(items[i], ""); // $NON-NLS-1$ } } } } return newLine; }
@SuppressWarnings("unchecked") private static String getDisplayValue(final IElementParameter param) { Object value = param.getValue(); if (value instanceof String) { if (param.getName().equals("PROCESS_TYPE_VERSION") && value.equals(RelationshipItemBuilder.LATEST_VERSION)) { // $NON-NLS-1$ String jobId = (String) param .getParentParameter() .getChildParameters() .get("PROCESS_TYPE_PROCESS") .getValue(); //$NON-NLS-1$ ProcessItem processItem = ItemCacheManager.getProcessItem(jobId); if (processItem == null) { return ""; //$NON-NLS-1$ } return processItem.getProperty().getVersion(); } if (param.getName().equals("PROCESS_TYPE_CONTEXT")) { // $NON-NLS-1$ String jobId = (String) param .getParentParameter() .getChildParameters() .get("PROCESS_TYPE_PROCESS") .getValue(); //$NON-NLS-1$ ProcessItem processItem = ItemCacheManager.getProcessItem(jobId); if (processItem == null) { return ""; //$NON-NLS-1$ } // check if the selected context exists, if not, use the default context of the job. boolean contextExists = false; for (Object object : processItem.getProcess().getContext()) { if (object instanceof ContextType) { if (((ContextType) object).getName() != null && ((ContextType) object).getName().equals(value)) { contextExists = true; continue; } } } if (!contextExists) { return processItem.getProcess().getDefaultContext(); } return (String) value; } // hywang add for 6484 if ("SELECTED_FILE".equals(param.getRepositoryValue())) { // $NON-NLS-N$ //$NON-NLS-1$ IElementParameter propertyParam = param .getElement() .getElementParameter( "PROPERTY:REPOSITORY_PROPERTY_TYPE"); // $NON-NLS-N$ //$NON-NLS-1$ if (propertyParam != null && propertyParam.getValue() != null && !propertyParam.getValue().equals("")) { // $NON-NLS-1$ try { IRepositoryViewObject object = CoreRuntimePlugin.getInstance() .getProxyRepositoryFactory() .getLastVersion((String) propertyParam.getValue()); if (object != null) { Item item = object.getProperty().getItem(); String extension = null; String rule = ""; // $NON-NLS-1$ String processLabelAndVersion = null; if (item instanceof RulesItem) { RulesItem rulesItem = (RulesItem) item; extension = rulesItem.getExtension(); if (param.getElement() instanceof INode) { INode node = (INode) param.getElement(); IProcess process = node.getProcess(); String jobLabel = process.getName(); String jobVersion = process.getVersion(); processLabelAndVersion = JavaResourcesHelper.getJobFolderName(jobLabel, jobVersion); } rule = "rules/final/" + processLabelAndVersion + "/" + rulesItem.getProperty().getLabel() // $NON-NLS-1$ //$NON-NLS-2$ + rulesItem.getProperty().getVersion() + extension; } return TalendQuoteUtils.addQuotes(rule); } else { return param.getValue().toString(); } } catch (Exception e) { ExceptionHandler.process(e); } } } return (String) value; } if (param.getFieldType() == EParameterFieldType.RADIO || param.getFieldType() == EParameterFieldType.CHECK || param.getFieldType() == EParameterFieldType.AS400_CHECK) { if (value instanceof Boolean) { return ((Boolean) param.getValue()).toString(); } else { return Boolean.FALSE.toString(); } } if (param.getFieldType() == EParameterFieldType.TABLE) { List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue(); String[] items = param.getListItemsDisplayCodeName(); String stringValues = "{"; // $NON-NLS-1$ for (int i = 0; i < tableValues.size(); i++) { Map<String, Object> lineValues = tableValues.get(i); stringValues += "["; // $NON-NLS-1$ for (int j = 0; j < items.length; j++) { Object currentValue = lineValues.get(items[j]); if (currentValue instanceof Integer) { IElementParameter tmpParam = (IElementParameter) param.getListItemsValue()[j]; if (tmpParam.getListItemsDisplayName().length != 0) { stringValues += tmpParam.getListItemsDisplayName()[(Integer) currentValue]; } } else { stringValues += currentValue; } if (j != (items.length - 1)) { stringValues += ","; // $NON-NLS-1$ } } stringValues += "]"; // $NON-NLS-1$ if (i != (tableValues.size() - 1)) { stringValues += ","; // $NON-NLS-1$ } } stringValues += "}"; // $NON-NLS-1$ return stringValues; } return new String(""); // $NON-NLS-1$ }