View Javadoc
1   /*
2    * Copyright 2018-2022 Medical Information Systems Research Group (https://medical.zcu.cz),
3    * Department of Computer Science and Engineering, University of West Bohemia.
4    * Address: Univerzitni 8, 306 14 Plzen, Czech Republic.
5    *
6    * Author Petr Vcelak (vcelak@kiv.zcu.cz).
7    *
8    * This file is part of MRECore project.
9    *
10   * MRECore is free software: you can redistribute it and/or modify
11   * it under the terms of the GNU General Public License as published by
12   * the Free Software Foundation, either version 3 of the License.
13   *
14   * MRECore is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17   * GNU General Public License for more details.
18   *
19   * You should have received a copy of the GNU General Public License
20   * along with MRECore. If not, see <http://www.gnu.org/licenses/>.
21   */
22  package cz.zcu.mre.service.data;
23  
24  import cz.zcu.mre.data.rdf.VocabularyWrapper;
25  import java.util.List;
26  import org.apache.jena.rdf.model.Resource;
27  import org.springframework.beans.factory.InitializingBean;
28  
29  /**
30   * Vocabulary Service interface. Implementation should take care of providing
31   * vocabulary items.
32   *
33   * @author Petr Vcelak (vcelak@kiv.zcu.cz)
34   */
35  public interface VocabularyService extends InitializingBean {
36  
37      /**
38       * Get all vocabulary items.
39       *
40       * @param rdfClass Vocabulary class as a String.
41       * @return List of items as NamedIndividual instances.
42       */
43      List<VocabularyWrapper> itemsList(String rdfClass);
44  
45      /**
46       * Get all vocabulary items.
47       *
48       * @param rdfClass Vocabulary class.
49       * @return List of items as NamedIndividual instances.
50       */
51      List<VocabularyWrapper> itemsList(Resource rdfClass);
52  
53      /**
54       * Check whether any item exists.
55       *
56       * @param ontClass Vocabulary class.
57       * @return true if exist, false if no item exist.
58       */
59      boolean itemExist(final Resource ontClass);
60  
61      /**
62       * Get the item of the vocabulary by its code.
63       *
64       * @param ontClass Vocabulary class.
65       * @param itemCode Item code.
66       * @return Instance of the NamedIndividual.
67       */
68      VocabularyWrapper itemByCode(final Resource ontClass, final String itemCode);
69  
70      /**
71       * Check whether item with the code exist in the specified vocabulary.
72       *
73       * @param ontClass Vocabulary class.
74       * @param itemCode Item code.
75       * @return True it item exist, false otherwise.
76       */
77      boolean itemByCodeExist(Resource ontClass, String itemCode);
78  
79      /**
80       * Get the item of the vocabulary by its number.
81       *
82       * @param ontClass Vocabulary class.
83       * @param number Item number.
84       * @return Instance of the NamedIndividual.
85       */
86      VocabularyWrapper itemByNumber(final Resource ontClass, final int number);
87  
88      /**
89       * Check whether an item with the number exists.
90       *
91       * @param ontClass Vocabulary class.
92       * @param number Item number.
93       * @return True if exist, false otherwise.
94       */
95      boolean itemByNumberExist(final Resource ontClass, final int number);
96  
97      /**
98       * List items filtered by age and sex of patient.
99       *
100      * @param ontClass Vocabulary class.
101      * @param age Patient's age.
102      * @param sex Patient's sex.
103      * @return List of individuals for the Vocabulary class.
104      */
105     List<VocabularyWrapper> itemsFilteredByAgeSex(Resource ontClass, int age, String sex);
106 
107     /**
108      * Get default item. The default item has number 1 or has flagged as
109      * default.
110      *
111      * @param ontClass Type of class as a String.
112      * @return NamedIndividual of the class. Null on no instance.
113      */
114     VocabularyWrapper itemDefault(String ontClass);
115 
116     /**
117      * Get default item. The default item has number 1 or has flagged as
118      * default.
119      *
120      * @param ontClass Type of class.
121      * @return NamedIndividual of the class. Null on no instance.
122      */
123     VocabularyWrapper itemDefault(final Resource ontClass);
124 
125     /**
126      * Get the first item.
127      *
128      * @param ontClass Type of class.
129      * @return NamedIndividual of the class. Null on no instance.
130      */
131     VocabularyWrapper itemFirst(final Resource ontClass);
132 
133     /**
134      * Get the last item.
135      *
136      * @param ontClass Type of class.
137      * @return NamedIndividual of the class. Null on no instance.
138      */
139     VocabularyWrapper itemLast(final Resource ontClass);
140 
141     /**
142      * Get the number of available vocabulary items.
143      *
144      * @param ontClass Type of class.
145      * @return Zero or positive integer number.
146      */
147     int itemCount(final Resource ontClass);
148 
149     /**
150      * Get VocabularyWrapper for specified uri.
151      *
152      * @param uri URI of the vocabulary item (Individual).
153      * @return VocabularyWrapper instance or null.
154      */
155     VocabularyWrapper item(String uri);
156 
157     /**
158      * Get the resource label.
159      *
160      * @param resource The resource.
161      * @return The label.
162      */
163     String label(Resource resource);
164 
165     /**
166      * Get the resource code.
167      *
168      * @param resource The resource.
169      * @return The label.
170      */
171     String code(Resource resource);
172 
173 }