Search in sources :

Example 1 with IntelligentGraphSail

use of com.inova8.intelligentgraph.sail.IntelligentGraphSail in project com.inova8.intelligentgraph by peterjohnlawrence.

the class IntelligentGraphConnection method getStatements.

/**
 * Gets the statements.
 *
 * @param subj the subj
 * @param pred the pred
 * @param obj the obj
 * @param includeInferred the include inferred
 * @param contexts the contexts
 * @return the statements
 * @throws SailException the sail exception
 */
@Override
public CloseableIteration<? extends IntelligentStatement, SailException> getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws SailException {
    try {
        Resource[] extendedContexts = contexts;
        if (pred != null && !pred.stringValue().equals(SCRIPT.isprivate)) {
            extendedContexts = getContexts(contexts);
        }
        String[] predicateParts;
        if (pred != null) {
            predicateParts = decodePredicate(pred);
            switch(predicateParts[0]) {
                case PATHQL.getFact:
                case PATHQL.getFacts:
                    return getFacts(subj, decodePathQL(predicateParts, obj), obj, extendedContexts);
                case PATHQL.getPath:
                case PATHQL.getPaths:
                    return getPaths(subj, decodePathQL(predicateParts, obj), obj, extendedContexts);
                case PATHQL.traceFact:
                case PATHQL.traceFacts:
                    return traceFacts(subj, decodePathQL(predicateParts, obj), obj, extendedContexts);
                case PATHQL.clearCache:
                    return clearCache(subj, pred, obj, extendedContexts);
                case PATHQL.getScript:
                    return getScript(subj, decodePathQL(predicateParts, obj), obj, extendedContexts);
                default:
                    return new IntelligentGraphStatementsIterator(super.getStatements(subj, pred, obj, includeInferred, extendedContexts), intelligentGraphSail, this, extendedContexts);
            }
        } else {
            return new IntelligentGraphStatementsIterator(super.getStatements(subj, pred, obj, includeInferred, extendedContexts), intelligentGraphSail, this, extendedContexts);
        }
    } catch (Exception e) {
        throw new SailException(e.getMessage(), e);
    }
}
Also used : Resource(org.eclipse.rdf4j.model.Resource) SailException(org.eclipse.rdf4j.sail.SailException) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException) SailException(org.eclipse.rdf4j.sail.SailException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PathPatternException(com.inova8.pathql.processor.PathPatternException) RecognitionException(org.antlr.v4.runtime.RecognitionException)

Example 2 with IntelligentGraphSail

use of com.inova8.intelligentgraph.sail.IntelligentGraphSail in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Query method createNativeLuceneIntelligentGraphRepository.

/**
 * Creates the native lucene intelligent graph repository.
 *
 * @param dir the dir
 * @return the org.eclipse.rdf 4 j.repository. repository
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws SailConfigException the sail config exception
 */
public static org.eclipse.rdf4j.repository.Repository createNativeLuceneIntelligentGraphRepository(String dir) throws IOException, SailConfigException {
    File dataDir = new File(dir);
    FileUtils.deleteDirectory(dataDir);
    IntelligentGraphConfig intelligentGraphConfig = new IntelligentGraphConfig();
    IntelligentGraphFactory intelligentGraphFactory = new IntelligentGraphFactory();
    IntelligentGraphSail intelligentGraphSail = (IntelligentGraphSail) intelligentGraphFactory.getSail(intelligentGraphConfig);
    // IntelligentGraphSail intelligentGraphSail = new IntelligentGraphSail();
    LuceneSail lucenesail = new LuceneSail();
    lucenesail.setParameter(LuceneSail.LUCENE_RAMDIR_KEY, "true");
    Sail baseSail = new NativeStore(dataDir);
    lucenesail.setBaseSail(baseSail);
    intelligentGraphSail.setBaseSail(lucenesail);
    org.eclipse.rdf4j.repository.Repository workingRep = new SailRepository(intelligentGraphSail);
    return workingRep;
}
Also used : SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) LuceneSail(org.eclipse.rdf4j.sail.lucene.LuceneSail) Sail(org.eclipse.rdf4j.sail.Sail) IntelligentGraphSail(com.inova8.intelligentgraph.sail.IntelligentGraphSail) LuceneSail(org.eclipse.rdf4j.sail.lucene.LuceneSail) NativeStore(org.eclipse.rdf4j.sail.nativerdf.NativeStore) IntelligentGraphFactory(com.inova8.intelligentgraph.sail.IntelligentGraphFactory) IntelligentGraphSail(com.inova8.intelligentgraph.sail.IntelligentGraphSail) File(java.io.File) IntelligentGraphConfig(com.inova8.intelligentgraph.sail.IntelligentGraphConfig)

Example 3 with IntelligentGraphSail

use of com.inova8.intelligentgraph.sail.IntelligentGraphSail in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Query method createNativeIntelligentGraphRepository.

/**
 * Creates the native intelligent graph repository.
 *
 * @param dir the dir
 * @return the org.eclipse.rdf 4 j.repository. repository
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws SailConfigException the sail config exception
 */
public static org.eclipse.rdf4j.repository.Repository createNativeIntelligentGraphRepository(String dir) throws IOException, SailConfigException {
    File dataDir = new File(dir);
    FileUtils.deleteDirectory(dataDir);
    IntelligentGraphConfig intelligentGraphConfig = new IntelligentGraphConfig();
    IntelligentGraphFactory intelligentGraphFactory = new IntelligentGraphFactory();
    IntelligentGraphSail intelligentGraphSail = (IntelligentGraphSail) intelligentGraphFactory.getSail(intelligentGraphConfig);
    // IntelligentGraphSail intelligentGraphSail = new IntelligentGraphSail();
    Sail baseSail = new NativeStore(dataDir);
    intelligentGraphSail.setBaseSail(baseSail);
    org.eclipse.rdf4j.repository.Repository workingRep = new SailRepository(intelligentGraphSail);
    return workingRep;
}
Also used : SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) LuceneSail(org.eclipse.rdf4j.sail.lucene.LuceneSail) Sail(org.eclipse.rdf4j.sail.Sail) IntelligentGraphSail(com.inova8.intelligentgraph.sail.IntelligentGraphSail) NativeStore(org.eclipse.rdf4j.sail.nativerdf.NativeStore) IntelligentGraphFactory(com.inova8.intelligentgraph.sail.IntelligentGraphFactory) IntelligentGraphSail(com.inova8.intelligentgraph.sail.IntelligentGraphSail) File(java.io.File) IntelligentGraphConfig(com.inova8.intelligentgraph.sail.IntelligentGraphConfig)

Example 4 with IntelligentGraphSail

use of com.inova8.intelligentgraph.sail.IntelligentGraphSail in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Query method createMemoryIntelligentGraphRepository.

/**
 * Creates the memory intelligent graph repository.
 *
 * @param dir the dir
 * @return the org.eclipse.rdf 4 j.repository. repository
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws SailConfigException the sail config exception
 */
public static org.eclipse.rdf4j.repository.Repository createMemoryIntelligentGraphRepository(String dir) throws IOException, SailConfigException {
    File dataDir = new File(dir);
    FileUtils.deleteDirectory(dataDir);
    IntelligentGraphConfig intelligentGraphConfig = new IntelligentGraphConfig();
    IntelligentGraphFactory intelligentGraphFactory = new IntelligentGraphFactory();
    IntelligentGraphSail intelligentGraphSail = (IntelligentGraphSail) intelligentGraphFactory.getSail(intelligentGraphConfig);
    Sail baseSail = new MemoryStore();
    intelligentGraphSail.setBaseSail(baseSail);
    org.eclipse.rdf4j.repository.Repository workingRep = new SailRepository(intelligentGraphSail);
    return workingRep;
}
Also used : MemoryStore(org.eclipse.rdf4j.sail.memory.MemoryStore) SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) LuceneSail(org.eclipse.rdf4j.sail.lucene.LuceneSail) Sail(org.eclipse.rdf4j.sail.Sail) IntelligentGraphSail(com.inova8.intelligentgraph.sail.IntelligentGraphSail) IntelligentGraphFactory(com.inova8.intelligentgraph.sail.IntelligentGraphFactory) IntelligentGraphSail(com.inova8.intelligentgraph.sail.IntelligentGraphSail) File(java.io.File) IntelligentGraphConfig(com.inova8.intelligentgraph.sail.IntelligentGraphConfig)

Example 5 with IntelligentGraphSail

use of com.inova8.intelligentgraph.sail.IntelligentGraphSail in project com.inova8.intelligentgraph by peterjohnlawrence.

the class IntelligentGraphRepository method create.

/**
 * Creates the.
 *
 * @param intelligentGraphConnection the intelligent graph connection
 * @return the intelligent graph repository
 */
public static IntelligentGraphRepository create(IntelligentGraphConnection intelligentGraphConnection) {
    IntelligentGraphSail sail = intelligentGraphConnection.getIntelligentGraphSail();
    Integer key = sail.hashCode();
    if (pathQLRepositories.containsKey(key)) {
        return pathQLRepositories.get(key);
    } else {
        IntelligentGraphRepository pathQLRepository = new IntelligentGraphRepository(intelligentGraphConnection);
        pathQLRepositories.put(key, pathQLRepository);
        return pathQLRepository;
    }
}
Also used : IntelligentGraphSail(com.inova8.intelligentgraph.sail.IntelligentGraphSail)

Aggregations

IntelligentGraphSail (com.inova8.intelligentgraph.sail.IntelligentGraphSail)4 IntelligentGraphConfig (com.inova8.intelligentgraph.sail.IntelligentGraphConfig)3 IntelligentGraphFactory (com.inova8.intelligentgraph.sail.IntelligentGraphFactory)3 File (java.io.File)3 SailRepository (org.eclipse.rdf4j.repository.sail.SailRepository)3 Sail (org.eclipse.rdf4j.sail.Sail)3 LuceneSail (org.eclipse.rdf4j.sail.lucene.LuceneSail)3 NativeStore (org.eclipse.rdf4j.sail.nativerdf.NativeStore)2 PathPatternException (com.inova8.pathql.processor.PathPatternException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 RecognitionException (org.antlr.v4.runtime.RecognitionException)1 Resource (org.eclipse.rdf4j.model.Resource)1 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)1 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)1 SailException (org.eclipse.rdf4j.sail.SailException)1 MemoryStore (org.eclipse.rdf4j.sail.memory.MemoryStore)1