Search in sources :

Example 26 with SchemaDTO

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

the class ProjectTest method constraintViolation.

@Test(expected = Exception.class)
public void constraintViolation() {
    setUser(1);
    SchemaDTO schema = execute(new GetSchema());
    ProjectDTO project = schema.getProjectById(2);
    project.setName(null);
    execute(RequestChange.update(project, "name"));
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) Test(org.junit.Test)

Example 27 with SchemaDTO

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

the class ProjectTest method updateProject.

@Test
public void updateProject() {
    setUser(1);
    SchemaDTO schema = execute(new GetSchema());
    ProjectDTO project = schema.getProjectById(2);
    project.setName("RRMP II");
    project.setDescription("RRMP The Next Generation");
    execute(RequestChange.update(project, "name", "description"));
    schema = execute(new GetSchema());
    assertThat(schema.getProjectById(2).getName(), equalTo("RRMP II"));
    assertThat(schema.getProjectById(2).getDescription(), equalTo("RRMP The Next Generation"));
    project.setName("RRMP III");
    project.setDescription(null);
    execute(RequestChange.update(project, "name", "description"));
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) Test(org.junit.Test)

Example 28 with SchemaDTO

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

the class ProjectTest method deleteProject.

@Test
public void deleteProject() {
    setUser(1);
    long originalDatabaseVersion = lookupDbVersion(1);
    int projectId = 2;
    execute(RequestChange.delete("Project", projectId));
    SchemaDTO schema = execute(new GetSchema());
    assertThat(schema.getProjectById(projectId), nullValue());
    // make sure it's gone from sites
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Activity, 1);
    filter.addRestriction(DimensionType.Site, 3);
    SiteResult sites = execute(new GetSites(filter));
    assertThat(sites.getData().get(0).getProject(), is(nullValue()));
    // and doesn't show up in pivoting...
    PivotSites pivot = new PivotSites();
    Dimension projectDimension = new Dimension(DimensionType.Project);
    pivot.setDimensions(projectDimension);
    pivot.setFilter(filter);
    PivotResult buckets = execute(pivot);
    assertThat(buckets.getBuckets().size(), equalTo(1));
    assertThat(buckets.getBuckets().get(0).getCategory(projectDimension), is(nullValue()));
    // make sure the version number of the database is updated
    assertThat(lookupDbVersion(1), not(equalTo(originalDatabaseVersion)));
}
Also used : SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) PivotResult(org.activityinfo.legacy.shared.command.PivotSites.PivotResult) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) Test(org.junit.Test)

Example 29 with SchemaDTO

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

the class SiteGridPanel method updateHeading.

private void updateHeading(final Filter filter) {
    setHeadingText(I18N.CONSTANTS.sitesHeader());
    dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

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

        @Override
        public void onSuccess(SchemaDTO result) {
            if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
                int activityId = filter.getRestrictedCategory(DimensionType.Activity);
                ActivityDTO activity = result.getActivityById(activityId);
                setHeadingText(activity.getDatabaseName() + " - " + activity.getName());
            } else if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Database)) {
                int databaseId = filter.getRestrictedCategory(DimensionType.Database);
                UserDatabaseDTO db = result.getDatabaseById(databaseId);
                setHeadingText(db.getName());
            }
        }
    });
}
Also used : UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) ActivityDTO(org.activityinfo.legacy.shared.model.ActivityDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO)

Aggregations

SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)29 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)22 Test (org.junit.Test)19 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)9 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)7 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)4 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)4 OnDataSet (org.activityinfo.server.database.OnDataSet)4 CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)3 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)3 ActivityDTO (org.activityinfo.legacy.shared.model.ActivityDTO)3 Function (com.google.common.base.Function)2 Delete (org.activityinfo.legacy.shared.command.Delete)2 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)2 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)2 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)2 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)2 User (org.activityinfo.server.database.hibernate.entity.User)2 CacheResult (org.activityinfo.ui.client.dispatch.remote.cache.CacheResult)2 Before (org.junit.Before)2