Search in sources :

Example 16 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class RelevancePanelPresenter method fieldList.

private List<FormField> fieldList(FieldWidgetContainer container) {
    ResourceId thisFieldId = container.getFormField().getId();
    FormClass formClass = container.getFormDesigner().getModel().getFormClassByElementId(thisFieldId);
    List<FormField> formFields = new ArrayList<>();
    for (FormField formField : formClass.getFields()) {
        if (!formField.getId().equals(thisFieldId)) {
            formFields.add(formField);
        }
    }
    return formFields;
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) FormClass(org.activityinfo.model.form.FormClass) ArrayList(java.util.ArrayList) FormField(org.activityinfo.model.form.FormField)

Example 17 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class SingleClassTargetBuilder method newImporter.

public SingleClassImporter newImporter(Map<TargetSiteId, ColumnAccessor> mappings) {
    List<ColumnAccessor> sourceColumns = Lists.newArrayList();
    Map<FieldPath, Integer> referenceValues = targetCollector.getPathMap(mappings, sourceColumns);
    List<FieldImporterColumn> fieldImporterColumns = targetCollector.fieldImporterColumns(mappings);
    ResourceId rangeClassId = Iterables.getOnlyElement(rootField.getRange());
    return new SingleClassImporter(rangeClassId, rootField.getField().isRequired(), sourceColumns, referenceValues, fieldImporterColumns, rootField.getFieldId());
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) FieldPath(org.activityinfo.model.formTree.FieldPath)

Example 18 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class TargetCollector method getPathMap.

public Map<FieldPath, Integer> getPathMap(Map<TargetSiteId, ColumnAccessor> mappings, List<ColumnAccessor> sourceColumns) {
    Map<FieldPath, Integer> referenceValues = new HashMap<>();
    List<FieldImporterColumn> importerColumns = Lists.newArrayList();
    int columnIndex = 0;
    for (Map.Entry<TargetSiteId, ColumnAccessor> entry : mappings.entrySet()) {
        ImportTarget target = getTargetBySiteId(entry.getKey());
        ColumnAccessor source = entry.getValue();
        importerColumns.add(new FieldImporterColumn(target, source));
        sourceColumns.add(entry.getValue());
        ResourceId fieldId = ResourceId.valueOf(entry.getKey().asString());
        for (FieldPath path : getFieldPathMap().get(fieldId)) {
            referenceValues.put(path, columnIndex);
        }
        columnIndex++;
    }
    return referenceValues;
}
Also used : HashMap(java.util.HashMap) FieldPath(org.activityinfo.model.formTree.FieldPath) ResourceId(org.activityinfo.model.resource.ResourceId) Map(java.util.Map) HashMap(java.util.HashMap)

Example 19 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class DbEditor method onUIAction.

private void onUIAction(String actionId) {
    if (UIActions.SAVE.equals(actionId)) {
        save();
    } else if (UIActions.DELETE.equals(actionId)) {
        promptDeleteSelection();
    } else if (UIActions.IMPORT.equals(actionId)) {
        SchemaImportDialog dialog = new SchemaImportDialog(new SchemaImporterV2(service, db), new SchemaImporterV3(db.getId(), locator));
        dialog.show().then(() -> {
            refresh();
            return null;
        });
    } else if (UIActions.EDIT.equals(actionId)) {
        Optional<ResourceId> selectedFormId = getSelectedFormId();
        if (selectedFormId.isPresent()) {
            eventBus.fireEvent(new NavigationEvent(NavigationHandler.NAVIGATION_REQUESTED, new ResourcePlace(selectedFormId.get(), ResourcePage.DESIGN_PAGE_ID)));
        }
    } else if (UIActions.OPEN_TABLE.equals(actionId)) {
        Optional<ResourceId> selectedFormId = getSelectedFormId();
        if (selectedFormId.isPresent()) {
            App3.openNewTable(selectedFormId.get());
        }
    }
}
Also used : SchemaImporterV3(org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3) ResourcePlace(org.activityinfo.ui.client.page.resource.ResourcePlace) ResourceId(org.activityinfo.model.resource.ResourceId) SchemaImportDialog(org.activityinfo.ui.client.page.config.design.importer.SchemaImportDialog) SchemaImporterV2(org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV2)

Example 20 with ResourceId

use of org.activityinfo.model.resource.ResourceId in project activityinfo by bedatadriven.

the class SchemaImporterV3 method determineReferencesToValidate.

private List<ResourceId> determineReferencesToValidate() {
    List<ResourceId> validationList = new ArrayList<>(refMap.size());
    for (FormField refField : refMap.values()) {
        ReferenceType refType = (ReferenceType) refField.getType();
        ResourceId reference = refType.getRange().iterator().next();
        if (!isImportedReference(reference)) {
            validationList.add(reference);
        }
    }
    return validationList;
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) FormField(org.activityinfo.model.form.FormField) SubFormReferenceType(org.activityinfo.model.type.subform.SubFormReferenceType)

Aggregations

ResourceId (org.activityinfo.model.resource.ResourceId)198 Test (org.junit.Test)42 FormClass (org.activityinfo.model.form.FormClass)41 FormField (org.activityinfo.model.form.FormField)34 RecordRef (org.activityinfo.model.type.RecordRef)30 JsonValue (org.activityinfo.json.JsonValue)21 FormTree (org.activityinfo.model.formTree.FormTree)18 ReferenceValue (org.activityinfo.model.type.ReferenceValue)17 FieldValue (org.activityinfo.model.type.FieldValue)16 FormInstance (org.activityinfo.model.form.FormInstance)15 HashMap (java.util.HashMap)14 QuantityType (org.activityinfo.model.type.number.QuantityType)13 ColumnSet (org.activityinfo.model.query.ColumnSet)12 QueryModel (org.activityinfo.model.query.QueryModel)12 EnumValue (org.activityinfo.model.type.enumerated.EnumValue)11 SubFormReferenceType (org.activityinfo.model.type.subform.SubFormReferenceType)11 ReferenceType (org.activityinfo.model.type.ReferenceType)10 EnumItem (org.activityinfo.model.type.enumerated.EnumItem)10 FormStorage (org.activityinfo.store.spi.FormStorage)10 ArrayList (java.util.ArrayList)9