ProtoNetwork protoNetwork2, int documentId,
Map<Integer, Integer> termMap) {
TermTable termTable = protoNetwork2.getTermTable();
TermParameterMapTable mapTable =
protoNetwork2.getTermParameterMapTable();
ParameterTable parameterTable = protoNetwork2.getParameterTable();
Term termToMerge = termTable.getIndexedTerms().get(termId);
// tables for proto network we're merging into (1)
final TermTable mtt = protoNetwork1.getTermTable();
final ParameterTable mpt = protoNetwork1.getParameterTable();
final TermParameterMapTable mtpmt =
protoNetwork1.getTermParameterMapTable();
final ProtoNodeTable mpnt = protoNetwork1.getProtoNodeTable();
// if p1 contains an equivalent Term then return it's inndex without
// adding a new one.
Integer p1Index = mtt.getVisitedTerms().get(termToMerge);
if (p1Index != null) {
termMap.put(termId, p1Index);
return p1Index;
}
List<Integer> newTermParameterIndices = new ArrayList<Integer>();
List<Integer> termParameterIndices = mapTable.getTermParameterIndex()
.get(termId);
if (hasItems(termParameterIndices)) {
for (Integer termParameterIndex : termParameterIndices) {
TableParameter parameter = parameterTable.
getIndexTableParameter().get(termParameterIndex);
newTermParameterIndices.add(mpt
.addTableParameter(parameter));
}
}
Integer newTermIndex = mtt.addTerm(termToMerge);