當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryEvaluationException類代碼示例

本文整理匯總了Java中org.openrdf.query.QueryEvaluationException的典型用法代碼示例。如果您正苦於以下問題:Java QueryEvaluationException類的具體用法?Java QueryEvaluationException怎麽用?Java QueryEvaluationException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


QueryEvaluationException類屬於org.openrdf.query包,在下文中一共展示了QueryEvaluationException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: write

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
/**
 * Called by JAX-RS upon building a response.
 *
 * @param out the {@link OutputStream} to write the triples to
 * @throws IOException if there was an error during communication
 * @throws WebApplicationException if there was an error while serialising
 */
@Override
public void write(OutputStream out)
		throws IOException, WebApplicationException {
	try {
		RDFWriter writer = factory.getWriter(out);
		// evaluate query and stream result
		query.evaluate(writer);
		conn.close();
	} catch (RepositoryException |
			 QueryEvaluationException |
			 RDFHandlerException ex) {
		// server error
		close(conn, ex);
		throw new WebApplicationException(ex);
	}
}
 
開發者ID:lszeremeta,項目名稱:neo4j-sparql-extension-yars,代碼行數:24,代碼來源:SPARQLGraphStreamingOutput.java

示例2: runQuery

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
private QueryResult runQuery()
		throws IOException, QueryEvaluationException,
		       QueryResultParseException, TupleQueryResultHandlerException,
			   QueryResultHandlerException {
	TestResultHandler noninf = new TestResultHandler();
	TestResultHandler actual = new TestResultHandler();
	TestResultHandler expect = new TestResultHandler();
	parser.setQueryResultHandler(expect);
	parser.parseQueryResult(getResource(expected));
	nonInfQuery.evaluate(noninf);
	query.evaluate(actual);
	Multiset<BindingSet> noninfset = noninf.getSolutions();
	Multiset<BindingSet> expectset = expect.getSolutions();
	Multiset<BindingSet> actualset = actual.getSolutions();
	return new QueryResult(expectset, actualset, noninfset);
}
 
開發者ID:lszeremeta,項目名稱:neo4j-sparql-extension-yars,代碼行數:17,代碼來源:SPARQLInferenceTest.java

示例3: clear

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
public static void clear( IEngine engine ) throws RepositoryException {
	try {
		final Map<URI, Value> metas = engine.query( new MetadataQuery() );
		metas.remove( SEMTOOL.Database );

		engine.execute( new ModificationExecutorAdapter( true ) {

			@Override
			public void exec( RepositoryConnection conn ) throws RepositoryException {
				conn.remove( (Resource) null, null, null );
				ValueFactory vf = conn.getValueFactory();

				// re-add the metadata
				for ( Map.Entry<URI, Value> en : metas.entrySet() ) {
					conn.add( engine.getBaseUri(),
							URI.class.cast( EngineLoader.cleanValue( en.getKey(), vf ) ),
							EngineLoader.cleanValue( en.getValue(), vf ) );
				}
			}
		} );
	}
	catch ( MalformedQueryException | QueryEvaluationException e ) {
		log.error( e, e );
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:26,代碼來源:EngineUtil2.java

示例4: getReificationStyle

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
/**
 * Gets the reification model URI from the given engine
 *
 * @param engine
 * @return return the reification model, or {@link Constants#NONODE} if none
 * is defined
 */
public static ReificationStyle getReificationStyle( IEngine engine ) {
	URI reif = Constants.NONODE;
	if ( null != engine ) {
		MetadataQuery mq = new MetadataQuery( SEMTOOL.ReificationModel );
		try {
			engine.query( mq );
			Value str = mq.getOne();
			reif = ( null == str ? Constants.NONODE : URI.class.cast( str ) );
		}
		catch ( RepositoryException | MalformedQueryException | QueryEvaluationException e ) {
			// don't care
		}
	}

	return ReificationStyle.fromUri( reif );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:24,代碼來源:EngineUtil2.java

示例5: getConstruct

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
public static Model getConstruct( QueryExecutor<Model> query,
		RepositoryConnection rc, boolean dobindings )
		throws RepositoryException, MalformedQueryException, QueryEvaluationException {

	String sparql = processNamespaces( dobindings ? query.getSparql()
			: query.bindAndGetSparql(), query.getNamespaces() );

	GraphQuery tq = rc.prepareGraphQuery( QueryLanguage.SPARQL, sparql );
	tq.setIncludeInferred( query.usesInferred() );
	if ( dobindings ) {
		query.setBindings( tq, rc.getValueFactory() );
	}

	GraphQueryResult gqr = tq.evaluate();
	while ( gqr.hasNext() ) {
		query.getResults().add( gqr.next() );
	}
	gqr.close();

	return query.getResults();
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:22,代碼來源:AbstractSesameEngine.java

示例6: addGraphLevel

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
public Collection<GraphElement> addGraphLevel( Collection<URI> nodes,
		IEngine engine, int overlayLevel ) {
	try {
		for ( URI sub : nodes ) {
			SEMOSSVertex vert1 = createOrRetrieveVertex( sub, overlayLevel );
			vizgraph.addVertex( vert1 );
		}

		fetchProperties( nodes, null, engine, overlayLevel );
	}
	catch ( RepositoryException | QueryEvaluationException e ) {
		log.error( e, e );
	}

	fireModelChanged( overlayLevel );
	return elementsFromLevel( overlayLevel );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:18,代碼來源:GraphDataModel.java

示例7: actionPerformed

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
@Override
public void actionPerformed( ActionEvent ae ) {
	ProgressTask pt = new ProgressTask( "Expanding Graph", new Runnable() {
		
		@Override
		public void run() {
			try {
				Model model = gps.getEngine().construct( mqa );
				gps.overlay( model, gps.getEngine() );
			}
			catch ( RepositoryException | MalformedQueryException | QueryEvaluationException e ) {
				logger.error( e, e );
				GuiUtility.showError( e.getLocalizedMessage() );
			}
		}
	} );
	
	OperationsProgress.getInstance( PlayPane.UIPROGRESS ).add( pt );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:20,代碼來源:NeighborMenuItem.java

示例8: getAllPossibleProperties

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
protected static Collection<URI> getAllPossibleProperties( URI type, IEngine engine ) {
	String query = "SELECT DISTINCT ?pred WHERE { ?s ?pred ?o . ?s a ?type . FILTER ( isLiteral( ?o ) ) }";
	ListQueryAdapter<URI> qa = OneVarListQueryAdapter.getUriList( query, "pred" );
	qa.bind( "type", type );

	List<URI> props = new ArrayList<>();
	props.add( Constants.ANYNODE );
	try {
		props.addAll( engine.query( qa ) );
	}
	catch ( RepositoryException | MalformedQueryException | QueryEvaluationException e ) {
		log.error( e, e );
	}

	return props;
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:17,代碼來源:NodeEdgeBasePopup.java

示例9: refreshInverseOf

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
private void refreshInverseOf() throws QueryEvaluationException {
    final CloseableIteration<Statement, QueryEvaluationException> iter = RyaDAOHelper.query(ryaDAO, null, OWL.INVERSEOF, null, conf);
    final Map<URI, URI> invProp = new HashMap<>();
    try {
        while (iter.hasNext()) {
            final Statement st = iter.next();
            invProp.put((URI) st.getSubject(), (URI) st.getObject());
            invProp.put((URI) st.getObject(), (URI) st.getSubject());
        }
    } finally {
        if (iter != null) {
            iter.close();
        }
    }
    synchronized(inverseOfMap) {
        inverseOfMap.clear();
        inverseOfMap.putAll(invProp);
    }
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:20,代碼來源:InferenceEngine.java

示例10: refreshSomeValuesFromRestrictions

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
private void refreshSomeValuesFromRestrictions(final Map<Resource, URI> restrictions) throws QueryEvaluationException {
    someValuesFromByRestrictionType.clear();
    ryaDaoQueryWrapper.queryAll(null, OWL.SOMEVALUESFROM, null, new RDFHandlerBase() {
        @Override
        public void handleStatement(final Statement statement) throws RDFHandlerException {
            final Resource restrictionClass = statement.getSubject();
            if (restrictions.containsKey(restrictionClass) && statement.getObject() instanceof Resource) {
                final URI property = restrictions.get(restrictionClass);
                final Resource valueClass = (Resource) statement.getObject();
                // Should also be triggered by subclasses of the value class
                final Set<Resource> valueClasses = new HashSet<>();
                valueClasses.add(valueClass);
                if (valueClass instanceof URI) {
                    valueClasses.addAll(getSubClasses((URI) valueClass));
                }
                for (final Resource valueSubClass : valueClasses) {
                    if (!someValuesFromByRestrictionType.containsKey(restrictionClass)) {
                        someValuesFromByRestrictionType.put(restrictionClass, new ConcurrentHashMap<>());
                    }
                    someValuesFromByRestrictionType.get(restrictionClass).put(valueSubClass, property);
                }
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:26,代碼來源:InferenceEngine.java

示例11: getResourcesFromContext

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
/**
 * Returns all resources that exist in a specific context.
 * @param context The context from which to get resources.
 * @return All resources (IRIs) that are present in {@code context}.
 * @throws RepositoryException Thrown if an error occurs while querying the repository.
 */
private Set<ResourceObject> getResourcesFromContext(URI context) throws RepositoryException {
    try {
        String q = QUERY_PREFIX + "SELECT ?o " +
                "FROM NAMED <" + context.toString() + "> " +
                "{" +
                "   GRAPH <" + context.toString() + "> {" +
                "       { ?o ?p ?x . } UNION { ?x ?p ?o . }" +
                "       FILTER ( isIRI(?o) )" +
                "   }" +
                "}";

        Set<ResourceObject> resources = new HashSet<>();
        for (Object current : getConnection().prepareObjectQuery(q).evaluate().asSet()) {
            if(current instanceof ResourceObject) {
                resources.add((ResourceObject) current);
            }
        }

        return resources;

    } catch (QueryEvaluationException | MalformedQueryException e) {
        throw new RepositoryException(e);
    }
}
 
開發者ID:anno4j,項目名稱:anno4j,代碼行數:31,代碼來源:ValidatedTransaction.java

示例12: evaluate

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
@Override
public CloseableIteration<BindingSet,QueryEvaluationException> evaluate(Collection<BindingSet> bindingset) throws QueryEvaluationException {

    if(bindingset.size() < 2 && !this.evalOptUsed) {
        BindingSet bs = new QueryBindingSet();
        if (bindingset.size() == 1) {
            bs = bindingset.iterator().next();
        }
        return this.evaluate(bs);
    }
    //TODO possibly refactor if bindingset.size() > 0 to take advantage of optimization in evaluate(BindingSet bindingset)
    AccumuloDocIdIndexer adi = null;
    try {
        adi = new AccumuloDocIdIndexer(conf);
        return adi.queryDocIndex(starQuery, bindingset);
    } catch (Exception e) {
        throw new QueryEvaluationException(e);
    } finally {
        IOUtils.closeQuietly(adi);
    }
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:22,代碼來源:EntityTupleSet.java

示例13: FederationEvalStrategy

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
/**
	 * Creates a new Evaluation strategy using the supplied source finder.
	 * 
	 * @param finder the source finder to use.
	 * @param vf the value factory to use.
	 */
	public FederationEvalStrategy(final ValueFactory vf) {
	
		// use a dummy triple source
		// it can handle only single triple patterns but no basic graph patterns
		super(new TripleSource() {
			@Override public ValueFactory getValueFactory() {
				return vf;
			}
//			@Override public Cursor<? extends Statement> getStatements(
//					Resource subj, URI pred, Value obj, Resource... contexts) throws StoreException {
			@Override public CloseableIteration<? extends Statement, QueryEvaluationException> getStatements(
					Resource subj, URI pred, Value obj, Resource... contexts) throws QueryEvaluationException {
				throw new UnsupportedOperationException("Statement retrieval is not supported in federation");
			}
		});
	}
 
開發者ID:goerlitz,項目名稱:rdffederator,代碼行數:23,代碼來源:FederationEvalStrategy.java

示例14: getDistinctClasses

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
/**
 * Returns buildable named resource objects of RDFS classes that were found during
 * the last call to {@link #build()} which are pairwise distinct,
 * i.e. that are not declared equivalent.
 * @return All pairwise distinct named classes in the repository.
 * @throws RepositoryException Thrown if an error occurs while querying the repository.
 */
private Collection<BuildableRDFSClazz> getDistinctClasses() throws RepositoryException {
    try {
        ObjectConnection connection = anno4j.getObjectRepository().getConnection();
        ObjectQuery query = connection.prepareObjectQuery(
                "SELECT DISTINCT ?c {\n" +
                "   ?c rdfs:subClassOf+ owl:Thing . \n" +
                "   MINUS {\n" +
                "       ?e owl:equivalentClass ?c . \n" +
                "       FILTER(str(?e) < str(?c))\n" + // Impose order on equivalence. Pick only first lexicographical
                "   }\n" +
                "   FILTER( isIRI(?c) )\n" +
                "}"
        );

        return query.evaluate(BuildableRDFSClazz.class).asSet();

    } catch (MalformedQueryException | QueryEvaluationException e) {
        throw new RepositoryException(e);
    }
}
 
開發者ID:anno4j,項目名稱:anno4j,代碼行數:28,代碼來源:OWLJavaFileGenerator.java

示例15: testStringCombinationQueryWithDefaults

import org.openrdf.query.QueryEvaluationException; //導入依賴的package包/類
@Test
public void testStringCombinationQueryWithDefaults() throws QueryEvaluationException, MalformedQueryException, RepositoryException {

    StringQueryDefinition stringDef = qmgr.newStringDefinition().withCriteria("First");
    String posQuery = "ASK WHERE {<http://example.org/r9928> ?p ?o .}";
    String negQuery = "ASK WHERE {<http://example.org/r9929> ?p ?o .}";

    conn.setDefaultConstrainingQueryDefinition(stringDef);

    MarkLogicBooleanQuery askQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL,posQuery);
    Assert.assertEquals(true, askQuery.evaluate());

    askQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL,negQuery);
    askQuery.setConstrainingQueryDefinition(stringDef);
    Assert.assertEquals(false, askQuery.evaluate());

}
 
開發者ID:marklogic,項目名稱:marklogic-sesame,代碼行數:18,代碼來源:MarkLogicCombinationQueryTest.java


注:本文中的org.openrdf.query.QueryEvaluationException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。