Search in sources :

Example 6 with FieldProfile

use of org.activityinfo.geoadmin.merge2.view.profile.FieldProfile in project activityinfo by bedatadriven.

the class LookupTable method userMatchToKey.

private SourceLookupKey userMatchToKey(Map<FieldPath, String> valueMap) {
    List<FieldProfile> keyFields = sourceKeySet.getSourceFields();
    String[] keyValues = new String[keyFields.size()];
    for (int i = 0; i < keyFields.size(); ++i) {
        FieldPath keyPath = keyFields.get(i).getPath();
        if (!valueMap.containsKey(keyPath)) {
            return null;
        }
        keyValues[i] = valueMap.get(keyPath);
    }
    return new SourceLookupKey(keyValues);
}
Also used : FieldPath(org.activityinfo.model.formTree.FieldPath) FieldProfile(org.activityinfo.geoadmin.merge2.view.profile.FieldProfile)

Example 7 with FieldProfile

use of org.activityinfo.geoadmin.merge2.view.profile.FieldProfile in project activityinfo by bedatadriven.

the class KeyFieldPairSet method matchKeys.

/**
 * Constructs a {@code KeyFieldPairSet} from a source and target form by matching columns with similar
 * sets of values.
 */
public static KeyFieldPairSet matchKeys(FormProfile source, FormProfile target) {
    ScoreMatrix scoreMatrix = new FieldScoreMatrix(source.getFields(), target.getFields());
    dumpScoreMatrix(source, target, scoreMatrix);
    MatchGraph matchGraph = new MatchGraph(scoreMatrix);
    matchGraph.build();
    BiMap<FieldProfile, FieldProfile> targetToSource = HashBiMap.create();
    for (int sourceColumnIndex = 0; sourceColumnIndex != scoreMatrix.getRowCount(); ++sourceColumnIndex) {
        int targetColumnIndex = matchGraph.getBestMatchForSource(sourceColumnIndex);
        if (targetColumnIndex != -1) {
            FieldProfile sourceColumn = source.getFields().get(sourceColumnIndex);
            FieldProfile targetColumn = target.getFields().get(targetColumnIndex);
            targetToSource.put(targetColumn, sourceColumn);
            System.out.println("Matching FIELD " + sourceColumn.getLabel() + " => " + targetColumn.getLabel());
        }
    }
    return new KeyFieldPairSet(source, target, targetToSource);
}
Also used : ScoreMatrix(org.activityinfo.geoadmin.match.ScoreMatrix) FieldProfile(org.activityinfo.geoadmin.merge2.view.profile.FieldProfile)

Aggregations

FieldProfile (org.activityinfo.geoadmin.merge2.view.profile.FieldProfile)7 FieldPath (org.activityinfo.model.formTree.FieldPath)2 ResourceId (org.activityinfo.model.resource.ResourceId)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ScoreMatrix (org.activityinfo.geoadmin.match.ScoreMatrix)1 ReferenceMatch (org.activityinfo.geoadmin.merge2.model.ReferenceMatch)1 FeatureSourceStorage (org.activityinfo.geoadmin.source.FeatureSourceStorage)1 FeatureSourceStorageProvider (org.activityinfo.geoadmin.source.FeatureSourceStorageProvider)1 GeometryConverter (org.activityinfo.geoadmin.source.GeometryConverter)1 FormField (org.activityinfo.model.form.FormField)1 FormTree (org.activityinfo.model.formTree.FormTree)1 SimpleFeatureIterator (org.geotools.data.simple.SimpleFeatureIterator)1 SimpleFeatureSource (org.geotools.data.simple.SimpleFeatureSource)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1 GeometryType (org.opengis.feature.type.GeometryType)1