use of org.activityinfo.server.database.hibernate.entity.AttributeGroup 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.AttributeGroup 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.AttributeGroup 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.AttributeGroup 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());
}
use of org.activityinfo.server.database.hibernate.entity.AttributeGroup in project activityinfo by bedatadriven.
the class UpdateEntityHandler method updateAttribute.
private void updateAttribute(User user, UpdateEntity cmd, Map<String, Object> changes) {
Attribute attribute = entityManager().find(Attribute.class, cmd.getId());
// TODO: decide where attributes belong and how to manage them
// assertDesignPriviledges(user, attribute.get);
updateAttributeProperties(changes, attribute);
AttributeGroup ag = entityManager().find(AttributeGroup.class, attribute.getGroup().getId());
// Assume only
Activity activity = ag.getActivities().iterator().next();
// one
// activity
// for the
// attr group
activity.getDatabase().setLastSchemaUpdate(new Date());
}
Aggregations