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);
}
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);
}
Aggregations