Search in sources :

Example 1 with PeriodType

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

the class SubFormViewModelBuilder method find.

private FormInputViewModel find(RecordRef activeRecord, List<FormInputViewModel> subRecordViews) {
    for (FormInputViewModel subRecordView : subRecordViews) {
        if (subRecordView.getRecordRef().equals(activeRecord)) {
            return subRecordView;
        }
    }
    if (keyField.isPresent()) {
        PeriodType periodType = (PeriodType) keyField.get().getType();
        PeriodValue periodValue = periodType.fromSubFormKey(activeRecord);
        return formBuilder.placeholder(activeRecord, keyField.get(), periodValue);
    } else {
        return formBuilder.placeholder(activeRecord);
    }
}
Also used : PeriodType(org.activityinfo.model.type.time.PeriodType) PeriodValue(org.activityinfo.model.type.time.PeriodValue)

Example 2 with PeriodType

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

the class SubFormPatch method fromRecordId.

public static CursorObserver<ResourceId> fromRecordId(FormClass formClass, final CursorObserver<FieldValue> observer) {
    final ResourceId formId = formClass.getId();
    final PeriodType periodType = formClass.getSubFormKind().getPeriodType();
    return new CursorObserver<ResourceId>() {

        @Override
        public void onNext(ResourceId value) {
            observer.onNext(periodType.fromSubFormKey(new RecordRef(formId, value)));
        }

        @Override
        public void done() {
            observer.done();
        }
    };
}
Also used : PeriodType(org.activityinfo.model.type.time.PeriodType) ResourceId(org.activityinfo.model.resource.ResourceId) RecordRef(org.activityinfo.model.type.RecordRef)

Example 3 with PeriodType

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

the class SubFormViewModel method getActivePeriod.

public PeriodValue getActivePeriod() {
    RecordRef ref = getActiveRecordRef();
    PeriodType periodType = subFormKind.getPeriodType();
    return periodType.fromSubFormKey(ref);
}
Also used : PeriodType(org.activityinfo.model.type.time.PeriodType) RecordRef(org.activityinfo.model.type.RecordRef)

Aggregations

PeriodType (org.activityinfo.model.type.time.PeriodType)3 RecordRef (org.activityinfo.model.type.RecordRef)2 ResourceId (org.activityinfo.model.resource.ResourceId)1 PeriodValue (org.activityinfo.model.type.time.PeriodValue)1