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


Java RepositoryConnection.begin方法代碼示例

本文整理匯總了Java中org.openrdf.repository.RepositoryConnection.begin方法的典型用法代碼示例。如果您正苦於以下問題:Java RepositoryConnection.begin方法的具體用法?Java RepositoryConnection.begin怎麽用?Java RepositoryConnection.begin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openrdf.repository.RepositoryConnection的用法示例。


在下文中一共展示了RepositoryConnection.begin方法的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;
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:17,代碼來源:DbInfoMapper.java

示例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;
		}
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:18,代碼來源:DbInfoMapper.java

示例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;
		}
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:18,代碼來源:DbInfoMapper.java

示例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 );
		}
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:27,代碼來源:UserMapper.java

示例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 );
		}
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:28,代碼來源:UserMapper.java

示例6: finishLoading

import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
@Override
protected void finishLoading( Properties props ) throws RepositoryException {
	String realname = ( null == getEngineName()
			? props.getProperty( Constants.ENGINE_NAME,
					FilenameUtils.getBaseName( props.getProperty( Constants.SMSS_LOCATION ) ) )
			: getEngineName() );
	MetadataQuery mq = new MetadataQuery( RDFS.LABEL );
	queryNoEx( mq );
	String str = mq.getString();
	if ( null != str ) {
		realname = str;
	}
	setEngineName( realname );

	RepositoryConnection rc = getRawConnection();
	rc.begin();
	for ( Map.Entry<String, String> en : Utility.DEFAULTNAMESPACES.entrySet() ) {
		rc.setNamespace( en.getKey(), en.getValue() );
	}
	rc.commit();
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:22,代碼來源:AbstractSesameEngine.java

示例7: deleteStatements

import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
public static void deleteStatements( IEngine engine, Collection<Statement> statements ) {
	ProgressTask pt = new ProgressTask( "Deleting Statements from the Knowledge Base",
			new Runnable() {
				@Override
				public void run() {
					try {
						ModificationExecutor mea = new ModificationExecutorAdapter() {
							@Override
							public void exec( RepositoryConnection conn ) throws RepositoryException {
								conn.begin();
								conn.remove( statements );
							}
						};

						engine.execute( mea );
						engine.commit();
					}
					catch ( RepositoryException re ) {
						log.error( "RepositoryException trying to delete Statements: " + re, re );
					}
				}
			} );
	OperationsProgress.getInstance( PlayPane.UIPROGRESS ).add( pt );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:25,代碼來源:StatementPersistenceUtility.java

示例8: 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();
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:17,代碼來源:InMemorySesameEngineTest.java

示例9: 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 );
		}
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:48,代碼來源:EngineLoader.java

示例10: 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();
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:17,代碼來源:EngineLoader.java

示例11: 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();
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:11,代碼來源:GraphDataModelTest.java

示例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" ) ) );
	// 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();
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:14,代碼來源:MetadataQueryTest.java

示例13: 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();
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:9,代碼來源:OneVarListQueryAdapterTest.java

示例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 ) );
		}
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:39,代碼來源:EngineConsistencyCheckerTest.java

示例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?" ) );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:73,代碼來源:QaCheckerTest.java


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