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

📄 modelentity.java

📁 国外的一套开源CRM
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    public void setCopyright(String copyright) {
        this.copyright = copyright;
    }

    /** The author for documentation purposes */
    public String getAuthor() {
        return this.author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    /** The version for documentation purposes */
    public String getVersion() {
        return this.version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    /** An indicator to specify if this entity is never cached. 
     * If true causes the delegator to not clear caches on write and to not get 
     * from cache on read showing a warning messages to that effect 
     */
    public boolean getNeverCache() {
        return this.neverCache;
    }

    public void setNeverCache(boolean neverCache) {
        this.neverCache = neverCache;
    }

    /** An indicator to specify if this entity requires locking for updates */
    public boolean getDoLock() {
        return this.doLock;
    }

    public void setDoLock(boolean doLock) {
        this.doLock = doLock;
    }

    public boolean lock() {
        if (doLock && isField(STAMP_FIELD)) {
            return true;
        } else {
            doLock = false;
            return false;
        }
    }

    public void updatePkLists() {
        pks = new ArrayList();
        nopks = new ArrayList();
        for (int i = 0; i < fields.size(); i++) {
            ModelField field = (ModelField) fields.get(i);

            if (field.isPk)
                pks.add(field);
            else
                nopks.add(field);
        }
    }

    public boolean isField(String fieldName) {
        if (fieldName == null) return false;
        for (int i = 0; i < fields.size(); i++) {
            ModelField field = (ModelField) fields.get(i);

            if (field.name.equals(fieldName)) return true;
        }
        return false;
    }

    public boolean areFields(Collection fieldNames) {
        if (fieldNames == null) return false;
        Iterator iter = fieldNames.iterator();

        while (iter.hasNext()) {
            String fieldName = (String) iter.next();

            if (!isField(fieldName)) return false;
        }
        return true;
    }

    public int getPksSize() {
        return this.pks.size();
    }

    public ModelField getPk(int index) {
        return (ModelField) this.pks.get(index);
    }

    public Iterator getPksIterator() {
        return this.pks.iterator();
    }

    public List getPksCopy() {
        return new ArrayList(this.pks);
    }

    public int getNopksSize() {
        return this.nopks.size();
    }

    public ModelField getNopk(int index) {
        return (ModelField) this.nopks.get(index);
    }

    public Iterator getNopksIterator() {
        return this.nopks.iterator();
    }

    public List getNopksCopy() {
        return new ArrayList(this.nopks);
    }

    public int getFieldsSize() {
        return this.fields.size();
    }

    public ModelField getField(int index) {
        return (ModelField) this.fields.get(index);
    }

    public Iterator getFieldsIterator() {
        return this.fields.iterator();
    }

    public List getFieldsCopy() {
        return new ArrayList(this.fields);
    }

    /** The col-name of the Field, the alias of the field if this is on a view-entity */
    public String getColNameOrAlias(String fieldName) {
        ModelField modelField = this.getField(fieldName);
        String fieldString = modelField.getColName();
        return fieldString;
    }

    public ModelField getField(String fieldName) {
        if (fieldName == null) return null;
        if (fieldsMap == null) {
            createFieldsMap();
        }
        ModelField modelField = (ModelField) fieldsMap.get(fieldName);
        if (modelField == null) {
            // sometimes weird things happen and this getField method is called before the fields are all populated, so before moving on just re-create the fieldsMap again real quick...
            // the purpose of the fieldsMap is for speed, but if failures are a little slower, no biggie
            createFieldsMap();
            modelField = (ModelField) fieldsMap.get(fieldName);
        }
        return modelField;
    }
    
    protected synchronized void createFieldsMap() {
        Map tempMap = new HashMap(fields.size());
        for (int i = 0; i < fields.size(); i++) {
            ModelField field = (ModelField) fields.get(i);
            tempMap.put(field.name, field);
        }
        fieldsMap = tempMap;
    }

    public void addField(ModelField field) {
        if (field == null) return;
        this.fields.add(field);

        if (field.isPk) {
            pks.add(field);
        } else {
            nopks.add(field);
        }
    }

    public ModelField removeField(int index) {
        ModelField field = null;

        field = (ModelField) fields.remove(index);
        if (field == null) return null;

        if (field.isPk) {
            pks.remove(field);
        } else {
            nopks.remove(field);
        }
        return field;
    }

    public ModelField removeField(String fieldName) {
        if (fieldName == null) return null;
        ModelField field = null;

        for (int i = 0; i < fields.size(); i++) {
            field = (ModelField) fields.get(i);
            if (field.name.equals(fieldName)) {
                fields.remove(i);
                if (field.isPk) {
                    pks.remove(field);
                } else {
                    nopks.remove(field);
                }
            }
            field = null;
        }
        return field;
    }

    public List getAllFieldNames() {
        return getFieldNamesFromFieldVector(fields);
    }

    public List getPkFieldNames() {
        return getFieldNamesFromFieldVector(pks);
    }

    public List getNoPkFieldNames() {
        return getFieldNamesFromFieldVector(nopks);
    }

    public List getFieldNamesFromFieldVector(List modelFields) {
        List nameList = new ArrayList(modelFields.size());

        if (modelFields == null || modelFields.size() <= 0) return nameList;
        for (int i = 0; i < modelFields.size(); i++) {
            ModelField field = (ModelField) modelFields.get(i);

            nameList.add(field.name);
        }
        return nameList;
    }

    public int getRelationsSize() {
        return this.relations.size();
    }

    public ModelRelation getRelation(int index) {
        return (ModelRelation) this.relations.get(index);
    }

    public Iterator getRelationsIterator() {
        return this.relations.iterator();
    }

    public ModelRelation getRelation(String relationName) {
        if (relationName == null) return null;
        for (int i = 0; i < relations.size(); i++) {
            ModelRelation relation = (ModelRelation) relations.get(i);
            if (relationName.equals(relation.title + relation.relEntityName)) return relation;
        }
        return null;
    }

    public void addRelation(ModelRelation relation) {
        this.relations.add(relation);
    }

    public ModelRelation removeRelation(int index) {
        return (ModelRelation) this.relations.remove(index);
    }

    public int getIndexesSize() {
        return this.indexes.size();
    }

    public ModelIndex getIndex(int index) {
        return (ModelIndex) this.indexes.get(index);
    }

    public Iterator getIndexesIterator() {
        return this.indexes.iterator();
    }

    public ModelIndex getIndex(String indexName) {
        if (indexName == null) return null;
        for (int i = 0; i < indexes.size(); i++) {
            ModelIndex index = (ModelIndex) indexes.get(i);
            if (indexName.equals(index.getName())) return index;
        }
        return null;
    }

    public void addIndex(ModelIndex index) {
        this.indexes.add(index);
    }

    public ModelIndex removeIndex(int index) {
        return (ModelIndex) this.indexes.remove(index);
    }

    public String nameString(List flds) {
        return nameString(flds, ", ", "");
    }

    public String nameString(List flds, String separator, String afterLast) {
        StringBuffer returnString = new StringBuffer();

        if (flds.size() < 1) {
            return "";
        }

        int i = 0;

        for (; i < flds.size() - 1; i++) {
            returnString.append(((ModelField) flds.get(i)).name);
            returnString.append(separator);
        }
        returnString.append(((ModelField) flds.get(i)).name);
        returnString.append(afterLast);
        return returnString.toString();
    }

    public String typeNameString(List flds) {
        StringBuffer returnString = new StringBuffer();

        if (flds.size() < 1) {
            return "";
        }

        int i = 0;

        for (; i < flds.size() - 1; i++) {
            ModelField curField = (ModelField) flds.get(i);
            returnString.append(curField.type);
            returnString.append(" ");
            returnString.append(curField.name);
            returnString.append(", ");
        }
        ModelField curField = (ModelField) flds.get(i);
        returnString.append(curField.type);
        returnString.append(" ");
        returnString.append(curField.name);
        return returnString.toString();
    }

    public String fieldNameString() {
        return fieldNameString(", ", "");
    }

    public String fieldNameString(String separator, String afterLast) {
        return nameString(fields, separator, afterLast);
    }

    public String fieldTypeNameString() {
        return typeNameString(fields);
    }

    public String primKeyClassNameString() {
        return typeNameString(pks);
    }

    public String pkNameString() {
        return pkNameString(", ", "");
    }

    public String pkNameString(String separator, String afterLast) {
        return nameString(pks, separator, afterLast);
    }

⌨️ 快捷键说明

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