Search in sources :

Example 16 with Database

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);
    }
}
Also used : Database(org.activityinfo.server.database.hibernate.entity.Database)

Example 17 with Database

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;
}
Also used : Database(org.activityinfo.server.database.hibernate.entity.Database) GetSchema(org.activityinfo.legacy.shared.command.GetSchema)

Example 18 with Database

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;
}
Also used : Database(org.activityinfo.server.database.hibernate.entity.Database)

Example 19 with Database

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)));
}
Also used : User(org.activityinfo.server.database.hibernate.entity.User) Database(org.activityinfo.server.database.hibernate.entity.Database) Test(org.junit.Test)

Aggregations

Database (org.activityinfo.server.database.hibernate.entity.Database)19 User (org.activityinfo.server.database.hibernate.entity.User)6 UserPermission (org.activityinfo.server.database.hibernate.entity.UserPermission)5 Test (org.junit.Test)5 Date (java.util.Date)4 Partner (org.activityinfo.server.database.hibernate.entity.Partner)3 ArrayList (java.util.ArrayList)2 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)2 UserPermissionDTO (org.activityinfo.legacy.shared.model.UserPermissionDTO)2 HashMap (java.util.HashMap)1 AddProject (org.activityinfo.legacy.shared.command.AddProject)1 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)1 GetSyncRegions (org.activityinfo.legacy.shared.command.GetSyncRegions)1 RemovePartner (org.activityinfo.legacy.shared.command.RemovePartner)1 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)1 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)1 RemoveFailedResult (org.activityinfo.legacy.shared.command.result.RemoveFailedResult)1 RemoveResult (org.activityinfo.legacy.shared.command.result.RemoveResult)1 SyncRegion (org.activityinfo.legacy.shared.command.result.SyncRegion)1 SyncRegions (org.activityinfo.legacy.shared.command.result.SyncRegions)1