Project

General

Profile

Revision 285d1929

ID285d192974ef8dfa2289be0e296832fd4af192e0
Parent 597bc532
Child 9483fdc5

Added by Patricia Kelbert over 8 years ago

merge branch to trunk

View differences:

.gitattributes
475 475
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx/TaxonXModsImport.java -text
476 476
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx/TaxonXNomenclatureImport.java -text
477 477
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx/TaxonXTransformer.java -text
478
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXDataHolder.java -text
479
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXExtractor.java -text
480
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXImport.java -text
481
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXImportConfigurator.java -text
482
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXImportState.java -text
483
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXModsExtractor.java -text
484
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXTreatmentExtractor.java -text
485
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXXMLFieldGetter.java -text
478 486
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tcsrdf/CdmOneToManyXmlMapper.java -text
479 487
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tcsrdf/CdmSingleAttributeXmlMapperBase.java -text
480 488
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tcsrdf/CdmTextElementMapper.java -text
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/ExportConfiguratorBase.java
1 1
/**
2 2
* Copyright (C) 2008 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5 5
*/
6 6

  
......
23 23
	private static final Logger logger = Logger.getLogger(ExportConfiguratorBase.class);
24 24

  
25 25
	private CHECK check = CHECK.EXPORT_WITHOUT_CHECK;
26
	
26

  
27 27
	private ICdmDataSource source;
28 28
	private DESTINATION destination;
29 29
	protected IDatabase sourceReference;
......
33 33
	 * The transformer class to be used for Input
34 34
	 */
35 35
	private TRANSFORM transformer;
36
	
36

  
37 37
	public ExportConfiguratorBase(TRANSFORM transformer){
38 38
		super();
39 39
		//setDbSchemaValidation(DbSchemaValidation.UPDATE);
40 40
		makeIoClassList();
41 41
		this.setTransformer(transformer);
42 42
	}
43
	
43

  
44 44
	abstract protected void makeIoClassList();
45
	
46 45

  
47
	public TRANSFORM getTransformer() {
46

  
47
	@Override
48
    public TRANSFORM getTransformer() {
48 49
		return transformer;
49 50
	}
50 51

  
51
	public void setTransformer(TRANSFORM transformer) {
52
	@Override
53
    public void setTransformer(TRANSFORM transformer) {
52 54
		this.transformer = transformer;
53 55
	}
54
	
55
	
56
	public ICdmDataSource getSource() {
56

  
57

  
58
	@Override
59
    public ICdmDataSource getSource() {
57 60
		return source;
58 61
	}
59
	
60
	public void setSource(ICdmDataSource source) {
62

  
63
	@Override
64
    public void setSource(ICdmDataSource source) {
61 65
		this.source = source;
62 66
	}
63
	
67

  
64 68
	/**
65 69
	 * @param source the source to get
66 70
	 */
67 71
	public DESTINATION getDestination() {
68 72
		return destination;
69 73
	}
70
	
74

  
71 75
	/**
72 76
	 * @param source the source to set
73 77
	 */
74 78
	public void setDestination(DESTINATION destination) {
75 79
		this.destination = destination;
76 80
	}
77
	
78
	
79
	
81

  
82

  
83

  
80 84
	/* (non-Javadoc)
81 85
	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
82 86
	 */
......
91 95
		}
92 96
		return sourceReference;
93 97
	}
94
	
95
	public Class<ICdmIO>[] getIoClassList(){
98

  
99
	@Override
100
    public Class<ICdmIO>[] getIoClassList(){
96 101
		return ioClassList;
97 102
	}
98 103

  
99 104
	/* (non-Javadoc)
100 105
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getCheck()
101 106
	 */
102
	public CHECK getCheck() {
107
	@Override
108
    public CHECK getCheck() {
103 109
		return this.check;
104 110
	}
105
	
111

  
106 112
	/* (non-Javadoc)
107 113
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#setCheck(eu.etaxonomy.cdm.io.tcsrdf.TcsRdfImportConfigurator.CHECK)
108 114
	 */
109 115
	public void setCheck(CHECK check) {
110 116
		this.check = check;
111 117
	}
112
	
118

  
113 119
	/* (non-Javadoc)
114 120
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IExportConfigurator#getDbSchemaValidation()
115 121
	 */
116 122
//	public DbSchemaValidation getDbSchemaValidation() {
117 123
//		return dbSchemaValidation;
118 124
//	}
119
	
125

  
120 126
//	/**
121 127
//	 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
122 128
//	 * If a controller was already created before the last created controller is returned.
......
125 131
//	public CdmApplicationController getCdmAppController(){
126 132
//		return getCdmAppController(false);
127 133
//	}
128
	
134

  
129 135
	/**
130 136
	 * Returns a new instance of <code>CdmApplicationController</code> created by the values of this configuration.
131 137
	 * @return
......
133 139
	public CdmApplicationController getNewCdmAppController(){
134 140
		return getCdmAppController(true, false);
135 141
	}
136
	
142

  
137 143
	/**
138 144
	 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
139 145
	 * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
......
143 149
	public CdmApplicationController getCdmAppController(boolean createNew){
144 150
		return getCdmAppController(createNew, false);
145 151
	}
146
	
147
	
152

  
153

  
148 154
	/**
149 155
	 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
150 156
	 * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
......
157 163
		}
158 164
		return cdmApp;
159 165
	}
160
	
161
	
166

  
167

  
162 168
	/**
163 169
	 * @return
164 170
	 */
165
	public boolean isValid(){
171
	@Override
172
    public boolean isValid(){
166 173
		boolean result = true;
167 174
//		if (source == null && this.getCdmAppController() == null ){
168 175
//			logger.warn("Connection to CDM could not be established");
......
172 179
			logger.warn("Invalid export destination");
173 180
			result = false;
174 181
		}
175
		
182

  
176 183
		return result;
177 184
	}
178
	
179
	public String getSourceNameString() {
185

  
186
	@Override
187
    public String getSourceNameString() {
180 188
		if (this.getSource() == null) {
181 189
			return null;
182 190
		} else {
183
			return (String)this.getSource().getName();
191
			return this.getSource().getName();
184 192
		}
185 193
	}
186 194

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/TermUri.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
21 21
 */
22 22
public enum TermUri {
23 23
	CDM_SOURCE_REFERENCE("http://eu.etaxonomy.cdm.io.common.sourceReference"),
24
	
24

  
25 25
	DC_ACCESS_RIGHTS("http://purl.org/dc/terms/accessRights"),
26
	DC_AUDIENCE("http://purl.org/dc/terms/audience"),	
26
	DC_AUDIENCE("http://purl.org/dc/terms/audience"),
27 27
	DC_BIBLIOGRAPHIC_CITATION("http://purl.org/dc/terms/bibliographicCitation"),
28
	DC_CONTRIBUTOR("http://purl.org/dc/terms/contributor"),	
29
	DC_CREATED("http://purl.org/dc/terms/created"),	
28
	DC_CONTRIBUTOR("http://purl.org/dc/terms/contributor"),
29
	DC_CREATED("http://purl.org/dc/terms/created"),
30 30
	DC_CREATOR("http://purl.org/dc/terms/creator"),
31 31
	DC_DATE("http://purl.org/dc/terms/date"),
32 32
	DC_DESCRIPTION("http://purl.org/dc/terms/description"),
33
	DC_FORMAT("http://purl.org/dc/terms/format"),	
33
	DC_FORMAT("http://purl.org/dc/terms/format"),
34 34
	DC_IDENTIFIER("http://purl.org/dc/terms/identifier"),
35 35
	DC_LANGUAGE("http://purl.org/dc/terms/language"),
36
	DC_LICENSE("http://purl.org/dc/terms/license"),	
36
	DC_LICENSE("http://purl.org/dc/terms/license"),
37 37
	DC_MODIFIED("http://purl.org/dc/terms/modified"),
38
	DC_PUBLISHER("http://purl.org/dc/terms/publisher"),	
38
	DC_PUBLISHER("http://purl.org/dc/terms/publisher"),
39 39
	DC_RIGHTS("http://purl.org/dc/terms/rights"),
40 40
	DC_RIGHTS_HOLDER("http://purl.org/dc/terms/rightsHolder"),
41 41
	DC_SOURCE("http://purl.org/dc/terms/source"),
42
	DC_SPATIAL("http://purl.org/dc/terms/spatial"),	
42
	DC_SPATIAL("http://purl.org/dc/terms/spatial"),
43 43
	DC_SUBJECT("http://purl.org/dc/terms/subject"),
44 44
	DC_TEMPORAL("http://purl.org/dc/terms/temporal"),
45 45
	DC_TITLE("http://purl.org/dc/terms/title"),
46
	DC_TYPE("http://purl.org/dc/terms/type"),	
47
	
48
	GEO_WGS84_LATITUDE("http://www.w3.org/2003/01/geo/wgs84_pos#latitude"),	
49
	GEO_WGS84_LONGITUDE("http://www.w3.org/2003/01/geo/wgs84_pos#longitude"),	
50
	
46
	DC_TYPE("http://purl.org/dc/terms/type"),
47

  
48
	GEO_WGS84_LATITUDE("http://www.w3.org/2003/01/geo/wgs84_pos#latitude"),
49
	GEO_WGS84_LONGITUDE("http://www.w3.org/2003/01/geo/wgs84_pos#longitude"),
50

  
51 51
	GBIF_APPENDIX_CITES("http://rs.gbif.org/terms/1.0/appendixCITES"),
52 52
	GBIF_IS_PLURAL("http://rs.gbif.org/terms/1.0/isPlural"),
53 53
	GBIF_ORGANISM_PART("http://rs.gbif.org/terms/1.0/organismPart"),
......
55 55
	GBIF_VERBATIM_LABEL("http://rs.gbif.org/terms/1.0/verbatimLabel"),
56 56

  
57 57
	IUCN_THREAD_STATUS("http://iucn.org/terms/threatStatus"),
58
	
58

  
59 59
	DWC_VERNACULAR_NAME("http://rs.tdwg.org/dwc/terms/vernacularName"),
60 60
	DWC_LOCATION_ID("http://rs.tdwg.org/dwc/terms/locationID"),
61 61
	DWC_COUNTRY_CODE("http://rs.tdwg.org/dwc/terms/countryCode"),
......
66 66
	DWC_VERBATIM_EVENT_DATE("http://rs.tdwg.org/dwc/terms/verbatimEventDate"),
67 67
	DWC_VERBATIM_LONGITUDE("http://rs.tdwg.org/dwc/terms/verbatimLongitude"),
68 68
	DWC_VERBATIM_LATITUDE("http://rs.tdwg.org/dwc/terms/verbatimLatitude"),
69
	DWC_COORDINATES_PRECISION("http://rs.tdwg.org/dwc/terms/coordinatePrecision"),
69 70
	DWC_SCIENTIFIC_NAME_ID("http://rs.tdwg.org/dwc/terms/scientificNameID"),
70 71
	DWC_ACCEPTED_NAME_USAGE_ID("http://rs.tdwg.org/dwc/terms/acceptedNameUsageID"),
71 72
	DWC_PARENT_NAME_USAGE_ID("http://rs.tdwg.org/dwc/terms/parentNameUsageID"),
......
98 99
	DWC_INFORMATION_WITHHELD("http://rs.tdwg.org/dwc/terms/informationWithheld"),
99 100
	DWC_DATASET_NAME("http://rs.tdwg.org/dwc/terms/datasetName"),
100 101
	DWC_DATASET_ID("http://rs.tdwg.org/dwc/terms/datasetID"),
101
	
102

  
102 103
	DWC_RESOURCE_RELATIONSHIP("http://rs.tdwg.org/dwc/terms/ResourceRelationship"),
103 104
	DWC_TAXON("http://rs.tdwg.org/dwc/terms/Taxon"),
104
	
105

  
105 106
	DWC_TYPE_STATUS("http://rs.tdwg.org/dwc/terms/typeStatus"),
106 107
	DWC_TYPE_DESIGNATED_BY("http://rs.tdwg.org/dwc/terms/typeDesignatedBy"),
107 108
	DWC_OCCURRENCE_ID("http://rs.tdwg.org/dwc/terms/occurrenceID"),
......
125 126
	DWC_START_DAY_OF_YEAR("http://rs.tdwg.org/dwc/terms/startDayOfYear"),
126 127
	DWC_END_DAY_OF_YEAR("http://rs.tdwg.org/dwc/terms/endDayOfYear"),
127 128
	DWC_OCCURRENCE_REMARKS("http://rs.tdwg.org/dwc/terms/occurrenceRemarks"),
128
	
129

  
129 130
	TDWG_UNINOMIAL("http://rs.tdwg.org/ontology/voc/TaxonName#uninomial"),
130 131
	TDWG_GENUSPART("http://rs.tdwg.org/ontology/voc/TaxonName#genusPart"),
131 132
	TDWG_INFRAGENERICEPITHET("http://rs.tdwg.org/ontology/voc/TaxonName#infragenericEpithet"),
......
141 142

  
142 143
	EOL_AGENT("http://eol.org/schema/agent/Agent"),
143 144
	EOL_ORGANIZATION("http://eol.org/schema/agent/organization"),
144
	
145
	
145

  
146

  
146 147
	FOAF_FAMILY_NAME("http://xmlns.com/foaf/spec/#term_familyName"),
147 148
	FOAF_FIRST_NAME("http://xmlns.com/foaf/spec/#term_firstName"),
148 149
	FOAF_NAME("http://xmlns.com/foaf/spec/#term_Name"),
149 150
	FOAF_ACCOUNT_NAME("http://xmlns.com/foaf/spec/#term_accountName"),
150
	
151
	
151

  
152
	DWC_COORDINATES_SYSTEM("http://rs.tdwg.org/dwc/terms/verbatimCoordinateSystem"),
153

  
154

  
152 155
	;
153
	
156

  
154 157
	@SuppressWarnings("unused")
155 158
	private static final Logger logger = Logger.getLogger(TermUri.class);
156 159

  
157 160

  
158 161
	private URI uri;
159
	
162

  
160 163
	private TermUri(String uri){
161 164
		try {
162 165
			this.uri = new URI(uri);
......
164 167
			throw new RuntimeException(e);
165 168
		}
166 169
	}
167
		
170

  
168 171

  
169 172
	public String getUriString(){
170 173
		return this.uri.toString();
171 174
	}
172
	
175

  
173 176
	public URI getUri(){
174 177
		return this.uri;
175 178
	}
176
	
179

  
177 180
	@Override
178 181
	public String toString(){
179 182
		return getUriString();
180 183
	}
181
	
184

  
182 185
	public static TermUri valueOfUriString(String termUriString){
183 186
		for (TermUri term: TermUri.values()){
184 187
			if (term.getUriString().equals(termUriString)){
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaExportBase.java
1 1
/**
2
* Copyright (C) 2007 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
*/
2
 * Copyright (C) 2007 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 9
package eu.etaxonomy.cdm.io.dwca.out;
10 10

  
11 11
import java.io.File;
......
22 22
import java.util.Set;
23 23
import java.util.UUID;
24 24

  
25
import javax.swing.border.EmptyBorder;
26 25
import javax.xml.stream.XMLOutputFactory;
27 26
import javax.xml.stream.XMLStreamException;
28 27
import javax.xml.stream.XMLStreamWriter;
......
35 34
import eu.etaxonomy.cdm.io.common.ICdmExport;
36 35
import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
37 36
import eu.etaxonomy.cdm.model.common.CdmBase;
37
import eu.etaxonomy.cdm.model.common.DescriptionElementSource;
38 38
import eu.etaxonomy.cdm.model.common.IOriginalSource;
39 39
import eu.etaxonomy.cdm.model.common.ISourceable;
40 40
import eu.etaxonomy.cdm.model.location.NamedArea;
......
50 50
 *
51 51
 */
52 52
public abstract class DwcaExportBase extends CdmExportBase<DwcaTaxExportConfigurator, DwcaTaxExportState, IExportTransformer> implements ICdmExport<DwcaTaxExportConfigurator, DwcaTaxExportState>{
53
	private static final Logger logger = Logger.getLogger(DwcaExportBase.class);
54
	
55
	protected static final boolean IS_CORE = true;
56
	
57
	
58
	protected Set<Integer> existingRecordIds = new HashSet<Integer>();
59
	protected Set<UUID> existingRecordUuids = new HashSet<UUID>();
60
	
61
	
62

  
63
	/* (non-Javadoc)
64
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#countSteps()
65
	 */
66
	@Override
67
	public int countSteps() {
68
		List<TaxonNode> allNodes =  getClassificationService().getAllNodes();
69
		return allNodes.size();
70
	}
71

  
72
	
73
	
74
	/**
75
	 * Returns the list of {@link TaxonNode taxon nodes} that are part in one of the given {@link Classification classifications} 
76
	 * and do have a {@link Taxon} attached (empty taxon nodes should not but do exist in CDM databases).
77
	 * If <code>classificationList</code> is <code>null</code> or empty then all {@link TaxonNode taxon nodes} of all 
78
	 * {@link Classification classifications} are returned.<BR>
79
	 * Preliminary implementation. Better implement API method for this.
80
	 * @return
81
	 */
82
	protected List<TaxonNode> getAllNodes(Set<Classification> classificationList) {
83
		//handle empty list as no filter defined
84
		if (classificationList != null && classificationList.isEmpty()){
85
			classificationList = null;
86
		}
87
		
88
		List<TaxonNode> allNodes =  getClassificationService().getAllNodes();
89
		List<TaxonNode> result = new ArrayList<TaxonNode>();
90
		for (TaxonNode node : allNodes){
91
			if (node.getClassification() == null ){
92
				continue;
93
			}else if (classificationList != null && ! classificationList.contains(node.getClassification())){
94
				continue;
95
			}else{
96
				Taxon taxon = CdmBase.deproxy(node.getTaxon(), Taxon.class);
97
				if (taxon == null){
98
					String message = "There is a taxon node without taxon: " + node.getId();
99
					logger.warn(message);
100
					continue;
101
				}
102
				result.add(node);
103
			}
104
		}
105
		return result;
106
	}
107
	
108
	
109
	/**
110
	 * Creates the locationId, locality, countryCode triple
111
	 * @param record
112
	 * @param area
113
	 */
114
	protected void handleArea(IDwcaAreaRecord record, NamedArea area, TaxonBase<?> taxon, boolean required) {
115
		if (area != null){
116
			record.setLocationId(area);
117
			record.setLocality(area.getLabel());
118
			if (area.isInstanceOf(WaterbodyOrCountry.class)){
119
				WaterbodyOrCountry country = CdmBase.deproxy(area, WaterbodyOrCountry.class);
120
				record.setCountryCode(country.getIso3166_A2());
121
			}
122
		}else{
123
			if (required){
124
				String message = "Description requires area but area does not exist for taxon " + getTaxonLogString(taxon);
125
				logger.warn(message);
126
			}
127
		}
128
	}
129

  
130

  
131
	protected String getTaxonLogString(TaxonBase<?> taxon) {
132
		return taxon.getTitleCache() + "(" + taxon.getId() + ")";
133
	}
134
	
135

  
136
	/**
137
	 * @param el
138
	 * @return
139
	 */
140
	protected boolean recordExists(CdmBase el) {
141
		return existingRecordIds.contains(el.getId());
142
	}
143
	
144

  
145
	/**
146
	 * @param sec
147
	 */
148
	protected void addExistingRecord(CdmBase cdmBase) {
149
		existingRecordIds.add(cdmBase.getId());
150
	}
151
	
152
	/**
153
	 * @param el
154
	 * @return
155
	 */
156
	protected boolean recordExistsUuid(CdmBase el) {
157
		return existingRecordUuids.contains(el.getUuid());
158
	}
159
	
160
	/**
161
	 * @param sec
162
	 */
163
	protected void addExistingRecordUuid(CdmBase cdmBase) {
164
		existingRecordUuids.add(cdmBase.getUuid());
165
	}
166
	
167

  
168
	protected String getSources(ISourceable<?> sourceable, DwcaTaxExportConfigurator config) {
169
		String result = "";
170
		for (IOriginalSource source: sourceable.getSources()){
171
			if (StringUtils.isBlank(source.getIdInSource())){//idInSource indicates that this source is only data provenance, may be changed in future
172
				if (source.getCitation() != null){
173
					String ref = source.getCitation().getTitleCache();
174
					result = CdmUtils.concat(config.getSetSeparator(), result, ref);
175
				}
176
			}
177
		}
178
		return result;
179
	}
180
	
181

  
182
	/**
183
	 * @param config
184
	 * @return
185
	 * @throws IOException
186
	 * @throws FileNotFoundException
187
	 */
188
	protected FileOutputStream createFileOutputStream(DwcaTaxExportConfigurator config, String thisFileName) throws IOException, FileNotFoundException {
189
		String filePath = config.getDestinationNameString();
190
		String fileName = filePath + File.separatorChar + thisFileName;
191
		File f = new File(fileName);
192
		if (!f.exists()){
193
			f.createNewFile();
194
		}
195
		FileOutputStream fos = new FileOutputStream(f);
196
		return fos;
197
	}
198
	
199

  
200
	/**
201
	 * @param config
202
	 * @param factory
203
	 * @return
204
	 * @throws IOException
205
	 * @throws FileNotFoundException
206
	 * @throws XMLStreamException
207
	 */
208
	protected XMLStreamWriter createXmlStreamWriter(DwcaTaxExportState state, String fileName)
209
			throws IOException, FileNotFoundException, XMLStreamException {
210
		XMLOutputFactory factory = XMLOutputFactory.newInstance(); 
211
		OutputStream os;
212
		boolean useZip = state.isZip();
213
		if (useZip){
214
			os = state.getZipStream(fileName);
215
		}else{
216
			os = createFileOutputStream(state.getConfig(), fileName);
217
		}
218
		XMLStreamWriter  writer = factory.createXMLStreamWriter(os);
219
		return writer;
220
	}
221
	
222

  
223
	/**
224
	 * @param coreTaxFileName
225
	 * @param config
226
	 * @return
227
	 * @throws IOException
228
	 * @throws FileNotFoundException
229
	 * @throws UnsupportedEncodingException
230
	 */
231
	protected PrintWriter createPrintWriter(final String fileName, DwcaTaxExportState state) 
232
					throws IOException, FileNotFoundException, UnsupportedEncodingException {
233
		
234
		OutputStream os;
235
		boolean useZip = state.isZip();
236
		if (useZip){
237
			os = state.getZipStream(fileName);
238
		}else{
239
			os = createFileOutputStream(state.getConfig(), fileName);
240
		}
241
		PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, "UTF8"), true);
242
		
243
		return writer;
244
	}
245
	
246

  
247
	/**
248
	 * Closes the writer
249
	 * @param writer
250
	 * @param state
251
	 */
252
	protected void closeWriter(PrintWriter writer, DwcaTaxExportState state) {
253
		if (writer != null && state.isZip() == false){
254
			writer.close();
255
		}
256
	}
257
	
258

  
259
	
260
	/**
261
	 * Closes the writer.
262
	 * Note: XMLStreamWriter does not close the underlying stream.
263
	 * @param writer
264
	 * @param state
265
	 */
266
	protected void closeWriter(XMLStreamWriter writer, DwcaTaxExportState state) {
267
		if (writer != null && state.isZip() == false){
268
			try {
269
				writer.close();
270
			} catch (XMLStreamException e) {
271
				throw new RuntimeException(e);
272
			}
273
		}
274
	}
53
    private static final Logger logger = Logger.getLogger(DwcaExportBase.class);
54

  
55
    protected static final boolean IS_CORE = true;
56

  
57

  
58
    protected Set<Integer> existingRecordIds = new HashSet<Integer>();
59
    protected Set<UUID> existingRecordUuids = new HashSet<UUID>();
60

  
61

  
62

  
63
    /* (non-Javadoc)
64
     * @see eu.etaxonomy.cdm.io.common.CdmIoBase#countSteps()
65
     */
66
    @Override
67
    public int countSteps() {
68
        List<TaxonNode> allNodes =  getClassificationService().getAllNodes();
69
        return allNodes.size();
70
    }
71

  
72

  
73

  
74
    /**
75
     * Returns the list of {@link TaxonNode taxon nodes} that are part in one of the given {@link Classification classifications}
76
     * and do have a {@link Taxon} attached (empty taxon nodes should not but do exist in CDM databases).
77
     * If <code>classificationList</code> is <code>null</code> or empty then all {@link TaxonNode taxon nodes} of all
78
     * {@link Classification classifications} are returned.<BR>
79
     * Preliminary implementation. Better implement API method for this.
80
     * @return
81
     */
82
    protected List<TaxonNode> getAllNodes(Set<Classification> classificationList) {
83
        //handle empty list as no filter defined
84
        if (classificationList != null && classificationList.isEmpty()){
85
            classificationList = null;
86
        }
87

  
88
        List<TaxonNode> allNodes =  getClassificationService().getAllNodes();
89
        List<TaxonNode> result = new ArrayList<TaxonNode>();
90
        for (TaxonNode node : allNodes){
91
            if (node.getClassification() == null ){
92
                continue;
93
            }else if (classificationList != null && ! classificationList.contains(node.getClassification())){
94
                continue;
95
            }else{
96
                Taxon taxon = CdmBase.deproxy(node.getTaxon(), Taxon.class);
97
                if (taxon == null){
98
                    String message = "There is a taxon node without taxon: " + node.getId();
99
                    logger.warn(message);
100
                    continue;
101
                }
102
                result.add(node);
103
            }
104
        }
105
        return result;
106
    }
107

  
108

  
109
    /**
110
     * Creates the locationId, locality, countryCode triple
111
     * @param record
112
     * @param area
113
     */
114
    protected void handleArea(IDwcaAreaRecord record, NamedArea area, TaxonBase<?> taxon, boolean required) {
115
        if (area != null){
116
            record.setLocationId(area);
117
            record.setLocality(area.getLabel());
118
            if (area.isInstanceOf(WaterbodyOrCountry.class)){
119
                WaterbodyOrCountry country = CdmBase.deproxy(area, WaterbodyOrCountry.class);
120
                record.setCountryCode(country.getIso3166_A2());
121
            }
122
        }else{
123
            if (required){
124
                String message = "Description requires area but area does not exist for taxon " + getTaxonLogString(taxon);
125
                logger.warn(message);
126
            }
127
        }
128
    }
129

  
130

  
131
    protected String getTaxonLogString(TaxonBase<?> taxon) {
132
        return taxon.getTitleCache() + "(" + taxon.getId() + ")";
133
    }
134

  
135

  
136
    /**
137
     * @param el
138
     * @return
139
     */
140
    protected boolean recordExists(CdmBase el) {
141
        return existingRecordIds.contains(el.getId());
142
    }
143

  
144

  
145
    /**
146
     * @param sec
147
     */
148
    protected void addExistingRecord(CdmBase cdmBase) {
149
        existingRecordIds.add(cdmBase.getId());
150
    }
151

  
152
    /**
153
     * @param el
154
     * @return
155
     */
156
    protected boolean recordExistsUuid(CdmBase el) {
157
        return existingRecordUuids.contains(el.getUuid());
158
    }
159

  
160
    /**
161
     * @param sec
162
     */
163
    protected void addExistingRecordUuid(CdmBase cdmBase) {
164
        existingRecordUuids.add(cdmBase.getUuid());
165
    }
166

  
167

  
168
    protected String getSources(ISourceable<?> sourceable, DwcaTaxExportConfigurator config) {
169
        String result = "";
170
        for (IOriginalSource source: sourceable.getSources()){
171
            if (StringUtils.isBlank(source.getIdInSource())){//idInSource indicates that this source is only data provenance, may be changed in future
172
                if (source.getCitation() != null){
173
                    String ref = source.getCitation().getTitleCache();
174
                    result = CdmUtils.concat(config.getSetSeparator(), result, ref);
175
                }
176
            }
177
        }
178
        return result;
179
    }
180

  
181
    protected String getSources3(ISourceable<?> sourceable, DwcaTaxExportConfigurator config) {
182
        String result = "";
183
        for (IOriginalSource source: sourceable.getSources()){
184
                if (source.getCitation() != null){
185
                    String ref = source.getCitation().getTitleCache();
186
                    result = CdmUtils.concat(config.getSetSeparator(), result, ref);
187
                }
188
        }
189
        return result;
190
    }
191

  
192
    protected String getSources2(Set<DescriptionElementSource> set, DwcaTaxExportConfigurator config) {
193
        String result = "";
194
        for(DescriptionElementSource source: set){
195
            if (StringUtils.isBlank(source.getIdInSource())){//idInSource indicates that this source is only data provenance, may be changed in future
196
                if (source.getCitation() != null){
197
                    String ref = source.getCitation().getTitleCache();
198
                    result = CdmUtils.concat(config.getSetSeparator(), result, ref);
199
                }
200
            }
201
        }
202
        return result;
203
    }
204

  
205

  
206
    /**
207
     * @param config
208
     * @return
209
     * @throws IOException
210
     * @throws FileNotFoundException
211
     */
212
    protected FileOutputStream createFileOutputStream(DwcaTaxExportConfigurator config, String thisFileName) throws IOException, FileNotFoundException {
213
        String filePath = config.getDestinationNameString();
214
        String fileName = filePath + File.separatorChar + thisFileName;
215
        File f = new File(fileName);
216
        if (!f.exists()){
217
            f.createNewFile();
218
        }
219
        FileOutputStream fos = new FileOutputStream(f);
220
        return fos;
221
    }
222

  
223

  
224
    /**
225
     * @param config
226
     * @param factory
227
     * @return
228
     * @throws IOException
229
     * @throws FileNotFoundException
230
     * @throws XMLStreamException
231
     */
232
    protected XMLStreamWriter createXmlStreamWriter(DwcaTaxExportState state, String fileName)
233
            throws IOException, FileNotFoundException, XMLStreamException {
234
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
235
        OutputStream os;
236
        boolean useZip = state.isZip();
237
        if (useZip){
238
            os = state.getZipStream(fileName);
239
        }else{
240
            os = createFileOutputStream(state.getConfig(), fileName);
241
        }
242
        XMLStreamWriter  writer = factory.createXMLStreamWriter(os);
243
        return writer;
244
    }
245

  
246

  
247
    /**
248
     * @param coreTaxFileName
249
     * @param config
250
     * @return
251
     * @throws IOException
252
     * @throws FileNotFoundException
253
     * @throws UnsupportedEncodingException
254
     */
255
    protected PrintWriter createPrintWriter(final String fileName, DwcaTaxExportState state)
256
            throws IOException, FileNotFoundException, UnsupportedEncodingException {
257

  
258
        OutputStream os;
259
        boolean useZip = state.isZip();
260
        if (useZip){
261
            os = state.getZipStream(fileName);
262
        }else{
263
            os = createFileOutputStream(state.getConfig(), fileName);
264
        }
265
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, "UTF8"), true);
266

  
267
        return writer;
268
    }
269

  
270

  
271
    /**
272
     * Closes the writer
273
     * @param writer
274
     * @param state
275
     */
276
    protected void closeWriter(PrintWriter writer, DwcaTaxExportState state) {
277
        if (writer != null && state.isZip() == false){
278
            writer.close();
279
        }
280
    }
281

  
282

  
283

  
284
    /**
285
     * Closes the writer.
286
     * Note: XMLStreamWriter does not close the underlying stream.
287
     * @param writer
288
     * @param state
289
     */
290
    protected void closeWriter(XMLStreamWriter writer, DwcaTaxExportState state) {
291
        if (writer != null && state.isZip() == false){
292
            try {
293
                writer.close();
294
            } catch (XMLStreamException e) {
295
                throw new RuntimeException(e);
296
            }
297
        }
298
    }
275 299

  
276 300
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaTypesExport.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
47 47
@Component
48 48
public class DwcaTypesExport extends DwcaExportBase {
49 49
	private static final Logger logger = Logger.getLogger(DwcaTypesExport.class);
50
	
50

  
51 51
	private static final String ROW_TYPE = "http://rs.gbif.org/terms/1.0/TypesAndSpecimen";
52 52
	private static final String fileName = "typesAndSpecimen.txt";
53
	
53

  
54 54
	/**
55 55
	 * Constructor
56 56
	 */
......
62 62
	/** Retrieves data from a CDM DB and serializes them CDM to XML.
63 63
	 * Starts with root taxa and traverses the classification to retrieve children taxa, synonyms and relationships.
64 64
	 * Taxa that are not part of the classification are not found.
65
	 * 
65
	 *
66 66
	 * @param exImpConfig
67 67
	 * @param dbname
68 68
	 * @param filename
......
74 74

  
75 75
		PrintWriter writer = null;
76 76
		try {
77
			
77

  
78 78
			writer = createPrintWriter(fileName, state);
79 79
			DwcaMetaDataRecord metaRecord = new DwcaMetaDataRecord(! IS_CORE, fileName, ROW_TYPE);
80 80
			state.addMetaRecord(metaRecord);
81 81

  
82
			
82

  
83 83
			List<TaxonNode> allNodes =  getAllNodes(null);
84
			
84

  
85 85
			for (TaxonNode node : allNodes){
86 86
				Taxon taxon = CdmBase.deproxy(node.getTaxon(), Taxon.class);
87
				
87

  
88 88
				//TODO use API methods to retrieve all related specimen
89
				
89

  
90 90
				//individual associations
91 91
				Set<TaxonDescription> descriptions = taxon.getDescriptions();
92 92
				for (TaxonDescription description : descriptions){
......
101 101
						}
102 102
					}
103 103
				}
104
				
105
				//type specimen 
104

  
105
				//type specimen
106 106
				NonViralName<?> nvn = CdmBase.deproxy(taxon.getName(), NonViralName.class);
107 107
				handleTypeName(writer, taxon, nvn, metaRecord, config);
108 108
				for (Synonym synonym : taxon.getSynonyms()){
109 109
					handleTypeName(writer, synonym, nvn, metaRecord, config);
110 110
				}
111
				
111

  
112 112
				//FIXME
113 113
				//Determinations
114
				
115
				
114

  
115

  
116 116
				writer.flush();
117
				
117

  
118 118
			}
119 119
		} catch (FileNotFoundException e) {
120 120
			e.printStackTrace();
......
135 135
	 * @param writer
136 136
	 * @param taxon
137 137
	 * @param nvn
138
	 * @param config 
138
	 * @param config
139 139
	 * @return
140 140
	 */
141 141
	private Set<TypeDesignationBase> handleTypeName(PrintWriter writer, TaxonBase<?> taxonBase, NonViralName<?> nvn, DwcaMetaDataRecord metaRecord, DwcaTaxExportConfigurator config) {
......
149 149
		}
150 150
		return designations;
151 151
	}
152
	
152

  
153 153

  
154 154
	private boolean handleSpecimen(DwcaTypesRecord record, IndividualsAssociation individualsAssociation, TypeDesignationBase<?> designation, TaxonBase<?> taxonBase, DwcaTaxExportConfigurator config) {
155 155
		TypeDesignationStatusBase<?> status = null;
......
163 163
		if (facade == null){
164 164
			return false;
165 165
		}
166
		
166

  
167 167
		record.setId(taxonBase.getId());
168 168
		record.setUuid(taxonBase.getUuid());
169 169
		record.setBibliographicCitation(facade.getTitleCache());
170 170
		record.setTypeStatus(status);
171 171
		record.setTypeDesignatedBy( (designation == null || designation.getCitation()==null)? null: designation.getCitation().getTitleCache());
172
		
172

  
173 173
		TaxonNameBase<?,?> scientificName = getScientificName(facade);
174 174
		if (scientificName != null){
175 175
			record.setScientificName(scientificName.getTitleCache());
176 176
			record.setTaxonRank(scientificName.getRank());
177 177
		}
178
		
178

  
179 179
		record.setOccurrenceId(facade.innerDerivedUnit());
180 180
		Collection collection = facade.getCollection();
181 181
		if (collection != null){
......
189 189
		record.setSex(facade.getSex());
190 190
		record.setRecordedBy(facade.getCollector());
191 191
		//TODO ???
192
		record.setSource(getSources(facade.innerDerivedUnit(), config));
192

  
193
		String source2 = "";
194
		if (individualsAssociation!=null) {
195
            source2 = getSources2(individualsAssociation.getSources(), config);
196
        }
197

  
198
		record.setSource(getSources3(facade.innerDerivedUnit(), config));
199
		record.setDescriptionSource(source2);
200

  
193 201
		record.setEventDate(facade.getGatheringPeriod());
194 202
		//TODO missing
195 203
		record.setVerbatimLabel(null);
196 204
		if (facade.getExactLocation() != null){
197 205
			if (facade.getExactLocation().getLongitude() != null){
198
				record.setVerbatimLongitude(facade.getExactLocation().getLongitudeSexagesimal().toString());
206
//				record.setVerbatimLongitude(facade.getExactLocation().getLongitudeSexagesimal().toString());
207
			    record.setVerbatimLongitude(facade.getExactLocation().getLongitude().toString());
199 208
			}
200 209
			if (facade.getExactLocation().getLatitude() != null){
201
				record.setVerbatimLatitude(facade.getExactLocation().getLatitudeSexagesimal().toString());
210
//				record.setVerbatimLatitude(facade.getExactLocation().getLatitudeSexagesimal().toString());
211
			    record.setVerbatimLatitude(facade.getExactLocation().getLatitude().toString());
202 212
			}
213
			if(facade.getExactLocation().getErrorRadius() != null) {
214
                record.setCoordinatesPrecisionOrError(facade.getExactLocation().getErrorRadius().toString());
215
            }
216
			if(facade.getExactLocation().getReferenceSystem() != null) {
217
                record.setCoordinatesSystem(facade.getExactLocation().getReferenceSystem().toString());
218
            }
203 219
		}
204 220
		return true;
205 221
	}
206
	
222

  
207 223
	private TaxonNameBase<?,?> getScientificName(DerivedUnitFacade facade) {
208 224
		Set<DeterminationEvent> detEvents = facade.getDeterminations();
209 225
		for (DeterminationEvent detEvent : detEvents){
210
			if (detEvent.getPreferredFlag()== true){
226
			if (detEvent.getPreferredFlag()== true || detEvents.size()==1){
211 227
				return detEvent.getTaxon().getName();
212 228
			}
213 229
		}
......
229 245
				String message = "DerivedUnit is too complex to be handled by facade based darwin core archive export";
230 246
				logger.warn(message);
231 247
				//TODO handle empty records
232
				return null; 
248
				return null;
233 249
			}
234 250
		}else{
235 251
			return null;
......
243 259
			String message = "Non DerivedUnit specimen can not yet be handled by this export";
244 260
			logger.warn(message);
245 261
			//TODO handle empty records
246
			return null; 
262
			return null;
247 263
		}else{
248 264
			DerivedUnitBase<?> derivedUnit = CdmBase.deproxy(specimen, DerivedUnitBase.class);
249 265
			try {
......
252 268
				String message = "DerivedUnit is too complex to be handled by facade based darwin core archive export";
253 269
				logger.warn(message);
254 270
				//TODO handle empty records
255
				return null; 
271
				return null;
256 272
			}
257
			
273

  
258 274
		}
259 275
		return facade;
260 276
	}
......
271 287
	protected boolean isIgnore(DwcaTaxExportState state) {
272 288
		return ! state.getConfig().isDoTypesAndSpecimen();
273 289
	}
274
	
290

  
275 291
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaTypesRecord.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
30 30
public class DwcaTypesRecord extends DwcaRecordBase {
31 31
	@SuppressWarnings("unused")
32 32
	private static final Logger logger = Logger.getLogger(DwcaTypesRecord.class);
33
	
33

  
34 34
	private String bibliographicCitation;
35 35
	private TypeDesignationStatusBase<?> typeStatus;
36 36
	private String typeDesignatedBy;
37 37
	private String scientificName;
38 38
	private Rank taxonRank;
39
	private DwcaId occurrenceId;
39
	private final DwcaId occurrenceId;
40 40
	private String institutionCode;
41 41
	private String collectionCode;
42 42
	private String catalogNumber;
......
44 44
	private Sex sex;
45 45
	private AgentBase<?> recordedBy;
46 46
	private String source;
47
	private String descriptionSource;
47 48
	private TimePeriod eventDate;
48 49
	private String verbatimLabel;
49 50
	private String verbatimLongitude;
50 51
	private String verbatimLatitude;
51
	
52
	private String coordinatesPrecision;
53

  
54
    private String referenceSystem;
55

  
52 56
	public DwcaTypesRecord(DwcaMetaDataRecord metaDataRecord, DwcaTaxExportConfigurator config){
53 57
		super(metaDataRecord, config);
54 58
		occurrenceId = new DwcaId(config);
......
57 61
	/* (non-Javadoc)
58 62
	 * @see eu.etaxonomy.cdm.io.dwca.out.DwcaRecordBase#registerKnownFields()
59 63
	 */
60
	protected void registerKnownFields(){
64
	@Override
65
    protected void registerKnownFields(){
61 66
		try {
62 67
			addKnownField("bibliographicCitation", "http://purl.org/dc/terms/bibliographicCitation");
63 68
			addKnownField("typeStatus", "http://rs.tdwg.org/dwc/terms/typeStatus");
......
72 77
			addKnownField("sex", "http://rs.tdwg.org/dwc/terms/sex");
73 78
			addKnownField("recordedBy", "http://rs.tdwg.org/dwc/terms/recordedBy");
74 79
			addKnownField("source", "http://purl.org/dc/terms/source");
80
			addKnownField("descriptionSource", "http://purl.org/dc/terms/source");
75 81
			addKnownField("verbatimEventDate", "http://rs.tdwg.org/dwc/terms/verbatimEventDate");
76 82
			addKnownField("verbatimLabel", "http://rs.gbif.org/terms/1.0/verbatimLabel");
77 83
			addKnownField("verbatimLongitude", "http://rs.tdwg.org/dwc/terms/verbatimLongitude");
78 84
			addKnownField("verbatimLatitude", "http://rs.tdwg.org/dwc/terms/verbatimLatitude");
85
			addKnownField("coordinatesPrecision", "http://rs.tdwg.org/dwc/terms/coordinatePrecision");
86
			addKnownField("referenceSystem","http://rs.tdwg.org/dwc/terms/verbatimCoordinateSystem");
79 87

  
80 88
		} catch (URISyntaxException e) {
81 89
			throw new RuntimeException(e);
82 90
		}
83 91
	}
84
	
85
	
92

  
93

  
86 94
//	@Override
87 95
//	public List<String> getHeaderList() {
88 96
//		String[] result = new String[]{
89
//				"coreid", 
97
//				"coreid",
90 98
//				"bibliographicCitation",
91 99
//				"typeStatus",
92
//				"typeDesignatedBy", 
93
//				"scientificName", 
94
//				"taxonRank", 
100
//				"typeDesignatedBy",
101
//				"scientificName",
102
//				"taxonRank",
95 103
//				"occurrenceId",
96 104
//				"institutionCode",
97 105
//				"collectionCode",
98
//				"catalogNumber", 
99
//				"locality", 
100
//				"sex", 
106
//				"catalogNumber",
107
//				"locality",
108
//				"sex",
101 109
//				"recordedBy",
102 110
//				"source",
103 111
//				"eventDate",
104
//				"verbatimLabel", 
105
//				"verbatimLongitude", 
112
//				"verbatimLabel",
113
//				"verbatimLongitude",
106 114
//				"verbatimLatitude"
107 115
//		};
108 116
//		return Arrays.asList(result);
109 117
//	}
110
	
111
	public void write(PrintWriter writer) {
118

  
119
	@Override
120
    public void write(PrintWriter writer) {
112 121
		printId(getUuid(), writer, IS_FIRST, "coreid");
113 122
		print(bibliographicCitation, writer, IS_NOT_FIRST, TermUri.DC_BIBLIOGRAPHIC_CITATION);
114 123
		print(getDesignationType(typeStatus), writer, IS_NOT_FIRST, TermUri.DWC_TYPE_STATUS);
......
123 132
		print(getSex(sex), writer, IS_NOT_FIRST, TermUri.DWC_SEX);
124 133
		print(recordedBy, writer, IS_NOT_FIRST, TermUri.DWC_RECORDED_BY);
125 134
		print(source, writer, IS_NOT_FIRST, TermUri.DC_SOURCE);
135
		print(descriptionSource, writer, IS_NOT_FIRST, TermUri.DC_SOURCE);
126 136
		print(getTimePeriod(eventDate), writer, IS_NOT_FIRST, TermUri.DWC_VERBATIM_EVENT_DATE);
127 137
		print(verbatimLabel, writer, IS_NOT_FIRST, TermUri.DWC_VERBATIM_LABEL);
128 138
		print(verbatimLongitude, writer, IS_NOT_FIRST, TermUri.DWC_VERBATIM_LONGITUDE);
129 139
		print(verbatimLatitude, writer, IS_NOT_FIRST, TermUri.DWC_VERBATIM_LATITUDE);
140
		print(coordinatesPrecision, writer, IS_NOT_FIRST, TermUri.DWC_COORDINATES_PRECISION);
141
		print(referenceSystem,writer,IS_NOT_FIRST,TermUri.DWC_COORDINATES_SYSTEM);
130 142
		writer.println();
131 143
	}
132 144

  
......
137 149
		this.source = source;
138 150
	}
139 151

  
152
	public String getDescriptionSource() {
153
        return descriptionSource;
154
    }
155
    public void setDescriptionSource(String descriptionSource) {
156
        this.descriptionSource = descriptionSource;
157
    }
158

  
140 159
	public String getBibliographicCitation() {
141 160
		return bibliographicCitation;
142 161
	}
......
265 284
		this.verbatimLatitude = verbatimLatitude;
266 285
	}
267 286

  
287
    /**
288
     * @param string
289
     */
290
    public void setCoordinatesPrecisionOrError(String coordinatesPrecision) {
291
        this.coordinatesPrecision=coordinatesPrecision;
292

  
293
    }
294

  
295
    /**
296
     * @param string
297
     */
298
    public void setCoordinatesSystem(String referenceSystem) {
299
        this.referenceSystem=referenceSystem;
300

  
301
    }
302

  
268 303
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/distribution/DistributionImportConfigurator.java
1 1
/**
2 2
* Copyright (C) 2008 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
11 11
import java.net.URI;
12 12

  
13 13
import org.apache.log4j.Logger;
14

  
14 15
import eu.etaxonomy.cdm.database.ICdmDataSource;
15 16
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
16
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
17
import eu.etaxonomy.cdm.io.common.ImportStateBase;
18 17
import eu.etaxonomy.cdm.io.excel.common.ExcelImportConfiguratorBase;
19 18
import eu.etaxonomy.cdm.io.excel.common.ExcelImportState;
20
import eu.etaxonomy.cdm.model.reference.IDatabase;
21 19
import eu.etaxonomy.cdm.model.reference.Reference;
22 20
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
23 21

  
......
29 27
public class DistributionImportConfigurator extends ExcelImportConfiguratorBase implements IImportConfigurator {
30 28

  
31 29
	private static final Logger logger = Logger.getLogger(DistributionImportConfigurator.class);
32
	
33
	@SuppressWarnings("unchecked")
30

  
31
	@Override
32
    @SuppressWarnings("unchecked")
34 33
	protected void makeIoClassList() {
35 34
		ioClassList = new Class[] {
36 35
				DistributionImport.class
37 36
		};
38 37
	};
39
	
38

  
40 39
	public static DistributionImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
41 40
		return new DistributionImportConfigurator(uri, destination);
42 41
	}
43
	
44
	
42

  
43

  
45 44
	/**
46 45
	 * @param url
47 46
	 * @param destination
......
49 48
	private DistributionImportConfigurator(URI uri, ICdmDataSource destination) {
50 49
		super(uri, destination);
51 50
	}
52
	
53
	
54
	
51

  
52

  
53

  
55 54

  
56 55
	/* (non-Javadoc)
57 56
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
58 57
	 */
59
	public ExcelImportState getNewState() {
58
	@Override
59
    public ExcelImportState getNewState() {
60 60
		return new ExcelImportState(this);
61 61
	}
62
	
62

  
63 63

  
64 64
	/* (non-Javadoc)
65 65
	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
......
75 75
		return sourceReference;
76 76
	}
77 77

  
78
	
78

  
79 79
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/UnitsGatheringEvent.java
67 67
            this.setTeam(team, config);
68 68
        }
69 69
    }
70
//
71
    public UnitsGatheringEvent(ITermService termService, String locality, String collectorName, Double longitude,
72
            Double latitude, TaxonXImportConfigurator config,IAgentService agentService){
73
        if (!StringUtils.isEmpty(locality)) {
74
            this.setLocality(termService, locality, null);
75
        }
76
                this.setCoordinates(longitude, latitude);
77
        if (!StringUtils.isEmpty(collectorName)) {
78
            this.setCollector(collectorName, config, agentService);
79
        }
80
        //        if (!team.isEmpty()) {
81
        //            this.setTeam(team, config);
82
        //        }
83
    }
70 84

  
71 85
//    public UnitsGatheringEvent(ITermService termService, String locality, String collectorName, Double longitude,
72 86
//            Double latitude, TaxonXImportConfigurator config,IAgentService agentService){
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206XMLFieldGetter.java
455 455
            getHierarchie(group.item(0));
456 456
            dataHolder.knownABCDelements.add(path);
457 457
            path = "";
458
            dataHolder.longitude = Double.valueOf(group.item(0)
459
                    .getTextContent());
458
            dataHolder.longitude = Double.valueOf(group.item(0).getTextContent());
460 459
        } catch (NullPointerException e) {
461 460
            dataHolder.longitude = null;
462 461
        }
......
466 465
            getHierarchie(group.item(0));
467 466
            dataHolder.knownABCDelements.add(path);
468 467
            path = "";
469
            dataHolder.latitude = Double
470
                    .valueOf(group.item(0).getTextContent());
468
            dataHolder.latitude = Double.valueOf(group.item(0).getTextContent());
471 469
        } catch (NullPointerException e) {
472 470
            dataHolder.latitude = null;
473 471
        }
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/excel/in/SpecimenCdmExcelImport.java
272 272
		facade.setGatheringPeriod(getTimePeriod(row.getCollectingDate(), row.getCollectingDateEnd()));
273 273
		facade.setLocality(row.getLocality());
274 274
		facade.setFieldNotes(row.getFieldNotes());
275
		facade.setFieldNumber(NB(row.getCollectorsNumber()));
276
		facade.setEcology(NB(row.getEcology()));
277
		facade.setPlantDescription(NB(row.getPlantDescription()));
275
		facade.setFieldNumber(row.getCollectorsNumber());
276
		facade.setEcology(row.getEcology());
277
		facade.setPlantDescription(row.getPlantDescription());
278 278
//		facade.setSex(row.get)
279 279
		handleExactLocation(facade, row, state);
280 280
		facade.setCollector(getOrMakeAgent(state, row.getCollectors()));
......
283 283
		
284 284
		
285 285
		//derivedUnit
286
		facade.setBarcode(NB(row.getBarcode()));
287
		facade.setAccessionNumber(NB(row.getAccessionNumber()));
286
		facade.setBarcode(row.getBarcode());
287
		facade.setAccessionNumber(row.getAccessionNumber());
288 288
		facade.setCollection(getOrMakeCollection(state, row.getCollectionCode(), row.getCollection()));
289 289
		for (IdentifiableSource source : row.getSources()){
290 290
			facade.addSource(source);
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXDataHolder.java
1
// $Id$
2
/**
3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.taxonx2013;
11

  
12
import java.util.ArrayList;
13
import java.util.HashMap;
14
import java.util.UUID;
15

  
16
import org.apache.log4j.Logger;
17

  
18
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
19

  
20
/**
21
 * @author a.mueller
22
 * @date 16.06.2010
23
 *
24
 */
25
public class TaxonXDataHolder {
26
	@SuppressWarnings("unused")
27
	private static final Logger logger = Logger.getLogger(TaxonXDataHolder.class);
28
	
29
	
30
	protected String atomisedStr;
31
	protected String nomenclatureCode;
32
	protected String institutionCode;
33
	protected String collectionCode;
34
	protected String unitID;
35
	protected String recordBasis;
36
	protected String accessionNumber;
37
//	protected String collectorsNumber;
38
	
39
	protected String fieldNumber;
40
	protected Double longitude;
41
	protected Double latitude;
42
	protected String locality;
43
	protected String languageIso = null;
44
	protected String country;
45
	protected String isocountry;
46
	protected int depth;
47
	protected int altitude;
48
	
49
	protected ArrayList<String> gatheringAgentList;
50
	protected ArrayList<String> identificationList;
51
	protected ArrayList<SpecimenTypeDesignationStatus> statusList;
52
	protected ArrayList<HashMap<String, String>> atomisedIdentificationList;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)