use of org.activityinfo.shared.dto.UserDatabaseDTO 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);
synchronizeFirstTime();
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));
ActivityDTO activity = schema.getActivityById(1);
assertThat(activity.getAttributeGroups().size(), equalTo(3));
AttributeGroupDTO group = activity.getAttributeGroupById(1);
assertThat(group.getName(), equalTo("cause"));
assertThat(group.getAttributes().size(), equalTo(2));
}
use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class DatabaseGridPanel method createColumnModel.
private ColumnModel createColumnModel() {
ColumnConfig icon = new ColumnConfig("icon", 28);
icon.setSortable(false);
icon.setMenuDisabled(true);
icon.setRenderer(new GridCellRenderer<UserDatabaseDTO>() {
@Override
public Object render(UserDatabaseDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<UserDatabaseDTO> store, Grid<UserDatabaseDTO> grid) {
return linked.contains(model.getId()) ? IconImageBundle.ICONS.link().getHTML() : "";
}
});
ColumnConfig name = new ColumnConfig("name", I18N.CONSTANTS.database(), 150);
name.setSortable(false);
name.setMenuDisabled(true);
name.setRenderer(new GridCellRenderer<UserDatabaseDTO>() {
@Override
public Object render(UserDatabaseDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<UserDatabaseDTO> store, Grid<UserDatabaseDTO> grid) {
if (hasPermission(model)) {
return model.getName();
} else {
StringBuilder html = new StringBuilder();
html.append("<span style=\"color: gray\">").append(model.getName()).append("</span>");
return html.toString();
}
}
});
return new ColumnModel(Arrays.asList(icon, name));
}
use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class SiteGridPanel method updateHeading.
private void updateHeading(final Filter filter) {
setHeading(I18N.CONSTANTS.sitesHeader());
dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(SchemaDTO result) {
if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
int activityId = filter.getRestrictedCategory(DimensionType.Activity);
ActivityDTO activity = result.getActivityById(activityId);
setHeading(activity.getDatabase().getName() + " - " + activity.getName());
} else if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Database)) {
int databaseId = filter.getRestrictedCategory(DimensionType.Database);
UserDatabaseDTO db = result.getDatabaseById(databaseId);
setHeading(db.getName());
}
}
});
}
use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class DefaultColumnModelProvider method fetchColumnModels.
@Override
public void fetchColumnModels(final Filter filter, final GroupingModel grouping, final AsyncCallback<ColumnModel> callback) {
dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(SchemaDTO result) {
if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
ActivityDTO singleActivity = result.getActivityById(filter.getRestrictedCategory(DimensionType.Activity));
callback.onSuccess(forSingleActivity(grouping, singleActivity));
} else 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.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class ClusteringOptionsWidget method countriesForLayer.
private Set<CountryDTO> countriesForLayer(SchemaDTO schema, MapLayer layer) {
Set<Integer> indicatorIds = Sets.newHashSet(layer.getIndicatorIds());
Set<CountryDTO> countries = Sets.newHashSet();
for (UserDatabaseDTO database : schema.getDatabases()) {
if (databaseContainsIndicatorId(database, indicatorIds)) {
countries.add(database.getCountry());
}
}
return countries;
}
Aggregations