本文整理汇总了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);
}
示例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 "";
}
示例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);
}
}
示例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;
}
示例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(')');
}
示例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();
}
示例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;
}
示例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;
}
示例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));
}
}
}
}
示例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);
}
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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();
}
}
}
示例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));
}