1
|
/**
|
2
|
* Copyright (C) 2017 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.prometheus;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.List;
|
13
|
|
14
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
15
|
import eu.etaxonomy.cdm.io.csv.in.CsvImportState;
|
16
|
import eu.etaxonomy.cdm.model.agent.Person;
|
17
|
import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod;
|
18
|
import eu.etaxonomy.cdm.model.description.Feature;
|
19
|
import eu.etaxonomy.cdm.model.description.State;
|
20
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
21
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
22
|
import eu.etaxonomy.cdm.model.term.TermType;
|
23
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
24
|
|
25
|
/**
|
26
|
*
|
27
|
* @author pplitzner
|
28
|
* @date 18.02.2019
|
29
|
*
|
30
|
*/
|
31
|
public class PrometheusPropertiesCsvImportState extends CsvImportState<PrometheusPropertiesCsvImportConfigurator> {
|
32
|
|
33
|
private List<State> existingTerms = new ArrayList<>();
|
34
|
private final TermVocabulary<Feature> propertiesVoc;
|
35
|
private final Reference citation;
|
36
|
|
37
|
|
38
|
protected PrometheusPropertiesCsvImportState(PrometheusPropertiesCsvImportConfigurator config) {
|
39
|
super(config);
|
40
|
propertiesVoc = TermVocabulary.NewInstance(TermType.Feature);
|
41
|
propertiesVoc.setLabel("Properties");
|
42
|
|
43
|
citation = ReferenceFactory.newGeneric();
|
44
|
citation.setTitle("The Prometheus Description Model: an examination of the taxonomic description-building process and its representation.");
|
45
|
Person author = Person.NewInstance(null, "Pullan", null, "M.");
|
46
|
citation.setAuthorship(author);
|
47
|
VerbatimTimePeriod datePublished = VerbatimTimePeriod.NewVerbatimInstance();
|
48
|
datePublished.setStartYear(2005);
|
49
|
citation.setDatePublished(datePublished);
|
50
|
citation.setVolume("54");
|
51
|
citation.setPages("751-756");
|
52
|
}
|
53
|
|
54
|
public boolean isTermPresent(String termName, ITermService termService) {
|
55
|
if(existingTerms.isEmpty()){
|
56
|
existingTerms = termService.list(State.class, null, null, null, null);
|
57
|
}
|
58
|
return existingTerms.stream().map(term->term.getLabel()).anyMatch(label->label.equals(termName));
|
59
|
}
|
60
|
|
61
|
public TermVocabulary<Feature> getPropertiesVoc() {
|
62
|
return propertiesVoc;
|
63
|
}
|
64
|
|
65
|
Reference getCitation() {
|
66
|
return citation;
|
67
|
}
|
68
|
|
69
|
}
|