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));
}
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;
}
}
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)));
}
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;
}
Aggregations