use of org.activityinfo.shared.command.Command in project activityinfo by bedatadriven.
the class ImporterWizard method finish.
@Override
public void finish(final AsyncCallback<Void> callback) {
final KeyGenerator keyGenerator = new KeyGenerator();
int numColums = model.getData().getNumColumns();
ColumnBinding[] bindings = bindingsArray();
// do a first pass to match the location
List<Command> matchBatch = Lists.newArrayList();
for (ImportRowModel row : model.getData().getRowStore().getModels()) {
MatchLocation location = new MatchLocation();
location.setLocationType(model.getActivity().getLocationTypeId());
for (int i = 0; i != numColums; ++i) {
bindings[i].bindLocation(row.get(i), location);
}
matchBatch.add(location);
}
dispatcher.execute(new BatchCommand(matchBatch), new AsyncCallback<BatchResult>() {
@Override
public void onFailure(Throwable caught) {
MessageBox.alert("Match locations failed", "Exception", null);
}
@Override
public void onSuccess(BatchResult result) {
submitSites((List) result.getResults(), callback);
}
});
}
use of org.activityinfo.shared.command.Command in project activityinfo by bedatadriven.
the class CommandServlet method handleCommands.
/**
* Publicly visible for testing *
*/
@LogException
public List<CommandResult> handleCommands(List<Command> commands) {
applyUserFilters();
List<CommandResult> results = new ArrayList<CommandResult>();
for (Command command : commands) {
LOGGER.log(Level.INFO, authProvider.get().getEmail() + ": " + command.getClass().getSimpleName());
try {
results.add(handleCommand(command));
} catch (CommandException e) {
results.add(e);
}
}
return results;
}
use of org.activityinfo.shared.command.Command in project activityinfo by bedatadriven.
the class CommandDeserializer method deserialize.
@Override
public Command deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
ObjectNode root = (ObjectNode) mapper.readTree(jp);
String typeName = root.path("type").asText();
Class commandClass = lookupCommandClass(typeName);
return (Command) mapper.readValue(root.path("command"), commandClass);
}
Aggregations