예제 #1
0
 // adds the child properties to the top most property
 private void addChildProperties(
     EntityMetadata entityMetadata, EMProperty parentProperty, List<String> childPropertyNames) {
   String fullyQualifiedPropertyName = parentProperty.getName();
   for (String childPropertyName : childPropertyNames) {
     fullyQualifiedPropertyName = fullyQualifiedPropertyName + "." + childPropertyName;
     EMProperty childProperty = null;
     if (parentProperty.hasChildProperty(childPropertyName)) {
       // this property already added to the parent property
       childProperty = parentProperty.getChildProperty(childPropertyName);
     } else {
       // this is a new child property so create and add to the parent property
       childProperty = new EMProperty(childPropertyName);
       parentProperty.addChildProperty(childProperty);
       Vocabulary propertyVocabulary =
           entityMetadata.getPropertyVocabulary(fullyQualifiedPropertyName);
       for (Term vocTerm : propertyVocabulary.getTerms()) {
         if (TermComplexGroup.TERM_NAME.equals(vocTerm.getName())) {
           // complex group term not added as the properties are built in tree structure
           continue;
         }
         childProperty.addVocabularyTerm(new EMTerm(vocTerm.getName(), vocTerm.getValue()));
       }
     }
     parentProperty = childProperty;
   }
 }
예제 #2
0
 // adds the property tree to the entity metadata
 private void addProperties(
     EntityMetadata entityMetadata, EMEntity entity, String fyllyQualifiedPropertyName) {
   List<String> propertyNames =
       new ArrayList<String>(Arrays.asList(fyllyQualifiedPropertyName.split("\\.")));
   String rootPropertyName = propertyNames.get(0);
   EMProperty rootProperty = null;
   if (entity.contains(rootPropertyName)) {
     // this property already added to the entity
     rootProperty = entity.getProperty(rootPropertyName);
   } else {
     // new property so create and add to the entity
     rootProperty = new EMProperty(rootPropertyName);
     entity.addProperty(rootProperty);
     Vocabulary vocabulary = entityMetadata.getPropertyVocabulary(rootPropertyName);
     for (Term term : vocabulary.getTerms()) {
       rootProperty.addVocabularyTerm(new EMTerm(term.getName(), term.getValue()));
     }
   }
   propertyNames.remove(0); // removes root property as it's already added to the entity
   addChildProperties(entityMetadata, rootProperty, propertyNames);
 }