本文整理汇总了Java中org.openrdf.repository.RepositoryConnection.commit方法的典型用法代码示例。如果您正苦于以下问题:Java RepositoryConnection.commit方法的具体用法?Java RepositoryConnection.commit怎么用?Java RepositoryConnection.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.repository.RepositoryConnection
的用法示例。
在下文中一共展示了RepositoryConnection.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: remove
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public void remove( DbInfo t ) throws Exception {
RepositoryConnection rc = store.getConnection();
Resource idToRemove = getId( t, rc );
if ( null != idToRemove ) {
try{
rc.begin();
rc.remove( idToRemove, null, null );
rc.commit();
}
catch( RepositoryException re ){
rc.rollback();
throw re;
}
}
}
示例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: setUp
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
eng = InMemorySesameEngine.open();
RepositoryConnection rc = eng.getRawConnection();
rc.begin();
rc.add( DATA, null, RDFFormat.NTRIPLES );
rc.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
new LiteralImpl( "label" ) ) );
rc.remove( eng.getBaseUri(), MetadataConstants.DCT_MODIFIED, null );
rc.add( eng.getBaseUri(), MetadataConstants.DCT_MODIFIED,
rc.getValueFactory().createLiteral( new Date() ) );
rc.commit();
}
示例5: setAccesses
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
* Sets the access level from the given map. To remove access from a DB, user
* {@link DbAccess#NONE}.
*
* @param user
* @param access a mapping of URIs (either {@link DbInfo#getDataUrl()} or
* {@link DbInfo#getInsightsUrl()}) and the access given
*/
public void setAccesses( User user, Map<URI, DbAccess> access ) {
RepositoryConnection rc = store.getConnection();
try {
rc.begin();
Resource id = getId( user, rc );
addAccesses( id, access, rc );
rc.commit();
}
catch ( RepositoryException e ) {
log.error( e, e );
try {
rc.rollback();
}
catch ( Exception x ) {
log.warn( x, x );
}
}
}
示例6: execute
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public void execute( ModificationExecutor exe ) throws RepositoryException {
RepositoryConnection rc = getRawConnection();
try {
if ( exe.execInTransaction() ) {
rc.begin();
}
exe.exec( rc );
if ( exe.execInTransaction() ) {
rc.commit();
}
}
catch ( RepositoryException e ) {
if ( exe.execInTransaction() ) {
rc.rollback();
}
throw e;
}
}
示例7: moveStagingToEngine
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
* Moves the statements from the loading RC to the given engine. The internal
* repository is committed before the copy happens
*
* @param engine
* @param copyowls
* @param fileJustLoaded the file that was just loaded
* @return the metamodel statements. Will always be empty if
* <code>copyowls</code> is false
* @throws RepositoryException
*/
private void moveStagingToEngine( IEngine engine,
boolean copyowls ) throws RepositoryException {
myrc.commit();
log.debug( "moving staging data to engine" );
final RepositoryResult<Statement> stmts
= myrc.getStatements( null, null, null, false );
// we're done importing the files, so add all the statements to our engine
ModificationExecutor mea = new ModificationExecutorAdapter() {
@Override
public void exec( RepositoryConnection conn ) throws RepositoryException {
initNamespaces( conn );
conn.begin();
conn.add( stmts );
if ( copyowls ) {
conn.add( metamodel );
}
conn.commit();
}
};
engine.execute( mea );
if ( log.isTraceEnabled() ) {
File exportfile
= new File( FileUtils.getTempDirectory(), "file-load-export.nt" );
try ( Writer fw = new BufferedWriter( new FileWriter( exportfile ) ) ) {
myrc.export( new NTriplesWriter( fw ) );
}
catch ( RDFHandlerException | IOException ioe ) {
log.warn( ioe, ioe );
}
}
}
示例8: initNamespaces
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
* Method to add the common namespaces into the namespace hash of our
* RepositoryConnection. This function starts and commits a transaction.
*
* @param conn the connection to add the namespaces to
*
* @throws org.openrdf.repository.RepositoryException
*/
private static void initNamespaces( RepositoryConnection conn ) throws RepositoryException {
conn.begin();
for ( Map.Entry<String, String> e : Utility.DEFAULTNAMESPACES.entrySet() ) {
conn.setNamespace( e.getKey(), e.getValue() );
}
conn.commit();
}
示例9: setUp
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
eng = InMemorySesameEngine.open();
eng.setBuilders( datab, owlb );
RepositoryConnection rc = eng.getRawConnection();
rc.begin();
rc.add( DATAFILE, null, RDFFormat.NTRIPLES );
rc.commit();
}
示例10: commit
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public void commit() {
try {
RepositoryConnection rc = getRawConnection();
// updateLastModifiedDate();
rc.commit();
}
catch ( Exception e ) {
log.error( e, e );
}
}
示例11: 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();
}
示例12: 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();
}
示例13: 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() );
}
示例14: setUpClass
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
engine = InMemorySesameEngine.open();
engine.setBuilders( datab, UriBuilder.getBuilder( "http://os-em.com/ontologies/semtool/" ) );
RepositoryConnection rc = engine.getRawConnection();
rc.begin();
rc.add( LOADFILE, null, RDFFormat.NTRIPLES );
for ( URI extra : new URI[]{ YIGO, YUGO2, YUGO3 } ) {
rc.add( new StatementImpl( extra, RDF.TYPE, CAR ) );
rc.add( new StatementImpl( extra, RDFS.LABEL,
new LiteralImpl( extra.getLocalName() ) ) );
}
//rc.add( new StatementImpl( REL2, RDF.TYPE, REL ) );
rc.add( new StatementImpl( REL2, RDFS.LABEL, new LiteralImpl( "Yuri Purchased a Yigo" ) ) );
rc.add( new StatementImpl( REL2, RDFS.SUBPROPERTYOF, PURCHASE ) );
rc.add( new StatementImpl( REL2, new URIImpl( "http://os-em.com/ontologies/semtool/Price" ),
new LiteralImpl( "8000 USD" ) ) );
rc.remove( REL1, null, null );
rc.add( new StatementImpl( REL1, RDFS.LABEL, new LiteralImpl( "Yuri Purchased Yugo" ) ) );
rc.add( new StatementImpl( REL1, RDFS.SUBPROPERTYOF, PURCHASE ) );
rc.add( new StatementImpl( REL1, new URIImpl( "http://os-em.com/ontologies/semtool/Price" ),
new LiteralImpl( "3000 USD" ) ) );
rc.commit();
if ( log.isTraceEnabled() ) {
File tmpdir = FileUtils.getTempDirectory();
try ( Writer w = new BufferedWriter( new FileWriter( new File( tmpdir,
"ecctest.ttl" ) ) ) ) {
engine.getRawConnection().export( new TurtleWriter( w ) );
}
}
}
示例15: testLoadCachesLegacy
import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Test
public void testLoadCachesLegacy() throws Exception {
engine.setBuilders( UriBuilder.getBuilder( BASEURI ), OWLB );
RepositoryConnection rc = engine.getRawConnection();
rc.begin();
rc.add( new URIImpl( "http://junk.com/testfiles/Concept/Category/Beverages" ),
new URIImpl( "http://owl.junk.com/testfiles/Description" ),
new LiteralImpl( "Soft drinks, coffees, teas, beers, and ales" ) );
rc.add( new URIImpl( "http://junk.com/testfiles/Concept/Category/Beverages" ),
RDF.TYPE, new URIImpl( "http://owl.junk.com/testfiles/Category" ) );
rc.add( new URIImpl( "http://junk.com/testfiles/Concept/Category/Beverages" ),
RDFS.LABEL, new LiteralImpl( "Beverages" ) );
rc.add( new URIImpl( "http://junk.com/testfiles/Concept/Product/Chai" ),
new URIImpl( "http://junk.com/testfiles/Relation/Category/Chai_x_Beverages" ),
new URIImpl( "http://junk.com/testfiles/Concept/Category/Beverages" ) );
rc.add( new URIImpl( "http://junk.com/testfiles/Concept/Product/Chai" ),
RDF.TYPE, new URIImpl( "http://owl.junk.com/testfiles/Product" ) );
rc.add( new URIImpl( "http://junk.com/testfiles/Concept/Product/Chai" ),
RDFS.LABEL, new LiteralImpl( "Chai" ) );
rc.add( new URIImpl( "http://junk.com/testfiles/Concept/Product/Chang" ),
new URIImpl( "http://junk.com/testfiles/Relation/Category/Chang_x_Beverages" ),
new URIImpl( "http://junk.com/testfiles/Concept/Category/Beverages" ) );
rc.add( new URIImpl( "http://junk.com/testfiles/Relation/Category/Chai_x_Beverages" ),
new URIImpl( "http://owl.junk.com/testfiles/extraprop" ),
new LiteralImpl( "1.0", new URIImpl( "http://www.w3.org/2001/XMLSchema#double" ) ) );
rc.add( new URIImpl( "http://junk.com/testfiles/Relation/Category/Chai_x_Beverages" ),
RDFS.LABEL, new LiteralImpl( "Chai Category Beverages" ) );
rc.add( new URIImpl( "http://junk.com/testfiles/Relation/Category/Chai_x_Beverages" ),
RDFS.SUBPROPERTYOF, new URIImpl( "http://owl.junk.com/testfiles/Relation/Category" ) );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Relation/Category" ),
RDF.TYPE, OWL.OBJECTPROPERTY );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Relation/Category" ),
RDFS.LABEL, new LiteralImpl( "Category" ) );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Relation/Category" ),
RDFS.SUBPROPERTYOF, new URIImpl( "http://owl.junk.com/testfiles/Relation" ) );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Description" ),
RDFS.LABEL, new LiteralImpl( "Description" ) );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Description" ),
RDFS.SUBPROPERTYOF, new URIImpl( "http://owl.junk.com/testfiles/Relation" ) );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Description" ),
RDFS.SUBPROPERTYOF, new URIImpl( "http://owl.junk.com/testfiles/Relation/Contains" ) );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Relation/Category" ),
RDF.TYPE, OWL.OBJECTPROPERTY );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Relation/Category" ),
RDFS.LABEL, new LiteralImpl( "Category" ) );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Relation/Category" ),
RDFS.SUBPROPERTYOF, new URIImpl( "http://owl.junk.com/testfiles/Relation" ) );
rc.add( new URIImpl( "http://schema.org/xyz" ),
RDFS.LABEL, new LiteralImpl( "508 Compliant?" ) );
rc.add( new URIImpl( "http://schema.org/xyz" ),
RDFS.SUBPROPERTYOF, new URIImpl( "http://owl.junk.com/testfiles/Relation" ) );
rc.add( new URIImpl( "http://schema.org/xyz" ),
RDFS.SUBPROPERTYOF, new URIImpl( "http://owl.junk.com/testfiles/Relation/Contains" ) );
rc.add( new URIImpl( "http://owl.junk.com/testfiles/Relation" ),
RDF.TYPE, new URIImpl( "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property" ) );
rc.commit();
el.loadCaches( engine );
assertTrue( el.hasCachedPropertyClass( "Description" ) );
assertTrue( el.hasCachedPropertyClass( "508 Compliant?" ) );
}