⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modelentity.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        returnString.append(".get");        returnString.append(ModelUtil.upperFirstChar(((ModelField) flds.get(i)).name));        returnString.append("()");        return returnString.toString();    }    public String httpRelationArgList(List flds, ModelRelation relation) {        StringBuffer returnString = new StringBuffer();        if (flds.size() < 1) {            return "";        }        int i = 0;        for (; i < flds.size() - 1; i++) {            ModelKeyMap keyMap = relation.findKeyMapByRelated(((ModelField) flds.get(i)).name);            if (keyMap != null) {                returnString.append("\"");                returnString.append(tableName);                returnString.append("_");                returnString.append(((ModelField) flds.get(i)).colName);                returnString.append("=\" + ");                returnString.append(ModelUtil.lowerFirstChar(relation.mainEntity.entityName));                returnString.append(".get");                returnString.append(ModelUtil.upperFirstChar(keyMap.fieldName));                returnString.append("() + \"&\" + ");            } else {                Debug.logWarning("-- -- ENTITYGEN ERROR:httpRelationArgList: Related Key in Key Map not found for name: " + ((ModelField) flds.get(i)).name + " related entity: " + relation.relEntityName + " main entity: " + relation.mainEntity.entityName + " type: " + relation.type, module);            }        }        ModelKeyMap keyMap = relation.findKeyMapByRelated(((ModelField) flds.get(i)).name);        if (keyMap != null) {            returnString.append("\"");            returnString.append(tableName);            returnString.append("_");            returnString.append(((ModelField) flds.get(i)).colName);            returnString.append("=\" + ");            returnString.append(ModelUtil.lowerFirstChar(relation.mainEntity.entityName));            returnString.append(".get");            returnString.append(ModelUtil.upperFirstChar(keyMap.fieldName));            returnString.append("()");        } else {            Debug.logWarning("-- -- ENTITYGEN ERROR:httpRelationArgList: Related Key in Key Map not found for name: " + ((ModelField) flds.get(i)).name + " related entity: " + relation.relEntityName + " main entity: " + relation.mainEntity.entityName + " type: " + relation.type, module);        }        return returnString.toString();    }    /*     public String httpRelationArgList(ModelRelation relation) {     String returnString = "";     if(relation.keyMaps.size() < 1) { return ""; }     int i = 0;     for(; i < relation.keyMaps.size() - 1; i++) {     ModelKeyMap keyMap = (ModelKeyMap)relation.keyMaps.get(i);     if(keyMap != null)     returnString = returnString + "\"" + tableName + "_" + keyMap.relColName + "=\" + " + ModelUtil.lowerFirstChar(relation.mainEntity.entityName) + ".get" + ModelUtil.upperFirstChar(keyMap.fieldName) + "() + \"&\" + ";     }     ModelKeyMap keyMap = (ModelKeyMap)relation.keyMaps.get(i);     returnString = returnString + "\"" + tableName + "_" + keyMap.relColName + "=\" + " + ModelUtil.lowerFirstChar(relation.mainEntity.entityName) + ".get" + ModelUtil.upperFirstChar(keyMap.fieldName) + "()";     return returnString;     }     */    public String typeNameStringRelatedNoMapped(List flds, ModelRelation relation) {        StringBuffer returnString = new StringBuffer();        if (flds.size() < 1) {            return "";        }        int i = 0;        if (relation.findKeyMapByRelated(((ModelField) flds.get(i)).name) == null) {            returnString.append(((ModelField) flds.get(i)).type);            returnString.append(" ");            returnString.append(((ModelField) flds.get(i)).name);        }        i++;        for (; i < flds.size(); i++) {            if (relation.findKeyMapByRelated(((ModelField) flds.get(i)).name) == null) {                if (returnString.length() > 0) returnString.append(", ");                returnString.append(((ModelField) flds.get(i)).type);                returnString.append(" ");                returnString.append(((ModelField) flds.get(i)).name);            }        }        return returnString.toString();    }    public String typeNameStringRelatedAndMain(List flds, ModelRelation relation) {        StringBuffer returnString = new StringBuffer();        if (flds.size() < 1) {            return "";        }        int i = 0;        for (; i < flds.size() - 1; i++) {            ModelKeyMap keyMap = relation.findKeyMapByRelated(((ModelField) flds.get(i)).name);            if (keyMap != null) {                returnString.append(keyMap.fieldName);                returnString.append(", ");            } else {                returnString.append(((ModelField) flds.get(i)).name);                returnString.append(", ");            }        }        ModelKeyMap keyMap = relation.findKeyMapByRelated(((ModelField) flds.get(i)).name);        if (keyMap != null) returnString.append(keyMap.fieldName);        else returnString.append(((ModelField) flds.get(i)).name);        return returnString.toString();    }    public int compareTo(Object obj) {        ModelEntity otherModelEntity = (ModelEntity) obj;        /* This DOESN'T WORK, so forget it... using two passes         //sort list by fk dependencies                  if (this.getEntityName().equals(otherModelEntity.getEntityName())) {         return 0;         }         //look through relations for dependencies from this entity to the other         Iterator relationsIter = this.getRelationsIterator();         while (relationsIter.hasNext()) {         ModelRelation modelRelation = (ModelRelation) relationsIter.next();         if ("one".equals(modelRelation.getType()) && modelRelation.getRelEntityName().equals(otherModelEntity.getEntityName())) {         //this entity is dependent on the other entity, so put that entity earlier in the list         return -1;         }         }                  //look through relations for dependencies from the other to this entity         Iterator otherRelationsIter = otherModelEntity.getRelationsIterator();         while (otherRelationsIter.hasNext()) {         ModelRelation modelRelation = (ModelRelation) otherRelationsIter.next();         if ("one".equals(modelRelation.getType()) && modelRelation.getRelEntityName().equals(this.getEntityName())) {         //the other entity is dependent on this entity, so put that entity later in the list         return 1;         }         }                  return 0;         */        return this.getEntityName().compareTo(otherModelEntity.getEntityName());    }    public void convertFieldMapInPlace(Map inContext, GenericDelegator delegator) {        Iterator modelFields = this.getFieldsIterator();        while (modelFields.hasNext()) {            ModelField modelField = (ModelField) modelFields.next();            String fieldName = modelField.getName();            Object oldValue = inContext.get(fieldName);            if (oldValue != null) {                inContext.put(fieldName, this.convertFieldValue(modelField, oldValue, delegator));            }        }    }    public Object convertFieldValue(String fieldName, Object value, GenericDelegator delegator) {        ModelField modelField = this.getField(fieldName);        if (modelField == null) {            String errMsg = "Could not convert field value: could not find an entity field for the name: [" + fieldName + "] on the [" + this.getEntityName() + "] entity.";            throw new IllegalArgumentException(errMsg);        }        return convertFieldValue(modelField, value, delegator);    }    public Object convertFieldValue(ModelField modelField, Object value, GenericDelegator delegator) {        if (value == null || value == GenericEntity.NULL_FIELD) {            return null;        }        String fieldJavaType = null;        try {            fieldJavaType = delegator.getEntityFieldType(this, modelField.getType()).getJavaType();        } catch (GenericEntityException e) {            String errMsg = "Could not convert field value: could not find Java type for the field: [" + modelField.getName() + "] on the [" + this.getEntityName() + "] entity: " + e.toString();            Debug.logError(e, errMsg, module);            throw new IllegalArgumentException(errMsg);        }        try {            return ObjectType.simpleTypeConvert(value, fieldJavaType, null, null, false);        } catch (GeneralException e) {            String errMsg = "Could not convert field value for the field: [" + modelField.getName() + "] on the [" + this.getEntityName() + "] entity to the [" + fieldJavaType + "] type for the value [" + value + "]: " + e.toString();            Debug.logError(e, errMsg, module);            throw new IllegalArgumentException(errMsg);        }    }    /**     * @return Returns the noAutoStamp.     */    public boolean getNoAutoStamp() {        return this.noAutoStamp;    }    /**     * @param noAutoStamp The noAutoStamp to set.     */    public void setNoAutoStamp(boolean noAutoStamp) {        this.noAutoStamp = noAutoStamp;    }    public String toString() {        return "ModelEntity[" + getEntityName() + "]";    }    public Element toXmlElement(Document document, String packageName) {        if (UtilValidate.isNotEmpty(this.getPackageName()) && !packageName.equals(this.getPackageName())) {            Debug.logWarning("Export EntityModel XML Element [" + this.getEntityName() + "] with a NEW package - " + packageName, module);        }        Element root = document.createElement("entity");        root.setAttribute("entity-name", this.getEntityName());        if (!this.getEntityName().equals(ModelUtil.dbNameToClassName(this.getPlainTableName())) ||                !ModelUtil.javaNameToDbName(this.getEntityName()).equals(this.getPlainTableName())) {                root.setAttribute("table-name", this.getPlainTableName());        }        root.setAttribute("package-name", packageName);        // additional elements        if (UtilValidate.isNotEmpty(this.getDefaultResourceName())) {            root.setAttribute("default-resource-name", this.getDefaultResourceName());        }        if (UtilValidate.isNotEmpty(this.getDependentOn())) {            root.setAttribute("dependent-on", this.getDependentOn());        }        if (this.getDoLock()) {            root.setAttribute("enable-lock", "true");        }        if (this.getNoAutoStamp()) {            root.setAttribute("no-auto-stamp", "true");        }        if (this.getNeverCache()) {            root.setAttribute("never-cache", "true");        }        if (!this.getAutoClearCache()) {            root.setAttribute("auto-clear-cache", "false");        }        if (UtilValidate.isNotEmpty(this.getTitle())) {            root.setAttribute("title", this.getTitle());        }        if (UtilValidate.isNotEmpty(this.getCopyright())) {            root.setAttribute("copyright", this.getCopyright());        }        if (UtilValidate.isNotEmpty(this.getAuthor())) {            root.setAttribute("author", this.getAuthor());        }        if (UtilValidate.isNotEmpty(this.getVersion())) {            root.setAttribute("version", this.getVersion());        }        // description element        if (UtilValidate.isNotEmpty(this.getDescription())) {            UtilXml.addChildElementValue(root, "description", this.getDescription(), document);        }        // append field elements        Iterator fieldIter = this.getFieldsIterator();        while (fieldIter != null && fieldIter.hasNext()) {            ModelField field = (ModelField) fieldIter.next();            if (!field.getIsAutoCreatedInternal()) {                root.appendChild(field.toXmlElement(document));            }        }        // append PK elements        Iterator pkIter = this.getPksIterator();        while (pkIter != null && pkIter.hasNext()) {            ModelField pk = (ModelField) pkIter.next();            Element pkey = document.createElement("prim-key");            pkey.setAttribute("field", pk.getName());            root.appendChild(pkey);        }        // append relation elements        Iterator relIter = this.getRelationsIterator();        while (relIter != null && relIter.hasNext()) {            ModelRelation rel = (ModelRelation) relIter.next();        }        // append index elements        Iterator idxIter = this.getIndexesIterator();        while (idxIter != null && idxIter.hasNext()) {            ModelIndex idx = (ModelIndex) idxIter.next();            root.appendChild(idx.toXmlElement(document));        }        return root;    }    public Element toXmlElement(Document document) {        return this.toXmlElement(document, this.getPackageName());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -