Package cz.cvut.kbss.jopa.oom
Class ObjectOntologyMapperImpl
java.lang.Object
cz.cvut.kbss.jopa.oom.ObjectOntologyMapperImpl
- All Implemented Interfaces:
ObjectOntologyMapper,ConfigurationHolder
-
Constructor Summary
Constructors -
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.Gets provider configuration.<T> TgetEntityFromCacheOrOntology(Class<T> cls, URI identifier, Descriptor descriptor) <T> IdentifiableEntityType<T>getEntityType(Class<T> cls) <T> TgetOriginalInstance(T clone) <T> TgetReference(LoadingParameters<T> loadingParameters) Gets a reference to an entity corresponding to the specified parameters.getUow()booleanisInferred(Axiom<?> axiom, URI context) <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.booleanisManagedType(Class<?> cls) <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.Collection<Axiom<?>>loadRdfContainer(ContainerDescriptor containerDescriptor) Collection<Axiom<?>>loadReferencedList(ReferencedListDescriptor listDescriptor) loadSimpleList(SimpleListDescriptor listDescriptor) <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 entityDescriptor) Sets value of property represented by the specified field to the field's value.
-
Constructor Details
-
ObjectOntologyMapperImpl
-
-
Method Details
-
containsEntity
Description copied from interface:ObjectOntologyMapperChecks whether the storage contains an individual with the specified identifier and of the specified type.- Specified by:
containsEntityin interfaceObjectOntologyMapper- Parameters:
cls- Class representing the individual typeidentifier- Identifierdescriptor- Descriptor, can specify context- Returns:
trueif the ontology contains such an individual,falseotherwise
-
loadEntity
Description copied from interface:ObjectOntologyMapperLoads and reconstructs an entity from the ontology.- Specified by:
loadEntityin interfaceObjectOntologyMapper- Type Parameters:
T- Entity type- Parameters:
loadingParameters- Entity loading parameters- Returns:
- Reconstructed entity or
nullif there is none such
-
loadEntity
Description copied from interface:ObjectOntologyMapperLoads 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.
- Specified by:
loadEntityin interfaceObjectOntologyMapper- 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
Description copied from interface:ObjectOntologyMapperGets a reference to an entity corresponding to the specified parameters.The reference is an empty object with state fetched upon first access.
- Specified by:
getReferencein interfaceObjectOntologyMapper- Type Parameters:
T- Entity type- Parameters:
loadingParameters- Reference loading parameters- Returns:
- Entity reference
-
getEntityType
-
isManagedType
-
loadFieldValue
public <T> void loadFieldValue(T entity, FieldSpecification<? super T, ?> fieldSpec, Descriptor descriptor) Description copied from interface:ObjectOntologyMapperLoads entity field value and sets it on the specified entity.- Specified by:
loadFieldValuein interfaceObjectOntologyMapper- Parameters:
entity- The entity on which the field value will be setfieldSpec- The field to loaddescriptor- Descriptor possibly specifying the field context
-
persistEntity
Description copied from interface:ObjectOntologyMapperPersists the specified entity into the underlying ontology.- Specified by:
persistEntityin interfaceObjectOntologyMapper- Parameters:
identifier- Identifier of the persisted entity, possiblynullentity- The entity to persistdescriptor- Descriptor possibly specifying entity and attribute contexts
-
generateIdentifier
Description copied from interface:ObjectOntologyMapperGenerates a fresh identifier for an instance of the specified entity type.- Specified by:
generateIdentifierin interfaceObjectOntologyMapper- Parameters:
et- Entity type used as base for the identifier- Returns:
- New entity identifier
-
getEntityFromCacheOrOntology
-
getOriginalInstance
public <T> T getOriginalInstance(T clone) -
checkForUnpersistedChanges
public void checkForUnpersistedChanges()Description copied from interface:ObjectOntologyMapperChecks that there are not any pending changes in the mapper.- Specified by:
checkForUnpersistedChangesin interfaceObjectOntologyMapper
-
removeEntity
Description copied from interface:ObjectOntologyMapperRemoves entity with specified identifier from the ontology.- Specified by:
removeEntityin interfaceObjectOntologyMapper- Parameters:
identifier- Entity identifiercls- Entity classdescriptor- Descriptor specifying entity attribute contexts
-
updateFieldValue
public <T> void updateFieldValue(T entity, FieldSpecification<? super T, ?> fieldSpec, Descriptor entityDescriptor) Description copied from interface:ObjectOntologyMapperSets value of property represented by the specified field to the field's value.- Specified by:
updateFieldValuein interfaceObjectOntologyMapper- Parameters:
entity- Entity containing the fieldfieldSpec- The field to updateentityDescriptor- Optionally specifies context
-
loadSimpleList
-
loadReferencedList
-
loadRdfContainer
-
getConfiguration
Description copied from interface:ConfigurationHolderGets provider configuration.- Specified by:
getConfigurationin interfaceConfigurationHolder- Returns:
- Configuration
-
getAttributeAxioms
public <T> Set<Axiom<?>> getAttributeAxioms(T entity, FieldSpecification<? super T, ?> fieldSpec, Descriptor entityDescriptor) Description copied from interface:ObjectOntologyMapperExtracts the value of the specified field from the specified entity and transforms it to axioms.- Specified by:
getAttributeAxiomsin interfaceObjectOntologyMapper- 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
-
isInferred
public <T> boolean isInferred(T entity, FieldSpecification<? super T, ?> fieldSpec, Object value, Descriptor entityDescriptor) Description copied from interface:ObjectOntologyMapperChecks 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.- Specified by:
isInferredin interfaceObjectOntologyMapper- 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
-
getUow
-