Search in sources :

Example 1 with UserDatabasePolicy

use of org.activityinfo.server.command.handler.crud.UserDatabasePolicy in project activityinfo by bedatadriven.

the class UpdateEntityHandler method updateDatabase.

private void updateDatabase(UpdateEntity cmd, User user, PropertyMap changeMap) {
    UserDatabasePolicy policy = injector.getInstance(UserDatabasePolicy.class);
    policy.update(user, cmd.getId(), changeMap);
}
Also used : UserDatabasePolicy(org.activityinfo.server.command.handler.crud.UserDatabasePolicy)

Example 2 with UserDatabasePolicy

use of org.activityinfo.server.command.handler.crud.UserDatabasePolicy 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());
    }
}
Also used : ActivityPolicy(org.activityinfo.server.command.handler.crud.ActivityPolicy) PropertyMap(org.activityinfo.server.command.handler.crud.PropertyMap) CreateResult(org.activityinfo.shared.command.result.CreateResult) UserDatabasePolicy(org.activityinfo.server.command.handler.crud.UserDatabasePolicy) IllegalAccessCommandException(org.activityinfo.shared.exception.IllegalAccessCommandException) CommandException(org.activityinfo.shared.exception.CommandException)

Aggregations

UserDatabasePolicy (org.activityinfo.server.command.handler.crud.UserDatabasePolicy)2 ActivityPolicy (org.activityinfo.server.command.handler.crud.ActivityPolicy)1 PropertyMap (org.activityinfo.server.command.handler.crud.PropertyMap)1 CreateResult (org.activityinfo.shared.command.result.CreateResult)1 CommandException (org.activityinfo.shared.exception.CommandException)1 IllegalAccessCommandException (org.activityinfo.shared.exception.IllegalAccessCommandException)1