private void updateValueTypeFacet( RDFSNamedClass cls, Slot slot, OWLQuantifierRestriction restriction) { ValueType oldValueType = ((Cls) cls).getTemplateSlotValueType(slot); ValueType newValueType = oldValueType; Collection oldAllowedClses = ((Cls) cls).getTemplateSlotAllowedClses(slot); Collection newAllowedClses = oldAllowedClses; Collection oldAllowedValues = ((Cls) cls).getTemplateSlotAllowedValues(slot); Collection newAllowedValues = oldAllowedValues; RDFResource filler = restriction.getFiller(); if (filler instanceof RDFSClass) { RDFSClass quantifierClass = (RDFSClass) filler; if (RDFSNames.Cls.LITERAL.equals(quantifierClass.getName())) { newValueType = ValueType.ANY; } else { newValueType = ValueType.INSTANCE; newAllowedClses = getQuantifierClsClses(quantifierClass); } } else { if (filler instanceof OWLDataRange) { newAllowedValues = ((OWLDataRange) filler).getOneOf().getValues(); newValueType = ValueType.SYMBOL; } else { RDFSDatatype datatype = (RDFSDatatype) filler; if (datatype.equals(owlModel.getRDFXMLLiteralType())) { newValueType = ValueType.STRING; } else { String uri = XMLSchemaDatatypes.getXSDDatatype(datatype).getURI(); newValueType = XMLSchemaDatatypes.getValueType(uri); } } } if (oldValueType == newValueType) { if (newValueType == ValueType.INSTANCE && !oldAllowedClses.equals(newAllowedClses)) { setAllowedClses(cls, slot, newAllowedClses); } else if (newValueType == ValueType.SYMBOL && !oldAllowedValues.equals(newAllowedValues)) { setAllowedValues(cls, slot, newAllowedValues); } } else { if (log.isLoggable(Level.FINE)) { log.fine( "+ Setting :VALUE-TYPE of " + cls.getName() + "." + slot.getName() + " to " + newValueType); } ((Cls) cls).setTemplateSlotValueType(slot, newValueType); if (newValueType == ValueType.INSTANCE) { setAllowedClses(cls, slot, newAllowedClses); } else if (newValueType == ValueType.SYMBOL) { setAllowedValues(cls, slot, newAllowedValues); } } }
public static boolean isInvalidXMLLiteral(RDFProperty property, Object value) { if (XMLSchemaDatatypes.isXMLLiteralSlot(property) && value instanceof String) { if (!XMLLiteralType.theXMLLiteralType.isValid((String) value)) { ProtegeUI.getModalDialogFactory() .showErrorMessageDialog( property.getOWLModel(), "This value is not a valid XML literal:\n" + value); return true; } } return false; }
protected void updateAllRestrictions(Cls cls, RDFProperty property) { if (cls.hasDirectlyOverriddenTemplateFacet(property, valueTypeFacet)) { ValueType valueType = cls.getTemplateSlotValueType(property); if (valueType == ValueType.INSTANCE) { Collection clses = cls.getTemplateSlotAllowedClses(property); if (clses.size() == 0) { removeRestrictions(cls, property, metaCls); addAllRestriction(cls, property, owlModel.createOWLEnumeratedClass()); } else { ensureNoSurvivingClsesAreDeleted(cls, property, clses, metaCls); if (clses.size() == 1) { Cls allCls = (Cls) clses.iterator().next(); removeRestrictions(cls, property, metaCls); addAllRestriction(cls, property, allCls); } else { OWLUnionClass unionCls = owlModel.createOWLUnionClass(clses); removeRestrictions(cls, property, metaCls); addAllRestriction(cls, property, unionCls); } } } else if (valueType != ValueType.SYMBOL && valueType != ValueType.CLS) { removeRestrictions(cls, property, metaCls); RDFSDatatype datatype = owlModel.getRDFSDatatypeByURI( XMLSchemaDatatypes.getDefaultXSDDatatype(valueType).getURI()); OWLAllValuesFrom restriction = owlModel.createOWLAllValuesFrom(property, datatype); cls.addDirectSuperclass(restriction); if (log.isLoggable(Level.FINE)) { log.fine( "+ OWLAllValuesFrom " + restriction.getBrowserText() + " to " + cls.getName() + "." + property.getName()); } } } else { removeRestrictions(cls, property, metaCls); } }