Package org.apache.clerezza.rdf.jena.tdb.internals

Examples of org.apache.clerezza.rdf.jena.tdb.internals.ModelGraph


     * The returned instance will be also cached in {@link #initModels}.
     * @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;
        datasetLock.readLock().lock();
        try {
            modelGraph = initModels.get(name);
            if(modelGraph != null && 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);
                this.initModels.put(name, modelGraph);
            }
        } finally {
View Full Code Here


    public Graph createGraph(UriRef name, TripleCollection triples) throws UnsupportedOperationException,
                                                                   EntityAlreadyExistsException {
        if(name == null){
            throw new IllegalArgumentException("The parsed Grpah name MUST NOT be NULL!");
        }
        ModelGraph mg;
        datasetLock.writeLock().lock();
        try {
            if(graphNames.contains(name) || mGraphNames.contains(name) || name.equals(defaultGraphName)){
                throw new EntityAlreadyExistsException(name);
            }
            mg = getModelGraph(name,false,true);
            graphNames.add(name);
            try {
                writeGraphConfig();
            } catch (IOException e) {
                throw new IllegalStateException("Unable to wirte GraphName config file '"
                        + graphConfigFile+"'!",e);
            }
            //add the parsed data!
            if(triples != null) { //load the initial and final set of triples
                mg.getJenaAdapter().addAll(triples);
                mg.sync();
            }
        } finally {
            datasetLock.writeLock().unlock();
        }
        return mg.getGraph();
    }
View Full Code Here

                } catch (IOException e){
                    mGraphNames.add(name);//make it consistent with the file
                    throw new IllegalStateException("Unable to wirte MGraphName config file '"
                            + graphConfigFile+"'!",e);
                }
                ModelGraph mg = getModelGraph(name, true, false);
                mg.delete();
            } else if(graphNames.remove(name)){
                try {
                    writeGraphConfig();
                } catch (IOException e){
                    graphNames.add(name); //make it consistent with the file
                    throw new IllegalStateException("Unable to wirte GraphName config file '"
                            + graphConfigFile+"'!",e);
                }
                ModelGraph mg = getModelGraph(name, false, false);
                mg.delete();
            } else if (name.equals(defaultGraphName)){
                throw new EntityUndeletableException(defaultGraphName);
            }
            //delete the graph from the initModels list
            initModels.remove(name);
View Full Code Here

            throw new ConfigurationException("tdb.dir", "Configured jena TDB data directory '"
                    + dataDir+"' already exists, but is not a Directory!");
        } //else exists and is a directory ... nothing to do
        TDB.getContext().set(TDB.symUnionDefaultGraph, true);
        setDataset( TDBFactory.createDataset(dataDir.getAbsolutePath()) );
        graphNameIndex = new ModelGraph(datasetLock, getDataset().getDefaultModel(),true);

        // Remove existing default graph names from the index (if might have changed
        // in the mean time).
        removeDefaultGraphFromIndex();
View Full Code Here

     * 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);
View Full Code Here

    public Graph createGraph(UriRef name, TripleCollection triples) throws UnsupportedOperationException,
                                                                   EntityAlreadyExistsException {
        if(name == null){
            throw new IllegalArgumentException("The parsed Grpah name MUST NOT be NULL!");
        }
        ModelGraph mg;
        datasetLock.writeLock().lock();
        try {
            if(isExistingGraphName(name)){
                throw new EntityAlreadyExistsException(name);
            }
            mg = getModelGraph(name,false,true);
            addToIndex( name, Symbols.Graph);
           
            //add the parsed data!
            if(triples != null) { //load the initial and final set of triples
                mg.getJenaAdapter().addAll(triples);
                mg.sync();
            }
        } finally {
            datasetLock.writeLock().unlock();
        }
        return mg.getGraph();
    }
View Full Code Here

            throw new IllegalArgumentException("The parsed MGrpah name MUST NOT be NULL!");
        }
        datasetLock.writeLock().lock();
        try {
            if(isExistingGraphName(name,Symbols.MGraph)){
                ModelGraph mg = getModelGraph(name, true, false);
                mg.delete();
                removeFromIndex( name, Symbols.MGraph );
            } else if(isExistingGraphName(name,Symbols.Graph)){
                ModelGraph mg = getModelGraph(name, false, false);
                mg.delete();
                removeFromIndex( name, Symbols.Graph );
            } else if (name.equals(defaultGraphName)){
                throw new EntityUndeletableException(defaultGraphName);
            }
            //delete the graph from the initModels list
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.jena.tdb.internals.ModelGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.