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);
}
}
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;
}
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;
}
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;
}
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;
}
}
Aggregations