Package cz.cvut.kbss.jopa.oom
Interface ObjectOntologyMapper
- All Known Implementing Classes:
ObjectOntologyMapperImpl
public interface ObjectOntologyMapper
-
Method Summary
Modifier and TypeMethodDescriptionvoidChecks that there are not any pending changes in the mapper.<T> booleancontainsEntity(Class<T> cls, URI identifier, Descriptor descriptor) Checks whether the storage contains an individual with the specified identifier and of the specified type.generateIdentifier(EntityType<?> et) Generates a fresh identifier for an instance of the specified entity type.getAttributeAxioms(T entity, FieldSpecification<? super T, ?> fieldSpec, Descriptor entityDescriptor) Extracts the value of the specified field from the specified entity and transforms it to axioms.<T> TgetReference(LoadingParameters<T> loadingParameters) Gets a reference to an entity corresponding to the specified parameters.<T> booleanisInferred(T entity, FieldSpecification<? super T, ?> fieldSpec, Object value, Descriptor entityDescriptor) Checks if the specified attribute value of the specified entity is inferred in the repository.<T> TloadEntity(AxiomBasedLoadingParameters<T> loadingParameters) Loads entity from the specified axioms.<T> TloadEntity(LoadingParameters<T> loadingParameters) Loads and reconstructs an entity from the ontology.<T> voidloadFieldValue(T entity, FieldSpecification<? super T, ?> fieldSpec, Descriptor descriptor) Loads entity field value and sets it on the specified entity.<T> voidpersistEntity(URI identifier, T entity, Descriptor descriptor) Persists the specified entity into the underlying ontology.<T> voidremoveEntity(URI identifier, Class<T> cls, Descriptor descriptor) Removes entity with specified identifier from the ontology.<T> voidupdateFieldValue(T entity, FieldSpecification<? super T, ?> fieldSpec, Descriptor descriptor) Sets value of property represented by the specified field to the field's value.
-
Method Details
-
containsEntity
Checks whether the storage contains an individual with the specified identifier and of the specified type.- Parameters:
cls- Class representing the individual typeidentifier- Identifierdescriptor- Descriptor, can specify context- Returns:
trueif the ontology contains such an individual,falseotherwise
-
loadEntity
Loads and reconstructs an entity from the ontology.- Type Parameters:
T- Entity type- Parameters:
loadingParameters- Entity loading parameters- Returns:
- Reconstructed entity or
nullif there is none such
-
loadEntity
Loads entity from the specified axioms.This means the axioms are (assumed to be) already loaded from the storage, and we only need to reconstruct the entity.
- Type Parameters:
T- Entity type- Parameters:
loadingParameters- Entity loading parameters- Returns:
- Loaded entity or
nullif no entity of the expected target class can be reconstructed
-
getReference
Gets a reference to an entity corresponding to the specified parameters.The reference is an empty object with state fetched upon first access.
- Type Parameters:
T- Entity type- Parameters:
loadingParameters- Reference loading parameters- Returns:
- Entity reference
-
loadFieldValue
Loads entity field value and sets it on the specified entity.- Parameters:
entity- The entity on which the field value will be setfieldSpec- The field to loaddescriptor- Descriptor possibly specifying the field context
-
generateIdentifier
Generates a fresh identifier for an instance of the specified entity type.- Parameters:
et- Entity type used as base for the identifier- Returns:
- New entity identifier
-
persistEntity
Persists the specified entity into the underlying ontology.- Parameters:
identifier- Identifier of the persisted entity, possiblynullentity- The entity to persistdescriptor- Descriptor possibly specifying entity and attribute contexts
-
removeEntity
Removes entity with specified identifier from the ontology.- Parameters:
identifier- Entity identifiercls- Entity classdescriptor- Descriptor specifying entity attribute contexts
-
checkForUnpersistedChanges
void checkForUnpersistedChanges()Checks that there are not any pending changes in the mapper.- Throws:
UnpersistedChangeException- Thrown when there are unpersisted changes
-
updateFieldValue
<T> void updateFieldValue(T entity, FieldSpecification<? super T, ?> fieldSpec, Descriptor descriptor) Sets value of property represented by the specified field to the field's value.- Parameters:
entity- Entity containing the fieldfieldSpec- The field to updatedescriptor- Optionally specifies context
-
getAttributeAxioms
<T> Set<Axiom<?>> getAttributeAxioms(T entity, FieldSpecification<? super T, ?> fieldSpec, Descriptor entityDescriptor) Extracts the value of the specified field from the specified entity and transforms it to axioms.- Type Parameters:
T- Entity type- Parameters:
entity- Entity to extract attribute fromfieldSpec- Field specification determining which values to extractentityDescriptor- Entity descriptor- Returns:
- Set of axioms representing the field value
-
isInferred
<T> boolean isInferred(T entity, FieldSpecification<? super T, ?> fieldSpec, Object value, Descriptor entityDescriptor) Checks if the specified attribute value of the specified entity is inferred in the repository.Note that attribute context may be ignored by the underlying repository, based on its inference storing strategy. Also note that if the corresponding statement is both inferred and asserted, this method will return
true.- Type Parameters:
T- Entity type- Parameters:
entity- Entity whose attribute value to examinefieldSpec- Field specification representing the property to examinevalue- Value whose inference status to examineentityDescriptor- Entity descriptor used to specify repository context- Returns:
trueif the value is inferred,falseotherwise
-