Project

General

Profile

« Previous | Next » 

Revision 531fc7bc

Added by Andreas Müller almost 8 years ago

Remove generics from Reference in cdmlib (except for cdmlib-model) #5830

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/GbifReferenceCsv2CdmConverter.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
*/
......
47 47
 * @date 22.11.2011
48 48
 *
49 49
 */
50
public class GbifReferenceCsv2CdmConverter extends PartitionableConverterBase<DwcaDataImportConfiguratorBase, DwcaDataImportStateBase<DwcaDataImportConfiguratorBase>>  
50
public class GbifReferenceCsv2CdmConverter extends PartitionableConverterBase<DwcaDataImportConfiguratorBase, DwcaDataImportStateBase<DwcaDataImportConfiguratorBase>>
51 51
						implements IPartitionableConverter<StreamItem, IReader<CdmBase>, String>{
52
	
52

  
53 53
	private static final Logger logger = Logger.getLogger(GbifReferenceCsv2CdmConverter.class);
54 54

  
55 55
	private static final String CORE_ID = "coreId";
56
	
56

  
57 57
	/**
58 58
	 * @param state
59 59
	 */
......
61 61
		super(state);
62 62
	}
63 63

  
64
	public IReader<MappedCdmBase> map(StreamItem item ){
65
		List<MappedCdmBase> resultList = new ArrayList<MappedCdmBase>(); 
66
		
64
	@Override
65
    public IReader<MappedCdmBase> map(StreamItem item ){
66
		List<MappedCdmBase> resultList = new ArrayList<MappedCdmBase>();
67

  
67 68
		Map<String, String> csv = item.map;
68
		Reference<?> sourceReference = state.getTransactionalSourceReference();
69
		Reference sourceReference = state.getTransactionalSourceReference();
69 70
		String sourceReferecenDetail = null;
70
		
71

  
71 72
		String id = getSourceId(item);
72 73
		TaxonBase<?> taxon = getTaxonBase(id, item, TaxonBase.class, state);
73 74
		if (isNotBlank(id) && taxon == null){
......
75 76
			message = String.format(message, id);
76 77
			fireWarningEvent(message, item, 8);
77 78
		}
78
		
79

  
79 80
		String strCreator = getValue(item, TermUri.DC_CREATOR);
80 81
		String strDate = getValue(item, TermUri.DC_DATE);
81 82
		String strTitle = getValue(item, TermUri.DC_TITLE);
82 83
		String strSource = getValue(item, TermUri.DC_SOURCE);
83 84
		String strIdentifier = getValue(item, TermUri.DC_IDENTIFIER);
84 85
		String strType = getValue(item, TermUri.DC_TYPE);
85
		
86
		Reference<?> reference = ReferenceFactory.newGeneric();
86

  
87
		Reference reference = ReferenceFactory.newGeneric();
87 88
		resultList.add(new MappedCdmBase<CdmBase>(reference));
88 89

  
89 90
		//author
......
95 96
		//title
96 97
		reference.setTitle(strTitle);
97 98
		//inreference
98
		Reference<?> inRef = handleInRef(strSource);
99
		Reference inRef = handleInRef(strSource);
99 100
		if (inRef != null){
100 101
			reference.setInReference(inRef);
101 102
			resultList.add(new MappedCdmBase<CdmBase>(inRef));
......
103 104

  
104 105
		//URI
105 106
		handleIdentifier(strIdentifier, reference);
106
		
107

  
107 108
		//type
108 109
		handleType(reference, strType, taxon, resultList, item);
109
		
110
		
110

  
111

  
111 112
		return new ListReader<MappedCdmBase>(resultList);
112 113
	}
113 114

  
114
	
115
	private void handleType(Reference<?> reference, String strType, TaxonBase<?> taxon, List<MappedCdmBase> resultList, StreamItem item) {
115

  
116
	private void handleType(Reference reference, String strType, TaxonBase<?> taxon, List<MappedCdmBase> resultList, StreamItem item) {
116 117
		// TODO handleType not yet implemented
117
		
118

  
118 119
		if (taxon == null){
119 120
			String message = "Taxon is null. Reference not imported.";
120 121
			fireWarningEvent(message,item, 4);
......
132 133
					}
133 134
				}
134 135
			}
135
			
136

  
136 137
			//guess a nom ref
137 138
			if (isNomRef == false && config.isGuessNomenclaturalReferences()){
138 139
				//if reference equals in author and year we assume that it is the nom ref
......
149 150
						origYear = zooName.getOriginalPublicationYear();
150 151
					}
151 152
					String refYear = reference.getYear();
152
					
153

  
153 154
					//combination compare
154 155
					if (taxonAuthor != null && taxonAuthor.equals(refAuthor)){
155 156
						if (combYear != null && String.valueOf(combYear).equals(refYear)){
......
160 161
							//TODO not yet handled by CDM
161 162
						}
162 163
					}
163
	
164

  
164 165
				}
165 166
			}
166 167
			if (config.isHandleAllRefsAsCitation()){
......
176 177
						resultList.add(new MappedCdmBase<CdmBase>(desc));
177 178
					}
178 179
				}
179
				
180

  
180 181
			}
181
		
182
		}		
183
		
184
		
182

  
183
		}
184

  
185

  
185 186
	}
186 187

  
187 188
	private void createCitation(TaxonDescription desc, Reference ref, TaxonNameBase nameUsedInSource) {
......
212 213
			logger.debug("Reference is not an URI");
213 214
		}
214 215
		//TODO further identifier types
215
		
216

  
216 217
	}
217 218

  
218
	private Reference<?> handleInRef(String strSource) {
219
	private Reference handleInRef(String strSource) {
219 220
		if (StringUtils.isBlank(strSource)){
220 221
			return null;
221 222
		}else{
222
			Reference<?> inRef = ReferenceFactory.newGeneric();
223
			Reference inRef = ReferenceFactory.newGeneric();
223 224
			return inRef;
224 225
		}
225 226
	}
226
	
227

  
227 228

  
228 229
	private TimePeriod handleDate(String strDate) {
229 230
		TimePeriod tp = TimePeriodParser.parseString(strDate);
......
241 242
		return id;
242 243
	}
243 244

  
244
	
245

  
245 246
//********************** PARTITIONABLE **************************************/
246 247

  
247 248
	@Override
......
254 255
			keySet.add(value);
255 256
		}
256 257
	}
257
	
258
	
258

  
259

  
259 260
	@Override
260 261
	public Set<String> requiredSourceNamespaces() {
261 262
		Set<String> result = new HashSet<String>();
262 263
 		result.add(TermUri.DWC_TAXON.toString());
263 264
 		return result;
264 265
	}
265
	
266

  
266 267
//******************* TO STRING ******************************************/
267
	
268

  
268 269
	@Override
269 270
	public String toString(){
270 271
		return this.getClass().getName();

Also available in: Unified diff