public void makeAliasColName(StringBuilder colNameBuffer,StringBuilder fieldTypeBuffer,ModelViewEntity modelViewEntity,ModelReader modelReader){
  if (UtilValidate.isEmpty(entityAlias) && UtilValidate.isEmpty(field) && UtilValidate.isNotEmpty(value)) {
    colNameBuffer.append(value);
  }
 else {
    ModelEntity modelEntity=modelViewEntity.getAliasedEntity(entityAlias,modelReader);
    ModelField modelField=modelViewEntity.getAliasedField(modelEntity,field,modelReader);
    String colName=entityAlias + "." + modelField.getColName();
    if (UtilValidate.isNotEmpty(defaultValue)) {
      colName="COALESCE(" + colName + ","+ defaultValue+ ")";
    }
    if (UtilValidate.isNotEmpty(function)) {
      String prefix=functionPrefixMap.get(function);
      if (prefix == null) {
        Debug.logWarning("[" + modelViewEntity.getEntityName() + "]: Specified alias function ["+ function+ "] not valid; must be: min, max, sum, avg, count or count-distinct; using a column name with no function function",module);
      }
 else {
        colName=prefix + colName + ")";
      }
    }
    colNameBuffer.append(colName);
    if (fieldTypeBuffer.length() == 0) {
      fieldTypeBuffer.append(modelField.getType());
    }
  }
}

public void makeAliasColName ( StringBuilder colNameBuffer , StringBuilder fieldTypeBuffer , ModelViewEntity modelViewEntity , ModelReader modelReader ) { if ( UtilValidate . isEmpty ( entityAlias ) && UtilValidate . isEmpty ( field ) && UtilValidate . isNotEmpty ( value ) ) { colNameBuffer . append ( value ) ; } else { ModelEntity modelEntity = modelViewEntity . getAliasedEntity ( entityAlias , modelReader ) ; ModelField modelField = modelViewEntity . getAliasedField ( modelEntity , field , modelReader ) ; String colName = entityAlias + "." + modelField . getColName ( ) ; if ( UtilValidate . isNotEmpty ( defaultValue ) ) { colName = "COALESCE(" + colName + "," + defaultValue + ")" ; } if ( UtilValidate . isNotEmpty ( function ) ) { String prefix = functionPrefixMap . get ( function ) ; if ( prefix == null ) { Debug . logWarning ( "[" + modelViewEntity . getEntityName ( ) + "]: Specified alias function [" + function + "] not valid; must be: min, max, sum, avg, count or count-distinct; using a column name with no function function" , module ) ; } else { colName = prefix + colName + ")" ; } } colNameBuffer . append ( colName ) ; if ( fieldTypeBuffer . length ( ) == 0 ) { fieldTypeBuffer . append ( modelField . getType ( ) ) ; } } }
make the alias as follows : function ( coalesce ( entityalias . field , defaultvalue ) )
