Examples of ObjectRepresentation


Examples of org.conserve.tools.ObjectRepresentation

  private void addLinkStatement(StatementPrototype sp, ObjectStack propertyStack, Class<?> propertyClass)
  {
    int maxLevel = propertyStack.getLevel(propertyClass);
    for (int x = propertyStack.getSize() - 1; x > maxLevel; x--)
    {
      ObjectRepresentation objRep = propertyStack.getRepresentation(x);
      ObjectRepresentation superRep = propertyStack.getRepresentation(x - 1);
      sp.getIdStatementGenerator().addLinkStatement(superRep, objRep);
    }
    ObjectRepresentation objRep = propertyStack.getRepresentation(maxLevel);
    if (objRep.isArray())
    {
      sp.getIdStatementGenerator().addPropertyTableToJoin(Defaults.ARRAY_TABLE_NAME, objRep.getAsName());
    }
    else
    {
      sp.getIdStatementGenerator().addPropertyTableToJoin(objRep.getTableName(), objRep.getAsName());
    }
  }
View Full Code Here

Examples of org.conserve.tools.ObjectRepresentation

   * @throws SQLException
   */
  private void generateArrayQuery(Selector sel, StatementPrototype sp, ObjectStack oStack, Boolean sorted)
      throws SQLException
  {
    ObjectRepresentation rep = oStack.getActualRepresentation();
    sp.getIdStatementGenerator().addPropertyTableToJoin(Defaults.ARRAY_TABLE_NAME, rep.getAsName());
    // iterate over all non-null array entries
    // satisfy all the non-null members of the array
    int length = Array.getLength(sel.getSelectionObject());
    // first, count the number of non-null entries
    int numEntries = 0;
    for (int x = 0; x < length; x++)
    {
      Object o = Array.get(sel.getSelectionObject(), x);
      if (o != null)
      {
        numEntries++;
      }
    }
    // only add relation statements if the array has entries
    if (numEntries > 0)
    {
      // add array relation
      for (int x = 0; x < length; x++)
      {
        Object o = Array.get(sel.getSelectionObject(), x);
        if (o != null)
        {
          Class<?> propertyClass = sel.getSelectionObject().getClass().getComponentType();
          ArrayList<Object> conditionalValues = new ArrayList<Object>();
          StringBuilder sb = new StringBuilder(rep.getAsName());
          sb.append(".");
          sb.append(Defaults.ID_COL);
          sb.append(" = ");
          // add an as statement for the relation
          String relationTable = rep.getTableName();
          String relationAsName = this.uidGenerator.next();
          sp.getIdStatementGenerator().addPropertyTableToJoin(relationTable, relationAsName);

          sb.append(relationAsName);
          sb.append(".");
          sb.append(Defaults.ARRAY_MEMBER_ID);
          sb.append(" AND ");

          if (sorted)
          {
            // position is only valid for queries with sorted types
            sb.append(relationAsName);
            sb.append(".");
            sb.append(Defaults.ARRAY_POSITION);
            sb.append(" = ? AND ");
            conditionalValues.add(Integer.valueOf(x));

          }
          sb.append(relationAsName);
          sb.append(".");
          sb.append(Defaults.VALUE_COL);
          sb.append(" ");
          if (ObjectTools.isPrimitive(o.getClass()) && ObjectTools.isPrimitive(propertyClass))
          {
            sb.append(sel.getRelationalRepresentation());
            if (sel.takesPlaceholder())
            {
              sb.append("?");
              conditionalValues.add(o);
            }
            // put the stuff in the query
            sp.addConditionalStatement(sb.toString());
            sp.addConditionalValues(conditionalValues);
          }
          else
          {
            // check if we have queried this property before
            Long id = (long) System.identityHashCode(o);
            if (rep.getDelayedInsertionBuffer().isKnown(id))
            {
              break;
            }
            rep.getDelayedInsertionBuffer().addId(id);
            // name the property
            ObjectStack propertyStack = new ObjectStack(adapter, o.getClass(), o,
                rep.getDelayedInsertionBuffer());
            nameStack(relationAsName + "." + Defaults.VALUE_COL, propertyStack);
            ObjectRepresentation propertyRep = propertyStack.getRepresentation(propertyClass);
            sb.append(" = ");
            sb.append(propertyRep.getAsName());
            sb.append(".");
            sb.append(Defaults.ID_COL);
            // save to query
            sp.addConditionalStatement(sb.toString());
            sp.addConditionalValues(conditionalValues);
View Full Code Here

Examples of org.restlet.representation.ObjectRepresentation

        {
            if( MediaType.APPLICATION_JAVA_OBJECT.equals( response.getEntity().getMediaType() ) )
            {
                try
                {
                    Object exception = new ObjectRepresentation( response.getEntity() ).getObject();
                    throw new ResourceException( (Throwable) exception );
                }
                catch( IOException e )
                {
                    throw new ResourceException( e );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.