當前位置: 首頁>>代碼示例>>Java>>正文


Java ModelField類代碼示例

本文整理匯總了Java中org.ofbiz.entity.model.ModelField的典型用法代碼示例。如果您正苦於以下問題:Java ModelField類的具體用法?Java ModelField怎麽用?Java ModelField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ModelField類屬於org.ofbiz.entity.model包,在下文中一共展示了ModelField類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: update

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
public int update(GenericEntity entity) throws GenericEntityException {
    ModelEntity modelEntity = entity.getModelEntity();

    if (modelEntity == null) {
        throw new GenericModelException("Could not find ModelEntity record for entityName: " + entity.getEntityName());
    }

    // we don't want to update ALL fields, just the nonpk fields that are in the passed GenericEntity
    List<ModelField> partialFields = new LinkedList<ModelField>();
    Collection<String> keys = entity.getAllKeys();

    Iterator<ModelField> nopkIter = modelEntity.getNopksIterator();
    while (nopkIter.hasNext()) {
        ModelField curField = nopkIter.next();
        if (keys.contains(curField.getName())) {
            partialFields.add(curField);
        }
    }

    return customUpdate(entity, modelEntity, partialFields);
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:22,代碼來源:GenericDAO.java

示例2: makeWhereClause

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
public static String makeWhereClause(ModelEntity modelEntity, List<ModelField> modelFields, Map<String, Object> fields, String operator, String joinStyle) throws GenericEntityException {
    StringBuilder whereString = new StringBuilder("");

    if (UtilValidate.isNotEmpty(modelFields)) {
        whereString.append(makeWhereStringFromFields(modelFields, fields, "AND"));
    }

    String viewClause = makeViewWhereClause(modelEntity, joinStyle);

    if (viewClause.length() > 0) {
        if (whereString.length() > 0) {
            whereString.append(' ');
            whereString.append(operator);
            whereString.append(' ');
        }

        whereString.append(viewClause);
    }

    if (whereString.length() > 0) {
        return " WHERE " + whereString.toString();
    }

    return "";
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:26,代碼來源:SqlJdbcUtil.java

示例3: repairColumnSizeChanges

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
public void repairColumnSizeChanges(Map<String, ModelEntity> modelEntities, List<String> fieldsWrongSize, List<String> messages) {
    if (modelEntities == null || UtilValidate.isEmpty(fieldsWrongSize)) {
        messages.add("No fields to repair");
        return;
    }

    if (messages == null) messages = new ArrayList<String>();

    for (String fieldInfo: fieldsWrongSize) {
        String entityName = fieldInfo.substring(0, fieldInfo.indexOf('.'));
        String fieldName = fieldInfo.substring(fieldInfo.indexOf('.') + 1);

        ModelEntity modelEntity = modelEntities.get(entityName);
        ModelField modelField = modelEntity.getField(fieldName);
        repairColumnSize(modelEntity, modelField, messages);
    }
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:18,代碼來源:DatabaseUtil.java

示例4: getColName

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
protected String getColName(Map<String, String> tableAliases, ModelEntity modelEntity, ModelField modelField, String fieldName, boolean includeTableNamePrefix, Datasource datasourceInfo) {
    if (modelEntity == null || modelField == null) return fieldName;

    // if this is a view entity and we are configured to alias the views, use the alias here instead of the composite (ie table.column) field name
    if (datasourceInfo != null && datasourceInfo.getAliasViewColumns() && modelEntity instanceof ModelViewEntity) {
        ModelViewEntity modelViewEntity = (ModelViewEntity) modelEntity;
        ModelAlias modelAlias = modelViewEntity.getAlias(fieldName);
        if (modelAlias != null) {
            return modelAlias.getColAlias();
        }
    }

    String colName = getColName(modelField, fieldName);
    if (includeTableNamePrefix && datasourceInfo != null) {
        String tableName = modelEntity.getTableName(datasourceInfo);
        if (tableAliases.containsKey(tableName)) {
            tableName = tableAliases.get(tableName);
        }
        colName = tableName + "." + colName;
    }
    return colName;
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:23,代碼來源:EntityConditionBase.java

示例5: appendRHSList

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
protected void appendRHSList(List<EntityConditionParam> entityConditionParams, StringBuilder whereStringBuilder, ModelField field, R rhs) {
    whereStringBuilder.append('(');

    if (rhs instanceof Collection<?>) {
        Iterator<R> rhsIter = UtilGenerics.<Collection<R>>cast(rhs).iterator();

        while (rhsIter.hasNext()) {
            Object inObj = rhsIter.next();

            addValue(whereStringBuilder, field, inObj, entityConditionParams);
            if (rhsIter.hasNext()) {
                whereStringBuilder.append(", ");
            }
        }
    } else {
        addValue(whereStringBuilder, field, rhs, entityConditionParams);
    }
    whereStringBuilder.append(')');
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:20,代碼來源:EntityOperator.java

示例6: SequenceUtil

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
public SequenceUtil(GenericHelperInfo helperInfo, ModelEntity seqEntity, String nameFieldName, String idFieldName) {
    this.helperInfo = helperInfo;
    if (seqEntity == null) {
        throw new IllegalArgumentException("The sequence model entity was null but is required.");
    }
    this.tableName = seqEntity.getTableName(helperInfo.getHelperBaseName());

    ModelField nameField = seqEntity.getField(nameFieldName);

    if (nameField == null) {
        throw new IllegalArgumentException("Could not find the field definition for the sequence name field " + nameFieldName);
    }
    this.nameColName = nameField.getColName();

    ModelField idField = seqEntity.getField(idFieldName);

    if (idField == null) {
        throw new IllegalArgumentException("Could not find the field definition for the sequence id field " + idFieldName);
    }
    this.idColName = idField.getColName();
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:22,代碼來源:SequenceUtil.java

示例7: currentGenericValue

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
/** NOTE: Calling this method does return the current value, but so does calling next() or previous(), so calling one of those AND this method will cause the value to be created twice */
public GenericValue currentGenericValue() throws GenericEntityException {
    if (closed) throw new GenericResultSetClosedException("This EntityListIterator has been closed, this operation cannot be performed");

    GenericValue value = GenericValue.create(modelEntity);
    value.setDelegator(this.delegator);

    for (int j = 0; j < selectFields.size(); j++) {
        ModelField curField = selectFields.get(j);

        SqlJdbcUtil.getValue(resultSet, j + 1, curField, value, modelFieldTypeReader);
    }

    value.synchronizedWithDatasource();
    this.haveMadeValue = true;
    return value;
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:18,代碼來源:EntityListIterator.java

示例8: induceFieldInfoFromEntityField

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
private boolean induceFieldInfoFromEntityField(String defaultFieldType, ModelReader entityModelReader) {
    if (UtilValidate.isEmpty(this.getEntityName()) || UtilValidate.isEmpty(this.getFieldName()))
        return false;
    try {
        ModelEntity modelEntity = entityModelReader.getModelEntity(this.getEntityName());
        if (modelEntity != null) {
            ModelField modelField = modelEntity.getField(this.getFieldName());
            if (modelField != null) {
                // okay, populate using the entity field info...
                this.induceFieldInfoFromEntityField(modelEntity, modelField, defaultFieldType);
                return true;
            }
        }
    } catch (GenericEntityException e) {
        Debug.logError(e, module);
    }
    return false;
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:19,代碼來源:ModelFormFieldBuilder.java

示例9: encryptFields

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
public void encryptFields(GenericEntity entity) throws GenericEntityException {
    ModelEntity model = entity.getModelEntity();
    String entityName = model.getEntityName();

    Iterator<ModelField> i = model.getFieldsIterator();
    while (i.hasNext()) {
        ModelField field = i.next();
        if (field.getEncrypt()) {
            Object obj = entity.get(field.getName());
            if (obj != null) {
                if (obj instanceof String && UtilValidate.isEmpty(obj)) {
                    continue;
                }
                entity.dangerousSetNoCheckButFast(field, this.encryptFieldValue(entityName, obj));
            }
        }
    }
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:19,代碼來源:GenericDelegator.java

示例10: decryptFields

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
public void decryptFields(GenericEntity entity) throws GenericEntityException {
    ModelEntity model = entity.getModelEntity();
    String entityName = model.getEntityName();

    Iterator<ModelField> i = model.getFieldsIterator();
    while (i.hasNext()) {
        ModelField field = i.next();
        if (field.getEncrypt()) {
            String keyName = entityName;
            if (model instanceof ModelViewEntity) {
                ModelViewEntity modelView = (ModelViewEntity) model;
                keyName = modelView.getAliasedEntity(modelView.getAlias(field.getName()).getEntityAlias(), modelReader).getEntityName();
            }

            String encValue = (String) entity.get(field.getName());
            if (UtilValidate.isNotEmpty(encValue)) {
                try {
                    entity.dangerousSetNoCheckButFast(field, crypto.decrypt(keyName, encValue));
                } catch (EntityCryptoException e) {
                    // not fatal -- allow returning of the encrypted value
                    Debug.logWarning(e, "Problem decrypting field [" + entityName + " / " + field.getName() + "]", module);
                }
            }
        }
    }
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:27,代碼來源:GenericDelegator.java

示例11: currentGenericValue

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
/** NOTE: Calling this method does return the current value, but so does calling next() or previous(), so calling one of those AND this method will cause the value to be created twice */
public GenericValue currentGenericValue() throws GenericEntityException {
    if (closed) throw new GenericResultSetClosedException("This EntityListIterator has been closed, this operation cannot be performed");

    GenericValue value = GenericValue.create(modelEntity);

    for (int j = 0; j < selectFields.size(); j++) {
        ModelField curField = selectFields.get(j);

        SqlJdbcUtil.getValue(resultSet, j + 1, curField, value, modelFieldTypeReader);
    }

    value.setDelegator(this.delegator);
    value.synchronizedWithDatasource();
    this.haveMadeValue = true;
    if (delegator != null) {
        delegator.decryptFields(value);
    }
    return value;
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:21,代碼來源:EntityListIterator.java

示例12: induceFieldInfoFromEntityField

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
public boolean induceFieldInfoFromEntityField(String defaultFieldType) {
    if (UtilValidate.isEmpty(this.getEntityName()) || UtilValidate.isEmpty(this.getFieldName())) return false;
    
    ModelReader entityModelReader = this.getModelForm().entityModelReader;
    try {
        ModelEntity modelEntity = entityModelReader.getModelEntity(this.getEntityName());
        if (modelEntity != null) {
            ModelField modelField = modelEntity.getField(this.getFieldName());
            if (modelField != null) {
                // okay, populate using the entity field info...
                this.induceFieldInfoFromEntityField(modelEntity, modelField, defaultFieldType);
                return true;
            }
        }
    } catch (GenericEntityException e) {
        Debug.logError(e, module);
    }
    return false;
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:20,代碼來源:ModelFormField.java

示例13: addAutoFieldsFromEntity

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
public void addAutoFieldsFromEntity(AutoFieldsEntity autoFieldsEntity) {
    autoFieldsEntities.add(autoFieldsEntity);
    // read entity def and auto-create fields
    ModelEntity modelEntity = null;
    try {
        modelEntity = this.entityModelReader.getModelEntity(autoFieldsEntity.entityName);
    } catch (GenericEntityException e) {
        Debug.logError(e, module);
    }
    if (modelEntity == null) {
        throw new IllegalArgumentException("Error finding Entity with name " + autoFieldsEntity.entityName + " for auto-fields-entity in a form widget");
    }

    Iterator<ModelField> modelFieldIter = modelEntity.getFieldsIterator();
    while (modelFieldIter.hasNext()) {
        ModelField modelField = modelFieldIter.next();
        if (modelField.getIsAutoCreatedInternal()) {
            // don't ever auto-add these, should only be added if explicitly referenced
            continue;
        }
        ModelFormField modelFormField = this.addFieldFromEntityField(modelEntity, modelField, autoFieldsEntity.defaultFieldType, autoFieldsEntity.defaultPosition);
        if (UtilValidate.isNotEmpty(autoFieldsEntity.mapName)) {
            modelFormField.setMapName(autoFieldsEntity.mapName);
        }
    }
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:27,代碼來源:ModelForm.java

示例14: setEntityName

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
public void setEntityName(String name) {
    this.entityName = name;
    if (UtilValidate.isNotEmpty(this.entityName)) {
        ModelEntity modelEntity = modelTree.delegator.getModelEntity(this.entityName);
        if (modelEntity.getPksSize() == 1) {
            ModelField modelField = modelEntity.getOnlyPk();
            this.pkName = modelField.getName();
        } else {
            List<String> pkFieldsName = modelEntity.getPkFieldNames();
            StringBuilder sb = new StringBuilder();
            for (String pk: pkFieldsName) {
                    sb.append(pk);
                    sb.append("|");
            }
            this.pkName = sb.toString();
        }
    }
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:19,代碼來源:ModelTree.java

示例15: addFieldIfMissing

import org.ofbiz.entity.model.ModelField; //導入依賴的package包/類
private void addFieldIfMissing(List<ModelField> fieldsToSave, String fieldName, ModelEntity modelEntity) {
    for (ModelField fieldToSave: fieldsToSave) {
        if (fieldName.equals(fieldToSave.getName())) {
            return;
        }
    }
    // at this point we didn't find it
    fieldsToSave.add(modelEntity.getField(fieldName));
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:10,代碼來源:GenericDAO.java


注:本文中的org.ofbiz.entity.model.ModelField類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。