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
        if(Literals.containsKey(currentProperty.getType())) {
          returned.setNavigationSuccessfull(true);
        } else {
          returned.setNavigationSuccessfull(false);
        }
      }
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

   * @param expectedIdClasses a collection of expected id classes.If that collection is null, no check is performed.
   */
  public static Property locateIdField(Class<?> containedClass, Property[] fields, Collection<Class> expectedIdClasses) {
    List<Property> probableId = AnnotationsFinder.findAll(fields,
        Annotations.ID);
    Property idField;
    if (probableId.size() != 1) {
      throw new BadIdAnnotatedClassException(containedClass, expectedIdClasses);
    } else {
      idField = probableId.get(0);
      /*
       * Someone using Shcrodinger cat in a Java blog post can't be evil
       * ;-) http://sensualjava.blogspot.com/2007
       * /11/reflection-and-auto-boxing.html
       */
      if(expectedIdClasses!=null) {
        boolean found = false;
        Iterator<Class> iterator = expectedIdClasses.iterator();
        while(iterator.hasNext() && !found) {
          found = idField.getType().isAssignableFrom(iterator.next());
        }
        if(!found) {
          throw new BadIdAnnotatedClassException(containedClass, expectedIdClasses);
        }
      }
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

    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(value==null) {
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

  @Override
  protected boolean callMatchManaged(Vertex currentVertex, Property finalProperty) {
    /* 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(this.getClass());
    List<Property> localPath = Arrays.asList(classCollection);
    CollectionContains classesContains = new CollectionContains(strategy, driver, localPath, expected);
    /*
     * Now classes are stored as literal values, this distinction is quite important
     */
 
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

class OperateOnProperties {
  public void execute(Map<Property, Collection<CascadeType>> containedProperties, CascadeType cascade, Operation operation) {
    String operationSimpleName = operation.getClass().getSimpleName();
      Logger logger = Logger.getLogger(operation.getClass().getName());
        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 {
                  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,
                            String.format("operation %s not performed on %s has no cascade %s defined\n"
                                    + "To fix that, simply add %s.%s to its JPA annotation",
                                    operationSimpleName,
                                    p.toGenericString(),
                                    cascade,
                                    cascade.getClass().getSimpleName(),
                                    cascade));
                  }
                }
View Full Code Here

        }
        edgeLabelToProperty.get(edgeLabel).add(e);
      }
      for (GraphBasedPropertyBuilder<DataType> builder : edgeLabelToProperty.values()) {
        try {
          Property built = builder.build();
          // only add property if absent from properties laoded from the bean, as properties loaded from the bean are respectfull to initial data type
          if(!returned.containsKey(built))
            returned.put(built, StrategyUtils.extractCascadeOfJPAAnnotations(built));
        } catch(NoEdgeInNamedGraphsException e) {
          logger.info(e.getMessage());
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.