use of org.activityinfo.server.command.handler.crud.ActivityPolicy in project activityinfo by bedatadriven.
the class UpdateEntityHandler method updateActivity.
private void updateActivity(UpdateEntity cmd, User user, PropertyMap changeMap) {
ActivityPolicy policy = injector.getInstance(ActivityPolicy.class);
policy.update(user, cmd.getId(), changeMap);
}
use of org.activityinfo.server.command.handler.crud.ActivityPolicy in project activityinfo by bedatadriven.
the class CreateEntityHandler method execute.
@Override
public CommandResult execute(CreateEntity cmd, User user) throws CommandException {
Map<String, Object> properties = cmd.getProperties().getTransientMap();
PropertyMap propertyMap = new PropertyMap(cmd.getProperties().getTransientMap());
if ("UserDatabase".equals(cmd.getEntityName())) {
UserDatabasePolicy policy = injector.getInstance(UserDatabasePolicy.class);
return new CreateResult((Integer) policy.create(user, propertyMap));
} else if ("Activity".equals(cmd.getEntityName())) {
ActivityPolicy policy = injector.getInstance(ActivityPolicy.class);
return new CreateResult((Integer) policy.create(user, propertyMap));
} else if ("AttributeGroup".equals(cmd.getEntityName())) {
return createAttributeGroup(cmd, properties);
} else if ("Attribute".equals(cmd.getEntityName())) {
return createAttribute(cmd, properties);
} else if ("Indicator".equals(cmd.getEntityName())) {
return createIndicator(user, cmd, properties);
} else {
throw new CommandException("Invalid entity class " + cmd.getEntityName());
}
}
use of org.activityinfo.server.command.handler.crud.ActivityPolicy in project activityinfo by bedatadriven.
the class UpdateEntityHandler method execute.
@Override
public CommandResult execute(UpdateEntity cmd, User user) throws CommandException {
LOG.fine("[execute] Update command for entity: " + cmd.getEntityName() + ".");
Map<String, Object> changes = cmd.getChanges().getTransientMap();
PropertyMap changeMap = new PropertyMap(changes);
if ("Activity".equals(cmd.getEntityName())) {
ActivityPolicy policy = injector.getInstance(ActivityPolicy.class);
policy.update(user, cmd.getId(), changeMap);
} else if ("AttributeGroup".equals(cmd.getEntityName())) {
updateAttributeGroup(cmd, changes);
} else if ("Attribute".equals(cmd.getEntityName())) {
updateAttribute(user, cmd, changes);
} else if ("Indicator".equals(cmd.getEntityName())) {
updateIndicator(user, cmd, changes);
} else if ("LockedPeriod".equals(cmd.getEntityName())) {
updateLockedPeriod(user, cmd, changes);
} else if ("Target".equals(cmd.getEntityName())) {
updateTarget(user, cmd, changes);
} else {
throw new RuntimeException("unknown entity type");
}
return null;
}
Aggregations