Package de.iritgo.aktera.persist

Examples of de.iritgo.aktera.persist.PersistentMetaData


    }
  }

  public final void addOutputs(ModelResponse res, Persistent p) throws PersistenceException, ModelException
  {
    PersistentMetaData pmd = p.getMetaData();
    String oneFieldName = null;

    for (Iterator i = pmd.getFieldNames().iterator(); i.hasNext();)
    {
      oneFieldName = (String) i.next();

      Output oneOutput = res.createOutput(oneFieldName);
View Full Code Here


   *             SVC-PERSIST-HIBERNATE/HibernatePersistentFactory
   */
  public final void addQuery(final ModelResponse res, final Persistent p, final String outputName)
    throws PersistenceException, ModelException
  {
    final PersistentMetaData pmd = p.getMetaData();
    final Set fieldNames = pmd.getFieldNames();

    //TODO: Set this up in such a manner that the key fields are first.
    final String[] fields = (String[]) fieldNames.toArray(new String[fieldNames.size()]);

    addQuery(res, p, outputName, fields);
View Full Code Here

  private static String createSqlSelectFields(ListingDescriptor listing)
    throws ModelException, PersistenceException, SQLException
  {
    PersistentDescriptor persistents = listing.getPersistents();
    StringBuffer sql = new StringBuffer("SELECT ");
    PersistentMetaData idPersistentMeta = persistents.getMetaData(listing.getIdPersistent());

    if (idPersistentMeta == null)
    {
      throw new ModelException("ListTools: Unknown persistent specified for id column '" + listing.getIdColumn()
              + "'");
    }

    if (listing.getNumIdColumns() == 1)
    {
      sql.append(listing.getIdPersistent() + "." + idPersistentMeta.getDBFieldName(listing.getIdField())
              + " AS id");
    }
    else
    {
      int col = 1;

      for (Iterator i = listing.getIdColumns().iterator(); i.hasNext();)
      {
        ListingDescriptor.IdColumnInfo idInfo = (ListingDescriptor.IdColumnInfo) i.next();

        if (col > 1)
        {
          sql.append(", ");
        }

        sql
                .append(idInfo.persistent + "." + idPersistentMeta.getDBFieldName(idInfo.field)
                        + " AS id" + (col++));
      }
    }

    for (Iterator i = listing.columnIterator(); i.hasNext();)
    {
      ColumnDescriptor column = (ColumnDescriptor) i.next();

      if ("custom".equals(column.getViewer()) || column.getViewer().startsWith("js:"))
      {
        continue;
      }

      sql.append(", ");

      PersistentMetaData columnPersistentMeta = persistents.getMetaData(column.getPersistent());

      if (columnPersistentMeta == null)
      {
        throw new ModelException("ListTools: Unknown persistent specified for column '" + column.getName()
                + "'");
      }

      sql.append(column.getPersistent() + "." + columnPersistentMeta.getDBFieldName(column.getField()) + " AS "
              + column.getAs());
    }

    return sql.toString();
  }
View Full Code Here

    {
      throw new ModelException("No persistents defined for listing " + listing.getHeader());
    }

    String key = (String) iKey.next();
    PersistentMetaData persistentMeta = persistents.getMetaData(key);

    sql.append(" FROM " + persistentMeta.getTableName() + " AS " + key);

    for (; iKey.hasNext();)
    {
      key = (String) iKey.next();
      persistentMeta = persistents.getMetaData(key);
      sql.append(" LEFT JOIN " + persistentMeta.getTableName() + " AS " + key + " ON ");

      PersistentDescriptor.JoinInfo join = persistents.getJoin(key);

      if (join == null)
      {
        throw new ModelException("ListTools: No join info defined for persistent '" + key + "'");
      }

      PersistentMetaData persistentMetaJoin = persistents.getMetaData(join.getPersistent());

      sql.append(join.getPersistent() + "." + persistentMetaJoin.getDBFieldName(join.getKey()) + " = " + key
              + "." + persistentMeta.getDBFieldName(join.getMyKey()));

      if (join.getCondition() != null)
      {
        sql.append(" AND " + join.getCondition());
View Full Code Here

   * @return The SQL WHERE clause
   */
  private static String createSqlWhere(ModelRequest request, ListingDescriptor listing) throws PersistenceException
  {
    PersistentDescriptor persistents = listing.getPersistents();
    PersistentMetaData idPersistentMeta = persistents.getMetaData(listing.getIdPersistent());

    StringBuffer condition = new StringBuffer();

    if (! StringTools.isTrimEmpty(listing.getCondition()))
    {
      condition.append(" WHERE " + listing.getCondition());
    }

    if (listing.getSortColumns().size() > 0)
    {
      condition.append(" ORDER BY ");
    }

    for (Iterator i = listing.sortColumnIterator(); i.hasNext();)
    {
      ColumnDescriptor column = (ColumnDescriptor) i.next();

      condition.append(column.getName() + (column.getSort() == SortOrder.DESCENDING ? " DESC" : " ASC"));

      if (i.hasNext())
      {
        condition.append(", ");
      }
    }

    StringBuffer sqlCondition = new StringBuffer();

    for (StringTokenizer st = new StringTokenizer(condition.toString()); st.hasMoreTokens();)
    {
      String token = st.nextToken();
      int dotIndex = token.indexOf('.');

      if (dotIndex != - 1)
      {
        String persistent = token.substring(0, dotIndex);
        String field = token.substring(dotIndex + 1);
        PersistentMetaData meta = persistents.getMetaData(persistent);

        if (meta != null)
        {
          sqlCondition.append(" " + persistent + "." + meta.getDBFieldName(field) + " ");
        }
      }
      else if (token.startsWith("#") || (token.startsWith("'#") && token.endsWith("'")))
      {
        String paramName = null;
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.persist.PersistentMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.