Search in sources :

Example 6 with LocationType

use of org.activityinfo.server.database.hibernate.entity.LocationType in project activityinfo by bedatadriven.

the class LocationTypePolicy method create.

@Override
public Integer create(User user, PropertyMap properties) {
    int databaseId = properties.get(DATABASE_ID_PROPERTY);
    Database database = em.find(Database.class, databaseId);
    PermissionOracle.using(em).assertDesignPrivileges(database, user);
    // create the entity
    LocationType locationType = new LocationType();
    locationType.setVersion(1L);
    locationType.setName(properties.get(NAME_PROPERTY));
    locationType.setCountry(database.getCountry());
    locationType.setWorkflowId(properties.getOptionalString(WORKFLOW_ID_PROPERTY, LocationTypeDTO.CLOSED_WORKFLOW_ID));
    locationType.setDatabase(database);
    em.persist(locationType);
    return locationType.getId();
}
Also used : Database(org.activityinfo.server.database.hibernate.entity.Database) LocationType(org.activityinfo.server.database.hibernate.entity.LocationType)

Example 7 with LocationType

use of org.activityinfo.server.database.hibernate.entity.LocationType in project activityinfo by bedatadriven.

the class LocationTypePolicy method update.

@Override
public void update(User user, Object entityId, PropertyMap changes) {
    LocationType locationType = em.find(LocationType.class, entityId);
    PermissionOracle.using(em).assertDesignPrivileges(locationType.getDatabase(), user);
    applyProperties(locationType, changes);
    locationType.incrementVersion();
}
Also used : LocationType(org.activityinfo.server.database.hibernate.entity.LocationType)

Aggregations

LocationType (org.activityinfo.server.database.hibernate.entity.LocationType)7 AdminEntity (org.activityinfo.server.database.hibernate.entity.AdminEntity)4 Location (org.activityinfo.server.database.hibernate.entity.Location)3 AdminLevel (org.activityinfo.server.database.hibernate.entity.AdminLevel)2 NewAdminEntity (org.activityinfo.server.endpoint.rest.model.NewAdminEntity)2 NewAdminLevel (org.activityinfo.server.endpoint.rest.model.NewAdminLevel)2 Timed (org.activityinfo.server.util.monitoring.Timed)2 Date (java.util.Date)1 EntityManager (javax.persistence.EntityManager)1 CreateLocation (org.activityinfo.legacy.shared.command.CreateLocation)1 CommandException (org.activityinfo.legacy.shared.exception.CommandException)1 KeyGenerator (org.activityinfo.model.legacy.KeyGenerator)1 PropertyMap (org.activityinfo.server.command.handler.crud.PropertyMap)1 Database (org.activityinfo.server.database.hibernate.entity.Database)1 NewLocation (org.activityinfo.server.endpoint.rest.model.NewLocation)1