示例#1
0
 public List<Model.Property> listProperties() {
   List<Model.Property> properties = new ArrayList<Model.Property>();
   Set<Field> fields = new LinkedHashSet<Field>();
   Class<?> tclazz = clazz;
   while (!tclazz.equals(Object.class)) {
     Collections.addAll(fields, tclazz.getDeclaredFields());
     tclazz = tclazz.getSuperclass();
   }
   for (Field f : fields) {
     int mod = f.getModifiers();
     if (Modifier.isTransient(mod) || Modifier.isStatic(mod)) {
       continue;
     }
     if (f.isAnnotationPresent(Transient.class)) {
       continue;
     }
     if (f.isAnnotationPresent(NoBinding.class)) {
       NoBinding a = f.getAnnotation(NoBinding.class);
       List<String> values = Arrays.asList(a.value());
       if (values.contains("*")) {
         continue;
       }
     }
     Model.Property mp = buildProperty(f);
     if (mp != null) {
       properties.add(mp);
     }
   }
   return properties;
 }
示例#2
0
  public List<Method> getMethods(Object objeto) {

    List<Method> methodGet = mappedMethods.get(objeto.getClass());

    if (methodGet != null) {
      return methodGet;
    }

    methodGet = new ArrayList<Method>();
    Method methods[] = objeto.getClass().getMethods();

    List exclude = Arrays.asList(EXCLUDED_FIELDS);

    try {
      Field field;
      String fieldName;
      for (int j = 0; j < methods.length; j++) {
        field = null;
        fieldName = "";
        try {
          if (methods[j] != null
              && !methods[j].isAnnotationPresent(Transient.class)
              && !methods[j].isAnnotationPresent(NotAudited.class)
              && !methods[j].isAnnotationPresent(Id.class)
              && !exclude.contains(methods[j].getName())) {
            fieldName = getMethodName(methods[j]);
          }
          if (fieldName != null && !fieldName.equals("")) {
            try {
              field = getDeclaredField(methods[j].getDeclaringClass(), fieldName);
            } catch (NoSuchFieldException ex) {
              continue;
            }
            if (field != null
                && !field.isAnnotationPresent(Transient.class)
                && !field.isAnnotationPresent(NotAudited.class)
                && !field.isAnnotationPresent(Id.class)) {
              methodGet.add(methods[j]);
            }
          }
        } catch (Exception ex) {
          logger.log(Level.SEVERE, ex.getMessage(), ex);
        }
      }
    } catch (Exception ex) {
      logger.log(Level.SEVERE, ex.getMessage(), ex);
    }
    mappedMethods.put(objeto.getClass(), methodGet);
    return methodGet;
  }
示例#3
0
 String getSearchQuery(List<String> searchFields) {
   String q = "";
   for (Model.Property property : listProperties()) {
     if (property.isSearchable
         && (searchFields == null || searchFields.isEmpty()
             ? true
             : searchFields.contains(property.name))) {
       if (!q.equals("")) {
         q += " or ";
       }
       q += "lower(" + property.name + ") like ?1";
     }
   }
   return q;
 }
示例#4
0
 public void addTriangleListener(TriangleListener listener) {
   if (!listeners.contains(listener)) listeners.add(listener);
   addTriangleModificationListener(listener);
   addTriangleCommentListener(listener);
 }