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


Java OntModel.getImportedModel方法代碼示例

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


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

示例1: listSubModelsAndPrefixes

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
private Map<String, String> listSubModelsAndPrefixes(Map<String, String> map, OntModel m, String modelUri) {
	Ontology onto = m.getOntology(modelUri);
	if (onto != null) {
		String prefix = m.getNsURIPrefix(modelUri);
		if (prefix == null) {
			prefix = getGlobalPrefix(modelUri);
		}
		if (!map.containsKey(modelUri)) {
			map.put(modelUri, prefix);
		}
		ExtendedIterator<OntResource> importsItr = onto.listImports();
		if (importsItr.hasNext()) {
			while (importsItr.hasNext()) {
				OntResource or = importsItr.next();
				logger.debug("Ontology of model '" + modelUri + "' has import '" + or.toString() + "' with prefix '" + prefix + "'");
				if (!map.containsKey(or.toString())) {
					OntModel submodel = m.getImportedModel(or.getURI());
					if (submodel != null) {
						map = listSubModelsAndPrefixes(map, submodel, or.getURI());
					}
				}
			}
		}
	}
	return map;
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:27,代碼來源:ConfigurationManager.java

示例2: namespaceIsImported

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
private boolean namespaceIsImported(String namespace, OntModel currentModel) {
	OntModel importedModel = currentModel.getImportedModel(namespace.replace("#", ""));
	if (importedModel != null) {
		return true;
	}
	return false;
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:8,代碼來源:JenaBasedSadlModelProcessor.java

示例3: loadImportedModel

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
@Override
	public List<ImportMapping> loadImportedModel(Ontology importingOntology, OntModel importingModel,
			String publicImportUri, String altImportUrl) throws ConfigurationException {
    	// if not given the publicImportUri, then we must have the altImportUrl so find the publicImportUri in mapping
    	if (publicImportUri == null) {
    		if (altImportUrl == null) {
    			throw new ConfigurationException("Must have either a public URI or an actual URL to import a model.");
    		}
    		publicImportUri = getPublicUriFromActualUrl(altImportUrl);
    	}
    	
    	if (importingOntology == null) {
    		throw new ConfigurationException("Importing ontology is null!");
    	}
    	    	    	
    	// if not given altImportUrl, then we must have the publicImportUri so find the altImportUrl in mapping
    	if (altImportUrl == null) {
    		altImportUrl = getAltUrlFromPublicUri(publicImportUri);
    	}
    	
    	String importingOntologyUri = importingOntology.getURI();
    	if (importingOntologyUri == null) {
    		throw new ConfigurationException("Importing ontology '" + importingOntology.toString() + "' does not have an ontology declaration.");
    	}
    	if (!importingOntologyUri.equals(publicImportUri)) {	// don't import to self
	    	// Now load import model (with setCachedModels true so it loads any indirect imports)
	       	// and add all import OntModels to importing mappings
	    	Resource importedOntology = importingModel.createResource(publicImportUri);
	    	importingOntology.addImport(importedOntology);
    	}
//    	this.getJenaDocumentMgr().setCacheModels(true);
   		this.getJenaDocumentMgr().setProcessImports(true);
   		ReadFailureHandler rfh = this.getJenaDocumentMgr().getReadFailureHandler();
   		if (rfh instanceof SadlReadFailureHandler) {
   			((SadlReadFailureHandler)rfh).setSadlConfigMgr(this);
   		}
   		getModelGetter().configureToModel(importingModel);
		importingModel.loadImports();
		if (readError != null) {
			String err = readError;
			readError = null;
			if (importingModel.hasLoadedImport(publicImportUri)) {
				// this must be removed or it will prevent correct loading from another project
				importingModel.removeLoadedImport(publicImportUri);
			}
	   		this.getJenaDocumentMgr().setProcessImports(false);
			throw new ConfigurationException(err);
		}
   		this.getJenaDocumentMgr().setProcessImports(false);
    	
    	List<ImportMapping> map = new ArrayList<ImportMapping>();
		Iterator<String> itr = importingModel.listImportedOntologyURIs(true).iterator();
		while (itr.hasNext()) {
			String impUri = itr.next();
			if (impUri.equals(importingOntology.getURI())) {
				// don't count ourselves as an import
				importingModel.setNsPrefix("", ConfigurationManager.addHashToNonTerminatedNamespace(impUri));
				continue;
			}
			String prefix = importingModel.getNsURIPrefix(ConfigurationManager.addHashToNonTerminatedNamespace(impUri));
			if (prefix == null) {
				prefix = getGlobalPrefix(impUri);
				if (prefix != null) {
					importingModel.setNsPrefix(prefix, ConfigurationManager.addHashToNonTerminatedNamespace(impUri));
				}
			}
			OntModel impModel = importingModel.getImportedModel(impUri);
			String actImpUrl = getAltUrlFromPublicUri(impUri);
			logger.debug("processing importingModel, url = "+actImpUrl);
			ImportMapping im = new ImportMapping(impUri, actImpUrl, null);
			im.setModel(impModel);
			im.setPrefix(prefix);
			map.add(im);
		}	
		this.getJenaDocumentMgr().setProcessImports(false);
//		this.getJenaDocumentMgr().setCacheModels(false);
    	return map;
	}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:79,代碼來源:ConfigurationManager.java


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