use of org.activityinfo.server.database.hibernate.entity.Database in project activityinfo by bedatadriven.
the class UpdatePartnerHandler method execute.
@Override
@SuppressWarnings("unchecked")
public CommandResult execute(UpdatePartner cmd, User user) {
Database db = em.find(Database.class, cmd.getDatabaseId());
PermissionOracle.using(em).assertManagePartnerAllowed(db, user);
// Does this partner already exist?
if (cmd.getPartner().hasId()) {
return updatePartner(db, cmd);
} else {
return addNewPartner(cmd, db);
}
}
use of org.activityinfo.server.database.hibernate.entity.Database in project activityinfo by bedatadriven.
the class GeoDigestModelBuilder method createModel.
@Override
public GeoDigestModel createModel(UserDigest userDigest) throws IOException {
GeoDigestModel model = new GeoDigestModel(userDigest);
List<Database> databases = findDatabases(userDigest.getUser());
LOGGER.finest("found " + databases.size() + " database(s) for user " + userDigest.getUser().getId());
if (!databases.isEmpty()) {
model.setSchemaDTO(dispatcher.execute(new GetSchema()));
for (Database database : databases) {
createDatabaseModel(model, database);
}
}
return model;
}
use of org.activityinfo.server.database.hibernate.entity.Database in project activityinfo by bedatadriven.
the class ActivityDigestModelBuilder method createModel.
@Override
public ActivityDigestModel createModel(UserDigest userDigest) throws IOException {
ActivityDigestModel model = new ActivityDigestModel(userDigest);
List<Database> databases = findDatabases(userDigest.getUser());
LOGGER.finest("found " + databases.size() + " database(s) for user " + userDigest.getUser().getId());
if (!databases.isEmpty()) {
for (Database database : databases) {
createDatabaseModel(model, database);
}
}
return model;
}
use of org.activityinfo.server.database.hibernate.entity.Database in project activityinfo by bedatadriven.
the class GeoDigestModelBuilderTest method testFindDatabasesViewAndNotification.
@Test
public void testFindDatabasesViewAndNotification() throws Exception {
// view & notification
User user = em.find(User.class, 3);
List<Database> dbs = geoDigestModelBuilder.findDatabases(user);
assertThat(dbs.size(), is(equalTo(1)));
assertTrue(dbs.contains(em.find(Database.class, 1)));
}
Aggregations