use of org.activityinfo.shared.dto.ProjectDTO in project activityinfo by bedatadriven.
the class DbTargetEditor method onEdit.
@Override
protected void onEdit(final TargetDTO dto) {
this.view.showAddDialog(dto, db, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
final Record record = store.getRecord(dto);
service.execute(new UpdateEntity(dto, getChangedProperties(record)), dlg, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(VoidResult result) {
PartnerDTO partner = db.getPartnerById((Integer) record.get("partnerId"));
dto.setPartner(partner);
ProjectDTO project = db.getProjectById((Integer) record.get("projectId"));
dto.setProject(project);
store.commitChanges();
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
});
}
});
}
use of org.activityinfo.shared.dto.ProjectDTO 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.dto.ProjectDTO in project activityinfo by bedatadriven.
the class GetSitesHandler method toSite.
private SiteDTO toSite(SqlResultSetRow row) {
SiteDTO model = new SiteDTO();
model.setId(row.getInt("SiteId"));
model.setLinked(row.getBoolean("Linked"));
model.setActivityId(row.getInt("ActivityId"));
model.setDate1(row.getDate("Date1"));
model.setDate2(row.getDate("Date2"));
model.setDateCreated(row.getDate("DateCreated"));
model.setTimeEdited(row.getDouble("TimeEdited"));
model.setLocationId(row.getInt("LocationId"));
model.setLocationName(row.getString("LocationName"));
model.setLocationAxe(row.getString("LocationAxe"));
if (!row.isNull("x") && !row.isNull("y")) {
model.setX(row.getDouble("x"));
model.setY(row.getDouble("y"));
}
model.setComments(row.getString("Comments"));
PartnerDTO partner = new PartnerDTO();
partner.setId(row.getInt("PartnerId"));
partner.setName(row.getString("PartnerName"));
if (!row.isNull("ProjectId") && row.isNull("ProjectDateDeleted")) {
ProjectDTO project = new ProjectDTO();
project.setId(row.getInt("ProjectId"));
project.setName(row.getString("ProjectName"));
model.setProject(project);
}
model.setPartner(partner);
return model;
}
use of org.activityinfo.shared.dto.ProjectDTO in project activityinfo by bedatadriven.
the class CreateSiteTest method testAdminBoundCreate.
@Test
@Ignore("WIP")
public void testAdminBoundCreate() throws CommandException {
// create a new detached, client model
SiteDTO newSite = new SiteDTO();
newSite.setActivityId(4);
newSite.setPartner(new PartnerDTO(1, "Foobar"));
newSite.setDate1((new GregorianCalendar(2008, 12, 1)).getTime());
newSite.setDate2((new GregorianCalendar(2009, 1, 3)).getTime());
newSite.setAdminEntity(1, new AdminEntityDTO(1, 2, "Sud Kivu"));
newSite.setAdminEntity(2, new AdminEntityDTO(2, 11, "Walungu"));
newSite.setAdminEntity(3, null);
newSite.setX(27.432);
newSite.setY(1.23);
newSite.setComments("huba huba");
newSite.setProject(new ProjectDTO(1, "SomeProject"));
// create command
CreateSite cmd = new CreateSite(newSite);
// execute the command
setUser(1);
newSite.setProject(new ProjectDTO(1, "SomeProject"));
CreateResult result = execute(cmd);
newSite.setId(result.getNewId());
// try to retrieve what we've created
PagingLoadResult<SiteDTO> loadResult = execute(GetSites.byId(newSite.getId()));
Assert.assertEquals(1, loadResult.getData().size());
SiteDTO secondRead = loadResult.getData().get(0);
// confirm that the changes are there
Assert.assertEquals("site.location.name", "Walungu", secondRead.getLocationName());
}
use of org.activityinfo.shared.dto.ProjectDTO in project activityinfo by bedatadriven.
the class ProjectTest method updateProject.
@Test
public void updateProject() {
setUser(1);
SchemaDTO schema = execute(new GetSchema());
ProjectDTO project = schema.getProjectById(2);
project.setName("RRMP II");
project.setDescription("RRMP The Next Generation");
execute(RequestChange.update(project, "name", "description"));
schema = execute(new GetSchema());
assertThat(schema.getProjectById(2).getName(), equalTo("RRMP II"));
assertThat(schema.getProjectById(2).getDescription(), equalTo("RRMP The Next Generation"));
project.setName("RRMP III");
project.setDescription(null);
execute(RequestChange.update(project, "name", "description"));
}
Aggregations