* The returned instance will be also cached in {@link #syncModels}.
* @throws NoSuchEntityException If <code>create == false</code> and no
* {@link Model} for the parsed <code>name</code> exists.
*/
private ModelGraph getModelGraph(UriRef name, boolean readWrite,boolean create) throws NoSuchEntityException {
ModelGraph modelGraph = null;
datasetLock.readLock().lock();
try {
if(readWrite) {
// Reuse existing model if not yet garbage collected.
modelGraph = syncModels.get(name);
}
if((modelGraph != null || isExistingGraphName(name)) && create){
throw new EntityAlreadyExistsException(name);
} else if(modelGraph == null){
String modelName = name.getUnicodeString();
modelGraph = new ModelGraph(datasetLock, name.equals(defaultGraphName) ?
getDataset().getNamedModel("urn:x-arq:UnionGraph") :
getDataset().getNamedModel(modelName),readWrite);
if(readWrite) {
// Keep track of readwrite model to be able to sync them.
this.syncModels.put(name, modelGraph);