Search in sources :

Example 1 with EntityDTO

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);
}
Also used : AttributeDTO(org.activityinfo.shared.dto.AttributeDTO) EntityDTO(org.activityinfo.shared.dto.EntityDTO) ModelData(com.extjs.gxt.ui.client.data.ModelData) AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 2 with EntityDTO

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);
    }
}
Also used : EntityDTO(org.activityinfo.shared.dto.EntityDTO) ModelData(com.extjs.gxt.ui.client.data.ModelData) UpdateTargetValue(org.activityinfo.shared.command.UpdateTargetValue) Record(com.extjs.gxt.ui.client.store.Record)

Aggregations

ModelData (com.extjs.gxt.ui.client.data.ModelData)2 EntityDTO (org.activityinfo.shared.dto.EntityDTO)2 Record (com.extjs.gxt.ui.client.store.Record)1 UpdateTargetValue (org.activityinfo.shared.command.UpdateTargetValue)1 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)1 AttributeDTO (org.activityinfo.shared.dto.AttributeDTO)1 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)1 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1