Exemplo n.º 1
0
 @Override
 protected void setValue(OClass entity, String critery, V value) {
   ODatabaseDocument db = OrientDbWebSession.get().getDatabase();
   db.commit();
   try {
     CustomAttributes custom;
     if (OClassPrototyper.CLUSTER_SELECTION.equals(critery)) {
       if (value != null) entity.setClusterSelection(value.toString());
     } else if ((CustomAttributes.ON_CREATE_FIELDS.getName().equals(critery))
         && (custom = CustomAttributes.fromString(critery)) != null) {
       custom.setValue(entity, value != null ? Joiner.on(",").join((List<String>) value) : null);
     } else if ((custom = CustomAttributes.fromString(critery)) != null) {
       custom.setValue(entity, value);
     } else if (OClassPrototyper.SUPER_CLASSES.equals(critery)) {
       if (value != null) entity.setSuperClasses((List<OClass>) value);
     } else {
       PropertyResolver.setValue(
           critery,
           entity,
           value,
           new PropertyResolverConverter(
               Application.get().getConverterLocator(), Session.get().getLocale()));
     }
   } finally {
     db.begin();
   }
 }
Exemplo n.º 2
0
 @SuppressWarnings("unchecked")
 @Override
 protected V getValue(OClass entity, String critery) {
   CustomAttributes custom;
   if ("clusterSelection".equals(critery)) {
     OClusterSelectionStrategy strategy = entity.getClusterSelection();
     return (V) (strategy != null ? strategy.getName() : null);
   } else if (OClassPrototyper.SUPER_CLASSES.equals(critery)) {
     List<OClass> superClasses = entity.getSuperClasses();
     // Additional wrapping to ArrayList is required , because getSuperClasses return unmodifiable
     // list
     return (V)
         (superClasses != null ? new ArrayList<OClass>(superClasses) : new ArrayList<OClass>());
   } else if ((CustomAttributes.ON_CREATE_FIELDS.getName().equals(critery))
       && (custom = CustomAttributes.fromString(critery)) != null) {
     String onCreateFields = custom.getValue(entity);
     return (V)
         (!Strings.isNullOrEmpty(onCreateFields)
             ? Lists.newArrayList(onCreateFields.split(","))
             : new ArrayList<String>());
   } else if ((custom = CustomAttributes.fromString(critery)) != null) {
     return custom.getValue(entity);
   } else {
     return (V) PropertyResolver.getValue(critery, entity);
   }
 }