Search in sources :

Example 1 with ReferenceMatch

use of org.activityinfo.geoadmin.merge2.model.ReferenceMatch in project activityinfo by bedatadriven.

the class LookupDialog method buildReferenceMatch.

/**
 * Build a ReferenceMatch that can be stored as part of the model.
 * since this will form part of the model "state" it cannot depend
 * on computed values in any way, so we need to map our row indices and SourceKeys
 * back to the original ids.
 *
 * @param candidateIndex the index within the list of candidate target matches (from LookupGraph)
 */
private ReferenceMatch buildReferenceMatch(int candidateIndex) {
    ResourceId targetId = tableModel.getTargetInstanceId(candidateIndex);
    Map<FieldPath, String> keyMap = new HashMap<>();
    java.util.List<FieldProfile> keyFields = lookupTable.getSourceKeyFields();
    for (int i = 0; i < keyFields.size(); i++) {
        keyMap.put(keyFields.get(i).getPath(), sourceKey.get(i));
    }
    return new ReferenceMatch(keyMap, targetId);
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) HashMap(java.util.HashMap) FieldPath(org.activityinfo.model.formTree.FieldPath) FieldProfile(org.activityinfo.geoadmin.merge2.view.profile.FieldProfile) ReferenceMatch(org.activityinfo.geoadmin.merge2.model.ReferenceMatch)

Aggregations

HashMap (java.util.HashMap)1 ReferenceMatch (org.activityinfo.geoadmin.merge2.model.ReferenceMatch)1 FieldProfile (org.activityinfo.geoadmin.merge2.view.profile.FieldProfile)1 FieldPath (org.activityinfo.model.formTree.FieldPath)1 ResourceId (org.activityinfo.model.resource.ResourceId)1