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


Java OntModel.loadImports方法代碼示例

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


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

示例1: addImport

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
@Override
public boolean addImport(String modelName, String importedModelUri) throws ConfigurationException, IOException, InvalidNameException, URISyntaxException {
	try {
		String altImportUrl = getConfigurationMgr().getAltUrlFromPublicUri(importedModelUri);
		OntModel model = getOntModelForEditing(modelName);
		Resource importingOntology = model.getOntology(modelName);
		if (importingOntology == null) {
			importingOntology = model.createResource(modelName);
		}
		model.getOntology(modelName).addImport(importingOntology);
		model.loadImports();
		return true;
	} catch (ConfigurationException e) {
		throw new ConfigurationException("Model cannot be imported as its location is unknown.", e);
	}
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:17,代碼來源:SadlServerPEImpl.java

示例2: buildInferenceModel

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
private void buildInferenceModel() {

		OntModel vocabularyModel = this.getVocabularyModel();
		vocabularyModel.loadImports();
		//TODO which reasoner should we use as default. RDFSSimple is by far the fastest
		//TODO Reasoner boundReasoner = ReasonerRegistry.getOWLMicroReasoner();
		this.boundReasoner = ReasonerRegistry.getRDFSSimpleReasoner();
		this.boundReasoner = this.boundReasoner.bindSchema(this.vocabularyModel);
	}
 
開發者ID:peterjohnlawrence,項目名稱:com.inova8.remediator,代碼行數:10,代碼來源:Void.java

示例3: getOntModelForEditing

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
private OntModel getOntModelForEditing(String thisModelName) throws IOException, ConfigurationException, InvalidNameException, URISyntaxException {
	if (editedTboxModels != null && editedTboxModels.containsKey(thisModelName)) {
		return editedTboxModels.get(thisModelName);
	}
	try {
		if (modelName != null && !modelName.equals(thisModelName)) {
			if (instanceDataModels != null && instanceDataModels.containsKey(thisModelName)) {
				return instanceDataModels.get(thisModelName);
			}
			else if (getInstanceDataName() == null || thisModelName.equals(getInstanceDataName())) {
				if (getInstanceDataName() == null) {
					setInstanceDataNamespace(thisModelName + "#");
				}
				return createInstanceModel(thisModelName);
			}
		}
	} catch (ConfigurationException e) {
		// it's ok for instance names space to fail
	}
	String altUrl = canModifyModel(thisModelName);
	if (altUrl != null) {
		OntModel ontModel = ModelFactory.createOntologyModel(getConfigurationMgr().getOntModelSpec(null));
		altUrl = getConfigurationMgr().fileNameToFileUrl(altUrl);
		ontModel.getSpecification().setImportModelGetter((ModelGetter) configurationMgr.getModelGetter());
		ontModel.read(altUrl);
		ontModel.getDocumentManager().setProcessImports(true);
		ontModel.loadImports();
		ontModel.getDocumentManager().setProcessImports(false);
		if (editedTboxModels == null) {
			editedTboxModels = new HashMap<String, OntModel>();
		}
		editedTboxModels.put(thisModelName, ontModel);
		return ontModel;
	}
	return null;
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:37,代碼來源:SadlServerPEImpl.java

示例4: createInstanceModel

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
private OntModel createInstanceModel(String thisModelName)
			throws IOException,
			ConfigurationException {
		if (instanceDataModels != null && instanceDataModels.containsKey(thisModelName)) {
			return instanceDataModels.get(thisModelName);
		}
		if (editedTboxModels != null && editedTboxModels.containsKey(thisModelName)) {
			return editedTboxModels.get(thisModelName);
		}
		OntModel model = ModelFactory.createOntologyModel(getConfigurationMgr().getOntModelSpec(null));
		model.getDocumentManager().setFileManager(getConfigurationMgr().getJenaDocumentMgr().getFileManager());
		Resource importOnt = model.getResource(getModelName());
		Ontology ont = model.createOntology(thisModelName);
		ont.addImport(importOnt);
		ont.addComment("This ontology model was created by SadlServerPE.", "en");
		model.getDocumentManager().setProcessImports(true);
		model.loadImports();
//		if (logger.isDebugEnabled()) {
			Iterator<String> importItr = model.listImportedOntologyURIs().iterator();
			while (importItr.hasNext()) {
//				logger.debug("Model '" + thisModelName + "' imports '" + importItr.next() + "'");
				System.out.println("Model '" + thisModelName + "' imports '" + importItr.next() + "'");
		}
//		}
		model.getDocumentManager().setProcessImports(false);
		if (instanceDataModels == null) {
			instanceDataModels = new HashMap<String, OntModel>(); 
		}
		instanceDataModels.put(thisModelName, model);
		return model;
	}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:32,代碼來源:SadlServerPEImpl.java

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