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


Java RDFHandlerException類代碼示例

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


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

示例1: addToGraphstore

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
/**
 * Helper method for handleAdd.
 */
private void addToGraphstore(
		RepositoryConnection conn,
		InputStream in,
		String base,
		RDFFormat format,
		Resource dctx,
		boolean chunked) throws IOException, RDFParseException,
		RDFHandlerException, RepositoryException {
	if (chunked) {
		RDFParser parser = getRDFParser(format);
		parser.setRDFHandler(
				new ChunkedCommitHandler(conn, chunksize, dctx));
		parser.parse(in, base);
	} else {
		if (dctx != null) {
			conn.add(in, base, format, dctx);
		} else {
			conn.add(in, base, format);
		}
	}
}
 
開發者ID:lszeremeta,項目名稱:neo4j-sparql-extension-yars,代碼行數:25,代碼來源:GraphStore.java

示例2: write

import org.openrdf.rio.RDFHandlerException; //導入依賴的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 {
		// get an RDF writer to stream the triples
		RDFWriter writer = factory.getWriter(out);
		// export triples from graphs
		conn.export(writer, contexts);
		conn.close();
	} catch (RepositoryException | RDFHandlerException ex) {
		// server error
		close(conn, ex);
		throw new WebApplicationException(ex);
	}
}
 
開發者ID:lszeremeta,項目名稱:neo4j-sparql-extension-yars,代碼行數:23,代碼來源:RDFStreamingOutput.java

示例3: write

import org.openrdf.rio.RDFHandlerException; //導入依賴的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

示例4: handleStatement

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
/**
 * Handles a statement.
 * 
 * The statements will be added up until chunk size is reached.
 * After a chunk of statements is added the transaction will be committed
 * and new transaction will be started.
 * @param stmnt
 * @throws RDFHandlerException 
 */
@Override
public void handleStatement(Statement stmnt) throws RDFHandlerException {
	try {
		// check if triple should be added to a specific graph
		if (dctx != null) {
			conn.add(stmnt, dctx);
		} else {
			conn.add(stmnt);
		}
		// check if chunk size is reached and transaction should be
		// committed
		count++;
		if (count >= size) {
			count = 0;
			conn.commit();
			conn.begin();
		}
	} catch (RepositoryException ex) {
		throw new RDFHandlerException(ex);
	}
}
 
開發者ID:lszeremeta,項目名稱:neo4j-sparql-extension-yars,代碼行數:31,代碼來源:ChunkedCommitHandler.java

示例5: getCopier

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
private static RepositoryCopier getCopier( RepositoryConnection conn,
		Map<URI, URI> fromto, URI schema, URI data ) {
	final UriBuilder owlb = UriBuilder.getBuilder( schema );
	final UriBuilder datab = UriBuilder.getBuilder( data );

	return new RepositoryCopier( conn ) {

		@Override
		public void handleStatement( Statement stmt ) throws RDFHandlerException {
			URI sub = URI.class.cast( stmt.getSubject() );
			URI pred = stmt.getPredicate();
			Value obj = stmt.getObject();

			sub = upgrade( sub, fromto, owlb, datab );
			pred = upgrade( pred, fromto, owlb, datab );
			if ( obj instanceof URI ) {
				obj = upgrade( URI.class.cast( obj ), fromto, owlb, datab );
			}

			super.handleStatement( new StatementImpl( sub, pred, obj ) );
		}
	};
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:24,代碼來源:LegacyUpgrader.java

示例6: handleStatement

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
@Override
public void handleStatement( Statement stmt ) throws RDFHandlerException {
	try {
		// RPB: need to rebox these statements because BigData blows up if
		// you try to copy one statement to another repository
		conn.add( EngineLoader.cleanStatement( stmt, conn.getValueFactory() ) );
		adds++;
		totalAdds++;
		if ( adds >= commitlimit ) {
			log.debug( "committed " + totalAdds + " statements..." );
			conn.commit();
			conn.begin();
			adds = 0;
		}
	}
	catch ( Exception e ) {
		try {
			conn.rollback();
		}
		catch ( Exception ex ) {
			throw new RDFHandlerException( ex );
		}
		throw new RDFHandlerException( e );
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:26,代碼來源:RepositoryCopier.java

示例7: copyToTdb

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
private void copyToTdb() throws RepositoryException {
	if ( !needsSave || null == tdbdir ) {
		return;
	}

	final Dataset dataset = TDBFactory.createDataset( tdbdir.getAbsolutePath() );

	try {
		rc.export( new TdbExporter( dataset ) );
	}
	catch ( RepositoryException | RDFHandlerException e ) {
		log.error( "Problem exporting data to TDB", e );
		dataset.abort();
	}
	finally {
		dataset.close();
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:19,代碼來源:JenaEngine.java

示例8: toByteArray

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
public static byte[] toByteArray(Set<Statement> statements) {
	ByteArrayOutputStream os = new ByteArrayOutputStream();
	RDFHandler rdfHandler = new BinaryRDFWriter(os);

	try {
		rdfHandler.startRDF();

		for (Statement statement : statements) {
			rdfHandler.handleStatement(statement);
		}

		rdfHandler.endRDF();
	} catch (RDFHandlerException e) {
		e.printStackTrace();
	}

	return os.toByteArray();
}
 
開發者ID:markusstocker,項目名稱:emrooz,代碼行數:19,代碼來源:StatementUtils.java

示例9: furtherSplit

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
/**
 * Subdivides the files in a given directory if they exceed a certain count of statements
 * @param inDir
 * @throws IOException
 * @throws FileNotFoundException
 * @throws RDFHandlerException 
 */
private static void furtherSplit(File inDir) throws IOException, FileNotFoundException, RDFHandlerException {
    long stmtsPerFile = 200000;
    long resourcesPerFile = 50000;

    ArrayList<File> fileList = findLongFiles(inDir, stmtsPerFile);

    for (File f : fileList) {
        int idx = f.getAbsolutePath().lastIndexOf(".");
        String prefix = f.getAbsolutePath().substring(0, idx);
        prefix = prefix + "_";
        Splitter.split(f, prefix, resourcesPerFile);
        f.delete();
    }

}
 
開發者ID:linked-swissbib,項目名稱:reshaperdf,代碼行數:23,代碼來源:BlockCommand.java

示例10: representRdfXml

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
private Representation representRdfXml( final EntityState entity )
    throws ResourceException
{
    Representation representation = new WriterRepresentation( MediaType.APPLICATION_RDF_XML )
    {
        @Override
        public void write( Writer writer )
            throws IOException
        {
            try
            {
                Iterable<Statement> statements = entitySerializer.serialize( entity );
                new RdfXmlSerializer().serialize( statements, writer );
            }
            catch( RDFHandlerException e )
            {
                throw new IOException( e );
            }
        }
    };
    representation.setCharacterSet( CharacterSet.UTF_8 );
    return representation;
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:24,代碼來源:EntityResource.java

示例11: writePredicateStatToVoid

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
private void writePredicateStatToVoid(URI dataset, URI predicate, long pCount, int distS, int distO) {
	BNode propPartition = vf.createBNode();
	Literal count = vf.createLiteral(String.valueOf(pCount));
	Literal distinctS  = vf.createLiteral(String.valueOf(distS));
	Literal distinctO  = vf.createLiteral(String.valueOf(distO));
	try {
		writer.handleStatement(vf.createStatement(dataset, vf.createURI(VOID2.propertyPartition.toString()), propPartition));
		writer.handleStatement(vf.createStatement(propPartition, vf.createURI(VOID2.property.toString()), predicate));
		writer.handleStatement(vf.createStatement(propPartition, vf.createURI(VOID2.triples.toString()), count));
		writer.handleStatement(vf.createStatement(propPartition, vf.createURI(VOID2.distinctSubjects.toString()), distinctS));
		writer.handleStatement(vf.createStatement(propPartition, vf.createURI(VOID2.distinctObjects.toString()), distinctO));
	} catch (RDFHandlerException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
開發者ID:goerlitz,項目名稱:rdffederator,代碼行數:17,代碼來源:NXVoidGenerator.java

示例12: testEntitySerializer

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
@Test
public void testEntitySerializer()
    throws RDFHandlerException
{
    EntityReference entityReference = EntityReference.parseEntityReference( "test2" );
    Usecase usecase = UsecaseBuilder.newUsecase( "Test" );
    Instant currentTime = SystemTime.now();
    EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( module, usecase, currentTime );
    EntityState entityState = unitOfWork.entityStateOf( module, entityReference );

    Iterable<Statement> graph = serializer.serialize( entityState );

    String[] prefixes = new String[]{ "rdf", "dc", " vc" };
    String[] namespaces = new String[]{ Rdfs.RDF, DcRdf.NAMESPACE, "http://www.w3.org/2001/vcard-rdf/3.0#" };

    new RdfXmlSerializer().serialize( graph, new PrintWriter( System.out ), prefixes, namespaces );
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:18,代碼來源:EntitySerializerTest.java

示例13: refreshSomeValuesFromRestrictions

import org.openrdf.rio.RDFHandlerException; //導入依賴的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

示例14: refreshAllValuesFromRestrictions

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

示例15: sparqlQuery

import org.openrdf.rio.RDFHandlerException; //導入依賴的package包/類
protected void sparqlQuery(final Exchange exchange, final Collection<String> queries) throws RepositoryException, MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, RDFHandlerException {

        final List list = new ArrayList();
        for (final String query : queries) {

//            Long startTime = exchange.getIn().getHeader(START_TIME_QUERY_PROP, Long.class);
//            Long ttl = exchange.getIn().getHeader(TTL_QUERY_PROP, Long.class);
            final String auth = exchange.getIn().getHeader(CONF_QUERY_AUTH, String.class);
            final Boolean infer = exchange.getIn().getHeader(CONF_INFER, Boolean.class);

            final Object output = performSelect(query, auth, infer);
            if (queries.size() == 1) {
                exchange.getOut().setBody(output);
                return;
            } else {
                list.add(output);
            }

        }
        exchange.getOut().setBody(list);
    }
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:22,代碼來源:CbSailProducer.java


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