예제 #1
0
 /** {@inheritDoc} */
 @Override
 public void create(Feature fp) {
   if (fp == null) {
     throw new IllegalArgumentException("Feature cannot be null nor empty");
   }
   if (exist(fp.getUid())) {
     throw new FeatureAlreadyExistException(fp.getUid());
   }
   collection.save(MAPPER.toDBObject(fp));
 }
예제 #2
0
 /** {@inheritDoc} */
 @Override
 public void update(Feature fp) {
   if (fp == null) {
     throw new IllegalArgumentException("Feature cannot be null nor empty");
   }
   Feature fpExist = read(fp.getUid());
   collection.save(MAPPER.toDBObject(fp));
   // enable/disable
   if (fp.isEnable() != fpExist.isEnable()) {
     if (fp.isEnable()) {
       enable(fp.getUid());
     } else {
       disable(fp.getUid());
     }
   }
 }
 /** {@inheritDoc} */
 @Override
 public void update(Feature fp) {
   if (fp == null) {
     throw new IllegalArgumentException("Feature cannot be null nor empty");
   }
   Feature fpExist = read(fp.getUid());
   collection.updateOne(
       BUILDER.getFeatUid(fp.getUid()), new Document(MONGO_SET, MAPPER.toDocument(fp)));
   // enable/disable
   if (fp.isEnable() != fpExist.isEnable()) {
     if (fp.isEnable()) {
       enable(fp.getUid());
     } else {
       disable(fp.getUid());
     }
   }
 }
예제 #4
0
 /** {@inheritDoc} */
 @Override
 public Map<String, Feature> readAll() {
   LinkedHashMap<String, Feature> mapFP = new LinkedHashMap<String, Feature>();
   for (DBObject dbObject : collection.find()) {
     Feature feature = MAPPER.mapFeature(dbObject);
     mapFP.put(feature.getUid(), feature);
   }
   return mapFP;
 }
예제 #5
0
 /** {@inheritDoc} */
 @Override
 public Map<String, Feature> readGroup(String groupName) {
   if (groupName == null || groupName.isEmpty()) {
     throw new IllegalArgumentException("Groupname cannot be null nor empty");
   }
   if (!existGroup(groupName)) {
     throw new GroupNotFoundException(groupName);
   }
   LinkedHashMap<String, Feature> mapFP = new LinkedHashMap<String, Feature>();
   for (DBObject dbObject : collection.find(BUILDER.getGroupName(groupName))) {
     Feature feature = MAPPER.mapFeature(dbObject);
     mapFP.put(feature.getUid(), feature);
   }
   return mapFP;
 }