Search in sources :

Example 21 with LocalDate

use of org.activityinfo.model.type.time.LocalDate in project activityinfo by bedatadriven.

the class ActivityFormClassBuilderTest method partnersFieldIsAlwaysVisible.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void partnersFieldIsAlwaysVisible() {
    setUser(BAVON_USER_ID);
    FormClass formClass = assertResolves(locator.getFormClass(CuidAdapter.activityFormClass(1)));
    int databaseId = 1;
    ResourceId partnerFieldId = CuidAdapter.field(formClass.getId(), CuidAdapter.PARTNER_FIELD);
    FormField partnerField = formClass.getField(partnerFieldId);
    // according to ai-1009 : partner field is always visible
    assertThat(partnerField, hasProperty("visible", equalTo(true)));
    // Make sure we can update if partner is not specified
    FormInstance instance = new FormInstance(CuidAdapter.newLegacyFormInstanceId(formClass.getId()), formClass.getId());
    instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.START_DATE_FIELD), new LocalDate(2014, 1, 1));
    instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.END_DATE_FIELD), new LocalDate(2014, 1, 2));
    instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.LOCATION_FIELD), new ReferenceValue(new RecordRef(CuidAdapter.locationFormClass(1), CuidAdapter.locationInstanceId(1))));
    instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.PARTNER_FIELD), CuidAdapter.partnerRef(databaseId, 1));
    assertResolves(locator.persist(instance));
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) FormClass(org.activityinfo.model.form.FormClass) ReferenceValue(org.activityinfo.model.type.ReferenceValue) RecordRef(org.activityinfo.model.type.RecordRef) FormInstance(org.activityinfo.model.form.FormInstance) FormField(org.activityinfo.model.form.FormField) LocalDate(org.activityinfo.model.type.time.LocalDate) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 22 with LocalDate

use of org.activityinfo.model.type.time.LocalDate in project activityinfo by bedatadriven.

the class DateIntervalFieldWidget method getValue.

private LocalDateInterval getValue() {
    Date startDate = startDateBox.getValue();
    Date endDate = endDateBox.getValue();
    if (startDate != null && endDate != null && (startDate.equals(endDate) || startDate.before(endDate))) {
        return new LocalDateInterval(new LocalDate(startDate), new LocalDate(endDate));
    } else {
        // TODO: how do we signal the container that the value is invalid?
        return null;
    }
}
Also used : LocalDate(org.activityinfo.model.type.time.LocalDate) LocalDate(org.activityinfo.model.type.time.LocalDate) Date(java.util.Date) LocalDateInterval(org.activityinfo.model.type.time.LocalDateInterval)

Example 23 with LocalDate

use of org.activityinfo.model.type.time.LocalDate in project activityinfo by bedatadriven.

the class AbstractWeekWidget method onDatePicked.

private void onDatePicked(ValueChangeEvent<Date> event) {
    LocalDate date = new LocalDate(event.getValue());
    dateMenu.hide();
    updater.update(new FieldInput(periodType.containingDate(date)));
}
Also used : FieldInput(org.activityinfo.ui.client.input.model.FieldInput) LocalDate(org.activityinfo.model.type.time.LocalDate)

Example 24 with LocalDate

use of org.activityinfo.model.type.time.LocalDate in project activityinfo by bedatadriven.

the class ColumnFilterParser method parseComparison.

private boolean parseComparison(FormulaNode node, Multimap<Integer, FilterConfig> result) {
    if (!(node instanceof FunctionCallNode)) {
        return false;
    }
    // Check that this is a binary
    FunctionCallNode callNode = (FunctionCallNode) node;
    if (callNode.getArgumentCount() != 2) {
        return false;
    }
    // Does this comparison involve one of our fields?
    Integer columnIndex = findColumnIndex(callNode.getArgument(0));
    if (columnIndex == null) {
        return false;
    }
    // Is it compared with a constant value?
    FieldValue value = parseLiteral(callNode.getArgument(1));
    if (value == null) {
        return false;
    }
    FilterConfig config;
    if (value instanceof Quantity) {
        config = numericFilter(callNode, (Quantity) value);
    } else if (value instanceof LocalDate) {
        config = dateFilter(callNode, (LocalDate) value);
    } else {
        return false;
    }
    result.put(columnIndex, config);
    return true;
}
Also used : Quantity(org.activityinfo.model.type.number.Quantity) FilterConfig(com.sencha.gxt.data.shared.loader.FilterConfig) FieldValue(org.activityinfo.model.type.FieldValue) LocalDate(org.activityinfo.model.type.time.LocalDate)

Aggregations

LocalDate (org.activityinfo.model.type.time.LocalDate)24 Test (org.junit.Test)11 Quantity (org.activityinfo.model.type.number.Quantity)8 FormInstance (org.activityinfo.model.form.FormInstance)7 RecordRef (org.activityinfo.model.type.RecordRef)7 EnumValue (org.activityinfo.model.type.enumerated.EnumValue)6 ResourceId (org.activityinfo.model.resource.ResourceId)5 OnDataSet (org.activityinfo.server.database.OnDataSet)5 FormClass (org.activityinfo.model.form.FormClass)4 FieldValue (org.activityinfo.model.type.FieldValue)4 ReferenceValue (org.activityinfo.model.type.ReferenceValue)4 Date (java.util.Date)3 GeoPoint (org.activityinfo.model.type.geo.GeoPoint)3 FieldInput (org.activityinfo.ui.client.input.model.FieldInput)3 FormInputModel (org.activityinfo.ui.client.input.model.FormInputModel)3 FormField (org.activityinfo.model.form.FormField)2 FormulaSyntaxException (org.activityinfo.model.formula.diagnostic.FormulaSyntaxException)2 KeyGenerator (org.activityinfo.model.legacy.KeyGenerator)2 FilterConfig (com.sencha.gxt.data.shared.loader.FilterConfig)1 Calendar (java.util.Calendar)1