use of org.apache.ofbiz.entity.model.ModelViewEntity.ModelAlias in project ofbiz-framework by apache.
the class EntityConditionBase method getColName.
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;
}
use of org.apache.ofbiz.entity.model.ModelViewEntity.ModelAlias in project ofbiz-framework by apache.
the class EntityFieldValue method init.
public void init(String fieldName, String entityAlias, List<String> entityAliasStack, ModelViewEntity modelViewEntity) {
this.fieldName = fieldName;
this.entityAlias = entityAlias;
if (UtilValidate.isNotEmpty(entityAliasStack)) {
this.entityAliasStack = new LinkedList<>();
this.entityAliasStack.addAll(entityAliasStack);
}
this.modelViewEntity = modelViewEntity;
if (UtilValidate.isNotEmpty(this.entityAliasStack) && UtilValidate.isEmpty(this.entityAlias)) {
// look it up on the view entity so it can be part of the big list, this only happens for aliased fields, so find the entity-alias and field-name for the alias
ModelAlias modelAlias = this.modelViewEntity.getAlias(this.fieldName);
if (modelAlias != null) {
this.entityAlias = modelAlias.getEntityAlias();
this.fieldName = modelAlias.getField();
}
// TODO/NOTE: this will ignore function, group-by, etc... should maybe support those in conditions too at some point
}
}
Aggregations