Project

General

Profile

Download (2.62 KB) Statistics
| Branch: | Tag: | Revision:
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.util.Arrays;
12

    
13
import org.apache.logging.log4j.LogManager;
14
import org.apache.logging.log4j.Logger;
15
import org.springframework.stereotype.Component;
16

    
17
import com.hp.hpl.jena.rdf.model.ResIterator;
18
import com.hp.hpl.jena.rdf.model.Resource;
19

    
20
import eu.etaxonomy.cdm.common.URI;
21
import eu.etaxonomy.cdm.io.common.CdmImportBase;
22
import eu.etaxonomy.cdm.io.descriptive.owl.OwlUtil;
23
import eu.etaxonomy.cdm.model.description.Character;
24

    
25
/**
26
 * @author pplitzner
27
 * @since Aug 28, 2019
28
 */
29
@Component("characterOwlImport")
30
public class CharacterOwlImport
31
        extends CdmImportBase<StructureTreeOwlImportConfigurator, StructureTreeOwlImportState> {
32

    
33
    private static final long serialVersionUID = -3659780404413458511L;
34

    
35
    private final static Logger logger = LogManager.getLogger();
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
}
(1-1/6)