Package com.dooapp.gaedo.google.datastore

Examples of com.dooapp.gaedo.google.datastore.IdManager


    if (!repository.containsKey(parentField.getType())) {
      throw new NonStoredParentException(parentField);
    }
    DatastoreFinderService parentService = (DatastoreFinderService) repository
        .get(parentField.getType());
    IdManager parentIdManager = parentService.getIdManager();
    Object parentObject = parentField.get(data);
    String parentKind = parentService.getKind();
    if (!parentIdManager.hasKey(parentKind, parentObject)) {
      parentIdManager.createKey(parentKind, parentObject);
    }
    return parentIdManager.getKey(parentKind, parentObject);
  }
View Full Code Here


   * @return
   */
  public static IdManager createIdManager(Class<?> containedClass,
      DatastoreService datastore, ServiceRepository repository, PropertyProvider provider, HierarchyManager hierarchyManager) {
    logger.config("defining id manager");
    IdManager returned = null;
    Field[] fields = containedClass.getDeclaredFields();
    for (Field f : fields) {
      // only non static fields are used
      if (!Modifier.isStatic(f.getModifiers())) {
        boolean isIdField = f.getAnnotation(Id.class) != null;
        if (isIdField) {
          if (logger.isLoggable(Level.FINE)) {
            logger.fine("found id field of "
                + containedClass.getName() + "\nIt is "
                + f.toGenericString());
          }
          if (returned != null)
            throw new BadIdAnnotatedClassException(containedClass);
          if (logger.isLoggable(Level.CONFIG))
            logger.config("the field " + f.toGenericString()
                + " seems to be an id field");
          if (Long.class.equals(f.getType())
              || Long.TYPE.equals(f.getType())) {
            returned = new LongIdManager(containedClass, datastore, provider, repository, hierarchyManager);
            logger.config("using standard LongIdManager");
          } else if (String.class.equals(f.getType())) {
            logger.config("using standard StringIdManager");
          } else {
            throw new NoSuchIdManagerException(f);
          }
          if (logger.isLoggable(Level.FINE)) {
            logger.fine("As a consequence, id manager is a "
                + returned.getClass().getName());
          }
        }
        // Side effect : access to the field !
        f.setAccessible(true);
      }
View Full Code Here

   */
  public static IdManager createIdManager(Class<?> containedClass,
      DatastoreService datastore, ServiceRepository repository, PropertyProvider provider, HierarchyManager hierarchyManager) {
    logger.config("defining id manager");
    Property id = AnnotationUtils.locateIdField(provider, containedClass, Long.TYPE, Long.class, String.class);
    IdManager returned = null;
    if (Long.class.equals(id.getType())
            || Long.TYPE.equals(id.getType())) {
      returned = new LongIdManager(containedClass, datastore, provider, repository, hierarchyManager);
    }
    if (returned == null)
View Full Code Here

   * @return
   */
  public static IdManager createIdManager(Class<?> containedClass,
      DatastoreService datastore, ServiceRepository repository, PropertyProvider provider, HierarchyManager hierarchyManager) {
    logger.config("defining id manager");
    IdManager returned = null;
    Field[] fields = containedClass.getDeclaredFields();
    for (Field f : fields) {
      // only non static fields are used
      if (!Modifier.isStatic(f.getModifiers())) {
        boolean isIdField = f.getAnnotation(Id.class) != null;
        if (isIdField) {
          if (logger.isLoggable(Level.FINE)) {
            logger.fine("found id field of "
                + containedClass.getName() + "\nIt is "
                + f.toGenericString());
          }
          if (returned != null)
            throw new BadIdAnnotatedClass(containedClass);
          if (logger.isLoggable(Level.CONFIG))
            logger.config("the field " + f.toGenericString()
                + " seems to be an id field");
          if (Long.class.equals(f.getType())
              || Long.TYPE.equals(f.getType())) {
            returned = new LongIdManager(containedClass, datastore, provider, repository, hierarchyManager);
            logger.config("using standard LongIdManager");
          } else if (String.class.equals(f.getType())) {
            logger.config("using standard StringIdManager");
          } else {
            throw new NoSuchIdManager(f);
          }
          if (logger.isLoggable(Level.FINE)) {
            logger.fine("As a consequence, id manager is a "
                + returned.getClass().getName());
          }
        }
        // Side effect : access to the field !
        f.setAccessible(true);
      }
View Full Code Here

    if (!repository.containsKey(parentField.getType())) {
      throw new NonStoredParent(parentField);
    }
    DatastoreFinderService parentService = (DatastoreFinderService) repository
        .get(parentField.getType());
    IdManager parentIdManager = parentService.getIdManager();
    Object parentObject = parentField.get(data);
    String parentKind = parentService.getKind();
    if (!parentIdManager.hasKey(parentKind, parentObject)) {
      parentIdManager.createKey(parentKind, parentObject);
    }
    return parentIdManager.getKey(parentKind, parentObject);
  }
View Full Code Here

TOP

Related Classes of com.dooapp.gaedo.google.datastore.IdManager

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.