本文整理汇总了Java中org.openrdf.repository.RepositoryConnection.add方法的典型用法代码示例。如果您正苦于以下问题:Java RepositoryConnection.add方法的具体用法?Java RepositoryConnection.add怎么用?Java RepositoryConnection.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.repository.RepositoryConnection
的用法示例。
在下文中一共展示了RepositoryConnection.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToGraphstore
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的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);
}
}
}
示例2: create
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public DbInfo create( DbInfo t ) throws Exception {
RepositoryConnection rc = store.getConnection();
UriBuilder urib = UriBuilder.getBuilder( WEBDS.NAMESPACE + "dbinfo" );
URI uri = urib.uniqueUri();
rc.begin();
try{
rc.add( getCreateStatements( uri, t, rc.getValueFactory() ) );
rc.commit();
}
catch( RepositoryException re ){
rc.rollback();
throw re;
}
return t;
}
示例3: update
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public void update( DbInfo data ) throws Exception {
RepositoryConnection rc = store.getConnection();
Resource id = getId( data, rc );
if ( null != id ) {
try{
rc.begin();
rc.remove( id, null, null );
rc.add( getCreateStatements( id, data, rc.getValueFactory() ) );
rc.commit();
}
catch( RepositoryException re ){
rc.rollback();
throw re;
}
}
}
示例4: update
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public void update( User user ) throws Exception {
RepositoryConnection rc = store.getConnection();
try {
Map<URI, DbAccess> accesses = getAccesses( user );
Resource id = getId( user, rc );
if ( null != id ) {
rc.begin();
rc.remove( id, null, null );
rc.add( getCreateStatements( id, user, rc.getValueFactory() ) );
addAccesses( id, accesses, rc );
rc.commit();
}
}
catch ( RepositoryException e ) {
log.error( e, e );
try {
rc.rollback();
}
catch ( Exception x ) {
log.warn( x, x );
}
}
}
示例5: save
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
private void save( Model model ) {
// get old model, which we'll remove
Model olds = getModel();
ModificationExecutor eme = new ModificationExecutorAdapter( true ) {
@Override
public void exec( RepositoryConnection conn ) throws RepositoryException {
conn.remove( olds );
conn.add( model );
}
};
try {
engine.execute( eme );
}
catch ( Exception e ) {
log.error( e, e );
}
}
示例6: testCreateFromRepository
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Test
public void testCreateFromRepository() throws Exception {
Repository repo = new SailRepository( new MemoryStore() );
repo.initialize();
RepositoryConnection rc = repo.getConnection();
rc.add( SRCFILE, null, RDFFormat.TURTLE );
rc.commit();
rc.close();
InsightManager imi = InsightManagerImpl.createFromRepository( repo );
repo.shutDown();
assertEquals( 1, imi.getPerspectives().size() );
}
示例7: setUpClass
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
eng = InMemorySesameEngine.open();
RepositoryConnection rc = eng.getRawConnection();
rc.begin();
rc.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL, new LiteralImpl( "test" ) ) );
rc.commit();
}
示例8: addFile
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
* Import RDF data from a file
*
* @param location
* of file (/path/file) with RDF data
* @param format
* RDF format of the string (used to select parser)
*/
public void addFile(String filepath, RDFFormat format) {
try {
RepositoryConnection con = therepository.getConnection();
try {
con.add(new File(filepath), "", format, new Resource[0]);
} finally {
con.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: setUpClass
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
eng = InMemorySesameEngine.open();
RepositoryConnection rc = eng.getRawConnection();
rc.begin();
rc.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL, new LiteralImpl( "test" ) ) );
// DC.PULISHER should get silently upgraded to MetadataConstants.DCT_PUBLISHER
rc.add( new StatementImpl( eng.getBaseUri(), DC.PUBLISHER,
new LiteralImpl( "me" ) ) );
rc.add(new StatementImpl( eng.getBaseUri(), RDF.TYPE, SEMTOOL.Database ) );
rc.commit();
}
示例10: create
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public User create( User t ) throws Exception {
RepositoryConnection rc = store.getConnection();
UriBuilder urib = UriBuilder.getBuilder( WEBDS.NAMESPACE + "user" );
try {
rc.add( getCreateStatements( urib.uniqueUri(), t, rc.getValueFactory() ) );
}
catch ( RepositoryException e ) {
log.error( e, e );
}
return t;
}
示例11: setupClass
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@BeforeClass
public static void setupClass() {
TimeZone.setDefault( TimeZone.getTimeZone( "GMT-04:00" ) );
engine = InMemorySesameEngine.open();
try {
RepositoryConnection rc = engine.getRawConnection();
GregorianCalendar gCalendar = new GregorianCalendar();
gCalendar.setTime( date );
XMLGregorianCalendar xmlcal = null;
try {
xmlcal = DatatypeFactory.newInstance().newXMLGregorianCalendar( gCalendar );
}
catch ( DatatypeConfigurationException ex ) {
}
ValueFactory vf = rc.getValueFactory();
rc.add( new StatementImpl( ENTITYONE, RDF.TYPE, TYPEONE ) );
rc.add( new StatementImpl( ENTITYONE, TYPEB, vf.createLiteral( true ) ) );
rc.add( new StatementImpl( ENTITYONE, TYPED, vf.createLiteral( 1.0 ) ) );
rc.add( new StatementImpl( ENTITYONE, TYPEI, vf.createLiteral( 1 ) ) );
rc.add( new StatementImpl( ENTITYONE, TYPES, vf.createLiteral( "string" ) ) );
rc.add( new StatementImpl( ENTITYONE, TYPES, vf.createLiteral( "cuerda", "es" ) ) );
rc.add( new StatementImpl( ENTITYONE, TYPEA, vf.createLiteral( xmlcal ) ) );
}
catch ( Exception e ) {
}
}
示例12: getExpectedGraph
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
private static Model getExpectedGraph( File rdf ) {
SailRepository repo = new SailRepository( new MemoryStore() );
RepositoryConnection expectedrc = null;
List<Statement> stmts = new ArrayList<>();
try {
repo.initialize();
expectedrc = repo.getConnection();
expectedrc.add( rdf, null, RDFFormat.TURTLE );
stmts.addAll( Iterations.asList( expectedrc.getStatements( null, null,
null, true ) ) );
}
catch ( RepositoryException | IOException | RDFParseException e ) {
}
finally {
if ( null != expectedrc ) {
try {
expectedrc.close();
}
catch ( Exception ex ) {
// don't care
}
try {
repo.shutDown();
}
catch ( Exception exc ) {
// don't care
}
}
}
return new LinkedHashModel( stmts );
}
示例13: addNode
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public URI addNode( LoadingNodeAndPropertyValues nap, Map<String, String> namespaces,
LoadingSheetData sheet, ImportMetadata metas, RepositoryConnection myrc ) throws RepositoryException {
String typename = nap.getSubjectType();
String rawlabel = nap.getSubject();
URI subject = addSimpleNode( typename, rawlabel, namespaces, metas, myrc );
ValueFactory vf = myrc.getValueFactory();
boolean savelabel = metas.isAutocreateMetamodel();
if ( !metas.isLegacyMode() && rawlabel.contains( ":" ) ) {
// we have something with a colon in it, so we need to figure out if it's
// a namespace-prefixed string, or just a string with a colon in it
Value val = getRDFStringValue( rawlabel, namespaces, vf );
// check if we have a prefixed URI
URI u = getUriFromRawString( rawlabel, namespaces );
savelabel = ( savelabel && null == u );
rawlabel = val.stringValue();
}
// if we have a label property, skip this label-making
// (it'll get handled in the addProperties function later)
if ( savelabel && !nap.hasProperty( RDFS.LABEL, namespaces ) ) {
myrc.add( subject, RDFS.LABEL, vf.createLiteral( rawlabel ) );
}
addProperties( subject, nap, namespaces, sheet, metas, myrc );
return subject;
}
示例14: addNode
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public URI addNode( LoadingSheetData.LoadingNodeAndPropertyValues nap,
Map<String, String> namespaces, LoadingSheetData sheet, ImportMetadata metas,
RepositoryConnection myrc ) throws RepositoryException {
String typename = nap.getSubjectType();
String rawlabel = nap.getSubject();
URI subject = addSimpleNode( typename, rawlabel, namespaces, metas, myrc, true );
ValueFactory vf = myrc.getValueFactory();
boolean savelabel = metas.isAutocreateMetamodel();
if ( rawlabel.contains( ":" ) ) {
// we have something with a colon in it, so we need to figure out if it's
// a namespace-prefixed string, or just a string with a colon in it
Value val = getRDFStringValue( rawlabel, namespaces, vf );
// check if we have a prefixed URI
URI u = getUriFromRawString( rawlabel, namespaces );
savelabel = ( savelabel && null == u );
rawlabel = val.stringValue();
}
// if we have a label property, skip this label-making
// (it'll get handled in the addProperties function later)
if ( savelabel && !nap.hasProperty( RDFS.LABEL, namespaces ) ) {
myrc.add( subject, RDFS.LABEL, vf.createLiteral( rawlabel ) );
}
addProperties( subject, nap, namespaces, sheet, metas, myrc );
return subject;
}
示例15: setUp
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Before
public void setUp() {
engine = InMemorySesameEngine.open();
try {
RepositoryConnection rc = engine.getRawConnection();
rc.add(bldr.toUri(), RDF.TYPE, SEMTOOL.Database );
}
catch ( Exception e ) {
}
}