Package com.getperka.flatpack.ext

Examples of com.getperka.flatpack.ext.Property


      toReturn.setDocString(replaceLinks(docString));
    }

    // Iterate over the properties
    for (Iterator<Property> it = toReturn.getProperties().iterator(); it.hasNext();) {
      Property prop = it.next();
      propertiesToEntities.put(prop, toReturn);

      // Record a reference to (possibly) an entity type
      reference(prop.getType());

      Method accessor = prop.getGetter();
      if (accessor == null) {
        accessor = prop.getSetter();
      }

      // Send down interesting annotations
      prop.setDocAnnotations(extractInterestingAnnotations(accessor));

      // The property set include all properties defined in supertypes
      Class<?> declaringClass = accessor.getDeclaringClass();
      strings = getDocStrings(declaringClass);
      if (strings != null) {
        String memberName = declaringClass.getName() + ":" + accessor.getName() + "()";
        prop.setDocString(replaceLinks(strings.get(memberName)));
      }
    }
    return toReturn;
  }
View Full Code Here


    // Check various type-level permissions
    checkMerchantPermissions(p);

    // Check property-level permissions, especially type- and global-overrides
    Property name = getProperty(fp.getTypeContext(), clazz, "name");
    p = name.getGroupPermissions();
    assertNotNull(p);
    // Just replacing a previous declaration
    assertEquals(5, p.getOperations().size());
    checkPermissions(p, "*", "crudOperation.read");

    // Test the "allow only" construct
    Property note = getProperty(fp.getTypeContext(), clazz, "note");
    p = note.getGroupPermissions();
    assertNotNull(p);
    assertEquals(1, p.getOperations().size());
    checkPermissions(p, "internalUser", "*.*");

    // Verify that unreferenced properties inherit the type's allow
    Property other = getProperty(fp.getTypeContext(), clazz, "other");
    p = other.getGroupPermissions();
    assertNotNull(p);
    checkMerchantPermissions(p);
  }
View Full Code Here

        .mapForIteration();
    for (EntityDescription entity : api.getEntities()) {
      allEntities.put(entity.getTypeName(), entity);
      for (Iterator<Property> it = entity.getProperties().iterator(); it
          .hasNext();) {
        Property prop = it.next();
        if ("uuid".equals(prop.getName())) {
          // Crop the UUID property
          it.remove();
        } else if (!prop.getEnclosingType().equals(entity)) {
          // Remove properties not declared in the current type
          it.remove();
        }
      }
    }
View Full Code Here

    group.registerModelAdaptor(Property.class, new ObjectModelAdaptor() {
      @Override
      public Object getProperty(Interpreter interp, ST self, Object o,
          Object property, String propertyName)
          throws STNoSuchPropertyException {
        Property p = (Property) o;
        if ("attrName".equals(propertyName)) {
          return camelCaseToUnderscore(p.getName());
        }

        else if ("requireName".equals(propertyName)) {
          return requireNameForType(p.getType().getName());
        }
        return super.getProperty(interp, self, o, property, propertyName);
      }
    });
View Full Code Here

      return;
    }

    allEntities.put(typeName, entity);
    for (Iterator<Property> it = entity.getProperties().iterator(); it.hasNext();) {
      Property prop = it.next();
      if ("uuid".equals(prop.getName())) {
        // Crop the UUID property
        it.remove();
      } else if (!prop.getEnclosingType().equals(entity)) {
        // Remove properties not declared in the current type
        it.remove();
      }
    }
View Full Code Here

    });
    group.registerModelAdaptor(Property.class, new ObjectModelAdaptor() {
      @Override
      public Object getProperty(Interpreter interp, ST self, Object o, Object property,
          String propertyName) throws STNoSuchPropertyException {
        Property p = (Property) o;
        if ("getterName".equals(propertyName)) {
          return upcase(p.getName());
        } else if ("needsImplied".equals(propertyName)) {
          // Returns true if the property has @Implies / @OneToMany and is a list
          return p.getImpliedProperty() != null && p.getType().getListElement() != null;
        } else if ("needsAdder".equals(propertyName)) {
          return JsonKind.LIST.equals(p.getType().getJsonKind());
        } else if ("needsPutter".equals(propertyName)) {
          return JsonKind.MAP.equals(p.getType().getJsonKind());
        }
        return super.getProperty(interp, self, o, property, propertyName);
      }
    });
    group.registerModelAdaptor(Type.class, new ObjectModelAdaptor() {
View Full Code Here

    Map<String, EntityDescription> allEntities = FlatPackCollections
        .mapForIteration();
    for (EntityDescription entity : api.getEntities()) {
      allEntities.put(entity.getTypeName(), entity);
      for (Iterator<Property> it = entity.getProperties().iterator(); it.hasNext();) {
        Property prop = it.next();
        // Remove the uuid property
        if ("uuid".equals(prop.getName())) {
          it.remove();
        }

        // and properties not declared in the current type
        else if (!prop.getEnclosingType().equals(entity)) {
          it.remove();
        }
      }
    }
View Full Code Here

    group.registerModelAdaptor(Property.class, new ObjectModelAdaptor() {
      @Override
      public Object getProperty(Interpreter interp, ST self, Object o,
          Object property, String propertyName)
          throws STNoSuchPropertyException {
        Property p = (Property) o;
        if ("docString".equals(propertyName)) {
          String docString = p.getDocString();

          List<String> enumValues = p.getType().getEnumValues();
          if (enumValues != null) {
            docString = docString == null ? "" : docString;
            docString += "\n\nPossible values: ";
            for (int i = 0; i < enumValues.size(); i++) {
              docString += enumValues.get(i);
              if (i < enumValues.size() - 1) docString += ", ";
            }
          }
          return doxygenDocString(docString);
        }
        else if ("requireName".equals(propertyName)) {
          return requireNameForType(p.getType().getName());
        }
        else if ("phpType".equals(propertyName)) {
          return phpTypeForProperty(p);
        }
        else if ("modifiers".equals(propertyName)) {
          List<String> modifiers = new ArrayList<String>();
          String safeName = getSafeName(p.getName());
          if (p.getImpliedProperty() != null
            && p.getImpliedProperty().getType().getJsonKind().equals(JsonKind.LIST)) {
            modifiers.add("weak");
          }
          else {
            modifiers.add("strong");
          }
          if (p.getType().getJsonKind().equals(JsonKind.BOOLEAN)) {
            modifiers.add("getter=is" + upcase(safeName));
          }
          // http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html
          if (p.getName().startsWith("new")) {
            modifiers.add("getter=a" + upcase(safeName));
          }
          return modifiers;
        }
        else if ("safeName".equals(propertyName)) {
          return getSafeName(p.getName());
        }
        else if ("upcaseName".equals(propertyName)) {
          return upcase(getSafeName(p.getName()));
        }
        else if ("listElementphpType".equals(propertyName)) {
          return phpTypeForType(p.getType().getListElement());
        }
        else if ("singularUpcaseName".equals(propertyName)) {
          if (p.getType().getListElement() != null) {
            String type = phpTypeForType(p.getType().getListElement());
            return type.substring(2);
          }
          return upcase(p.getName());
        }

        return super.getProperty(interp, self, o, property, propertyName);
      }
    });
View Full Code Here

TOP

Related Classes of com.getperka.flatpack.ext.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.