use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class ConfigNavigator method loadDbList.
private void loadDbList(final AsyncCallback<List<Link>> callback, SchemaDTO result) {
List<Link> list = new ArrayList<Link>();
for (UserDatabaseDTO db : result.getDatabases()) {
if (db.isDesignAllowed() || db.isManageUsersAllowed()) {
Link link = Link.to(new DbPageState(DbConfigPresenter.PAGE_ID, db.getId())).labeled(db.getName()).withIcon(icons.database()).build();
link.set("db", db);
list.add(link);
}
}
callback.onSuccess(list);
}
use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class DbListPresenter method onAdd.
public void onAdd() {
final UserDatabaseDTO db = new UserDatabaseDTO();
DatabaseForm form = new DatabaseForm(dispatcher);
form.getBinding().bind(db);
final FormDialogImpl dialog = new FormDialogImpl(form);
dialog.setWidth(400);
dialog.setHeight(200);
dialog.setHeading(I18N.CONSTANTS.newDatabase());
dialog.show(new FormDialogCallback() {
@Override
public void onValidated() {
save(db, dialog);
}
});
}
use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class LockedPeriodsPresenter method onCreate.
@Override
public void onCreate(CreateEvent event) {
view.getCreatingMonitor().beforeRequest();
final LockedPeriodDTO lockedPeriod = view.getValue();
CreateLockedPeriod lockUserDatabase = new CreateLockedPeriod(lockedPeriod);
if (lockedPeriod.getParent() instanceof ActivityDTO) {
lockUserDatabase.setActivityId(lockedPeriod.getParent().getId());
}
if (lockedPeriod.getParent() instanceof ProjectDTO) {
lockUserDatabase.setProjectId(lockedPeriod.getParent().getId());
}
if (lockedPeriod.getParent() instanceof UserDatabaseDTO) {
lockUserDatabase.setUserDatabaseId(lockedPeriod.getParent().getId());
}
service.execute(lockUserDatabase, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
view.getCreatingMonitor().onServerError();
MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer() + "\n\n" + caught.getMessage(), null);
}
@Override
public void onSuccess(CreateResult result) {
// Update the Id for the child instance
lockedPeriod.setId(result.getNewId());
// Tell the view there's a new kid on the block
view.create(lockedPeriod);
// Actually add the lock to it's parent
lockedPeriod.getParent().getLockedPeriods().add(lockedPeriod);
}
});
}
use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class ShareReportDialog method populateGrid.
private void populateGrid(SchemaDTO schema, ReportVisibilityResult visibility) {
gridStore.removeAll();
Set<Integer> indicators = currentReport.getIndicators();
Map<Integer, ReportVisibilityDTO> databases = Maps.newHashMap();
for (ReportVisibilityDTO model : visibility.getList()) {
databases.put(model.getDatabaseId(), model);
}
for (UserDatabaseDTO db : schema.getDatabases()) {
if (hasAny(db, indicators)) {
if (databases.containsKey(db.getId())) {
gridStore.add(databases.get(db.getId()));
} else {
ReportVisibilityDTO model = new ReportVisibilityDTO();
model.setDatabaseId(db.getId());
model.setDatabaseName(db.getName());
gridStore.add(model);
}
}
}
if (gridStore.getCount() == 0) {
MessageBox.alert(I18N.CONSTANTS.share(), "This report is still empty, so it can't yet be shared.", new Listener<MessageBoxEvent>() {
@Override
public void handleEvent(MessageBoxEvent be) {
hide();
}
});
}
}
use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class DimensionPruner method getSelectedActivities.
private Set<ActivityDTO> getSelectedActivities(SchemaDTO schema) {
Set<ActivityDTO> activities = Sets.newHashSet();
Set<Integer> indicatorIds = Sets.newHashSet(model.getFilter().getRestrictions(DimensionType.Indicator));
for (UserDatabaseDTO db : schema.getDatabases()) {
for (ActivityDTO activity : db.getActivities()) {
for (IndicatorDTO indicator : activity.getIndicators()) {
if (indicatorIds.contains(indicator.getId())) {
activities.add(activity);
}
}
}
}
return activities;
}
Aggregations