private BidiMap<NonTerminalMolecule, NamedNode> ntCurrentlyBeingAdded = new BidiMapImpl<NonTerminalMolecule, NamedNode>();
public NamedNode addFunctionallyGroundedNode(
FunctionallyGroundedNode functionallyGroundedNode) {
NamedNode result = getNameOfFunctionallyGroundedNode(functionallyGroundedNode);
if (result != null) {
return result;
}
try {
ComponentDirectory componentDirectory;
synchronized (currentlyBeingAdded) {
componentDirectory = new ComponentDirectory();
currentlyBeingAdded.put(functionallyGroundedNode,
componentDirectory.getNode());
}
File directory = componentDirectory.getDirectory();
directory.mkdirs();
// writeMetaInf(directory, componentDirectory.getNode(),
// METAMODEL.FunctionallyGroundedNode, functionallyGroundedNode);
File metaInfFile = new File(directory, "meta-inf");
Model metaInfModel = ModelFactory.createDefaultModel();
Resource componentRes = metaInfModel
.createResource(componentDirectory.getNode().getURIRef());
componentRes.addProperty(RDF.type,
METAMODEL.FunctionallyGroundedNode);
componentRes.addProperty(METAMODEL.hashCode, metaInfModel
.createTypedLiteral(functionallyGroundedNode.hashCode()));
componentRes.addProperty(METAMODEL.strongHashCode, metaInfModel
.createTypedLiteral(functionallyGroundedNode
.strongHashCode()));
for (NonTerminalMolecule molecule : functionallyGroundedNode
.getGroundingMolecules()) {
// storeNTMolecule doesn't add duplicate
NamedNode moleculeName;
try {
moleculeName = storeNTMolecule(molecule);
} catch (IOException e) {
throw new RuntimeException(e);
}
componentRes.addProperty(METAMODEL.containsNonTerminalMolecule,
metaInfModel.createResource(moleculeName.getURIRef()));
}
OutputStream metaInfOut = new FileOutputStream(metaInfFile);
try {
metaInfModel.write(metaInfOut, "N-TRIPLE");
} finally {