use of org.activityinfo.legacy.shared.model.ProjectDTO in project activityinfo by bedatadriven.
the class ProjectDimBinding method extractFieldData.
@Override
public BaseModelData[] extractFieldData(BaseModelData[] dataArray, ColumnSet columnSet) {
ColumnView id = columnSet.getColumnView(PROJECT_ID_COLUMN);
ColumnView label = columnSet.getColumnView(PROJECT_LABEL_COLUMN);
for (int i = 0; i < columnSet.getNumRows(); i++) {
String projectId = id.getString(i);
String projectLabel = Strings.nullToEmpty(label.getString(i));
if (projectId != null && !Strings.isNullOrEmpty(projectLabel)) {
ProjectDTO project = new ProjectDTO(CuidAdapter.getLegacyIdFromCuid(projectId), projectLabel);
dataArray[i].set(PROJECT_FIELD, project);
}
}
return dataArray;
}
use of org.activityinfo.legacy.shared.model.ProjectDTO in project activityinfo by bedatadriven.
the class SiteDTOs method newSite.
public static SiteDTO newSite() {
SiteDTO newSite = new SiteDTO();
newSite.setId(new KeyGenerator().generateInt());
newSite.setActivityId(1);
newSite.setLocationId(1);
newSite.setPartner(new PartnerDTO(1, "Foobar"));
newSite.setReportingPeriodId(new KeyGenerator().generateInt());
newSite.setDate1((new GregorianCalendar(2008, 12, 1)).getTime());
newSite.setDate2((new GregorianCalendar(2009, 1, 3)).getTime());
newSite.setIndicatorValue(1, 996.0);
newSite.setIndicatorValue(2, null);
newSite.setAttributeValue(1, true);
newSite.setAttributeValue(2, false);
newSite.setComments("huba huba");
newSite.setProject(new ProjectDTO(1, "WoeiProject"));
return newSite;
}
use of org.activityinfo.legacy.shared.model.ProjectDTO 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) {
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.legacy.shared.model.ProjectDTO in project activityinfo by bedatadriven.
the class DbProjectEditor method onEdit.
@Override
protected void onEdit(final ProjectDTO model) {
final ProjectDTO copy = new ProjectDTO();
copy.setProperties(model.getProperties());
final FormDialogImpl<ProjectForm> dialog = new FormDialogImpl<ProjectForm>(new ProjectForm()) {
@Override
public void onCancel() {
model.setProperties(copy.getProperties());
}
};
dialog.setWidth(450);
dialog.setHeight(300);
dialog.getForm().getBinding().bind(model);
List<ProjectDTO> allowed = Lists.newArrayList(store.getModels());
allowed.remove(model);
dialog.getForm().getNameField().setValidator(new UniqueNameValidator(allowed));
dialog.show(new FormDialogCallback() {
@Override
public void onValidated() {
service.execute(RequestChange.update(model, "name", "description"), dialog, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
// handled by monitor
}
@Override
public void onSuccess(VoidResult result) {
dialog.hide();
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
view.refresh();
}
});
}
});
}
use of org.activityinfo.legacy.shared.model.ProjectDTO in project activityinfo by bedatadriven.
the class ProjectTest method constraintViolation.
@Test(expected = Exception.class)
public void constraintViolation() {
setUser(1);
SchemaDTO schema = execute(new GetSchema());
ProjectDTO project = schema.getProjectById(2);
project.setName(null);
execute(RequestChange.update(project, "name"));
}
Aggregations