コード例 #1
0
 /**
  * Takes care of the id properties, either identifying the Ids or getting them from idProperties
  * of @Path
  *
  * @throws Exception
  */
 private void parseNodeProperty() throws Exception {
   if (Is.empty(treeAnnotation.idProperties())) {
     idProperties = "";
     for (Field field : nodeClass.getDeclaredFields()) {
       if (field.isAnnotationPresent(Id.class)) {
         if (!Is.empty(idProperties)) {
           idProperties = idProperties + ",";
         }
         idProperties = idProperties + field.getName();
       }
     }
   } else {
     idProperties = treeAnnotation.idProperties();
   }
   if (Is.empty(idProperties)) {
     throw new Exception(XavaResources.getString("error.nodePropertiesUndefined"));
   }
   String[] properties = idProperties.split(",");
   idPropertiesList = new ArrayList<String>();
   for (String property : properties) {
     if (!Is.empty(property.trim())) {
       idPropertiesList.add(property.trim());
     }
   }
 }
コード例 #2
0
 /**
  * Parse the @TreeView annotation.
  *
  * @param nodeClass Object to be parsed.
  * @throws Exception
  */
 @SuppressWarnings("rawtypes")
 protected void parseTreeView(Tree path, Class nodeClass, Class parentClass, String collectionName)
     throws Exception {
   this.treeAnnotation = path;
   this.nodeClass = nodeClass;
   this.parentClass = parentClass;
   this.collectionName = collectionName;
   if (treeAnnotation == null) {
     treeAnnotation =
         this.getClass().getDeclaredField("defaultPathAnnotation").getAnnotation(Tree.class);
   }
   if (Is.empty(treeAnnotation.pathProperty())) {
     throw new XavaException("error.collectionDoesNotRepresentATreeView");
   }
   this.pathProperty = treeAnnotation.pathProperty();
   this.idSeparator = treeAnnotation.idSeparator();
   parseNodeProperty();
   this.orderProperty = null;
   this.initialExpandedState = treeAnnotation.initialExpandedState();
   this.keyIncrement = treeAnnotation.orderIncrement();
   if (this.keyIncrement < 2) {
     this.keyIncrement = 2;
   }
   setPathSeparator(treeAnnotation.pathSeparator());
   if (nodeClass.getClass().isAnnotationPresent(Id.class)) {
     entityObject = true;
   } else {
     entityObject = false;
   }
   parseOrderDefined();
   parseEntityObject();
 }