Search in sources :

Example 1 with UpdateBuilder

use of org.activityinfo.server.command.handler.sync.UpdateBuilder in project activityinfo by bedatadriven.

the class GetSyncRegionUpdatesHandler method execute.

@Override
public CommandResult execute(GetSyncRegionUpdates cmd, User user) throws CommandException {
    Log.info("Fetching updates for " + cmd.getRegionId() + ", localVersion = " + cmd.getLocalVersion());
    UpdateBuilder builder;
    if (cmd.getRegionId().equals("schema")) {
        builder = injector.getInstance(SchemaUpdateBuilder.class);
    } else if (cmd.getRegionId().startsWith("admin/")) {
        builder = injector.getInstance(AdminUpdateBuilder.class);
    } else if (cmd.getRegionId().startsWith("location/")) {
        builder = injector.getInstance(LocationUpdateBuilder.class);
    } else if (cmd.getRegionId().startsWith("site/")) {
        builder = injector.getInstance(SiteUpdateBuilder.class);
    } else if (cmd.getRegionId().equals("site-tables")) {
        builder = injector.getInstance(SiteTableUpdateBuilder.class);
    } else {
        throw new CommandException("Unknown sync region: " + cmd.getRegionId());
    }
    try {
        return builder.build(user, cmd);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : SchemaUpdateBuilder(org.activityinfo.server.command.handler.sync.SchemaUpdateBuilder) LocationUpdateBuilder(org.activityinfo.server.command.handler.sync.LocationUpdateBuilder) SiteTableUpdateBuilder(org.activityinfo.server.command.handler.sync.SiteTableUpdateBuilder) UpdateBuilder(org.activityinfo.server.command.handler.sync.UpdateBuilder) AdminUpdateBuilder(org.activityinfo.server.command.handler.sync.AdminUpdateBuilder) LocationUpdateBuilder(org.activityinfo.server.command.handler.sync.LocationUpdateBuilder) SiteTableUpdateBuilder(org.activityinfo.server.command.handler.sync.SiteTableUpdateBuilder) SiteUpdateBuilder(org.activityinfo.server.command.handler.sync.SiteUpdateBuilder) SchemaUpdateBuilder(org.activityinfo.server.command.handler.sync.SchemaUpdateBuilder) CommandException(org.activityinfo.shared.exception.CommandException) CommandException(org.activityinfo.shared.exception.CommandException)

Aggregations

AdminUpdateBuilder (org.activityinfo.server.command.handler.sync.AdminUpdateBuilder)1 LocationUpdateBuilder (org.activityinfo.server.command.handler.sync.LocationUpdateBuilder)1 SchemaUpdateBuilder (org.activityinfo.server.command.handler.sync.SchemaUpdateBuilder)1 SiteTableUpdateBuilder (org.activityinfo.server.command.handler.sync.SiteTableUpdateBuilder)1 SiteUpdateBuilder (org.activityinfo.server.command.handler.sync.SiteUpdateBuilder)1 UpdateBuilder (org.activityinfo.server.command.handler.sync.UpdateBuilder)1 CommandException (org.activityinfo.shared.exception.CommandException)1