use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.
the class DetailTab method setSite.
public void setSite(final SiteDTO site) {
content.setText(I18N.CONSTANTS.loading());
dispatcher.execute(new GetActivityForm(site.getActivityId()), new AsyncCallback<ActivityFormDTO>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(ActivityFormDTO result) {
render(result, site);
}
});
}
use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.
the class DefaultColumnModelProvider method fetchColumnModels.
@Override
public void fetchColumnModels(final Filter filter, final GroupingModel grouping, final AsyncCallback<ColumnModel> callback) {
if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
final int activityId = filter.getRestrictedCategory(DimensionType.Activity);
dispatcher.execute(new GetActivityForm(activityId)).then(new AsyncCallback<ActivityFormDTO>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(ActivityFormDTO activity) {
dispatcher.execute(new GetSchema()).then(new AsyncCallback<SchemaDTO>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(SchemaDTO schema) {
callback.onSuccess(forSingleActivity(grouping, schema.getDatabaseById(activity.getDatabaseId()), activity));
}
});
}
});
} else {
dispatcher.execute(new GetSchema()).then(new AsyncCallback<SchemaDTO>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(SchemaDTO result) {
if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Database)) {
UserDatabaseDTO singleDatabase = result.getDatabaseById(filter.getRestrictedCategory(DimensionType.Database));
callback.onSuccess(forSingleDatabase(grouping, singleDatabase));
} else {
callback.onSuccess(forMultipleDatabases(grouping, result));
}
}
});
}
}
use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.
the class AttributeGroupTest method testUpdate.
@Test
public void testUpdate() throws Exception {
// change the name of an entity group
ActivityFormDTO activity = execute(new GetActivityForm(1));
AttributeGroupDTO group = activity.getAttributeGroups().get(0);
group.setName("Foobar");
Map<String, Object> changes = new HashMap<String, Object>();
changes.put("name", group.getName());
execute(new UpdateEntity(group, changes));
// reload data
activity = execute(new GetActivityForm(1));
// verify the property has been duly changed
assertThat(activity.getAttributeGroups().get(0).getName(), equalTo(group.getName()));
}
use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.
the class DeleteTest method testDeleteIndicator.
@Test
public void testDeleteIndicator() throws CommandException {
int activityId = 1;
int indicatorId = 1;
execute(new Delete("Indicator", indicatorId));
ActivityFormDTO form = execute(new GetActivityForm(activityId));
assertNull(form.getIndicatorById(indicatorId));
PagingResult<SiteDTO> sites = execute(GetSites.byId(1));
assertNull(sites.getData().get(0).getIndicatorValue(1));
}
use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.
the class LocalGetSchemaHandlerIntTest method forUser.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void forUser() throws CommandException {
// only has view access to databse 1
setUser(4);
synchronize();
SchemaDTO schema = executeLocally(new GetSchema());
assertThat(schema.getDatabases().size(), equalTo(2));
UserDatabaseDTO pearDb = schema.getDatabaseById(1);
assertThat(pearDb.getAmOwner(), equalTo(false));
assertThat(pearDb.isViewAllAllowed(), equalTo(false));
assertThat(pearDb.isEditAllowed(), equalTo(false));
assertThat(pearDb.isEditAllAllowed(), equalTo(true));
ActivityFormDTO activity = executeLocally(new GetActivityForm(1));
assertThat(activity.getAttributeGroups().size(), equalTo(3));
AttributeGroupDTO group = activity.getAttributeGroupById(1);
assertThat(group.getName(), equalTo("cause"));
assertThat(group.getAttributes().size(), equalTo(2));
}
Aggregations