|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfo.sswap.impl.empire.model.ModelImpl
info.sswap.impl.empire.model.ElementImpl
info.sswap.impl.empire.model.IndividualImpl
public abstract class IndividualImpl
Implementation of a SSWAP individual (objects in SSWAP). The RDF properties of SSWAPIndividuals are generally converted into SSWAPProperties. Yet, there is a group of properties which have special meaning, and their RDF details are hidden from the users of this API (e.g., rdf:type). Usually, the data encoded in such hidden properties is available via a special function in this API (e.g., getTypes()).
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.clarkparsia.empire.SupportsRdfId |
---|
com.clarkparsia.empire.SupportsRdfId.BNodeKey, com.clarkparsia.empire.SupportsRdfId.RdfKey<T>, com.clarkparsia.empire.SupportsRdfId.URIKey |
Field Summary | |
---|---|
private SSWAPType |
declaredTypeIntersection
Contains a type that is intersection of all declared types. |
private java.util.Set<java.lang.String> |
ignoredProperties
A set of rdf properties that is ignored (i.e., not visible to the users of this object) |
private java.util.Set<java.lang.String> |
ignoredTypes
|
private SSWAPType |
inferredTypeIntersection
Contains a type that is intersection of all inferred types. |
private java.util.HashMap<java.net.URI,java.util.List<SSWAPProperty>> |
properties
The list of all visible SSWAPProperties of this individual. |
private static java.lang.String |
RDF_TYPE_URI
Constant for rdf:type property |
private java.util.Set<SSWAPType> |
types
The list of all declared (told) types of this individual. |
Constructor Summary | |
---|---|
IndividualImpl()
Creates an empty individual. |
Method Summary | |
---|---|
private void |
addCloseWorldRestrictions(java.net.URI predicateURI,
int count)
|
void |
addComment(java.lang.String comment)
Adds and rdfs:comment to this type. |
protected void |
addIgnoredProperty(java.lang.String ignoredProperty)
Adds a new property to the list of ignored properties. |
protected void |
addIgnoredType(java.lang.String ignoredType)
|
void |
addLabel(java.lang.String label)
Adds an rdfs:label statement to this type. |
SSWAPProperty |
addProperty(SSWAPPredicate predicate,
SSWAPIndividual individual)
Adds a property to this individual with the specified individual as the value. |
SSWAPProperty |
addProperty(SSWAPPredicate predicate,
SSWAPLiteral literal)
Adds a property to this individual with the specified literal value |
SSWAPProperty |
addProperty(SSWAPPredicate predicate,
java.lang.String value)
Adds a property to this individual with the specified value. |
SSWAPProperty |
addProperty(SSWAPPredicate predicate,
java.lang.String value,
java.net.URI datatype)
Adds a property to this individual with the specified literal value with the specified datatype. |
(package private) void |
addProperty(SSWAPProperty property)
|
void |
addType(SSWAPType type)
Adds a new declared type to the individual |
SSWAPIndividual |
asIndividual()
Allows to safely cast this individual to SSWAPIndividual. |
protected void |
assertType(java.lang.String typeURI)
|
void |
clearProperty(SSWAPPredicate predicate)
Removes all property instances of the specified predicate. |
void |
clearProperty(java.net.URI uri)
|
(package private) void |
closeWorld()
Closing the world for all *existing* properties of the individual by adding an owl:maxCardinality restriction for each property (i.e., we are not closing the world for properties that are not known for this individual) |
private PropertyImpl |
createProperty(java.net.URI uri,
SSWAPElement value)
Creates a property instance for the specified predicate URI and value |
private void |
detachProperties(java.util.Collection<SSWAPProperty> properties)
Detaches SSWAPProperties from this individual and source model. |
private void |
disableUNA(java.util.Collection<SSWAPElement> values)
|
private void |
doAddProperty(SSWAPProperty property)
|
private void |
doAddType(SSWAPType type)
|
private void |
doRemoveProperty(SSWAPProperty property)
|
private void |
doRemoveType(SSWAPType type)
|
boolean |
equals(java.lang.Object o)
Overridden equals() method. |
private void |
forEachProperty(com.google.common.base.Function<com.hp.hpl.jena.rdf.model.Statement,java.lang.Void> function)
Executes a function for every non-ignored Jena property for this individual. |
SSWAPType |
getDeclaredType()
Gets a single type for this individual that summarizes all the declared types. |
java.util.Collection<SSWAPType> |
getDeclaredTypes()
Gets all declared (told) types of this individual. |
private java.util.Map<SSWAPProperty,SSWAPProperty> |
getEquivalentPropertiesMap()
|
protected java.util.Set<java.lang.String> |
getIgnoredProperties()
Gets the information about the ignored properties (hidden) from the user. |
protected java.util.Set<java.lang.String> |
getIgnoredTypes()
|
SSWAPIndividual |
getInferredIndividual()
Retrieves an inferred view (a copy) of the individual. |
java.util.Collection<SSWAPProperty> |
getProperties()
Gets a set of properties for this object. |
java.util.Collection<SSWAPProperty> |
getProperties(SSWAPPredicate predicate)
Gets all the properties (and their values) for the predicate |
SSWAPProperty |
getProperty(SSWAPPredicate predicate)
Gets the property by its Predicate. |
private java.util.List<SSWAPProperty> |
getPropertyListForURI(java.net.URI name)
Gets a list of properties from the properties map that holds all the SSWAPProperties with the given URI. |
SSWAPType |
getType()
Gets a single type for this individual that summarizes all the types for this individual (both explicitly declared and inferred). |
java.util.Collection<SSWAPType> |
getTypes()
Gets all types for this individual (including both explicitly declared types and inferred types). |
int |
hashCode()
Overridden hash code method to make sure that the generated hashcodes are consistent with the overriden equals() method. |
java.util.Collection<SSWAPProperty> |
hasValue(SSWAPElement element)
Retrieves all properties of the individual with the specified value (regardless of the predicate of these properties) |
boolean |
hasValue(SSWAPPredicate predicate,
SSWAPElement element)
Checks whether the individual has a property with the specified value for the predicate. |
boolean |
isCompatibleWith(SSWAPType type)
Checks whether this individual is compatible with the argument type; i.e., if the individual is asserted to be of this type (e.g., via addType(SSWAPType) method), would the ontology remain consistent or become inconsistent? |
boolean |
isIndividual()
Allows to check whether this is a SSWAP individual. |
boolean |
isOfType(SSWAPType type)
Checks whether this individual is of a given type. |
private static boolean |
isRDGPropertyDefined(SSWAPProperty rdgProperty,
java.util.Collection<SSWAPProperty> properties)
Checks whether a property defined in the RDG is defined for this individual (or whether a subproperty of the RDG's property is defined for this individual) |
private static boolean |
isUNADisabledWhenClosingWorld()
|
void |
persist()
Synchronizes the information stored in this individual to the underlying data source. |
private void |
readProperties()
Scans the source model to find all the properties of this object, and initializes properties map. |
private void |
readTypes(com.hp.hpl.jena.rdf.model.Model model,
com.hp.hpl.jena.rdf.model.Resource resource)
Reads the declared type information about an individual |
void |
refresh()
Refreshes the information stored in this individual by rescanning the underlying data source. |
private void |
removeProperties()
Removes all statements about this object that correspond to non-ignored properties. |
void |
removeProperty(SSWAPPredicate predicate,
SSWAPElement value)
Removes a single property from this individual (property is identified by the predicate and the value) |
void |
removeProperty(SSWAPProperty property)
Removes a property from this individual. |
void |
removeType(SSWAPType type)
Removes a type from the individual. |
private void |
removeTypes()
|
(package private) void |
setDefaultParameterValues(IndividualImpl rdgIndividual)
Sets the default parameter values for this individual based on the information from the individual in an RDG. |
SSWAPProperty |
setProperty(SSWAPPredicate predicate,
SSWAPIndividual individual)
Sets the value of the property to the individual. |
SSWAPProperty |
setProperty(SSWAPPredicate predicate,
SSWAPLiteral literal)
Sets the value of the property to the literal object. |
SSWAPProperty |
setProperty(SSWAPPredicate predicate,
java.lang.String value)
Sets the value of the property to the specified value. |
SSWAPProperty |
setProperty(SSWAPPredicate predicate,
java.lang.String value,
java.net.URI datatype)
Sets the value of the property to the specified value and datatype URI. |
(package private) void |
setProperty(SSWAPProperty property)
|
void |
setSourceModel(SourceModel sourceModel)
Sets the source model for this individual. |
private void |
storeProperties()
Creates statements about all non-ignored properties. |
private void |
storeTypes()
|
private void |
updateProperties()
Updates the SSWAPProperties in the underlying data source. |
private void |
updateTypes()
|
private void |
verifyReservedPredicate(SSWAPPredicate predicate)
|
Methods inherited from class info.sswap.impl.empire.model.ElementImpl |
---|
asBoolean, asDouble, asInteger, asList, asLiteral, asString, getComment, getJenaResource, getLabel, isAnonymous, isList, isLiteral |
Methods inherited from class info.sswap.impl.empire.model.ModelImpl |
---|
addImport, assertModel, assertSourceModel, checkProfile, dereference, dereference, doClosure, getAllDependentObjects, getDependentObject, getDocument, getExpressivity, getImports, getInputStream, getNsPrefixMap, getReasoningService, getSourceModel, getTypeSignature, getURI, hasSourceModel, hasSourceModelWithEntityManager, isDereferenced, rdfIdEquals, rdfIdHashCode, refreshSiblings, removeImport, removeNsPrefix, serialize, serialize, setDereferenced, setNsPrefix, setURI, validate |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface info.sswap.api.model.SSWAPIndividual |
---|
isAnonymous |
Methods inherited from interface info.sswap.api.model.SSWAPElement |
---|
asBoolean, asDouble, asInteger, asList, asLiteral, asString, getComment, getLabel, isList, isLiteral |
Methods inherited from interface info.sswap.api.model.SSWAPModel |
---|
addImport, checkProfile, dereference, dereference, doClosure, getDocument, getImports, getInputStream, getNsPrefixMap, getReasoningService, getTypeSignature, getURI, isDereferenced, removeImport, removeNsPrefix, serialize, serialize, setNsPrefix, validate |
Methods inherited from interface com.clarkparsia.empire.SupportsRdfId |
---|
getRdfId, setRdfId |
Field Detail |
---|
private static final java.lang.String RDF_TYPE_URI
private java.util.Set<java.lang.String> ignoredProperties
private java.util.HashMap<java.net.URI,java.util.List<SSWAPProperty>> properties
private java.util.Set<SSWAPType> types
private java.util.Set<java.lang.String> ignoredTypes
private SSWAPType declaredTypeIntersection
private SSWAPType inferredTypeIntersection
Constructor Detail |
---|
public IndividualImpl()
Method Detail |
---|
public java.util.Collection<SSWAPProperty> getProperties()
getProperties
in interface SSWAPIndividual
public SSWAPProperty getProperty(SSWAPPredicate predicate)
SSWAPIndividual
getProperty
in interface SSWAPIndividual
predicate
- the predicate for which property should be retrieved
public java.util.Collection<SSWAPProperty> getProperties(SSWAPPredicate predicate)
SSWAPIndividual
getProperties
in interface SSWAPIndividual
predicate
- the predicate for which the properties should be retrieved
private java.util.List<SSWAPProperty> getPropertyListForURI(java.net.URI name)
name
- the URI of the property
public java.util.Collection<SSWAPType> getDeclaredTypes()
getDeclaredTypes
in interface SSWAPIndividual
public void addType(SSWAPType type)
SSWAPIndividual
addType
in interface SSWAPIndividual
type
- the type to be addedprivate void doAddType(SSWAPType type)
public void removeType(SSWAPType type)
SSWAPIndividual
removeType
in interface SSWAPIndividual
type
- the type to be removed.private void doRemoveType(SSWAPType type)
public SSWAPType getDeclaredType()
SSWAPIndividual
getDeclaredType
in interface SSWAPIndividual
public SSWAPType getType()
SSWAPIndividual
getType
in interface SSWAPIndividual
public java.util.Collection<SSWAPType> getTypes()
SSWAPIndividual
getTypes
in interface SSWAPIndividual
void addProperty(SSWAPProperty property)
private void doAddProperty(SSWAPProperty property)
void setProperty(SSWAPProperty property)
public void removeProperty(SSWAPProperty property)
removeProperty
in interface SSWAPIndividual
property
- the property to be removedSSWAPIndividual.removeProperty(SSWAPPredicate, SSWAPElement)
,
SSWAPIndividual.clearProperty(SSWAPPredicate)
public void removeProperty(SSWAPPredicate predicate, SSWAPElement value)
SSWAPIndividual
removeProperty
in interface SSWAPIndividual
predicate
- the predicate for the property to be removedvalue
- the value for the property to be removedprivate void doRemoveProperty(SSWAPProperty property)
public void clearProperty(java.net.URI uri)
public void clearProperty(SSWAPPredicate predicate)
SSWAPIndividual
clearProperty
in interface SSWAPIndividual
predicate
- the predicate whose all values should be removedSSWAPIndividual.removeProperty(SSWAPProperty)
private java.util.Map<SSWAPProperty,SSWAPProperty> getEquivalentPropertiesMap()
private void readProperties()
private void forEachProperty(com.google.common.base.Function<com.hp.hpl.jena.rdf.model.Statement,java.lang.Void> function)
function
- the function to be executedprivate void updateTypes()
private void removeTypes()
private void storeTypes()
private void updateProperties()
private void removeProperties()
private void storeProperties()
private void readTypes(com.hp.hpl.jena.rdf.model.Model model, com.hp.hpl.jena.rdf.model.Resource resource)
model
- the model containing the information about the individualresource
- the Jena resource corresponding to the individualpublic void setSourceModel(SourceModel sourceModel)
setSourceModel
in class ModelImpl
sourceModel
- the new source modelpublic void refresh()
refresh
in class ModelImpl
public void persist()
persist
in class ModelImpl
protected java.util.Set<java.lang.String> getIgnoredProperties()
protected java.util.Set<java.lang.String> getIgnoredTypes()
protected void addIgnoredProperty(java.lang.String ignoredProperty)
ignoredProperty
- the URL of the property that should be ignoredprotected void addIgnoredType(java.lang.String ignoredType)
public SSWAPIndividual asIndividual()
asIndividual
in interface SSWAPElement
asIndividual
in class ElementImpl
public boolean isIndividual()
isIndividual
in interface SSWAPElement
isIndividual
in class ElementImpl
protected void assertType(java.lang.String typeURI) throws ValidationException
ValidationException
private static boolean isRDGPropertyDefined(SSWAPProperty rdgProperty, java.util.Collection<SSWAPProperty> properties)
rdgProperty
- the property defined in RDGproperties
- the properties defined for this individual
void setDefaultParameterValues(IndividualImpl rdgIndividual)
rdgIndividual
- public boolean isOfType(SSWAPType type)
SSWAPIndividual
isOfType
in interface SSWAPIndividual
type
- the type to be checked
public boolean isCompatibleWith(SSWAPType type)
SSWAPIndividual
isCompatibleWith
in interface SSWAPIndividual
type
- type whose compatibility with this individual should be
checked
private PropertyImpl createProperty(java.net.URI uri, SSWAPElement value) throws java.lang.IllegalArgumentException
uri
- the URI of the predicatevalue
- the value
java.lang.IllegalArgumentException
- if the value is not legal for the specified predicate (e.g., literal for an object
property)public SSWAPProperty addProperty(SSWAPPredicate predicate, SSWAPIndividual individual) throws java.lang.IllegalArgumentException
SSWAPIndividual
addProperty
in interface SSWAPIndividual
predicate
- the predicate for the added propertyindividual
- the value for the property
java.lang.IllegalArgumentException
- if the individual is not legal for the predicate (e.g., an
object for a datatype property)public SSWAPProperty addProperty(SSWAPPredicate predicate, java.lang.String value) throws java.lang.IllegalArgumentException
SSWAPIndividual
rdfs:range
, the system will tag
the value with the appropriate datatype.
addProperty
in interface SSWAPIndividual
predicate
- the predicate for the added propertyvalue
- the literal value for the property
java.lang.IllegalArgumentException
- if the value is not legal for the predicate (e.g., a literal
for an object property)public SSWAPProperty addProperty(SSWAPPredicate predicate, java.lang.String value, java.net.URI datatype) throws java.lang.IllegalArgumentException
SSWAPIndividual
addProperty
in interface SSWAPIndividual
predicate
- the predicate for the added propertyvalue
- the literal value for the propertydatatype
- URI for typing the literal value (e.g.,
SSWAPDatatype.XSD.anyURI
)
java.lang.IllegalArgumentException
- if the value or datatype is not legal for the predicate
(e.g., a literal for an object property)public SSWAPProperty addProperty(SSWAPPredicate predicate, SSWAPLiteral literal) throws java.lang.IllegalArgumentException
SSWAPIndividual
addProperty
in interface SSWAPIndividual
predicate
- the predicate for the added propertyliteral
- the literal value for the property
java.lang.IllegalArgumentException
- if the literal is not legal for the predicate (e.g., a
literal for an object property)public SSWAPProperty setProperty(SSWAPPredicate predicate, SSWAPIndividual individual) throws java.lang.IllegalArgumentException
SSWAPIndividual
setProperty
in interface SSWAPIndividual
predicate
- the predicate for the added propertyindividual
- the individual
java.lang.IllegalArgumentException
- if the individual is not legal for the predicate (e.g., an
object for a datatype property)public SSWAPProperty setProperty(SSWAPPredicate predicate, java.lang.String value) throws java.lang.IllegalArgumentException
SSWAPIndividual
rdfs:range
, the
system will tag the value with the appropriate datatype.
setProperty
in interface SSWAPIndividual
predicate
- the predicate for the added propertyvalue
- the literal value
java.lang.IllegalArgumentException
- if the value is not legal for the predicate (e.g., a literal
for an object property)public SSWAPProperty setProperty(SSWAPPredicate predicate, java.lang.String value, java.net.URI datatype) throws java.lang.IllegalArgumentException
SSWAPIndividual
setProperty
in interface SSWAPIndividual
predicate
- the predicate for the added propertyvalue
- the literal valuedatatype
- URI for typing the literal value (e.g.,
SSWAPDatatype.XSD.anyURI
)
java.lang.IllegalArgumentException
- if the value or datatype is not legal for the predicate
(e.g., a literal for an object property)public SSWAPProperty setProperty(SSWAPPredicate predicate, SSWAPLiteral literal)
SSWAPIndividual
setProperty
in interface SSWAPIndividual
predicate
- the predicate for the added propertyliteral
- value for the property
public boolean hasValue(SSWAPPredicate predicate, SSWAPElement element)
SSWAPIndividual
hasValue
in interface SSWAPIndividual
predicate
- the predicate for the propertyelement
- the value for the property
public java.util.Collection<SSWAPProperty> hasValue(SSWAPElement element)
SSWAPIndividual
hasValue
in interface SSWAPIndividual
element
- the value for properties to be returned
private void detachProperties(java.util.Collection<SSWAPProperty> properties)
properties
- public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- another object to be compared for equality with this one
public int hashCode()
hashCode
in class java.lang.Object
public void addLabel(java.lang.String label)
SSWAPElement
addLabel
in interface SSWAPElement
addLabel
in class ElementImpl
label
- the label to be addedpublic void addComment(java.lang.String comment)
SSWAPElement
addComment
in interface SSWAPElement
addComment
in class ElementImpl
comment
- the comment to be added to this typepublic SSWAPIndividual getInferredIndividual()
SSWAPIndividual
getInferredIndividual
in interface SSWAPIndividual
private void verifyReservedPredicate(SSWAPPredicate predicate) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
private static boolean isUNADisabledWhenClosingWorld()
void closeWorld()
private void addCloseWorldRestrictions(java.net.URI predicateURI, int count)
private void disableUNA(java.util.Collection<SSWAPElement> values)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |