Skip to content

Package: ObjectOntologyMapper

ObjectOntologyMapper

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.oom;
16:
17: import java.lang.reflect.Field;
18: import java.net.URI;
19:
20: import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
21: import cz.cvut.kbss.jopa.oom.exceptions.UnpersistedChangeException;
22: import cz.cvut.kbss.jopa.sessions.LoadingParameters;
23:
24: public interface ObjectOntologyMapper {
25:
26: /**
27: * Checks whether the storage contains individual with the specified
28: * identifier and of the specified type. </p>
29: *
30: * @param cls Class representing the individual type
31: * @param primaryKey Identifier
32: * @param descriptor Descriptor, can specify context
33: * @return {@code true} if the ontology contains such individual,
34: * {@code false} otherwise
35: */
36: public <T> boolean containsEntity(Class<T> cls, URI primaryKey, Descriptor descriptor);
37:
38: /**
39: * Loads and reconstructs the entity from the ontology. </p>
40: *
41: * @param loadingParameters Entity loading parameters
42: * @return Reconstructed entity or {@code null} if there is none such
43: */
44: public <T> T loadEntity(LoadingParameters<T> loadingParameters);
45:
46: /**
47: * Loads entity field value and sets it on the specified entity. </p>
48: *
49: * @param entity The entity on which the field value will be set
50: * @param field The field to load
51: * @param descriptor Descriptor possibly specifying the field context
52: */
53: public <T> void loadFieldValue(T entity, Field field, Descriptor descriptor);
54:
55: /**
56: * Persists the specified entity into the underlying ontology. </p>
57: *
58: * @param primaryKey Primary key of the persisted entity, possibly {@code null}
59: * @param entity The entity to persist
60: * @param descriptor Descriptor possibly specifying entity and attribute contexts
61: */
62: public <T> void persistEntity(URI primaryKey, T entity, Descriptor descriptor);
63:
64: /**
65: * Removes entity with specified identifier from the ontology.
66: *
67: * @param primaryKey Entity identifier
68: * @param cls Entity class
69: * @param descriptor Descriptor specifying entity attribute contexts
70: */
71: public <T> void removeEntity(URI primaryKey, Class<T> cls, Descriptor descriptor);
72:
73: /**
74: * Checks that there are no pending changes in the mapper. </p>
75: *
76: * @throws UnpersistedChangeException
77: */
78: public void checkForUnpersistedChanges();
79:
80: /**
81: * Sets value of property represented by the specified field to the field's
82: * value.
83: *
84: * @param entity Entity containing the field
85: * @param field The field to update
86: * @param descriptor Optionally specifies context
87: */
88: public <T> void updateFieldValue(T entity, Field field, Descriptor descriptor);
89: }