Search in sources :

Example 1 with Activity

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

the class CreateEntityHandler method createIndicator.

private CommandResult createIndicator(User user, CreateEntity cmd, Map<String, Object> properties) throws IllegalAccessCommandException {
    Indicator indicator = new Indicator();
    Activity activity = entityManager().getReference(Activity.class, properties.get("activityId"));
    indicator.setActivity(activity);
    assertDesignPriviledges(user, indicator.getActivity().getDatabase());
    updateIndicatorProperties(indicator, properties);
    entityManager().persist(indicator);
    activity.getDatabase().setLastSchemaUpdate(new Date());
    return new CreateResult(indicator.getId());
}
Also used : CreateResult(org.activityinfo.shared.command.result.CreateResult) Activity(org.activityinfo.server.database.hibernate.entity.Activity) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator) Date(java.util.Date)

Example 2 with Activity

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

the class UpdateEntityHandler method updateAttributeGroup.

private void updateAttributeGroup(UpdateEntity cmd, Map<String, Object> changes) {
    AttributeGroup group = entityManager().find(AttributeGroup.class, cmd.getId());
    updateAttributeGroupProperties(group, changes);
    // Assume
    Activity activity = group.getActivities().iterator().next();
    // only one
    // activity
    // for the
    // attr
    // group
    activity.getDatabase().setLastSchemaUpdate(new Date());
}
Also used : AttributeGroup(org.activityinfo.server.database.hibernate.entity.AttributeGroup) Activity(org.activityinfo.server.database.hibernate.entity.Activity) Date(java.util.Date)

Example 3 with Activity

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

the class SchemaUpdateBuilder method createAndSyncAttributeGroupInActivity.

private void createAndSyncAttributeGroupInActivity(JpaUpdateBuilder builder) throws JSONException {
    builder.executeStatement("create table if not exists AttributeGroupInActivity (ActivityId integer, AttributeGroupId integer)");
    builder.executeStatement("delete from AttributeGroupInActivity");
    if (anyAttributes()) {
        builder.beginPreparedStatement("insert into AttributeGroupInActivity (ActivityId, AttributeGroupId) values (?,?)");
        for (UserDatabase db : databases) {
            for (Activity activity : db.getActivities()) {
                for (AttributeGroup group : activity.getAttributeGroups()) {
                    builder.addExecution(activity.getId(), group.getId());
                }
            }
        }
        builder.finishPreparedStatement();
    }
}
Also used : UserDatabase(org.activityinfo.server.database.hibernate.entity.UserDatabase) AttributeGroup(org.activityinfo.server.database.hibernate.entity.AttributeGroup) Activity(org.activityinfo.server.database.hibernate.entity.Activity)

Example 4 with Activity

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

the class CreateEntityHandler method createAttributeGroup.

private CommandResult createAttributeGroup(CreateEntity cmd, Map<String, Object> properties) {
    AttributeGroup group = new AttributeGroup();
    updateAttributeGroupProperties(group, properties);
    entityManager().persist(group);
    Activity activity = entityManager().find(Activity.class, properties.get("activityId"));
    activity.getAttributeGroups().add(group);
    activity.getDatabase().setLastSchemaUpdate(new Date());
    return new CreateResult(group.getId());
}
Also used : CreateResult(org.activityinfo.shared.command.result.CreateResult) AttributeGroup(org.activityinfo.server.database.hibernate.entity.AttributeGroup) Activity(org.activityinfo.server.database.hibernate.entity.Activity) Date(java.util.Date)

Example 5 with Activity

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

the class CreateEntityHandler method createAttribute.

private CommandResult createAttribute(CreateEntity cmd, Map<String, Object> properties) {
    Attribute attribute = new Attribute();
    AttributeGroup ag = entityManager().getReference(AttributeGroup.class, properties.get("attributeGroupId"));
    attribute.setGroup(ag);
    updateAttributeProperties(properties, attribute);
    // Assume
    Activity activity = ag.getActivities().iterator().next();
    // group has
    // only one
    // activity
    entityManager().persist(attribute);
    activity.getDatabase().setLastSchemaUpdate(new Date());
    return new CreateResult(attribute.getId());
}
Also used : CreateResult(org.activityinfo.shared.command.result.CreateResult) Attribute(org.activityinfo.server.database.hibernate.entity.Attribute) AttributeGroup(org.activityinfo.server.database.hibernate.entity.AttributeGroup) Activity(org.activityinfo.server.database.hibernate.entity.Activity) Date(java.util.Date)

Aggregations

Activity (org.activityinfo.server.database.hibernate.entity.Activity)10 Date (java.util.Date)6 AttributeGroup (org.activityinfo.server.database.hibernate.entity.AttributeGroup)6 UserDatabase (org.activityinfo.server.database.hibernate.entity.UserDatabase)4 CreateResult (org.activityinfo.shared.command.result.CreateResult)4 Attribute (org.activityinfo.server.database.hibernate.entity.Attribute)3 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)2 Project (org.activityinfo.server.database.hibernate.entity.Project)2 IndicatorLinkEntity (org.activityinfo.server.database.hibernate.entity.IndicatorLinkEntity)1 LocationType (org.activityinfo.server.database.hibernate.entity.LocationType)1 LockedPeriod (org.activityinfo.server.database.hibernate.entity.LockedPeriod)1 Partner (org.activityinfo.server.database.hibernate.entity.Partner)1 User (org.activityinfo.server.database.hibernate.entity.User)1 CreateLockedPeriod (org.activityinfo.shared.command.CreateLockedPeriod)1 LockedPeriodDTO (org.activityinfo.shared.dto.LockedPeriodDTO)1 CommandException (org.activityinfo.shared.exception.CommandException)1