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());
}
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());
}
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();
}
}
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());
}
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());
}
Aggregations