use of org.activityinfo.shared.dto.EntityDTO in project activityinfo by bedatadriven.
the class DesignPresenter method onNew.
public void onNew(String entityName) {
final EntityDTO newEntity;
ModelData parent;
ModelData selected = view.getSelection();
if ("Activity".equals(entityName)) {
newEntity = new ActivityDTO(db);
newEntity.set("databaseId", db.getId());
parent = null;
} else if ("AttributeGroup".equals(entityName)) {
ActivityDTO activity = findActivityFolder(selected);
newEntity = new AttributeGroupDTO();
newEntity.set("activityId", activity.getId());
parent = treeStore.getChild(activity, 0);
} else if ("Attribute".equals(entityName)) {
AttributeGroupDTO group = findAttributeGroupNode(selected);
newEntity = new AttributeDTO();
newEntity.set("attributeGroupId", group.getId());
parent = group;
} else if ("Indicator".equals(entityName)) {
ActivityDTO activity = findActivityFolder(selected);
IndicatorDTO newIndicator = new IndicatorDTO();
newIndicator.setAggregation(IndicatorDTO.AGGREGATE_SUM);
newEntity = newIndicator;
newEntity.set("activityId", activity.getId());
parent = treeStore.getChild(activity, 1);
} else {
// TODO log error
return;
}
createEntity(parent, newEntity);
}
use of org.activityinfo.shared.dto.EntityDTO in project activityinfo by bedatadriven.
the class TargetIndicatorPresenter method prepareBatch.
protected void prepareBatch(BatchCommand batch, ModelData model) {
if (model instanceof EntityDTO) {
Record record = treeStore.getRecord(model);
if (record.isDirty()) {
UpdateTargetValue cmd = new UpdateTargetValue((Integer) model.get("targetId"), (Integer) model.get("indicatorId"), this.getChangedProperties(record));
batch.add(cmd);
}
}
for (ModelData child : treeStore.getChildren(model)) {
prepareBatch(batch, child);
}
}
Aggregations