use of org.activityinfo.shared.command.AddProject in project activityinfo by bedatadriven.
the class AddProjectHandler method execute.
@Override
public CommandResult execute(AddProject cmd, User user) throws CommandException {
UserDatabase db = em.find(UserDatabase.class, cmd.getDatabaseId());
ProjectDTO from = cmd.getProjectDTO();
Project project = new Project();
project.setName(from.getName());
project.setDescription(from.getDescription());
project.setUserDatabase(db);
db.setLastSchemaUpdate(new Date());
em.persist(project);
em.persist(db);
db.getProjects().add(project);
return new CreateResult(project.getId());
}
use of org.activityinfo.shared.command.AddProject in project activityinfo by bedatadriven.
the class DbProjectEditor method onAdd.
@Override
protected void onAdd() {
final ProjectDTO newProject = new ProjectDTO();
this.view.showAddDialog(newProject, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
service.execute(new AddProject(db.getId(), newProject), dlg, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof DuplicatePartnerException) {
MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
} else {
MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
}
}
@Override
public void onSuccess(CreateResult result) {
newProject.setId(result.getNewId());
store.add(newProject);
db.getProjects().add(newProject);
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
});
}
});
}
Aggregations