1
|
/**
|
2
|
* Copyright (C) 2019 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.io.descriptive.owl.in;
|
10
|
|
11
|
import java.net.URI;
|
12
|
import java.util.Arrays;
|
13
|
|
14
|
import org.springframework.stereotype.Component;
|
15
|
|
16
|
import com.hp.hpl.jena.rdf.model.ResIterator;
|
17
|
import com.hp.hpl.jena.rdf.model.Resource;
|
18
|
|
19
|
import eu.etaxonomy.cdm.io.common.CdmImportBase;
|
20
|
import eu.etaxonomy.cdm.io.descriptive.owl.OwlUtil;
|
21
|
import eu.etaxonomy.cdm.model.description.Character;
|
22
|
|
23
|
/**
|
24
|
*
|
25
|
* @author pplitzner
|
26
|
* @since Aug 28, 2019
|
27
|
*/
|
28
|
@Component("characterOwlImport")
|
29
|
public class CharacterOwlImport
|
30
|
extends CdmImportBase<StructureTreeOwlImportConfigurator, StructureTreeOwlImportState> {
|
31
|
|
32
|
private static final long serialVersionUID = -3659780404413458511L;
|
33
|
|
34
|
static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(CharacterOwlImport.class);
|
35
|
|
36
|
|
37
|
@Override
|
38
|
protected boolean doCheck(StructureTreeOwlImportState state) {
|
39
|
logger.warn("Checking not yet implemented for " + this.getClass().getSimpleName());
|
40
|
return true;
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public void doInvoke(StructureTreeOwlImportState state) {
|
45
|
URI source = state.getConfig().getSource();
|
46
|
state.getModel().read(source.toString());
|
47
|
ResIterator iterator = state.getModel().listResourcesWithProperty(OwlUtil.propIsA, OwlUtil.CHARACTER);
|
48
|
while(iterator.hasNext()){
|
49
|
Resource characterResource = iterator.next();
|
50
|
Character character = OwlImportUtil.findTerm(Character.class, characterResource, this, state.getModel(), state);
|
51
|
character = (Character) getTermService().load(character.getUuid(), Arrays.asList(new String[] {
|
52
|
"structure",
|
53
|
"structure.term",
|
54
|
"property",
|
55
|
"property.term",
|
56
|
"structureModifier",
|
57
|
"propertyModifier",
|
58
|
"recommendedModifierEnumeration",
|
59
|
"recommendedStatisticalMeasures",
|
60
|
"recommendedMeasurementUnits",
|
61
|
"supportedCategoricalEnumerations",
|
62
|
}));
|
63
|
OwlImportUtil.addCharacterProperties(character, characterResource, this, state.getModel(), state);
|
64
|
getTermService().saveOrUpdate(character);
|
65
|
}
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
protected boolean isIgnore(StructureTreeOwlImportState state) {
|
70
|
return false;
|
71
|
}
|
72
|
|
73
|
}
|