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; }
/** * load the Element's parameters to EMF Model * * @param elemParam * @param paType */ public static void loadElementParameters( Element elemParam, ParametersType paType, String repParamName) { if (paType == null || elemParam == null) { return; } EList listParamType = paType.getElementParameter(); ElementParameterType repositoryParam = null; if (repParamName != null && !repParamName.equals("")) { repositoryParam = findElementParameterType(paType, repParamName); } else { repositoryParam = findElementParameterType( paType, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName()); } IElementParameter statsDBType = null; IElementParameter implicitDBType = null; IElementParameter statsDBVersion = null; IElementParameter implicitDBVersion = null; for (int j = 0; j < listParamType.size(); j++) { ElementParameterType pType = (ElementParameterType) listParamType.get(j); if (pType != null) { String pTypeName = pType.getName(); if (pTypeName != null && !"".equals(pTypeName)) { IElementParameter param = elemParam.getElementParameter(pTypeName); if (pTypeName.equals("DB_TYPE")) { // $NON-NLS-1$ statsDBType = param; } else if (pTypeName.equals("DB_VERSION")) { // $NON-NLS-1$ statsDBVersion = param; } else if (pTypeName.equals("DB_TYPE_IMPLICIT_CONTEXT")) { // $NON-NLS-1$ implicitDBType = param; } else if (pTypeName.equals("DB_VERSION_IMPLICIT_CONTEXT")) { // $NON-NLS-1$ implicitDBVersion = param; } if (param != null) { String name = param.getName(); param.setContextMode(pType.isContextMode()); if (param.isReadOnly() && !(EParameterName.UNIQUE_NAME.getName().equals(name) || EParameterName.VERSION.getName().equals(name))) { continue; // if the parameter is read only, don't load // it (this will prevent to overwrite the // value) } String value = null; if ("STATANDLOG_USE_PROJECT_SETTINGS".equals(name) // $NON-NLS-1$ || "IMPLICITCONTEXT_USE_PROJECT_SETTINGS".equals(name)) { // $NON-NLS-1$ Object value2 = param.getValue(); if (value2 != null) { value = value2.toString(); } } else { value = pType.getValue(); } if (param.getFieldType().equals(EParameterFieldType.CHECK) || param.getFieldType().equals(EParameterFieldType.RADIO)) { if (Boolean.FALSE.toString().equalsIgnoreCase(value) || Boolean.TRUE.toString().equalsIgnoreCase(value) || !pType.isContextMode()) { Boolean boolean1 = new Boolean(value); elemParam.setPropertyValue(pTypeName, boolean1); } else { elemParam.setPropertyValue(pTypeName, value); } // if (EParameterName.ACTIVATE.getName().equals(param.getName())) { // if ((elemParam instanceof Node) && !boolean1) { // ((Node) elemParam).setDummy(!boolean1); // } // } } else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) { boolean valueSet = false; if (!ArrayUtils.contains(param.getListItemsValue(), value)) { if (ArrayUtils.contains(param.getListItemsDisplayName(), value)) { valueSet = true; int index = ArrayUtils.indexOf(param.getListItemsDisplayName(), value); if (index > -1) { elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[index]); } } else if (value.equals("") && name != null && (name.equals("LOAD_NEW_VARIABLE") || name.equals("NOT_LOAD_OLD_VARIABLE"))) { valueSet = true; elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[1]); } } if (!valueSet) { elemParam.setPropertyValue(pTypeName, value); } } else if (param.getFieldType().equals(EParameterFieldType.TABLE)) { List<Map<String, Object>> tableValues = new ArrayList<Map<String, Object>>(); String[] codeList = param.getListItemsDisplayCodeName(); Map<String, Object> lineValues = null; for (ElementValueType elementValue : (List<ElementValueType>) pType.getElementValue()) { boolean found = false; int length = codeList.length; if (length > 0) { for (int i = 0; i < length && !found; i++) { if (codeList[i].equals(elementValue.getElementRef())) { found = true; } } } IElementParameter tmpParam = null; for (Object o : param.getListItemsValue()) { if (o instanceof IElementParameter) { IElementParameter tableParam = (IElementParameter) o; if (tableParam.getName().equals(elementValue.getElementRef())) { tmpParam = tableParam; break; } } } if (found) { if ((lineValues == null) || (lineValues.get(elementValue.getElementRef()) != null)) { lineValues = new HashMap<String, Object>(); tableValues.add(lineValues); } String elemValue = elementValue.getValue(); if (tmpParam != null && EParameterFieldType.PASSWORD.equals(tmpParam.getFieldType())) { elemValue = elementValue.getRawValue(); } lineValues.put(elementValue.getElementRef(), elemValue); if (elementValue.getType() != null) { lineValues.put( elementValue.getElementRef() + IEbcdicConstant.REF_TYPE, elementValue.getType()); } } } elemParam.setPropertyValue(pTypeName, tableValues); } else if (param.getFieldType().equals(EParameterFieldType.PASSWORD)) { param.setValue(pType.getRawValue()); } else if (param.getFieldType().equals(EParameterFieldType.ENCODING_TYPE)) { // fix for bug 2193 boolean setToCustom = false; if (EmfComponent.REPOSITORY.equals( elemParam.getPropertyValue(EParameterName.PROPERTY_TYPE.getName())) && param.getRepositoryValue() != null && param.getRepositoryValue().equals("ENCODING")) { // $NON-NLS-1$ setToCustom = true; } String tempValue = null; IElementParameter iElementParameter = null; Map<String, IElementParameter> childParameters = param.getChildParameters(); if (childParameters != null) { iElementParameter = childParameters.get(EParameterName.ENCODING_TYPE.getName()); if (iElementParameter != null) { tempValue = (String) iElementParameter.getValue(); } } if (tempValue != null && !tempValue.equals(EmfComponent.ENCODING_TYPE_CUSTOM)) { tempValue = tempValue.replaceAll("'", ""); // $NON-NLS-1$ //$NON-NLS-2$ tempValue = tempValue.replaceAll("\"", ""); // $NON-NLS-1$ //$NON-NLS-2$ tempValue = TalendTextUtils.addQuotes(tempValue); if (!tempValue.equals(value)) { setToCustom = true; } } if (iElementParameter != null && setToCustom) { iElementParameter.setValue(EmfComponent.ENCODING_TYPE_CUSTOM); } elemParam.setPropertyValue(pTypeName, value); // end of fix for bug 2193 } else if (!param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) { if (param.getRepositoryValue() != null && !param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE)) { if (repositoryParam != null && EmfComponent.REPOSITORY.equals(repositoryParam.getValue())) { param.setRepositoryValueUsed(true); } else { param.setRepositoryValueUsed(false); } } elemParam.setPropertyValue(pTypeName, value); } } else if (UpdateTheJobsActionsOnTable.isClear && "CLEAR_TABLE".equals(pTypeName) // $NON-NLS-1$ && "true".equals(pType.getValue()) // $NON-NLS-1$ && "NONE" .equals( elemParam .getElementParameter(Process.TABLE_ACTION) .getValue())) { //$NON-NLS-1$ elemParam.setPropertyValue(Process.TABLE_ACTION, "CLEAR"); // $NON-NLS-1$ UpdateTheJobsActionsOnTable.isClear = false; } } } } // update combo list for dbversion if (statsDBType != null && statsDBVersion != null) { JobSettingVersionUtil.setDbVersion( statsDBVersion, String.valueOf(statsDBType.getValue()), String.valueOf(statsDBVersion.getValue())); } if (implicitDBType != null && implicitDBVersion != null) { JobSettingVersionUtil.setDbVersion( implicitDBVersion, String.valueOf(implicitDBType.getValue()), String.valueOf(implicitDBVersion.getValue())); } }