Package org.conserve.tools

Examples of org.conserve.tools.ObjectRepresentation


    for (ObjectStack existing : namedStacks)
    {
      int maxLevel = Math.min(stack.getSize(), existing.getSize());
      for (int x = 0; x < maxLevel; x++)
      {
        ObjectRepresentation o1 = stack.getRepresentation(x);
        ObjectRepresentation o2 = existing.getRepresentation(x);
        if (!o1.getRepresentedClass().equals(o2.getRepresentedClass()))
        {
          break;
        }
        else
        {
View Full Code Here


    // remove columns from subclasstable where they are no longer in the
    // class
    try
    {
      TableManager tm = adapter.getPersist().getTableManager();
      ObjectRepresentation objRes = toStack.getActualRepresentation();
      Map<String, String> valueTypeMap = tm.getDatabaseColumns(objRes.getTableName(),
          cw);
      for (Entry<String, String> e : valueTypeMap.entrySet())
      {
        String colName = e.getKey();
        if (!isSystemColumn(colName) && !objRes.hasProperty(colName))
        {
          tm.dropColumn(objRes.getTableName(), colName, cw);
        }
      }
    }
    catch (ClassNotFoundException ex)
    {
View Full Code Here

      for (int x = 1; x <= mdata.getColumnCount(); x++)
      {
        String colName = mdata.getColumnLabel(x);
        if (!isSystemColumn(colName))
        {
          ObjectRepresentation targetLevel = nuStack.getRepresentation(colName);
          if (targetLevel != null)
          {
            String toTable = targetLevel.getTableName();
            copyProperty(fromTableName, rs, x, mdata.getColumnType(x), colName, toTable,
                targetLevel.getId(), cw);
          }
        }
      }
    }
  }
View Full Code Here

    // add join tables
    if (addJoins)
    {
      for (int x = oStack.getSize() - 1; x > 0; x--)
      {
        ObjectRepresentation rep = oStack.getRepresentation(x);
        addLinkStatement(oStack.getRepresentation(x - 1), rep);
      }
    }
  }
View Full Code Here

  public void addPropertyTablesToJoin(ObjectStack propertyStack, Class<?> propertyClass)
  {
    boolean propertiesFound = false;
    for (int x = propertyStack.getSize() - 1; x >= 0; x--)
    {
      ObjectRepresentation rep = propertyStack.getRepresentation(x);
      if (!propertiesFound)
      {
        if (rep.getNonNullPropertyCount() > 0 || rep.isArray())
        {
          propertiesFound = true;
        }
        else if (propertyClass != null && rep.getRepresentedClass().equals(propertyClass))
        {
          propertiesFound = true;
        }
      }
      if (propertiesFound)
      {
        if (rep.isArray())
        {
          addPropertyTableToJoin(Defaults.ARRAY_TABLE_NAME, rep.getAsName());
        }
        else
        {
          addPropertyTableToJoin(rep.getTableName(), rep.getAsName());
        }
      }
      if (propertyClass != null && rep.getRepresentedClass().equals(propertyClass))
      {
        // end once we reach the desired class
        break;
      }
    }
View Full Code Here

      {
        res = null;
      }
      else
      {
        ObjectRepresentation orig = new ObjectRepresentation(adapter,
            obj.getClass(), obj, null);
        ObjectRepresentation nu = new ObjectRepresentation(adapter,
            nuObject.getClass(), nuObject, null);
        ArrayList<Long> idList = new ArrayList<Long>();
        refresh(orig, cache, nu, tmpCache, idList);
      }
      return res;
View Full Code Here

          Long nuDbId = nuCache.getDatabaseId(nuProperty);
          if (origDbId.equals(nuDbId))
          {
            // the id, and therefore the objects, are unchanged.
            // recurse
            ObjectRepresentation origPropertyPresentation = new ObjectRepresentation(
                adapter, origProperty.getClass(), origProperty,
                null);
            ObjectRepresentation nuPropertyPresentation = new ObjectRepresentation(
                adapter, nuProperty.getClass(), nuProperty,
                null);
            if (!idList.contains(origDbId))
            {
              idList.add(origDbId);
View Full Code Here

   */
  public void addTablesToJoin(ObjectStack stack)
  {
    for (int x = stack.getSize() - 1; x >= 0; x--)
    {
      ObjectRepresentation rep = stack.getRepresentation(x);
      this.joinRepresentations.add(rep);
      if (rep.isArray())
      {
        addTableToJoin(Defaults.ARRAY_TABLE_NAME, rep.getAsName());
      }
      else
      {
        addTableToJoin(rep.getTableName(), rep.getAsName());
      }
      if (!addJoins)
      {
        break;
      }
View Full Code Here

    ObjectStack oStack = new ObjectStack(adapter, sorter.getSortObject().getClass(), sorter.getSortObject());
    this.typeIds.nameStack(oStack);
    mainStatement.getIdStatementGenerator().addPropertyTablesToJoin(oStack, null);
    for (int t = 0; t < oStack.getSize(); t++)
    {
      ObjectRepresentation rep = oStack.getRepresentation(t);
      for (Integer index : rep)
      {
        StringBuilder statement = new StringBuilder();
        statement.append(rep.getAsName());
        statement.append(".");
        statement.append(rep.getPropertyName(index));
        statement.append(" ");
        statement.append(sorter.getKeyWord());
        mainStatement.addSortStatement(statement.toString());
      }
    }
View Full Code Here

        // only go up to the index of the selection class.
        cutoffIndex = classIndex + 1;
      }
      for (int t = 0; t < cutoffIndex; t++)
      {
        ObjectRepresentation rep = oStack.getRepresentation(t);
        if (rep.getNonNullPropertyCount() > 0)
        {
          minIndex = Math.min(t, minIndex);
          maxIndex = Math.max(t, maxIndex);
        }
      }
      for (int t = minIndex; t <= maxIndex; t++)
      {
        ObjectRepresentation rep = oStack.getRepresentation(t);
        if (t > minIndex)
        {
          // this also automatically adds rep to the list of tables to
          // join
          sp.getIdStatementGenerator().addLinkStatement(oStack.getRepresentation(t - 1), rep);
        }
        else
        {
          // because rep needs to be added to the join statements
          sp.getIdStatementGenerator().addPropertyTableToJoin(rep.getTableName(), rep.getAsName());
        }
        // iterate over the non-null values
        for (Integer x : rep)
        {
          Object property = rep.getPropertyValue(x);
          String propertyName = rep.getPropertyName(x);
          StringBuilder conditional = new StringBuilder(rep.getAsName());
          conditional.append(".");
          conditional.append(propertyName);
          if (rep.isPrimitive(x))
          {
            // the value is a primitive, so insert it directly
            conditional.append(sel.getRelationalRepresentation());
            if (sel.takesPlaceholder())
            {
              conditional.append("?");
              sp.addConditionalStatement(conditional.toString(), property);
            }
            else
            {
              sp.addConditionalStatement(conditional.toString());
            }
          }
          else
          {
            // the value is complex, insert a reference
            Long id = (long) System.identityHashCode(property);
            if (rep.getDelayedInsertionBuffer().isKnown(id))
            {
              break;
            }
            rep.getDelayedInsertionBuffer().addId(id);
            ObjectStack propertyStack = new ObjectStack(adapter, property.getClass(), property,
                rep.getDelayedInsertionBuffer());
            nameStack(rep.getAsName() + "." + propertyName, propertyStack);
            Class<?> propertyClass = rep.getReturnType(x);

            if (propertyClass.isInterface())
            {
              propertyClass = Object.class;
            }
            ObjectRepresentation propertyRep = propertyStack.getRepresentation(propertyClass);

            conditional.append(" = ");
            conditional.append(propertyRep.getAsName());
            conditional.append(".");
            conditional.append(Defaults.ID_COL);
            sp.addConditionalStatement(conditional.toString());
            // is this query using strict inheritance?
            // is the property and the property class different?
View Full Code Here

TOP

Related Classes of org.conserve.tools.ObjectRepresentation

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.