/* * (non-Javadoc) * * @see gate.creole.ontology.OInstance#addDatatypePropertyValue(gate.creole.ontology.DatatypeProperty, * gate.creole.ontology.Literal) */ public void addDatatypePropertyValue(DatatypeProperty aProperty, Literal value) throws InvalidValueException { // we need to check if the current instance is a valid domain for // the property if (!aProperty.isValidDomain(this)) { Utils.error( this.getURI().toString() + " is not a valid domain for the property " + aProperty.getURI().toString()); return; } DataType type = aProperty.getDataType(); if (value.getDataType() == null) { type = aProperty.getDataType(); } else { if (!type.getXmlSchemaURIString().equals(value.getDataType().getXmlSchemaURIString())) throw new GateOntologyException( "Datatype :" + value.getDataType().getXmlSchemaURIString() + " doesn't match with the property's datatype :" + type.getXmlSchemaURIString()); } owlim.addDatatypePropertyValue( this.repositoryID, this.uri.toString(), aProperty.getURI().toString(), type.getXmlSchemaURIString(), value.getValue()); ontology.fireResourcePropertyValueChanged( this, aProperty, value, OConstants.DATATYPE_PROPERTY_VALUE_ADDED_EVENT); }
/* * (non-Javadoc) * * @see gate.creole.ontology.OInstance#removeDatatypePropertyValue(gate.creole.ontology.DatatypeProperty, * gate.creole.ontology.Literal) */ public void removeDatatypePropertyValue(DatatypeProperty aProperty, Literal value) { owlim.removeDatatypePropertyValue( this.repositoryID, this.uri.toString(), aProperty.getURI().toString(), value.getDataType().getXmlSchemaURIString(), value.getValue()); ontology.fireResourcePropertyValueChanged( this, aProperty, value, OConstants.DATATYPE_PROPERTY_VALUE_REMOVED_EVENT); }
/** * Checks if the resource has the provided datatype property set on it with the specified value. * * @param aProperty * @param aValue * @return */ public boolean hasDatatypePropertyWithValue(DatatypeProperty aProperty, Literal aValue) { List<Literal> literals = getDatatypePropertyValues(aProperty); for (Literal l : literals) { if (l.getValue().equals(aValue.getValue())) { if (l.getDataType() != null && aValue.getDataType() != null) { if (!aValue .getDataType() .getXmlSchemaURIString() .equals(l.getDataType().getXmlSchemaURIString())) continue; } if (l.getLanguage() != null && aValue.getLanguage() != null) { if (!aValue.getLanguage().toString().equals(l.getLanguage().toString())) continue; } return true; } } return false; }