Search in sources :

Example 11 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class SchemaImporterV2Test method syria.

@Test
public void syria() throws IOException {
    UserDatabaseDTO syria = doImport("schema_1064.csv");
    int activityId = syria.getActivities().get(0).getId();
    ActivityFormDTO cash = execute(new GetActivityForm(activityId));
    for (AttributeGroupDTO group : cash.getAttributeGroups()) {
        System.out.println(group.getName());
    }
    assertThat(cash.getName(), equalTo("1.Provision of urgent cash assistance"));
    assertThat(cash.getAttributeGroups().size(), equalTo(3));
    SchemaCsvWriter writer = new SchemaCsvWriter(getDispatcherSync());
    writer.write(syria.getId());
    Files.write(writer.toString(), TestOutput.getFile(getClass(), "syria", ".csv"), Charsets.UTF_8);
}
Also used : AttributeGroupDTO(org.activityinfo.legacy.shared.model.AttributeGroupDTO) SchemaCsvWriter(org.activityinfo.server.endpoint.rest.SchemaCsvWriter) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Example 12 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class AttributeGroupTest method testCreate.

@Test
public void testCreate() throws Exception {
    // execute the command
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("name", "Type de Conflit");
    properties.put("multipleAllowed", true);
    properties.put("activityId", 1);
    CreateEntity cmd = new CreateEntity("AttributeGroup", properties);
    CreateResult result = execute(cmd);
    // check if it has been added
    ActivityFormDTO activity = execute(new GetActivityForm(1));
    AttributeGroupDTO group = activity.getAttributeGroupById(result.getNewId());
    Assert.assertNotNull("attribute group is created", group);
    Assert.assertEquals("name is correct", group.getName(), "Type de Conflit");
    Assert.assertTrue("multiple allowed is set to true", group.isMultipleAllowed());
}
Also used : CreateEntity(org.activityinfo.legacy.shared.command.CreateEntity) AttributeGroupDTO(org.activityinfo.legacy.shared.model.AttributeGroupDTO) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) HashMap(java.util.HashMap) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Example 13 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class CloneDatabaseTest method assertFormClassesCloned.

private void assertFormClassesCloned(UserDatabaseDTO sourceDb, UserDatabaseDTO targetDb) {
    assertEquals(sourceDb.getActivities().size(), targetDb.getActivities().size());
    for (ActivityDTO activityDTO : sourceDb.getActivities()) {
        ActivityFormDTO sourceActivity = execute(new GetActivityForm(activityDTO.getId()));
        ActivityFormDTO targetActivity = execute(new GetActivityForm(entityByName(targetDb.getActivities(), sourceActivity.getName()).getId()));
        // legacy level
        assertActivityClone(sourceActivity, targetActivity);
        // form class level
        FormClass sourceFormClass = assertResolves(locator.getFormClass(sourceActivity.getResourceId()));
        FormClass targetFormClass = assertResolves(locator.getFormClass(targetActivity.getResourceId()));
        assertFormClass(sourceFormClass, targetFormClass);
    }
}
Also used : FormClass(org.activityinfo.model.form.FormClass) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm)

Example 14 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteActivity.

@Test
public void testDeleteActivity() throws CommandException {
    ActivityFormDTO form = execute(new GetActivityForm(1));
    execute(new Delete(form));
    execute(new Delete("Activity", 4));
    SchemaDTO schema = execute(new GetSchema());
    assertNull("delete by entity reference", schema.getActivityById(1));
    assertNull("delete by id", schema.getActivityById(4));
}
Also used : Delete(org.activityinfo.legacy.shared.command.Delete) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Example 15 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteAttribute.

@Test
public void testDeleteAttribute() throws CommandException {
    ActivityFormDTO form = execute(new GetActivityForm(1));
    execute(new Delete(form.getAttributeById(1)));
    form = execute(new GetActivityForm(1));
    assertNull(form.getAttributeById(1));
}
Also used : Delete(org.activityinfo.legacy.shared.command.Delete) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Aggregations

GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)16 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)10 Test (org.junit.Test)8 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)6 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)3 Delete (org.activityinfo.legacy.shared.command.Delete)3 AttributeGroupDTO (org.activityinfo.legacy.shared.model.AttributeGroupDTO)3 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)3 HashMap (java.util.HashMap)2 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)2 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 StreamResult (javax.xml.transform.stream.StreamResult)1 CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)1 Filter (org.activityinfo.legacy.shared.command.Filter)1 UpdateEntity (org.activityinfo.legacy.shared.command.UpdateEntity)1 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)1 ActivityDTO (org.activityinfo.legacy.shared.model.ActivityDTO)1