use of org.activityinfo.shared.command.result.CreateResult in project activityinfo by bedatadriven.
the class DesignPresenter method createEntity.
private void createEntity(final ModelData parent, final EntityDTO newEntity) {
view.showNewForm(newEntity, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether tether) {
service.execute(new CreateEntity(newEntity), tether, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
GWT.log(caught.getMessage());
}
@Override
public void onSuccess(CreateResult result) {
// todo add
newEntity.set("id", result.getNewId());
if (parent == null) {
treeStore.add(newEntity, false);
} else {
treeStore.add(parent, newEntity, false);
}
if (newEntity instanceof ActivityDTO) {
treeStore.add(newEntity, new AttributeGroupFolder(messages.attributes()), false);
treeStore.add(newEntity, new IndicatorFolder(messages.indicators()), false);
}
tether.hide();
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
}
});
}
});
}
use of org.activityinfo.shared.command.result.CreateResult 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();
}
});
}
});
}
use of org.activityinfo.shared.command.result.CreateResult in project activityinfo by bedatadriven.
the class DbTargetEditor method onAdd.
@Override
protected void onAdd() {
final TargetDTO newTarget = new TargetDTO();
this.view.showAddDialog(newTarget, db, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
service.execute(new AddTarget(db.getId(), newTarget), dlg, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
}
@Override
public void onSuccess(CreateResult result) {
newTarget.setId(result.getNewId());
PartnerDTO partner = db.getPartnerById((Integer) newTarget.get("partnerId"));
newTarget.setPartner(partner);
ProjectDTO project = db.getProjectById((Integer) newTarget.get("projectId"));
newTarget.setProject(project);
store.add(newTarget);
store.commitChanges();
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
});
}
});
}
use of org.activityinfo.shared.command.result.CreateResult in project activityinfo by bedatadriven.
the class SiteDialog method saveNewSite.
private void saveNewSite() {
final SiteDTO newSite = new SiteDTO();
newSite.setId(new KeyGenerator().generateInt());
newSite.setActivityId(activity.getId());
if (activity.getReportingFrequency() == ActivityDTO.REPORT_ONCE) {
newSite.setReportingPeriodId(new KeyGenerator().generateInt());
}
updateModel(newSite);
dispatcher.execute(new CreateSite(newSite), new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
showError(caught);
}
@Override
public void onSuccess(CreateResult result) {
hide();
callback.onSaved(newSite);
}
});
}
use of org.activityinfo.shared.command.result.CreateResult in project activityinfo by bedatadriven.
the class ReportDesignPage method performCreate.
private void performCreate() {
currentModel.setTitle(currentModel.getTitle() + " (" + I18N.CONSTANTS.copy() + ")");
dispatcher.execute(new CreateReport(currentModel), new AsyncCallback<CreateResult>() {
@Override
public void onFailure(final Throwable caught) {
}
@Override
public void onSuccess(final CreateResult created) {
eventBus.fireEvent(new NavigationEvent(NavigationHandler.NAVIGATION_REQUESTED, new ReportDesignPageState(created.getNewId())));
}
});
}
Aggregations