triples.iterator().close();
return molecule;
}
private Molecule addLinkedTriple(Molecule molecule, Triple triple) throws GraphException {
Molecule subMolecule = moleculeFactory.createMolecule();
subMolecule.add(triple);
triplesChecked.add(triple);
// Put submolecule inside molecule's head triple
if (isDoubleLinkedTriple(molecule.getHeadTriple()) &&
molecule.getHeadTriple().getObject().equals(triple.getSubject())) {
getSubMolecule(subMolecule, triple);
return molecule.add(molecule.getHeadTriple(), subMolecule);
// Put molecule inside submolecule
} else if (triple.getObject().equals(molecule.getHeadTriple().getSubject())) {
getSubMolecule(subMolecule, triple);
return subMolecule.add(triple, molecule);
// Put submolecule inside molecule
} else {
getSubMolecule(subMolecule, triple);
if (isDoubleLinkedTriple(triple)) {
Set<Molecule> subMolecules = subMolecule.getSubMolecules(triple);
for (Molecule newMole : subMolecules) {
molecule.add(triple, newMole);
}
}
subMolecule.remove(triple);
getNewRootTriples(molecule, triple);
return molecule.add(triple, subMolecule);
}
}