Java Code Examples for com.hp.hpl.jena.rdf.model.RDFNode#asResource()

The following examples show how to use com.hp.hpl.jena.rdf.model.RDFNode#asResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataElementConceptImpl.java    From semanticMDR with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ObjectClassResource getDataElementConceptObjectClass() {
	RDFNode dataElementConceptObjectClass = getPropertyValue(mdrDatabase
			.getVocabulary().dataElementConceptObjectClass);
	if (dataElementConceptObjectClass == null) {
		logger.debug("DataElemenetConcept does not have an ObjectClass");
		return null;
	}
	OntClass ontClass = dataElementConceptObjectClass.as(OntResource.class)
			.asClass();
	ObjectClassResource objectClassIND = null;
	if (ontClass.hasSuperClass(mdrDatabase.getVocabulary().Concept)) {
		objectClassIND = new ConceptImpl(
				dataElementConceptObjectClass.asResource(), mdrDatabase);
	}
	if (ontClass
			.hasSuperClass(mdrDatabase.getVocabulary().ConceptRelationship)) {
		objectClassIND = new ConceptRelationshipImpl(
				dataElementConceptObjectClass.asResource(), mdrDatabase);
	}
	if (objectClassIND == null) {
		throw new IllegalStateException(
				"Property value should have a valid OntClass.");
	}
	return objectClassIND;
}
 
Example 2
Source File: ValueDomainImpl.java    From semanticMDR with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ConceptualDomainResource getRepresentingConceptualDomainRepresentation() {
	RDFNode representingConceptualDomainRepresentation = getPropertyValue(mdrDatabase
			.getVocabulary().representingConceptualDomainRepresentation);
	OntClass ontClass = representingConceptualDomainRepresentation.as(
			OntResource.class).asClass();

	ConceptualDomainResource conceptualDomainIND = null;
	if (ontClass
			.hasSuperClass(mdrDatabase.getVocabulary().EnumeratedConceptualDomain)) {
		conceptualDomainIND = new EnumeratedConceptualDomainImpl(
				representingConceptualDomainRepresentation.asResource(),
				mdrDatabase);
	}
	if (ontClass
			.hasSuperClass(mdrDatabase.getVocabulary().NonEnumeratedConceptualDomain)) {
		conceptualDomainIND = new NonEnumeratedConceptualDomainImpl(
				representingConceptualDomainRepresentation.asResource(),
				mdrDatabase);
	}
	if (conceptualDomainIND == null) {
		throw new IllegalStateException(
				"Property value should have a valid OntClass.");
	}
	return conceptualDomainIND;
}
 
Example 3
Source File: QueryHelper.java    From ldp4j with Apache License 2.0 5 votes vote down vote up
public Resource resource(String binding) {
	if(!this.solution.contains(binding)) {
		return null;
	}
	RDFNode node = this.solution.get(binding);
	if(!node.canAs(Resource.class)) {
		throw new IllegalStateException("Binding '"+binding+"' is not a resource");
	}
	return node.asResource();
}
 
Example 4
Source File: DataElementImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ValueDomainResource getRepresentedByDataElementRepresentation() {
	RDFNode representedByDataElementRepresentation = getPropertyValue(mdrDatabase
			.getVocabulary().representedByDataElementRepresentation);
	OntClass ontClass = representedByDataElementRepresentation.as(
			OntResource.class).asClass();

	ValueDomainResource valueDomainIND = null;
	if (ontClass
			.hasSuperClass(mdrDatabase.getVocabulary().EnumeratedValueDomain)) {
		valueDomainIND = new EnumeratedValueDomainImpl(
				representedByDataElementRepresentation.asResource(),
				mdrDatabase);
		logger.info("Representer ValueDomain is an EnumeratedValueDomain");
	}
	if (ontClass
			.hasSuperClass(mdrDatabase.getVocabulary().NonEnumeratedValueDomain)) {
		valueDomainIND = new NonEnumeratedValueDomainImpl(
				representedByDataElementRepresentation.asResource(),
				mdrDatabase);
	}
	if (valueDomainIND == null) {
		throw new IllegalStateException(
				"Property value should have a valid OntClass.");
	}
	return valueDomainIND;
}
 
Example 5
Source File: ContextImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public LanguageIdentificationResource getContextDescriptionLanguageIdentifier() {
	RDFNode contextDescriptionLanguageIdentifier = getPropertyResourceValue(mdrDatabase
			.getVocabulary().contextDescriptionLanguageIdentifier);
	if (contextDescriptionLanguageIdentifier == null) {
		logger.debug("Context does not have languageIdentifier");
		return null;
	}
	return new LanguageIdentificationImpl(
			contextDescriptionLanguageIdentifier.asResource(), mdrDatabase);
}
 
Example 6
Source File: ConceptImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ObjectClass getParentConcept() {
	NodeIterator l = this.listPropertyValues(RDFS.subClassOf);

	while (l.hasNext()) {
		RDFNode res = l.nextNode();
		if (res.canAs(OntClass.class)) {
			OntClass ontClass = res.as(OntClass.class);
			if (ontClass.hasSuperClass(mdrDatabase.getVocabulary().Concept)) {
				return new ConceptImpl(res.asResource(), mdrDatabase);
			}
		}
	}
	return null;
}
 
Example 7
Source File: DataElementConceptImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public PropertyResource getDataElementConceptProperty() {
	RDFNode dataElementConceptProperty = getPropertyValue(mdrDatabase
			.getVocabulary().dataElementConceptProperty);
	if (dataElementConceptProperty == null) {
		logger.debug("DataElementConcept does not have Property");
		return null;
	}
	return new PropertyImpl(dataElementConceptProperty.asResource(),
			mdrDatabase);
}
 
Example 8
Source File: DataElementConceptImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ConceptualDomainResource getHavingDataElementConceptConceptualDomainRelationship() {
	RDFNode havingDataElementConceptConceptualDomainRelationship = getPropertyValue(mdrDatabase
			.getVocabulary().havingDataElementConceptConceptualDomainRelationship);
	OntClass ontClass = havingDataElementConceptConceptualDomainRelationship
			.as(OntResource.class).asClass();
	ConceptualDomainResource conceptualDomainIND = null;
	if (ontClass
			.hasSuperClass(mdrDatabase.getVocabulary().EnumeratedConceptualDomain)) {
		conceptualDomainIND = new EnumeratedConceptualDomainImpl(
				havingDataElementConceptConceptualDomainRelationship
						.asResource(),
				mdrDatabase);
	}
	if (ontClass
			.hasSuperClass(mdrDatabase.getVocabulary().NonEnumeratedConceptualDomain)) {
		conceptualDomainIND = new NonEnumeratedConceptualDomainImpl(
				havingDataElementConceptConceptualDomainRelationship
						.asResource(),
				mdrDatabase);
	}
	if (conceptualDomainIND == null) {
		throw new IllegalStateException(
				"Property value should have a OntClass");
	}
	return conceptualDomainIND;
}
 
Example 9
Source File: ValueDomainImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public UnitOfMeasureResource getValueDomainUnitOfMeasure() {
	RDFNode valueDomainUnitOfMeasure = getPropertyValue(mdrDatabase
			.getVocabulary().valueDomainUnitOfMeasure);
	if (valueDomainUnitOfMeasure == null) {
		logger.debug("ValueDomain does not have UnitOfMeasure");
		return null;
	}
	return new UnitOfMeasureImpl(valueDomainUnitOfMeasure.asResource(),
			mdrDatabase);
}
 
Example 10
Source File: ValueDomainImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public RepresentationClassResource getTypedByValueDomainRepresentationClass() {
	RDFNode typedByValueDomainRepresentationClass = getPropertyValue(mdrDatabase
			.getVocabulary().typedByValueDomainRepresentationClass);
	if (typedByValueDomainRepresentationClass == null) {
		logger.debug("ValueDomain is not typed by RepresentationClass");
		return null;
	}
	return new RepresentationClassImpl(
			typedByValueDomainRepresentationClass.asResource(), mdrDatabase);
}
 
Example 11
Source File: RegistrarImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public RegistrationAuthorityResource getRepresent() {
	RDFNode representedRegistrationAuthority = getPropertyResourceValue(mdrDatabase
			.getVocabulary().represents);
	if (representedRegistrationAuthority == null) {
		logger.debug("Registrar does not have Registration Authority");
		return null;
	}
	return new RegistrationAuthorityImpl(
			representedRegistrationAuthority.asResource(), mdrDatabase);
}