|
1
|
|
|
/* |
|
2
|
|
|
* |
|
3
|
|
|
* Copyright (C) 2009-2017 Julian Mendez |
|
4
|
|
|
* |
|
5
|
|
|
* |
|
6
|
|
|
* This file is part of jcel. |
|
7
|
|
|
* |
|
8
|
|
|
* |
|
9
|
|
|
* The contents of this file are subject to the GNU Lesser General Public License |
|
10
|
|
|
* version 3 |
|
11
|
|
|
* |
|
12
|
|
|
* |
|
13
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
14
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
|
15
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
16
|
|
|
* (at your option) any later version. |
|
17
|
|
|
* |
|
18
|
|
|
* This program is distributed in the hope that it will be useful, |
|
19
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21
|
|
|
* GNU Lesser General Public License for more details. |
|
22
|
|
|
* |
|
23
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
24
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25
|
|
|
* |
|
26
|
|
|
* |
|
27
|
|
|
* Alternatively, the contents of this file may be used under the terms |
|
28
|
|
|
* of the Apache License, Version 2.0, in which case the |
|
29
|
|
|
* provisions of the Apache License, Version 2.0 are applicable instead of those |
|
30
|
|
|
* above. |
|
31
|
|
|
* |
|
32
|
|
|
* |
|
33
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
34
|
|
|
* you may not use this file except in compliance with the License. |
|
35
|
|
|
* You may obtain a copy of the License at |
|
36
|
|
|
* |
|
37
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
38
|
|
|
* |
|
39
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
40
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
41
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
42
|
|
|
* See the License for the specific language governing permissions and |
|
43
|
|
|
* limitations under the License. |
|
44
|
|
|
* |
|
45
|
|
|
*/ |
|
46
|
|
|
|
|
47
|
|
|
package de.tudresden.inf.lat.jcel.owlapi.translator; |
|
48
|
|
|
|
|
49
|
|
|
import java.util.HashMap; |
|
50
|
|
|
import java.util.Map; |
|
51
|
|
|
import java.util.Objects; |
|
52
|
|
|
import java.util.Optional; |
|
53
|
|
|
|
|
54
|
|
|
import org.semanticweb.owlapi.model.OWLAnnotationProperty; |
|
55
|
|
|
import org.semanticweb.owlapi.model.OWLAnnotationValue; |
|
56
|
|
|
import org.semanticweb.owlapi.model.OWLClass; |
|
57
|
|
|
import org.semanticweb.owlapi.model.OWLDataFactory; |
|
58
|
|
|
import org.semanticweb.owlapi.model.OWLDataProperty; |
|
59
|
|
|
import org.semanticweb.owlapi.model.OWLIndividual; |
|
60
|
|
|
import org.semanticweb.owlapi.model.OWLLiteral; |
|
61
|
|
|
import org.semanticweb.owlapi.model.OWLNamedIndividual; |
|
62
|
|
|
import org.semanticweb.owlapi.model.OWLObjectProperty; |
|
63
|
|
|
import org.semanticweb.owlapi.model.OWLOntology; |
|
64
|
|
|
|
|
65
|
|
|
import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerEntityManager; |
|
66
|
|
|
import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerEntityType; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* An object of this class is a repository used for the translation between OWL |
|
70
|
|
|
* API objects and the integer numbers. Each entity is identified by an integer |
|
71
|
|
|
* number. |
|
72
|
|
|
* |
|
73
|
|
|
* @author Julian Mendez |
|
74
|
|
|
*/ |
|
75
|
|
|
public class TranslationRepository { |
|
76
|
|
|
|
|
77
|
|
|
private final OWLClass bottomClass; |
|
78
|
|
|
private final OWLDataProperty bottomDataProperty; |
|
79
|
|
|
private final OWLObjectProperty bottomObjectProperty; |
|
80
|
|
|
private final Map<OWLClass, Integer> classInvMap = new HashMap<>(); |
|
81
|
|
|
private final Map<Integer, OWLClass> classMap = new HashMap<>(); |
|
82
|
|
|
private final Map<OWLDataProperty, Integer> dataPropertyInvMap = new HashMap<>(); |
|
83
|
|
|
private final Map<Integer, OWLDataProperty> dataPropertyMap = new HashMap<>(); |
|
84
|
|
|
private final IntegerEntityManager entityManager; |
|
85
|
|
|
private final Map<OWLNamedIndividual, Integer> individualInvMap = new HashMap<>(); |
|
86
|
|
|
private final Map<Integer, OWLNamedIndividual> individualMap = new HashMap<>(); |
|
87
|
|
|
private final Map<OWLLiteral, Integer> literalInvMap = new HashMap<>(); |
|
88
|
|
|
private final Map<Integer, OWLLiteral> literalMap = new HashMap<>(); |
|
89
|
|
|
private final Map<OWLObjectProperty, Integer> objectPropertyInvMap = new HashMap<>(); |
|
90
|
|
|
private final Map<Integer, OWLObjectProperty> objectPropertyMap = new HashMap<>(); |
|
91
|
|
|
private final Map<OWLAnnotationProperty, Integer> annotationPropertyInvMap = new HashMap<>(); |
|
92
|
|
|
private final Map<Integer, OWLAnnotationProperty> annotationPropertyMap = new HashMap<>(); |
|
93
|
|
|
private final Map<OWLAnnotationValue, Integer> annotationValueInvMap = new HashMap<>(); |
|
94
|
|
|
private final Map<Integer, OWLAnnotationValue> annotationValueMap = new HashMap<>(); |
|
95
|
|
|
private final OWLClass topClass; |
|
96
|
|
|
private final OWLDataProperty topDataProperty; |
|
97
|
|
|
private final OWLObjectProperty topObjectProperty; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Constructs a new translation repository. |
|
101
|
|
|
* |
|
102
|
|
|
* @param dataFactory |
|
103
|
|
|
* OWL ontology |
|
104
|
|
|
* @param manager |
|
105
|
|
|
* entity manager |
|
106
|
|
|
*/ |
|
107
|
|
|
public TranslationRepository(OWLDataFactory dataFactory, IntegerEntityManager manager) { |
|
108
|
|
|
Objects.requireNonNull(dataFactory); |
|
109
|
|
|
Objects.requireNonNull(manager); |
|
110
|
|
|
this.entityManager = manager; |
|
111
|
|
|
|
|
112
|
|
|
this.bottomClass = dataFactory.getOWLNothing(); |
|
113
|
|
|
this.topClass = dataFactory.getOWLThing(); |
|
114
|
|
|
this.bottomObjectProperty = dataFactory.getOWLBottomObjectProperty(); |
|
115
|
|
|
this.topObjectProperty = dataFactory.getOWLTopObjectProperty(); |
|
116
|
|
|
this.bottomDataProperty = dataFactory.getOWLBottomDataProperty(); |
|
117
|
|
|
this.topDataProperty = dataFactory.getOWLTopDataProperty(); |
|
118
|
|
|
|
|
119
|
|
|
initializeMaps(); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Adds the entities of an ontology to the repository. |
|
124
|
|
|
* |
|
125
|
|
|
* @param ontology |
|
126
|
|
|
* OWL ontology |
|
127
|
|
|
* @return <code>true</code> if and only if the repository has changed |
|
128
|
|
|
*/ |
|
129
|
|
|
public boolean addAxiomEntities(OWLOntology ontology) { |
|
130
|
|
|
Objects.requireNonNull(ontology); |
|
131
|
|
|
boolean ret = false; |
|
132
|
|
|
|
|
133
|
|
|
ret = ontology.getClassesInSignature().stream().map(cls -> addClass(cls)) // |
|
134
|
|
|
.reduce(ret, (accum, elem) -> (accum || elem)); |
|
135
|
|
|
|
|
136
|
|
|
ret = ontology.getObjectPropertiesInSignature().stream().map(objProp -> addObjectProperty(objProp)) // |
|
137
|
|
|
.reduce(ret, (accum, elem) -> (accum || elem)); |
|
138
|
|
|
|
|
139
|
|
|
ret = ontology.getIndividualsInSignature().stream().map(indiv -> addNamedIndividual(indiv)) // |
|
140
|
|
|
.reduce(ret, (accum, elem) -> (accum || elem)); |
|
141
|
|
|
|
|
142
|
|
|
ret = ontology.getDataPropertiesInSignature().stream().map(dataProp -> addDataProperty(dataProp)) // |
|
143
|
|
|
.reduce(ret, (accum, elem) -> (accum || elem)); |
|
144
|
|
|
|
|
145
|
|
|
return ret; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* Adds a class to the repository. |
|
150
|
|
|
* |
|
151
|
|
|
* @param cls |
|
152
|
|
|
* OWL class |
|
153
|
|
|
* @return <code>true</code> if and only if the repository has changed |
|
154
|
|
|
*/ |
|
155
|
|
|
public boolean addClass(OWLClass cls) { |
|
156
|
|
|
Objects.requireNonNull(cls); |
|
157
|
|
|
boolean ret = false; |
|
158
|
|
|
if (!this.classInvMap.containsKey(cls)) { |
|
159
|
|
|
Integer id = this.entityManager.createNamedEntity(IntegerEntityType.CLASS, cls.toStringID(), false); |
|
160
|
|
|
this.classMap.put(id, cls); |
|
161
|
|
|
this.classInvMap.put(cls, id); |
|
162
|
|
|
ret = true; |
|
163
|
|
|
} |
|
164
|
|
|
return ret; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Adds a data property to the repository. |
|
169
|
|
|
* |
|
170
|
|
|
* @param dataProp |
|
171
|
|
|
* OWL data property |
|
172
|
|
|
* @return <code>true</code> if and only if the repository has changed |
|
173
|
|
|
*/ |
|
174
|
|
|
public boolean addDataProperty(OWLDataProperty dataProp) { |
|
175
|
|
|
Objects.requireNonNull(dataProp); |
|
176
|
|
|
boolean ret = false; |
|
177
|
|
|
if (!this.dataPropertyInvMap.containsKey(dataProp)) { |
|
178
|
|
|
Integer id = this.entityManager.createNamedEntity(IntegerEntityType.DATA_PROPERTY, dataProp.toStringID(), |
|
179
|
|
|
false); |
|
180
|
|
|
this.dataPropertyMap.put(id, dataProp); |
|
181
|
|
|
this.dataPropertyInvMap.put(dataProp, id); |
|
182
|
|
|
ret = true; |
|
183
|
|
|
} |
|
184
|
|
|
return ret; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* Adds a literal to the repository. |
|
189
|
|
|
* |
|
190
|
|
|
* @param lit |
|
191
|
|
|
* OWL literal |
|
192
|
|
|
* @return <code>true</code> if and only if the repository has changed |
|
193
|
|
|
*/ |
|
194
|
|
|
public boolean addLiteral(OWLLiteral lit) { |
|
195
|
|
|
Objects.requireNonNull(lit); |
|
196
|
|
|
boolean ret = false; |
|
197
|
|
|
if (!this.literalInvMap.containsKey(lit)) { |
|
198
|
|
|
Integer id = this.entityManager.createNamedEntity(IntegerEntityType.LITERAL, lit.getLiteral(), false); |
|
199
|
|
|
this.literalMap.put(id, lit); |
|
200
|
|
|
this.literalInvMap.put(lit, id); |
|
201
|
|
|
ret = true; |
|
202
|
|
|
} |
|
203
|
|
|
return ret; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Adds an named individual to the repository. |
|
208
|
|
|
* |
|
209
|
|
|
* @param indiv |
|
210
|
|
|
* OWL named individual |
|
211
|
|
|
* @return <code>true</code> if and only if the repository has changed |
|
212
|
|
|
*/ |
|
213
|
|
|
public boolean addNamedIndividual(OWLNamedIndividual indiv) { |
|
214
|
|
|
Objects.requireNonNull(indiv); |
|
215
|
|
|
boolean ret = false; |
|
216
|
|
|
if (!this.individualInvMap.containsKey(indiv)) { |
|
217
|
|
|
Integer id = this.entityManager.createNamedEntity(IntegerEntityType.INDIVIDUAL, indiv.toStringID(), false); |
|
218
|
|
|
this.individualMap.put(id, indiv); |
|
219
|
|
|
this.individualInvMap.put(indiv, id); |
|
220
|
|
|
ret = true; |
|
221
|
|
|
} |
|
222
|
|
|
return ret; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* Adds an object property to the repository. |
|
227
|
|
|
* |
|
228
|
|
|
* @param objProp |
|
229
|
|
|
* OWL object property |
|
230
|
|
|
* @return <code>true</code> if and only if the repository has changed |
|
231
|
|
|
*/ |
|
232
|
|
|
public boolean addObjectProperty(OWLObjectProperty objProp) { |
|
233
|
|
|
Objects.requireNonNull(objProp); |
|
234
|
|
|
boolean ret = false; |
|
235
|
|
|
if (!this.objectPropertyInvMap.containsKey(objProp)) { |
|
236
|
|
|
Integer id = this.entityManager.createNamedEntity(IntegerEntityType.OBJECT_PROPERTY, objProp.toStringID(), |
|
237
|
|
|
false); |
|
238
|
|
|
this.objectPropertyMap.put(id, objProp); |
|
239
|
|
|
this.objectPropertyInvMap.put(objProp, id); |
|
240
|
|
|
ret = true; |
|
241
|
|
|
} |
|
242
|
|
|
return ret; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* Adds an annotation property to the repository. |
|
247
|
|
|
* |
|
248
|
|
|
* @param annProp |
|
249
|
|
|
* OWL annotation property |
|
250
|
|
|
* @return <code>true</code> if and only if the repository has changed |
|
251
|
|
|
*/ |
|
252
|
|
|
public boolean addAnnotationProperty(OWLAnnotationProperty annProp) { |
|
253
|
|
|
Objects.requireNonNull(annProp); |
|
254
|
|
|
boolean ret = false; |
|
255
|
|
|
if (!this.annotationPropertyInvMap.containsKey(annProp)) { |
|
256
|
|
|
Integer id = this.entityManager.createNamedEntity(IntegerEntityType.ANNOTATION_PROPERTY, |
|
257
|
|
|
annProp.toStringID(), false); |
|
258
|
|
|
this.annotationPropertyMap.put(id, annProp); |
|
259
|
|
|
this.annotationPropertyInvMap.put(annProp, id); |
|
260
|
|
|
ret = true; |
|
261
|
|
|
} |
|
262
|
|
|
return ret; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* Adds an annotation value to the repository. |
|
267
|
|
|
* |
|
268
|
|
|
* @param annValue |
|
269
|
|
|
* OWL annotation value |
|
270
|
|
|
* @return <code>true</code> if and only if the repository has changed |
|
271
|
|
|
*/ |
|
272
|
|
|
public boolean addAnnotationValue(OWLAnnotationValue annValue) { |
|
273
|
|
|
Objects.requireNonNull(annValue); |
|
274
|
|
|
boolean ret = false; |
|
275
|
|
|
if (!this.annotationValueInvMap.containsKey(annValue)) { |
|
276
|
|
|
if (annValue.asLiteral().isPresent()) { |
|
277
|
|
|
Integer id = this.entityManager.createNamedEntity(IntegerEntityType.ANNOTATION_VALUE, |
|
278
|
|
|
annValue.asLiteral().get().getLiteral(), false); |
|
279
|
|
|
this.annotationValueMap.put(id, annValue); |
|
280
|
|
|
this.annotationValueInvMap.put(annValue, id); |
|
281
|
|
|
ret = true; |
|
282
|
|
|
} |
|
283
|
|
|
} |
|
284
|
|
|
return ret; |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
public Integer getId(OWLClass owlClass) { |
|
288
|
|
|
Objects.requireNonNull(owlClass); |
|
289
|
|
|
Integer ret = this.classInvMap.get(owlClass); |
|
290
|
|
|
if (Objects.isNull(ret)) { |
|
291
|
|
|
throw TranslationException.newIncompleteMapException(owlClass.toStringID()); |
|
292
|
|
|
} |
|
293
|
|
|
return ret; |
|
294
|
|
|
} |
|
295
|
|
|
|
|
296
|
|
|
public Integer getId(OWLDataProperty owlDataProperty) { |
|
297
|
|
|
Objects.requireNonNull(owlDataProperty); |
|
298
|
|
|
Integer ret = this.dataPropertyInvMap.get(owlDataProperty); |
|
299
|
|
|
if (Objects.isNull(ret)) { |
|
300
|
|
|
throw TranslationException.newIncompleteMapException(owlDataProperty.toStringID()); |
|
301
|
|
|
} |
|
302
|
|
|
return ret; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
public Integer getId(OWLIndividual individual) { |
|
306
|
|
|
Objects.requireNonNull(individual); |
|
307
|
|
|
Integer ret = this.individualInvMap.get(individual); |
|
308
|
|
|
if (Objects.isNull(ret)) { |
|
309
|
|
|
throw TranslationException.newIncompleteMapException(individual.toStringID()); |
|
310
|
|
|
} |
|
311
|
|
|
return ret; |
|
312
|
|
|
} |
|
313
|
|
|
|
|
314
|
|
|
public Integer getId(OWLLiteral owlLiteral) { |
|
315
|
|
|
Objects.requireNonNull(owlLiteral); |
|
316
|
|
|
Integer ret = this.literalInvMap.get(owlLiteral); |
|
317
|
|
|
if (Objects.isNull(ret)) { |
|
318
|
|
|
throw TranslationException.newIncompleteMapException(owlLiteral.getLiteral()); |
|
319
|
|
|
} |
|
320
|
|
|
return ret; |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
public Integer getId(OWLObjectProperty owlObjectProperty) { |
|
324
|
|
|
Objects.requireNonNull(owlObjectProperty); |
|
325
|
|
|
Integer ret = this.objectPropertyInvMap.get(owlObjectProperty); |
|
326
|
|
|
if (Objects.isNull(ret)) { |
|
327
|
|
|
throw TranslationException.newIncompleteMapException(owlObjectProperty.toStringID()); |
|
328
|
|
|
} |
|
329
|
|
|
return ret; |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
public Integer getId(OWLAnnotationProperty owlAnnotationProperty) { |
|
333
|
|
|
Objects.requireNonNull(owlAnnotationProperty); |
|
334
|
|
|
Integer ret = this.annotationPropertyInvMap.get(owlAnnotationProperty); |
|
335
|
|
|
if (Objects.isNull(ret)) { |
|
336
|
|
|
throw TranslationException.newIncompleteMapException(owlAnnotationProperty.toStringID()); |
|
337
|
|
|
} |
|
338
|
|
|
return ret; |
|
339
|
|
|
} |
|
340
|
|
|
|
|
341
|
|
|
public Integer getId(OWLAnnotationValue owlAnnotationValue) { |
|
342
|
|
|
Objects.requireNonNull(owlAnnotationValue); |
|
343
|
|
|
Integer ret = this.annotationValueInvMap.get(owlAnnotationValue); |
|
344
|
|
|
if (Objects.isNull(ret)) { |
|
345
|
|
|
String msg = null; |
|
346
|
|
|
if (owlAnnotationValue.asLiteral().isPresent()) { |
|
347
|
|
|
msg = owlAnnotationValue.asLiteral().get().getLiteral(); |
|
348
|
|
|
} else { |
|
349
|
|
|
msg = owlAnnotationValue.toString(); |
|
350
|
|
|
} |
|
351
|
|
|
throw TranslationException.newIncompleteMapException(msg); |
|
352
|
|
|
} |
|
353
|
|
|
return ret; |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
public OWLClass getOWLClass(Integer index) { |
|
357
|
|
|
Objects.requireNonNull(index); |
|
358
|
|
|
OWLClass ret = this.classMap.get(index); |
|
359
|
|
|
if (Objects.isNull(ret)) { |
|
360
|
|
|
throw TranslationException.newIncompleteMapException(index.toString()); |
|
361
|
|
|
} |
|
362
|
|
|
return ret; |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
public OWLDataProperty getOWLDataProperty(Integer index) { |
|
366
|
|
|
Objects.requireNonNull(index); |
|
367
|
|
|
OWLDataProperty ret = this.dataPropertyMap.get(index); |
|
368
|
|
|
if (Objects.isNull(ret)) { |
|
369
|
|
|
throw TranslationException.newIncompleteMapException(index.toString()); |
|
370
|
|
|
} |
|
371
|
|
|
return ret; |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
public OWLNamedIndividual getOWLNamedIndividual(Integer index) { |
|
375
|
|
|
Objects.requireNonNull(index); |
|
376
|
|
|
OWLNamedIndividual ret = this.individualMap.get(index); |
|
377
|
|
|
if (Objects.isNull(ret)) { |
|
378
|
|
|
throw TranslationException.newIncompleteMapException(index.toString()); |
|
379
|
|
|
} |
|
380
|
|
|
return ret; |
|
381
|
|
|
} |
|
382
|
|
|
|
|
383
|
|
|
public OWLObjectProperty getOWLObjectProperty(Integer index) { |
|
384
|
|
|
Objects.requireNonNull(index); |
|
385
|
|
|
OWLObjectProperty ret = this.objectPropertyMap.get(index); |
|
386
|
|
|
if (Objects.isNull(ret)) { |
|
387
|
|
|
throw TranslationException.newIncompleteMapException(index.toString()); |
|
388
|
|
|
} |
|
389
|
|
|
return ret; |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
public OWLAnnotationProperty getOWLAnnotationProperty(Integer index) { |
|
393
|
|
|
Objects.requireNonNull(index); |
|
394
|
|
|
OWLAnnotationProperty ret = this.annotationPropertyMap.get(index); |
|
395
|
|
|
if (Objects.isNull(ret)) { |
|
396
|
|
|
throw TranslationException.newIncompleteMapException(index.toString()); |
|
397
|
|
|
} |
|
398
|
|
|
return ret; |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
public OWLAnnotationValue getOWLAnnotationValue(Integer index) { |
|
402
|
|
|
Objects.requireNonNull(index); |
|
403
|
|
|
OWLAnnotationValue ret = this.annotationValueMap.get(index); |
|
404
|
|
|
if (Objects.isNull(ret)) { |
|
405
|
|
|
throw TranslationException.newIncompleteMapException(index.toString()); |
|
406
|
|
|
} |
|
407
|
|
|
return ret; |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
public Optional<Integer> getOptId(OWLClass owlClass) { |
|
411
|
|
|
Objects.requireNonNull(owlClass); |
|
412
|
|
|
return Optional.ofNullable(this.classInvMap.get(owlClass)); |
|
413
|
|
|
} |
|
414
|
|
|
|
|
415
|
|
|
public Optional<Integer> getOptId(OWLDataProperty owlDataProperty) { |
|
416
|
|
|
Objects.requireNonNull(owlDataProperty); |
|
417
|
|
|
return Optional.ofNullable(this.dataPropertyInvMap.get(owlDataProperty)); |
|
418
|
|
|
} |
|
419
|
|
|
|
|
420
|
|
|
public Optional<Integer> getOptId(OWLIndividual individual) { |
|
421
|
|
|
Objects.requireNonNull(individual); |
|
422
|
|
|
return Optional.ofNullable(this.individualInvMap.get(individual)); |
|
423
|
|
|
} |
|
424
|
|
|
|
|
425
|
|
|
public Optional<Integer> getOptId(OWLLiteral owlLiteral) { |
|
426
|
|
|
Objects.requireNonNull(owlLiteral); |
|
427
|
|
|
return Optional.ofNullable(this.literalInvMap.get(owlLiteral)); |
|
428
|
|
|
} |
|
429
|
|
|
|
|
430
|
|
|
public Optional<Integer> getOptId(OWLObjectProperty owlObjectProperty) { |
|
431
|
|
|
Objects.requireNonNull(owlObjectProperty); |
|
432
|
|
|
return Optional.ofNullable(this.objectPropertyInvMap.get(owlObjectProperty)); |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
public Optional<Integer> getOptId(OWLAnnotationProperty owlAnnotationProperty) { |
|
436
|
|
|
Objects.requireNonNull(owlAnnotationProperty); |
|
437
|
|
|
return Optional.ofNullable(this.annotationPropertyInvMap.get(owlAnnotationProperty)); |
|
438
|
|
|
} |
|
439
|
|
|
|
|
440
|
|
|
public Optional<Integer> getOptId(OWLAnnotationValue owlAnnotationValue) { |
|
441
|
|
|
Objects.requireNonNull(owlAnnotationValue); |
|
442
|
|
|
Integer ret = this.annotationValueInvMap.get(owlAnnotationValue); |
|
443
|
|
|
if (Objects.isNull(ret)) { |
|
444
|
|
|
String msg = null; |
|
445
|
|
|
if (owlAnnotationValue.asLiteral().isPresent()) { |
|
446
|
|
|
msg = owlAnnotationValue.asLiteral().get().getLiteral(); |
|
447
|
|
|
} else { |
|
448
|
|
|
msg = owlAnnotationValue.toString(); |
|
449
|
|
|
} |
|
450
|
|
|
} |
|
451
|
|
|
return Optional.ofNullable(ret); |
|
452
|
|
|
} |
|
453
|
|
|
|
|
454
|
|
|
public Optional<OWLClass> getOptOWLClass(Integer index) { |
|
455
|
|
|
Objects.requireNonNull(index); |
|
456
|
|
|
return Optional.ofNullable(this.classMap.get(index)); |
|
457
|
|
|
} |
|
458
|
|
|
|
|
459
|
|
|
public Optional<OWLDataProperty> getOptOWLDataProperty(Integer index) { |
|
460
|
|
|
Objects.requireNonNull(index); |
|
461
|
|
|
return Optional.ofNullable(this.dataPropertyMap.get(index)); |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
public Optional<OWLNamedIndividual> getOptOWLNamedIndividual(Integer index) { |
|
465
|
|
|
Objects.requireNonNull(index); |
|
466
|
|
|
return Optional.ofNullable(this.individualMap.get(index)); |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
public Optional<OWLObjectProperty> getOptOWLObjectProperty(Integer index) { |
|
470
|
|
|
Objects.requireNonNull(index); |
|
471
|
|
|
return Optional.ofNullable(this.objectPropertyMap.get(index)); |
|
472
|
|
|
} |
|
473
|
|
|
|
|
474
|
|
|
public Optional<OWLAnnotationProperty> getOptOWLAnnotationProperty(Integer index) { |
|
475
|
|
|
Objects.requireNonNull(index); |
|
476
|
|
|
return Optional.ofNullable(this.annotationPropertyMap.get(index)); |
|
477
|
|
|
} |
|
478
|
|
|
|
|
479
|
|
|
public Optional<OWLAnnotationValue> getOptOWLAnnotationValue(Integer index) { |
|
480
|
|
|
Objects.requireNonNull(index); |
|
481
|
|
|
return Optional.ofNullable(this.annotationValueMap.get(index)); |
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
|
|
private void initializeMaps() { |
|
485
|
|
|
|
|
486
|
|
|
this.classMap.put(IntegerEntityManager.bottomClassId, this.bottomClass); |
|
487
|
|
|
this.classInvMap.put(this.bottomClass, IntegerEntityManager.bottomClassId); |
|
488
|
|
|
this.classMap.put(IntegerEntityManager.topClassId, this.topClass); |
|
489
|
|
|
this.classInvMap.put(this.topClass, IntegerEntityManager.topClassId); |
|
490
|
|
|
|
|
491
|
|
|
this.objectPropertyMap.put(IntegerEntityManager.bottomObjectPropertyId, this.bottomObjectProperty); |
|
492
|
|
|
this.objectPropertyInvMap.put(this.bottomObjectProperty, IntegerEntityManager.bottomObjectPropertyId); |
|
493
|
|
|
this.objectPropertyMap.put(IntegerEntityManager.topObjectPropertyId, this.topObjectProperty); |
|
494
|
|
|
this.objectPropertyInvMap.put(this.topObjectProperty, IntegerEntityManager.topObjectPropertyId); |
|
495
|
|
|
|
|
496
|
|
|
this.dataPropertyMap.put(IntegerEntityManager.bottomDataPropertyId, this.bottomDataProperty); |
|
497
|
|
|
this.dataPropertyInvMap.put(this.bottomDataProperty, IntegerEntityManager.bottomDataPropertyId); |
|
498
|
|
|
this.dataPropertyMap.put(IntegerEntityManager.topDataPropertyId, this.topDataProperty); |
|
499
|
|
|
this.dataPropertyInvMap.put(this.topDataProperty, IntegerEntityManager.topDataPropertyId); |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
@Override |
|
503
|
|
|
public String toString() { |
|
504
|
|
|
StringBuffer sbuf = new StringBuffer(); |
|
505
|
|
|
sbuf.append("\n"); |
|
506
|
|
|
sbuf.append(this.classMap.toString()); |
|
507
|
|
|
sbuf.append("\n"); |
|
508
|
|
|
sbuf.append(this.objectPropertyMap.toString()); |
|
509
|
|
|
sbuf.append("\n"); |
|
510
|
|
|
sbuf.append(this.individualMap.toString()); |
|
511
|
|
|
sbuf.append("\n"); |
|
512
|
|
|
sbuf.append(this.dataPropertyMap.toString()); |
|
513
|
|
|
sbuf.append("\n"); |
|
514
|
|
|
sbuf.append(this.literalMap.toString()); |
|
515
|
|
|
sbuf.append("\n"); |
|
516
|
|
|
sbuf.append(this.annotationPropertyMap.toString()); |
|
517
|
|
|
sbuf.append("\n"); |
|
518
|
|
|
sbuf.append(this.annotationValueMap.toString()); |
|
519
|
|
|
sbuf.append("\n"); |
|
520
|
|
|
return sbuf.toString(); |
|
521
|
|
|
} |
|
522
|
|
|
|
|
523
|
|
|
} |
|
524
|
|
|
|