Search in sources :

Example 1 with ActivityFormDTO

use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.

the class DetailTab method setSite.

public void setSite(final SiteDTO site) {
    content.setText(I18N.CONSTANTS.loading());
    dispatcher.execute(new GetActivityForm(site.getActivityId()), new AsyncCallback<ActivityFormDTO>() {

        @Override
        public void onFailure(Throwable caught) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onSuccess(ActivityFormDTO result) {
            render(result, site);
        }
    });
}
Also used : ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm)

Example 2 with ActivityFormDTO

use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.

the class DefaultColumnModelProvider method fetchColumnModels.

@Override
public void fetchColumnModels(final Filter filter, final GroupingModel grouping, final AsyncCallback<ColumnModel> callback) {
    if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
        final int activityId = filter.getRestrictedCategory(DimensionType.Activity);
        dispatcher.execute(new GetActivityForm(activityId)).then(new AsyncCallback<ActivityFormDTO>() {

            @Override
            public void onFailure(Throwable caught) {
                callback.onFailure(caught);
            }

            @Override
            public void onSuccess(ActivityFormDTO activity) {
                dispatcher.execute(new GetSchema()).then(new AsyncCallback<SchemaDTO>() {

                    @Override
                    public void onFailure(Throwable caught) {
                        callback.onFailure(caught);
                    }

                    @Override
                    public void onSuccess(SchemaDTO schema) {
                        callback.onSuccess(forSingleActivity(grouping, schema.getDatabaseById(activity.getDatabaseId()), activity));
                    }
                });
            }
        });
    } else {
        dispatcher.execute(new GetSchema()).then(new AsyncCallback<SchemaDTO>() {

            @Override
            public void onFailure(Throwable caught) {
                callback.onFailure(caught);
            }

            @Override
            public void onSuccess(SchemaDTO result) {
                if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Database)) {
                    UserDatabaseDTO singleDatabase = result.getDatabaseById(filter.getRestrictedCategory(DimensionType.Database));
                    callback.onSuccess(forSingleDatabase(grouping, singleDatabase));
                } else {
                    callback.onSuccess(forMultipleDatabases(grouping, result));
                }
            }
        });
    }
}
Also used : ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO)

Example 3 with ActivityFormDTO

use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.

the class AttributeGroupTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    // change the name of an entity group
    ActivityFormDTO activity = execute(new GetActivityForm(1));
    AttributeGroupDTO group = activity.getAttributeGroups().get(0);
    group.setName("Foobar");
    Map<String, Object> changes = new HashMap<String, Object>();
    changes.put("name", group.getName());
    execute(new UpdateEntity(group, changes));
    // reload data
    activity = execute(new GetActivityForm(1));
    // verify the property has been duly changed
    assertThat(activity.getAttributeGroups().get(0).getName(), equalTo(group.getName()));
}
Also used : AttributeGroupDTO(org.activityinfo.legacy.shared.model.AttributeGroupDTO) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) UpdateEntity(org.activityinfo.legacy.shared.command.UpdateEntity) HashMap(java.util.HashMap) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Example 4 with ActivityFormDTO

use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteIndicator.

@Test
public void testDeleteIndicator() throws CommandException {
    int activityId = 1;
    int indicatorId = 1;
    execute(new Delete("Indicator", indicatorId));
    ActivityFormDTO form = execute(new GetActivityForm(activityId));
    assertNull(form.getIndicatorById(indicatorId));
    PagingResult<SiteDTO> sites = execute(GetSites.byId(1));
    assertNull(sites.getData().get(0).getIndicatorValue(1));
}
Also used : Delete(org.activityinfo.legacy.shared.command.Delete) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Example 5 with ActivityFormDTO

use of org.activityinfo.legacy.shared.model.ActivityFormDTO in project activityinfo by bedatadriven.

the class LocalGetSchemaHandlerIntTest method forUser.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void forUser() throws CommandException {
    // only has view access to databse 1
    setUser(4);
    synchronize();
    SchemaDTO schema = executeLocally(new GetSchema());
    assertThat(schema.getDatabases().size(), equalTo(2));
    UserDatabaseDTO pearDb = schema.getDatabaseById(1);
    assertThat(pearDb.getAmOwner(), equalTo(false));
    assertThat(pearDb.isViewAllAllowed(), equalTo(false));
    assertThat(pearDb.isEditAllowed(), equalTo(false));
    assertThat(pearDb.isEditAllAllowed(), equalTo(true));
    ActivityFormDTO activity = executeLocally(new GetActivityForm(1));
    assertThat(activity.getAttributeGroups().size(), equalTo(3));
    AttributeGroupDTO group = activity.getAttributeGroupById(1);
    assertThat(group.getName(), equalTo("cause"));
    assertThat(group.getAttributes().size(), equalTo(2));
}
Also used : AttributeGroupDTO(org.activityinfo.legacy.shared.model.AttributeGroupDTO) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)14 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)10 Test (org.junit.Test)9 AttributeGroupDTO (org.activityinfo.legacy.shared.model.AttributeGroupDTO)5 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)4 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)4 Delete (org.activityinfo.legacy.shared.command.Delete)3 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 HashMap (java.util.HashMap)2 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)2 ActivityFormResults (org.activityinfo.legacy.shared.command.result.ActivityFormResults)2 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)1 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)1 Function (com.google.common.base.Function)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 StreamResult (javax.xml.transform.stream.StreamResult)1