public void addStandardFields(StandardFields standardFields) { if (standardFields != null && standardFields.getStandardFieldList() != null) { for (StandardField field : standardFields.getStandardFieldList()) { standardFieldMap.put(field.getId(), field); if(field.getNickNames()!=null){ for(NickName name:field.getNickNames()){ nickIdMap.put(name.getId(), field.getId()); } } } } }
public void addStandardFields(StandardFields standardFields) { if (standardFields != null && standardFields.getStandardFieldList() != null) { for (StandardField field : standardFields.getStandardFieldList()) { if (standardFieldMap.containsKey(field.getId())) { if (ConfigUtil.isCheckStrict()) { //重复id throw new MetadataRuntimeException(STDFIELD_ADD_ALREADY_ERROR, field.getId()); } else { LOGGER.error(new MetadataRuntimeException(STDFIELD_ADD_ALREADY_ERROR, field.getId())); continue; } } standardFieldMap.put(field.getId(), field); if (field.getNickNames() != null) { for (NickName name : field.getNickNames()) { StandardField newStandardField = new StandardField(); newStandardField.setId(name.getId()); newStandardField.setName(name.getName()); newStandardField.setTitle(name.getTitle()); newStandardField.setDefaultValue(field.getDefaultValue()); newStandardField.setDescription(field.getDescription()); newStandardField.setTypeId(field.getTypeId()); standardFieldMap.put(name.getId(), newStandardField); } } } } }
protected String getComment(StandardField standardField) { String title = standardField.getTitle(); String description = standardField.getDescription(); String comment = StringUtil.isBlank(title) ? description : (StringUtil.isBlank(description) ? title : (title + " " + description)); return comment == null ? "" : comment; }
/** * * 创建新的标准字段信息带有name和title属性 * @param relationField * @param stdField * @return */ public StandardField createNewStandardField(RelationField relationField, StandardField stdField) { String aliasName = relationField.getAliseName(); String title= relationField.getTitle(); String refFieldId=relationField.getRefFieldId(); if(!StringUtil.isBlank(refFieldId)){ if(StringUtil.isBlank(aliasName)){//如果 ref-field-id值不为空且没有设置别名,那么别名值取自field-id的值 aliasName=relationField.getFieldId(); } } StandardField newStdField = new StandardField(); if (StringUtil.isBlank(aliasName)) {//如果没有设置aliasName属性则取自标准字段 aliasName=stdField.getName(); } if(StringUtil.isBlank(title)){//如果为设置title属性则取自标准字段 title=stdField.getTitle(); } newStdField.setName(aliasName); newStdField.setTitle(title); return newStdField; }
/** * * * @param 标准字段 * @return */ public static String getDbFieldName(String standardFieldId) { return MetadataUtil.getStandardField(standardFieldId).getName(); }
public String getType(String id, String language) { StandardField standardField = getStandardField(id); String type = businessTypeProcessor.getType(standardField.getTypeId(), language); if (type != null) { return type; } throw new RuntimeException(String.format( "找不到ID:[%s]的标准字段对应的Language:[%s]类型。", id, language)); }
public static String getDataTpOfStdFiled(StandardField standardField, String language, ClassLoader loader) { BusinessType businessType = MetadataUtil.getBusinessType(standardField.getId(), loader); return MetadataUtil.getStandardFieldType(businessType, language, loader); } }
private String getDefaultId(TableField field, StandardField standardField) { String fieldDefaultId = standardField.getDefaultValue(); if (StringUtil.isEmpty(fieldDefaultId)) { StandardType standardType = MetadataUtil.getStandardType(standardField, getClass().getClassLoader()); fieldDefaultId = standardType.getDefaultValueId(); } return fieldDefaultId; }
public void removeStandardFields(StandardFields standardFields) { if (standardFields != null && standardFields.getStandardFieldList() != null) { for (StandardField field : standardFields.getStandardFieldList()) { standardFieldMap.remove(field.getId()); if (field.getNickNames() != null) { for (NickName name : field.getNickNames()) { standardFieldMap.remove(name.getId()); } } } } }
/** * * * @param 标准字段 * @return */ public static String getDbFieldName(String standardFieldId) { return MetadataUtil.getStandardField(standardFieldId).getName(); }
public static BusinessType getBusinessType(String fieldId, ClassLoader loader) { StandardField field = getStandardField(fieldId, loader); BusinessTypeProcessor businessTypeProcessor = getBusinessTypeProcessor(loader); BusinessType businessType = businessTypeProcessor .getBusinessTypes(field.getTypeId()); return businessType; }
/** * 根据标准字段获取标准类型 * @param standardField * @return */ private String getDataTpOfStdFiled(StandardField standardField) { BusinessType businessType = MetadataUtil.getBusinessType(standardField.getId(), getClass().getClassLoader()); return MetadataUtil.getStandardFieldType(businessType, getDatabaseType(), getClass().getClassLoader()); }
/** * * * @param 找不到标准字段则返回参数 * @return */ public String getDbFieldName(String standardFieldId) { try { StandardField standardField=getStandardField(standardFieldId); return standardField.getName(); } catch (Exception e) { } return standardFieldId; }
public static StandardType getStandardType(StandardField standardField, ClassLoader loader) { BusinessTypeProcessor businessTypeProcessor = getBusinessTypeProcessor(loader); BusinessType businessType = businessTypeProcessor .getBusinessTypes(standardField.getTypeId()); return getStandardType(businessType, loader); }
/** * * * @param 找不到标准字段则返回参数 * @return */ public String getDbFieldName(String standardFieldId) { try { StandardField standardField=getStandardField(standardFieldId); return standardField.getName(); } catch (Exception e) { } return standardFieldId; }
public String getType(String id, String language) { StandardField standardField = getStandardField(id); String type = businessTypeProcessor.getType(standardField.getTypeId(), language); if (type != null) { return type; } throw new MetadataRuntimeException(STDFIELD_LANGUAGE_TYPE_NOT_EXISTS_ERROR, id, language); }
private void appendFooterColumnComment(Table table, StandardField standardField, String standardComment, List list) { String schema = StringUtil.defaultIfBlank(table.getSchema(), "dbo"); String comment = String.format("execute sp_addextendedproperty N'MS_Description', N'%s', N'SCHEMA', N'%s', N'TABLE', N'%s', N'COLUMN', N'%s'" , standardComment, schema, table.getNameWithOutSchema(), standardField.getName()); list.add(comment); }
public static StandardType getStandardType(StandardField field) { BusinessTypeProcessor businessTypeProcessor = SpringUtil .getBean(MetadataUtil.BUSINESSTYPEPROCESSOR_BEAN); BusinessType businessType = businessTypeProcessor .getBusinessTypes(field.getTypeId()); StandardTypeProcessor standardTypeProcessor = SpringUtil .getBean(MetadataUtil.STANDARDTYPEPROCESSOR_BEAN); return standardTypeProcessor.getStandardType(businessType.getTypeId()); } }
public static StandardType getStandardType(String fieldId, ClassLoader loader) { StandardField field = getStandardField(fieldId, loader); BusinessTypeProcessor businessTypeProcessor = getBusinessTypeProcessor(loader); BusinessType businessType = businessTypeProcessor .getBusinessTypes(field.getTypeId()); StandardTypeProcessor standardTypeProcessor = getStandardTypeProcessor(loader); return standardTypeProcessor.getStandardType(businessType.getTypeId()); }
public static StandardType getStandardType(String fieldId) { StandardField field = getStandardField(fieldId); BusinessTypeProcessor businessTypeProcessor = SpringUtil .getBean(MetadataUtil.BUSINESSTYPEPROCESSOR_BEAN); BusinessType businessType = businessTypeProcessor .getBusinessTypes(field.getTypeId()); StandardTypeProcessor standardTypeProcessor = SpringUtil .getBean(MetadataUtil.STANDARDTYPEPROCESSOR_BEAN); return standardTypeProcessor.getStandardType(businessType.getTypeId()); }