Package com.dooapp.gaedo.properties

Examples of com.dooapp.gaedo.properties.Property


    VertexLocation returned = new VertexLocation();
    returned.loadInitialPath(path);
    returned.push(source);

    while(returned.hasPath()) {
      Property currentProperty = returned.nextInPath();
      Vertex currentVertex = returned.vertex();
      Iterable<Edge> outEdges = strategy.getOutEdgesFor(currentVertex, currentProperty);
      Iterator<Edge> edges = outEdges.iterator();
      returned.push(currentProperty);
      if(edges.hasNext()) {
        returned.push(edges.next().getVertex(Direction.IN));
      } else {
        /*
         * maybe that property can contain literal value.
         * This literal value can be stored either as a direct literal (type is a literal one) or using the infamous
         * TUples.serializables, in which case further analysis must be performed ...
         */
        Class<?> propertyType = currentProperty.getType();
        if(driver.getRepository().containsKey(propertyType)) {
          returned.setNavigationSuccessfull(false);
        } else {
          Object value = currentVertex.getProperty(GraphUtils.getEdgeNameFor(currentProperty));
          if(Literals.containsKey(propertyType)) {
View Full Code Here


    boolean hasPath() {
      return !initialPath.isEmpty() && isNavigationSuccessfull();
    }

    Property nextInPath() {
      Property firstProperty = initialPath.get(0);
      initialPath.remove(0);
      return firstProperty;
    }
View Full Code Here

   */
  private static Iterable<Property> improvePath(GraphDatabaseDriver driver, Iterable<Property> path) {
    /* we declare the class collection property as member of this type, as we won't use it as storage mechanism, but rather as adressing one
     * in which case the given class is not meaningful
     */
    Property classCollection = new ClassCollectionProperty(InstanceOf.class);

    List<Property> list = new ArrayList<Property>(CollectionUtils.asList(path));
    if(list.size()==0) {
      return Arrays.asList(classCollection);
    } else {
      Property last = list.get(list.size()-1);
      Class containedValueType = (Class) LiteralInCollectionUpdaterProperty.inferElementTypeIn(last.getGenericType());
      if(driver.getRepository().containsKey(containedValueType)) {
        list.add(classCollection);
      }
      return list;
    }
View Full Code Here

      builder.append("\t");
    }
    if(path!=null) {
      Iterator<Property> pathIter = path.iterator();
      while (pathIter.hasNext()) {
        Property property = (Property) pathIter.next();
        builder.append(property.getName());
        if(pathIter.hasNext()) {
          builder.append(".");
        }
      }
    }
View Full Code Here

   * @param path
   * @return
   */
  private <Type> VertexSet load(Type expected, Iterable<Property> path) {
    LinkedList<Property> updatablePath = new LinkedList<Property>(CollectionUtils.asList(path));
    Property lastProperty = updatablePath.removeLast();
    // if value is a literal, well, it's time for an index lookup
    Class<Type> expectedClass = (Class<Type>) expected.getClass();
    if (expected != null && Literals.containsKey(expectedClass)) {
      // Yup : gladly using implementation as it provides a last() method !
      Index<Vertex> vertices = (Index<Vertex>) service.getDatabase().getIndex(IndexNames.VERTICES.getIndexName(), IndexNames.VERTICES.getIndexed());
      // stinky code fragment for collections : as each value is stored under
      // a key in the form propertyName:index, we have to iterate upon them
      String propertyKeyInIndex = null;
      String propertyValueInIndex = null;
      if (Collection.class.isAssignableFrom(lastProperty.getType())) {
        propertyKeyInIndex = GraphUtils.getEdgeNameFor(new CollectionAccessByValueProperty(lastProperty, expected, Updater.ELEMENT_IN_COLLECTION_MARKER));
        propertyValueInIndex = Updater.ELEMENT_IN_COLLECTION_MARKER_GRAPH_VALUE;
      } else {
        propertyKeyInIndex = GraphUtils.getEdgeNameFor(lastProperty);
        LiteralTransformer<Type> transformer = Literals.get(expectedClass);
        if(Literals.containsKey(lastProperty.getType())) {
          transformer = Literals.get(lastProperty.getType());
        }
        propertyValueInIndex = transformer.toString(expected);
      }
      VertexSet returned = new VertexSet().withPropertyPath(updatablePath);
      returned.setVertices(new IndexLazyLoader(vertices, propertyKeyInIndex, propertyValueInIndex));
View Full Code Here

   * Get text associated to field part of basic expression
   * @param expression input expression
   * @return a view of the field
   */
  private String getFieldText(AbstractBasicExpression expression) {
    Property f = expression.getField();
    if(f==null)
      return "this";
    else
      return f.toGenericString();
  }
View Full Code Here

   * Get text associated to field part of basic expression
   * @param expression input expression
   * @return a view of the field
   */
  private String getFieldText(AbstractBasicExpression expression) {
    Property f = expression.getField();
    if(f==null)
      return "this";
    else
      return f.toGenericString();
  }
View Full Code Here

*
*/
class OperateOnProperties {
  public void execute(Map<Property, Collection<CascadeType>> containedProperties, CascadeType cascade, Operation operation) {
        for (Map.Entry<Property, Collection<CascadeType>> entry : containedProperties.entrySet()) {
            Property p = entry.getKey();
            // Static properties are by design not written
            if (!p.hasModifier(Modifier.STATIC) && !Annotations.TRANSIENT.is(p)) {
                // Per default, no operation is cascaded
                CascadeType used = null;
                // However, if property supports that cascade type, we cascade operation
                if (entry.getValue().contains(cascade)) {
                    used = cascade;
                } else {
                  // Internal class means getName will introduce an unwanted "$" sign
                  Logger logger = Logger.getLogger(operation.getClass().getCanonicalName());
                  if(logger.isLoggable(Level.FINE)) {
                    // just don't output anything for type or class collections, as they're special properties
                    if(!(TypeProperty.INSTANCE.equals(p) || new ClassCollectionProperty(getClass()).equals(p)))
                    logger.log(Level.FINE, "operation not performed on "+p.toGenericString()+" has no cascade "+cascade+" defined");
                  }
                }
                // We only perform operations on cascaded fields
                if(used!=null) {
                  operation.operateOn(p, cascade);
View Full Code Here

   * @param path
   * @return
   */
  private <Type> VertexSet load(Type expected, Iterable<Property> path) {
    LinkedList<Property> updatablePath = new LinkedList<Property>(CollectionUtils.asList(path));
    Property lastProperty = updatablePath.removeLast();
    // if value is a literal, well, it's time for an index lookup
    Class<Type> expectedClass = (Class<Type>) expected.getClass();
    if (expected != null && Literals.containsKey(expectedClass)) {
      // Yup : gladly using implementation as it provides a last() method !
      Index<Vertex> vertices = (Index<Vertex>) service.getDatabase().getIndex(IndexNames.VERTICES.getIndexName(), IndexNames.VERTICES.getIndexed());
      // stinky code fragment for collections : as each value is stored under
      // a key in the form propertyName:index, we have to iterate upon them
      String propertyKeyInIndex = null;
      String propertyValueInIndex = null;
      if (Collection.class.isAssignableFrom(lastProperty.getType())) {
        propertyKeyInIndex = GraphUtils.getEdgeNameFor(new LiteralInCollectionUpdaterProperty(lastProperty, expected, Updater.ELEMENT_IN_COLLECTION_MARKER));
        propertyValueInIndex = Updater.ELEMENT_IN_COLLECTION_MARKER_GRAPH_VALUE;
      } else {
        propertyKeyInIndex = GraphUtils.getEdgeNameFor(lastProperty);
        LiteralTransformer<Type> transformer = Literals.get(expectedClass);
        if(Literals.containsKey(lastProperty.getType())) {
          transformer = Literals.get(lastProperty.getType());
        }
        propertyValueInIndex = transformer.toString(expected);
      }
      VertexSet returned = new VertexSet().withPropertyPath(updatablePath);
      returned.setVertices(new IndexLazyLoader(vertices, propertyKeyInIndex, propertyValueInIndex));
View Full Code Here

        VertexLocation destination = navigator.navigateOn(propertyDescriptor.getFieldPath());

        Vertex destinationVertex = destination.vertex();
        try {
          // There may remain one unevaluated property - in which case it's a literal one
          Property destinationProperty = destination.property();
          Loader loader = new Loader();
          if(loader.hasLiteralProperty(destinationProperty, destinationVertex)) {
            return (Type) loader.loadSingleLiteral(getClass().getClassLoader(), destinationProperty, destinationVertex, cache);
          }
        } catch(EmptyStackException e) {
View Full Code Here

TOP

Related Classes of com.dooapp.gaedo.properties.Property

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.