private String changePropertiesByColumns(String source, boolean qualified) throws XavaException {
   StringBuffer r = new StringBuffer(source);
   int i = r.toString().indexOf("${");
   int f = 0;
   while (i >= 0) {
     f = r.toString().indexOf("}", i + 2);
     if (f < 0) break;
     String property = r.substring(i + 2, f);
     String column = "0"; // thus it remained if it is calculated
     if (!getMetaModel().isCalculated(property)) {
       column =
           Strings.isModelName(property)
               ? getTable(property)
               : qualified ? getQualifiedColumn(property) : getColumn(property);
     }
     r.replace(i, f + 1, column);
     i = r.toString().indexOf("${");
   }
   return r.toString();
 }
Exemple #2
0
 private String createSelect() throws XavaException {
   if (hasBaseCondition()) {
     String baseCondition = getBaseCondition();
     if (baseCondition.trim().toUpperCase().startsWith("SELECT ")) {
       return baseCondition;
     }
   }
   // basic select
   StringBuffer select = new StringBuffer("select ");
   Iterator itProperties = getPropertiesNames().iterator();
   while (itProperties.hasNext()) {
     String property = (String) itProperties.next();
     if (Strings.isModelName(property))
       select.append("0"); // the property is a table name not column name
     else {
       select.append("${");
       select.append(property);
       select.append('}');
     }
     if (itProperties.hasNext()) select.append(", ");
   }
   Iterator itHiddenProperties = getHiddenPropertiesNames().iterator();
   while (itHiddenProperties.hasNext()) {
     select.append(", ");
     select.append("${");
     select.append(itHiddenProperties.next());
     select.append('}');
   }
   select.append(" from ${");
   select.append(getModelName());
   select.append('}');
   select.append(' ');
   if (hasBaseCondition()) {
     select.append(" where ");
     select.append(getBaseCondition());
   }
   return select.toString();
 }