Search in sources :

Example 11 with SchemaDTO

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

the class SchemaCacheTest method testSchemaCache.

@Test
public void testSchemaCache() {
    CacheManager proxyMgr = new CacheManager(new MockEventBus());
    new SchemaCache(proxyMgr);
    SchemaDTO schema = DTOs.pear();
    proxyMgr.notifyListenersOfSuccess(new GetSchema(), schema);
    CacheResult<SchemaDTO> proxyResult = proxyMgr.execute(new GetSchema());
    Assert.assertTrue("could execute locally", proxyResult.isCouldExecute());
    Assert.assertEquals("PEAR", proxyResult.getResult().getDatabaseById(1).getName());
}
Also used : MockEventBus(org.activityinfo.ui.client.MockEventBus) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Example 12 with SchemaDTO

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

the class TargetTest method setUser.

@Before
public void setUser() {
    setUser(DATABASE_OWNER);
    SchemaDTO schema = execute(new GetSchema());
    db = schema.getDatabaseById(1);
}
Also used : SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) Before(org.junit.Before)

Example 13 with SchemaDTO

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

the class ExportIntegrationTest method fullTest.

@Test
public void fullTest() throws Throwable {
    User user = new User();
    user.setId(1);
    user.setName("Alex");
    SchemaDTO schema = execute(new GetSchema());
    TaskContext context = new TaskContext(getDispatcherSync(), new NullStorageProvider(), "XYZ");
    SiteExporter export = new SiteExporter(context);
    for (UserDatabaseDTO db : schema.getDatabases()) {
        for (ActivityDTO activity : db.getActivities()) {
            export.export(execute(new GetActivityForm(activity)), new Filter());
        }
    }
    File outputDir = new File("target/report-test/");
    outputDir.mkdirs();
    FileOutputStream fos = new FileOutputStream("target/report-test/ExportTest.xls");
    export.getBook().write(fos);
    fos.close();
}
Also used : SiteExporter(org.activityinfo.server.endpoint.export.SiteExporter) User(org.activityinfo.server.database.hibernate.entity.User) TaskContext(org.activityinfo.server.endpoint.export.TaskContext) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) Filter(org.activityinfo.legacy.shared.command.Filter) FileOutputStream(java.io.FileOutputStream) ActivityDTO(org.activityinfo.legacy.shared.model.ActivityDTO) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) File(java.io.File) NullStorageProvider(org.activityinfo.server.report.NullStorageProvider) Test(org.junit.Test)

Example 14 with SchemaDTO

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

the class LinkIndicatorTest method setUser.

@Before
public void setUser() {
    setUser(DATABASE_OWNER);
    /*
         * Initial data load
         */
    SchemaDTO schema = execute(new GetSchema());
    db = schema.getDatabaseById(1);
}
Also used : SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Before(org.junit.Before)

Example 15 with SchemaDTO

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

the class LockedPeriodTest method createForFolder.

@Test
public void createForFolder() {
    setUser(1);
    LockedPeriodDTO dto = new LockedPeriodDTO();
    dto.setName("NFI ");
    dto.setFromDate(new LocalDate(2011, 1, 1));
    dto.setToDate(new LocalDate(2011, 1, 31));
    dto.setEnabled(true);
    CreateLockedPeriod create = new CreateLockedPeriod(dto);
    create.setFolderId(1);
    execute(create);
    // Now verify that they appear
    SchemaDTO schema = execute(new GetSchema());
    assertThat(schema.getDatabaseById(1).getFolderById(1).getLockedPeriods(), Matchers.hasSize(1));
    LockedPeriodSet locks = new LockedPeriodSet(schema);
    assertTrue(locks.isActivityLocked(1, new LocalDate(2011, 1, 1)));
    // Verify that the new code works too...
    DatabaseProviderImpl provider = new DatabaseProviderImpl(Providers.of(em));
    UserDatabaseMeta metadata = provider.getDatabaseMetadata(CuidAdapter.databaseId(1), 1);
    ArrayList<RecordLock> folderLocks = Lists.newArrayList(metadata.getEffectiveLocks(CuidAdapter.folderId(1)));
    ArrayList<RecordLock> formLocks = Lists.newArrayList(metadata.getEffectiveLocks(CuidAdapter.activityFormClass(1)));
    assertThat(folderLocks, Matchers.hasSize(2));
    assertThat(formLocks, Matchers.hasSize(3));
}
Also used : DatabaseProviderImpl(org.activityinfo.server.endpoint.rest.DatabaseProviderImpl) RecordLock(org.activityinfo.model.database.RecordLock) LockedPeriodSet(org.activityinfo.legacy.shared.model.LockedPeriodSet) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) UserDatabaseMeta(org.activityinfo.model.database.UserDatabaseMeta) CreateLockedPeriod(org.activityinfo.legacy.shared.command.CreateLockedPeriod) LockedPeriodDTO(org.activityinfo.legacy.shared.model.LockedPeriodDTO) Test(org.junit.Test)

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