Search in sources :

Example 16 with RecordRef

use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.

the class TableToolBar method onNewRecord.

private void onNewRecord(SelectEvent event) {
    ResourceId newRecordId = ResourceId.generateSubmissionId(viewModel.getFormId());
    RecordRef newRecordRef = new RecordRef(viewModel.getFormId(), newRecordId);
    FormDialog dialog = new FormDialog(formStore, newRecordRef);
    dialog.show();
}
Also used : FormDialog(org.activityinfo.ui.client.input.view.FormDialog) ResourceId(org.activityinfo.model.resource.ResourceId) RecordRef(org.activityinfo.model.type.RecordRef)

Example 17 with RecordRef

use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.

the class TableView method updateGrid.

private void updateGrid(EffectiveTableModel effectiveTableModel) {
    panel.setHeading(effectiveTableModel.getFormLabel());
    // destorying everything
    if (grid != null && grid.updateView(effectiveTableModel)) {
        return;
    }
    if (grid != null) {
        center.remove(grid);
    }
    grid = new TableGrid(effectiveTableModel, viewModel.getColumnSet(), viewModel);
    grid.addSelectionChangedHandler(event -> {
        if (!event.getSelection().isEmpty()) {
            RecordRef ref = event.getSelection().get(0);
            viewModel.select(ref);
        }
    });
    center.add(grid, new VerticalLayoutContainer.VerticalLayoutData(1, 1));
    center.forceLayout();
    // grid and sidebars is set
    if (!container.isAttached()) {
        panel.setWidget(container);
    }
    panel.forceLayout();
}
Also used : VerticalLayoutContainer(com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer) RecordRef(org.activityinfo.model.type.RecordRef)

Example 18 with RecordRef

use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.

the class RecordStore method put.

public final void put(ResourceId formId, UpdatedRecord record) {
    RecordRef ref = new RecordRef(formId, ResourceId.valueOf(record.getRecordId()));
    impl.put(key(ref), RecordObject.from(record));
}
Also used : RecordRef(org.activityinfo.model.type.RecordRef)

Example 19 with RecordRef

use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.

the class RecordTreeLoaderTest method subforms.

@Test
public void subforms() {
    IncidentForm incidentForm = setup.getCatalog().getIncidentForm();
    RecordRef rootRecordRef = incidentForm.getRecordRef(0);
    Observable<Maybe<RecordTree>> recordTree = setup.getFormStore().getRecordTree(rootRecordRef);
    Connection<Maybe<RecordTree>> recordTreeView = setup.connect(recordTree);
    Iterable<FormInstance> subRecords = recordTreeView.assertLoaded().get().getSubRecords(rootRecordRef, ReferralSubForm.FORM_ID);
    assertThat(Iterables.size(subRecords), equalTo(4));
}
Also used : Maybe(org.activityinfo.promise.Maybe) RecordRef(org.activityinfo.model.type.RecordRef) FormInstance(org.activityinfo.model.form.FormInstance) IncidentForm(org.activityinfo.store.testing.IncidentForm) Test(org.junit.Test)

Example 20 with RecordRef

use of org.activityinfo.model.type.RecordRef in project activityinfo by bedatadriven.

the class RecordTreeLoaderTest method references.

@Test
public void references() {
    BioDataForm bioDataForm = setup.getBioDataForm();
    Observable<Maybe<RecordTree>> recordTree = setup.getFormStore().getRecordTree(bioDataForm.getRecordRef(0));
    Connection<Maybe<RecordTree>> recordTreeView = setup.connect(recordTree);
    RecordTree tree = recordTreeView.assertLoaded().get();
    LookupKeySet lookupKeySet = new LookupKeySet(tree.getFormTree(), tree.getFormTree().getRootField(BioDataForm.PROTECTION_CODE_FIELD_ID).getField());
    assertThat(lookupKeySet.getLookupKeys(), hasSize(1));
    ReferenceValue referenceValue = (ReferenceValue) tree.getRoot().get(BioDataForm.PROTECTION_CODE_FIELD_ID);
    RecordRef ref = referenceValue.getOnlyReference();
    assertThat(lookupKeySet.label(tree, ref), equalTo(Maybe.of("00667")));
}
Also used : RecordTree(org.activityinfo.model.formTree.RecordTree) Maybe(org.activityinfo.promise.Maybe) LookupKeySet(org.activityinfo.model.formTree.LookupKeySet) ReferenceValue(org.activityinfo.model.type.ReferenceValue) RecordRef(org.activityinfo.model.type.RecordRef) BioDataForm(org.activityinfo.store.testing.BioDataForm) Test(org.junit.Test)

Aggregations

RecordRef (org.activityinfo.model.type.RecordRef)66 Test (org.junit.Test)31 ResourceId (org.activityinfo.model.resource.ResourceId)26 ReferenceValue (org.activityinfo.model.type.ReferenceValue)26 FormInputModel (org.activityinfo.ui.client.input.model.FormInputModel)14 FormInstance (org.activityinfo.model.form.FormInstance)7 FormTree (org.activityinfo.model.formTree.FormTree)7 LocalDate (org.activityinfo.model.type.time.LocalDate)7 EnumValue (org.activityinfo.model.type.enumerated.EnumValue)6 Optional (com.google.common.base.Optional)5 FieldValue (org.activityinfo.model.type.FieldValue)5 FieldInput (org.activityinfo.ui.client.input.model.FieldInput)5 FormClass (org.activityinfo.model.form.FormClass)4 ResultSet (java.sql.ResultSet)3 FormField (org.activityinfo.model.form.FormField)3 RecordTree (org.activityinfo.model.formTree.RecordTree)3 ColumnSet (org.activityinfo.model.query.ColumnSet)3 ColumnView (org.activityinfo.model.query.ColumnView)3 RecordTransaction (org.activityinfo.model.resource.RecordTransaction)3 RecordUpdate (org.activityinfo.model.resource.RecordUpdate)3