Search in sources :

Example 1 with LockedPeriodSet

use of org.activityinfo.client.page.entry.LockedPeriodSet in project activityinfo by bedatadriven.

the class GetSchemaTest method testLockedProjects.

@Test
public void testLockedProjects() {
    setUser(1);
    SchemaDTO schema = execute(new GetSchema());
    assertThat(schema.getProjectById(1).getLockedPeriods().size(), equalTo(1));
    LockedPeriodSet locks = new LockedPeriodSet(schema);
    assertTrue(locks.isProjectLocked(1, new LocalDate(2009, 1, 1)));
    assertTrue(locks.isProjectLocked(1, new LocalDate(2009, 1, 6)));
    assertTrue(locks.isProjectLocked(1, new LocalDate(2009, 1, 12)));
    assertFalse(locks.isProjectLocked(1, new LocalDate(2008, 1, 12)));
    assertFalse(locks.isProjectLocked(1, new LocalDate(2010, 1, 12)));
}
Also used : LockedPeriodSet(org.activityinfo.client.page.entry.LockedPeriodSet) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate) Test(org.junit.Test)

Example 2 with LockedPeriodSet

use of org.activityinfo.client.page.entry.LockedPeriodSet in project activityinfo by bedatadriven.

the class LockedPeriodTest method rangeTest.

@Test
public void rangeTest() {
    UserDatabaseDTO db = new UserDatabaseDTO();
    LockedPeriodDTO lockedPeriod = new LockedPeriodDTO();
    lockedPeriod.setFromDate(new LocalDate(2000, 1, 1));
    lockedPeriod.setToDate(new LocalDate(2000, 1, 2));
    lockedPeriod.setEnabled(true);
    SiteDTO site = new SiteDTO(1);
    site.setDate1(new LocalDate(2000, 1, 1));
    site.setDate2(new LocalDate(2000, 1, 2));
    site.setActivityId(1);
    ActivityDTO activity = new ActivityDTO(1, "woei");
    activity.setDatabase(db);
    activity.getLockedPeriods().add(lockedPeriod);
    db.getActivities().add(activity);
    Assert.assertTrue("Site should fall within LockedPeriod", new LockedPeriodSet(activity).isLocked(site));
    LockedPeriodDTO lockedPeriod1 = new LockedPeriodDTO();
    lockedPeriod1.setFromDate(new LocalDate(2000, 1, 1));
    lockedPeriod1.setToDate(new LocalDate(2000, 1, 2));
    lockedPeriod1.setEnabled(true);
    SiteDTO site1 = new SiteDTO(2);
    site1.setActivityId(2);
    site1.setDate1(new LocalDate(2000, 1, 1));
    site1.setDate2(new LocalDate(2000, 1, 3));
    ActivityDTO activity1 = new ActivityDTO(2, "woei");
    activity1.setDatabase(db);
    activity1.getLockedPeriods().add(lockedPeriod1);
    LockedPeriodSet locks = new LockedPeriodSet(activity1);
    Assert.assertFalse("Site should NOT fall within LockedPeriod", locks.isLocked(site1));
// Assert.assertTrue("No affected LockedPeriods should be available",
// site1.getAffectedLockedPeriods(activity1).size() == 0);
}
Also used : LockedPeriodSet(org.activityinfo.client.page.entry.LockedPeriodSet) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate) Test(org.junit.Test)

Example 3 with LockedPeriodSet

use of org.activityinfo.client.page.entry.LockedPeriodSet in project activityinfo by bedatadriven.

the class ColumnModelBuilder method maybeAddLockColumn.

public ColumnModelBuilder maybeAddLockColumn(final ActivityDTO activity) {
    ColumnConfig columnLocked = new ColumnConfig("x", "", 28);
    columnLocked.setRenderer(new LockedColumnRenderer(new LockedPeriodSet(activity)));
    columnLocked.setSortable(false);
    columnLocked.setMenuDisabled(true);
    columns.add(columnLocked);
    return this;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) LockedPeriodSet(org.activityinfo.client.page.entry.LockedPeriodSet)

Aggregations

LockedPeriodSet (org.activityinfo.client.page.entry.LockedPeriodSet)3 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 Test (org.junit.Test)2 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)1 GetSchema (org.activityinfo.shared.command.GetSchema)1 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)1