/* * (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#removeDatatypePropertyValues(gate.creole.ontology.DatatypeProperty) */ public void removeDatatypePropertyValues(DatatypeProperty aProperty) { owlim.removeDatatypePropertyValues( this.repositoryID, this.uri.toString(), aProperty.getURI().toString()); ontology.fireResourcePropertyValueChanged( this, aProperty, null, OConstants.DATATYPE_PROPERTY_VALUE_REMOVED_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); }
/* * (non-Javadoc) * * @see gate.creole.ontology.OInstance#getDatatypePropertyValues(gate.creole.ontology.DatatypeProperty) */ public List<Literal> getDatatypePropertyValues(DatatypeProperty aProperty) { try { PropertyValue[] values = owlim.getDatatypePropertyValues( this.repositoryID, this.uri.toString(), aProperty.getURI().toString()); List<Literal> list = new ArrayList<Literal>(); for (int i = 0; i < values.length; i++) { list.add( new Literal( values[i].getValue(), OntologyUtilities.getDataType(values[i].getDatatype()))); } return list; } catch (InvalidValueException ive) { throw new GateOntologyException(ive); } }