protected String getParameterDefaultValue(String defValue, StandardField field) { if (StringUtils.isBlank(defValue)) { try { TypeDefaultValue tdv = MetadataServiceProvider.getTypeDefaultValueOfStdFieldByName(project, field.getName()); if (tdv != null) { if (resource != null && StringUtils.equals(resource.getType(), "procedure")) { String dt = (String) ((ARESProjectProperty) project.getProjectProperty()) .getProperties() .get("dbType"); if (StringUtils.isNotBlank(dt)) { return tdv.getData().get(dt.toLowerCase()); } } else { return tdv.getData().get(dataType); } } } catch (Exception e) { // e.printStackTrace(); } } return defValue; }
private String getDescription(MetadataItem mdItem) { // 标准字段提示具体的说明信息 TASK #8602 输入输出中标准字段参数,能显示具体的说明信息 if (mdItem instanceof StandardField) { StandardField field = (StandardField) mdItem; StringBuffer text = new StringBuffer(); String dictTypeStr = field.getDictionaryType(); if (StringUtils.isNotBlank(dictTypeStr)) { ReferenceInfo dictReferenceInfo = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.Dict, dictTypeStr, true); if (dictReferenceInfo != null) { DictionaryType objDictionaryType = (DictionaryType) dictReferenceInfo.getObject(); if (objDictionaryType != null) { for (DictionaryItem item : objDictionaryType.getItems()) { String value = StringUtils.defaultString(item.getValue()); String chineseName = StringUtils.defaultString(item.getChineseName()); text.append(objDictionaryType.getName()); text.append(":"); text.append(objDictionaryType.getChineseName()); text.append("-"); text.append(value); text.append(":"); text.append(chineseName); text.append("\r\n"); } } } } if (StringUtils.isNotBlank(text.toString()) && StringUtils.isNotBlank(field.getDescription())) { text.append("\r\n"); text.append(field.getDescription()); } String desc = StringUtils.defaultString( StringUtils.defaultIfBlank(text.toString(), field.getDescription())); if (StringUtils.isNotBlank(desc)) { return desc; } } return null; }
public void setDataType(String dataType) { StandardField std = getOriginalInfo(); if (std != null) { std.setDataType(dataType); } }
public void setDictInfo(String dictId) { StandardField std = getOriginalInfo(); if (std != null) { std.setDictionaryType(dictId); } }
public void setDescription(String description) { StandardField std = getOriginalInfo(); if (std != null) { std.setDescription(description); } }
public void setChineseName(String chinaeseName) { StandardField std = getOriginalInfo(); if (std != null) { std.setChineseName(chinaeseName); } }
public void setName(String name) { StandardField std = getOriginalInfo(); if (std != null) { std.setName(name); } }
@Override public String getText(Object element) { Parameter p = (Parameter) getOwner(element); EStructuralFeature feature = getEStructuralFeature(element); if (feature.getEType().equals(EcorePackage.Literals.EBOOLEAN) || feature.getEType().equals(EcorePackage.Literals.EBOOLEAN_OBJECT)) { return StringUtils.EMPTY; } // 不同参数类型分开处理 switch (p.getParamType()) { case NON_STD_FIELD: // 非标准字段参数的真实类型也不可编辑,显示对应的业务数据类型的设置的语言的值(在项目属性中设置) if (feature.equals(BizPackage.Literals.PARAMETER__REAL_TYPE)) { String bizType = p.getType(); if (StringUtils.isEmpty(bizType)) break; ReferenceInfo ref = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.BizType, bizType, true); if (ref != null) { BusinessDataType bizDataType = (BusinessDataType) ref.getObject(); if (bizDataType == null) break; String stdType = bizDataType.getStdType(); if (StringUtils.isEmpty(stdType)) break; ReferenceInfo stdTypeRef = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.StdType, stdType, true); if (stdTypeRef == null) break; StandardDataType stdDataType = (StandardDataType) stdTypeRef.getObject(); return stdDataType.getData().get(dataType); } } else if (BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { return getNonStdParameterDefaultValue(p.getDefaultValue(), p); } break; case STD_FIELD: if (BizPackage.Literals.PARAMETER__NAME.equals(feature) || BizPackage.Literals.PARAMETER__REAL_TYPE.equals(feature) || BizPackage.Literals.PARAMETER__TYPE.equals(feature) || BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature) || BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { ReferenceInfo referenceInfo = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.StdField, p.getId(), true); if (referenceInfo != null) { StandardField field = (StandardField) referenceInfo.getObject(); if (field == null) { return StringUtils.EMPTY; } if (BizPackage.Literals.PARAMETER__NAME.equals(feature)) { return field.getChineseName(); } else if (BizPackage.Literals.PARAMETER__REAL_TYPE.equals( feature)) { // 一般不存在此情况,如果要取真实类型可以继承此类重新实现 try { StandardDataType sdt = MetadataServiceProvider.getStandardDataTypeOfStdFieldByName( project, field.getName()); if (sdt != null) { return sdt.getData().get(dataType); } } catch (Exception e) { // e.printStackTrace(); } } else if (BizPackage.Literals.PARAMETER__TYPE.equals(feature)) { return field.getDataType(); } else if (BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature)) { StringBuffer text = new StringBuffer(); String dictTypeStr = field.getDictionaryType(); if (StringUtils.isNotBlank(dictTypeStr)) { ReferenceInfo dictReferenceInfo = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.Dict, dictTypeStr, true); if (dictReferenceInfo != null) { DictionaryType objDictionaryType = (DictionaryType) dictReferenceInfo.getObject(); if (objDictionaryType != null) { for (DictionaryItem item : objDictionaryType.getItems()) { String value = StringUtils.defaultString(item.getValue()); String chineseName = StringUtils.defaultString(item.getChineseName()); text.append(value); text.append(":"); text.append(chineseName); text.append(" "); } } } } if (StringUtils.isNotBlank(text.toString()) && StringUtils.isNotBlank(field.getDescription())) { text.append("\r\n"); text.append(field.getDescription()); } return StringUtils.defaultString( StringUtils.defaultIfBlank(text.toString(), field.getDescription())); } else if (BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { return getParameterDefaultValue(p.getDefaultValue(), field); } } } break; case OBJECT: // 如果有对象标准字段列表资源 if (BizUtil.hasStdObjList(project)) { String refId = p.getId(); ReferenceInfo ref = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IBizRefType.Std_Obj, refId, true); if (ref == null) break; StandardObjField field = (StandardObjField) ref.getObject(); String objId = field.getType(); ARESObject obj = BizUtil.getObject(objId, project); if (feature.equals(BizPackage.Literals.PARAMETER__TYPE)) { if (StringUtils.contains(objId, '.')) return StringUtils.substringAfterLast(objId, "."); } else if (feature.equals(BizPackage.Literals.PARAMETER__NAME)) { return obj == null ? StringUtils.EMPTY : obj.getChineseName(); } else if (feature.equals(BizPackage.Literals.PARAMETER__DESCRIPTION)) { return obj == null ? StringUtils.EMPTY : obj.getDescription(); } } else { String objId = p.getType(); ReferenceInfo ref = null; // ReferenceManager.getInstance().getFirstReferenceInfo(project, // IBizRefType.Object, objId, true); List<String> refTypes = ObjectRefTypes.getRefTypes(); for (String refType : refTypes) { ref = ReferenceManager.getInstance().getFirstReferenceInfo(project, refType, objId, true); if (ref != null) { break; } } // 2012-10-18 sundl 对象类型参数显示的时候,只显示最后一个点后面的部分 if (feature.equals(BizPackage.Literals.PARAMETER__TYPE)) { String type = super.getText(element); if (StringUtils.indexOf(type, '.') != -1) return StringUtils.substringAfterLast(type, "."); } else if (feature.equals(BizPackage.Literals.PARAMETER__NAME)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getChineseName(); } } else if (feature.equals(BizPackage.Literals.PARAMETER__DESCRIPTION)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getDescription(); } } } break; case PARAM_GROUP: String objId = p.getType(); ReferenceInfo ref = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IBizRefType.Object, objId, true); // 2012-10-18 sundl 对象类型参数显示的时候,只显示最后一个点后面的部分 if (feature.equals(BizPackage.Literals.PARAMETER__TYPE)) { String type = super.getText(element); if (StringUtils.indexOf(type, '.') != -1) return StringUtils.substringAfterLast(type, "."); } else if (feature.equals(BizPackage.Literals.PARAMETER__NAME)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getChineseName(); } } else if (feature.equals(BizPackage.Literals.PARAMETER__DESCRIPTION)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getDescription(); } } else if (feature.equals(BizPackage.Literals.PARAMETER__ID)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getName(); } } default: break; } return super.getText(element); }