Search in sources :

Example 1 with ActivityPolicy

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);
}
Also used : ActivityPolicy(org.activityinfo.server.command.handler.crud.ActivityPolicy)

Example 2 with ActivityPolicy

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());
    }
}
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)

Example 3 with ActivityPolicy

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;
}
Also used : ActivityPolicy(org.activityinfo.server.command.handler.crud.ActivityPolicy) PropertyMap(org.activityinfo.server.command.handler.crud.PropertyMap)

Aggregations

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