Project

General

Profile

Revision 2a99f685

ID2a99f6856aea57cf3cc32e5abe3a2bf5b4bb55c1
Parent 18564c8d
Child 9041c205

Added by Patricia Kelbert over 8 years ago

add param for user interaction

View differences:

src/main/java/eu/etaxonomy/cdm/io/common/ImportConfiguratorBase.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
*/
......
38 38

  
39 39
	//check
40 40
	private CHECK check = CHECK.CHECK_AND_IMPORT;
41
	
41

  
42 42
	//editor
43 43
	static EDITOR editor = EDITOR.EDITOR_AS_ANNOTATION;
44
	
44

  
45 45
	/**
46 46
	 * The transformer class to be used for Input
47 47
	 */
48 48
	private IInputTransformer transformer;
49 49

  
50
//	
50
//
51 51
//	//TODO
52 52
//	private boolean deleteAll = false;
53
		
53

  
54 54
	//nullValues
55 55
	private boolean ignoreNull = false;
56
	
56

  
57 57
	//Nomenclatural Code
58 58
	private NomenclaturalCode nomenclaturalCode = null;
59
	
59

  
60 60
	private Map<Integer, Feature>  featureMap = new HashMap<Integer, Feature>();
61 61

  
62 62
	 /* The classification name for the first classification.
63
	  * Needs only to be defined if the import does not handle the naming 
63
	  * Needs only to be defined if the import does not handle the naming
64 64
	  * itself (e.g. by using the taxon sec. reference title cache)
65 65
	  */
66 66
	private String classificationName = "Classification - no name";
67
	
67

  
68 68
	private UUID  classificationUuid = UUID.randomUUID();
69 69
	//uuid of concept reference
70 70
	private UUID  secUuid = UUID.randomUUID();
71
	
71

  
72 72
	private Object sourceSecId = -1;
73
	
73

  
74 74
	private SOURCE source;
75 75
	protected Reference<?> sourceReference;
76
	private UUID sourceRefUuid; 
76
	private UUID sourceRefUuid;
77 77
	private ICdmDataSource destination;
78 78
	private Person commentator =  Person.NewTitledInstance("automatic CDM importer");
79
	
79

  
80 80
	protected Class<ICdmIO>[] ioClassList;
81
	
81

  
82 82
	protected ICdmIO[] ioList;
83
	
83

  
84 84
	protected String[] ioBeans;
85
	
85

  
86
	/*user interaction*/
87
    private boolean askUserForHelp =false;
88

  
89

  
86 90
/* *****************CONSTRUCTOR *****************************/
87
	
91

  
88 92
	public ImportConfiguratorBase(IInputTransformer transformer){
89 93
		super();
90 94
		setDbSchemaValidation(DbSchemaValidation.UPDATE);
91 95
		this.transformer = transformer;
92
		
96

  
93 97
	}
94
	
98

  
95 99
	abstract protected void makeIoClassList();
96
	
100

  
97 101
	/* (non-Javadoc)
98 102
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getTransformer()
99 103
	 */
100
	public IInputTransformer getTransformer() {
104
	@Override
105
    public IInputTransformer getTransformer() {
101 106
		return this.transformer;
102 107
	}
103
	
108

  
104 109
	/* (non-Javadoc)
105 110
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#setTransformer(eu.etaxonomy.cdm.io.common.mapping.IInputTransformer)
106 111
	 */
107
	public void setTransformer(IInputTransformer transformer){
112
	@Override
113
    public void setTransformer(IInputTransformer transformer){
108 114
		this.transformer = transformer;
109 115
	}
110 116

  
111 117

  
112
	
113
	
118

  
119

  
114 120
	/**
115 121
	 * @param source the source to set
116 122
	 */
117 123
	public void setSource(SOURCE source) {
118 124
		this.source = source;
119 125
	}
120
	
121
	
126

  
127

  
122 128
	/**
123 129
	 * @param source the source to get
124 130
	 */
125
	public SOURCE getSource() {
131
	@Override
132
    public SOURCE getSource() {
126 133
		return source;
127 134
	}
128
	
135

  
129 136

  
130 137

  
131 138
	/* (non-Javadoc)
132 139
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#isValid()
133 140
	 */
134
	public boolean isValid(){
141
	@Override
142
    public boolean isValid(){
135 143
		boolean result = true;
136 144
		if (source == null){
137 145
			logger.warn("Connection to source could not be established");
138 146
			result = false;
139 147
		}
140
//Not valid any more as the importer may already have a destination		
148
//Not valid any more as the importer may already have a destination
141 149
//		if (destination == null ){
142 150
//			logger.warn("Connection to Cdm could not be established");
143 151
//			result = false;
144 152
//		}
145
		
153

  
146 154
		return result;
147 155
	}
148
	
149
	
150
	
151
/* ****************** GETTER/SETTER **************************/	
156

  
157

  
158

  
159
/* ****************** GETTER/SETTER **************************/
152 160

  
153 161
//	/**
154 162
//	 * @return the state
......
163 171
//	public void setState(STATE state) {
164 172
//		this.state = state;
165 173
//	}
166
	
174

  
167 175
	public void setIoClassList(ICdmIO[] ioList){
168 176
		this.ioList = ioList;
169 177
	}
170
	
171
	public Class<ICdmIO>[] getIoClassList(){
178

  
179
	@Override
180
    public Class<ICdmIO>[] getIoClassList(){
172 181
		if (ioClassList == null){
173 182
			makeIoClassList();
174 183
		}
......
182 191
		this.ioClassList = ioClassList;
183 192
	}
184 193

  
185
	
194

  
186 195
	/* (non-Javadoc)
187 196
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getCheck()
188 197
	 */
189
	public CHECK getCheck() {
198
	@Override
199
    public CHECK getCheck() {
190 200
		return this.check;
191 201
	}
192
	
202

  
193 203
	/* (non-Javadoc)
194 204
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#setCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK)
195 205
	 */
196
	public void setCheck(CHECK check) {
206
	@Override
207
    public void setCheck(CHECK check) {
197 208
		this.check = check;
198 209
	}
199
	
200
	
210

  
211

  
201 212
	/**
202 213
	 * @return the editor
203 214
	 */
204
	public EDITOR getEditor() {
215
	@Override
216
    public EDITOR getEditor() {
205 217
		return editor;
206 218
	}
207 219

  
208 220
	/**
209 221
	 * @param editor the editor to set
210 222
	 */
211
	public void setEditor(EDITOR editor) {
223
	@Override
224
    public void setEditor(EDITOR editor) {
212 225
		ImportConfiguratorBase.editor = editor;
213 226
	}
214 227

  
......
218 231
	 * Default value is <cod>false</code>.
219 232
	 * @return the ignoreNull
220 233
	 */
221
	public boolean isIgnoreNull() {
234
	@Override
235
    public boolean isIgnoreNull() {
222 236
		return ignoreNull;
223 237
	}
224 238

  
225 239
	/**
226 240
	 * @param ignoreNull the ignoreNull to set
227 241
	 */
228
	public void setIgnoreNull(boolean ignoreNull) {
242
	@Override
243
    public void setIgnoreNull(boolean ignoreNull) {
229 244
		this.ignoreNull = ignoreNull;
230 245
	}
231 246

  
232 247
	/* (non-Javadoc)
233 248
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getDestination()
234 249
	 */
235
	public ICdmDataSource getDestination() {
250
	@Override
251
    public ICdmDataSource getDestination() {
236 252
		return destination;
237 253
	}
238 254
	/* (non-Javadoc)
239 255
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#setDestination(eu.etaxonomy.cdm.database.ICdmDataSource)
240 256
	 */
241
	public void setDestination(ICdmDataSource destination) {
257
	@Override
258
    public void setDestination(ICdmDataSource destination) {
242 259
		this.destination = destination;
243 260
	}
244 261

  
......
246 263
	/* (non-Javadoc)
247 264
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
248 265
	 */
249
	public abstract Reference getSourceReference();
266
	@Override
267
    public abstract Reference getSourceReference();
250 268
	/* (non-Javadoc)
251 269
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#setSourceReference(eu.etaxonomy.cdm.model.reference.Reference)
252 270
	 */
253
	public void setSourceReference(Reference sourceReference) {
271
	@Override
272
    public void setSourceReference(Reference sourceReference) {
254 273
		this.sourceReference = sourceReference;
255 274
	}
256 275
	/* (non-Javadoc)
257 276
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReferenceTitle()
258 277
	 */
259
	public String getSourceReferenceTitle() {
278
	@Override
279
    public String getSourceReferenceTitle() {
260 280
		return getSourceReference().getTitleCache();
261 281
	}
262 282
	/* (non-Javadoc)
263 283
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#setSourceReferenceTitle(java.lang.String)
264 284
	 */
265
	public void setSourceReferenceTitle(String sourceReferenceTitle) {
285
	@Override
286
    public void setSourceReferenceTitle(String sourceReferenceTitle) {
266 287
		getSourceReference().setTitleCache(sourceReferenceTitle, true);
267 288
	}
268 289

  
......
270 291
	/* (non-Javadoc)
271 292
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getCommentator()
272 293
	 */
273
	public Person getCommentator() {
294
	@Override
295
    public Person getCommentator() {
274 296
		return commentator;
275 297
	}
276 298

  
277 299
	/* (non-Javadoc)
278 300
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#setCommentator(eu.etaxonomy.cdm.model.agent.Person)
279 301
	 */
280
	public void setCommentator(Person commentator) {
302
	@Override
303
    public void setCommentator(Person commentator) {
281 304
		this.commentator = commentator;
282 305
	}
283 306

  
284 307
	/**
285 308
	 * @return the nomenclaturalCode
286 309
	 */
287
	public NomenclaturalCode getNomenclaturalCode() {
310
	@Override
311
    public NomenclaturalCode getNomenclaturalCode() {
288 312
		return nomenclaturalCode;
289 313
	}
290 314

  
......
292 316
	/**
293 317
	 * @param nomenclaturalCode the nomenclaturalCode to set
294 318
	 */
295
	public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode) {
319
	@Override
320
    public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode) {
296 321
		this.nomenclaturalCode = nomenclaturalCode;
297 322
	}
298 323

  
......
300 325
	/* (non-Javadoc)
301 326
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getTreeUuid()
302 327
	 */
303
	public UUID getClassificationUuid() {
328
	@Override
329
    public UUID getClassificationUuid() {
304 330
		return classificationUuid;
305 331
	}
306 332

  
307 333

  
308
	public void setClassificationUuid(UUID classificationUuid) {
334
	@Override
335
    public void setClassificationUuid(UUID classificationUuid) {
309 336
		this.classificationUuid = classificationUuid;
310 337
	}
311
	
338

  
312 339
	/* (non-Javadoc)
313 340
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSecUuid()
314 341
	 */
315
	public UUID getSecUuid() {
342
	@Override
343
    public UUID getSecUuid() {
316 344
		return secUuid;
317 345
	}
318
	public void setSecUuid(UUID secUuid) {
346
	@Override
347
    public void setSecUuid(UUID secUuid) {
319 348
		this.secUuid = secUuid;
320 349
	}
321 350

  
322 351
	/**
323 352
	 * @return the sourceSecId
324 353
	 */
325
	public Object getSourceSecId() {
354
	@Override
355
    public Object getSourceSecId() {
326 356
		return sourceSecId;
327 357
	}
328 358

  
......
332 362
	public void setSourceSecId(Object sourceSecId) {
333 363
		this.sourceSecId = sourceSecId;
334 364
	}
335
	
365

  
336 366

  
337 367
	/**
338 368
	 * @return the featureMap
......
348 378
		this.featureMap = featureMap;
349 379
	}
350 380

  
351
	
381

  
352 382
	protected static Method getDefaultFunction(Class<?> clazz, String methodName){
353 383
		try {
354 384
			return clazz.getMethod(methodName, List.class) ;
......
361 391
		}
362 392
		return null;
363 393
	}
364
	
394

  
365 395

  
366 396
	/* (non-Javadoc)
367 397
	 * @see eu.etaxonomy.cdm.io.common.IIoConfigurator#getDestinationNameString()
368 398
	 */
369
	public String getDestinationNameString() {
399
	@Override
400
    public String getDestinationNameString() {
370 401
		if (this.getDestination() == null) {
371 402
			return null;
372 403
		} else {
373 404
			return this.getDestination().getName().toString();
374 405
		}
375 406
	}
376
	
407

  
377 408
	/* (non-Javadoc)
378 409
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
379 410
	 */
380
	public String getSourceNameString() {
411
	@Override
412
    public String getSourceNameString() {
381 413
		if (this.getSource() == null){
382 414
			return null;
383 415
		}else{
......
387 419

  
388 420
	/**
389 421
	 * The classification name for the first classification.
390
	 * Needs only to be defined if the import does not handle the naming 
422
	 * Needs only to be defined if the import does not handle the naming
391 423
	 * itself (e.g. by using the taxon sec. reference title cache)
392 424
	 * @param classificationName the classificationName to set
393 425
	 */
......
401 433
	public String getClassificationName() {
402 434
		return classificationName;
403 435
	}
404
	
436

  
405 437

  
406 438
	public UUID getSourceRefUuid() {
407 439
		return sourceRefUuid;
......
428 460
	public boolean isCreateNew(){
429 461
		return false;
430 462
	}
431
	
432
	public UsernamePasswordAuthenticationToken getAuthenticationToken(){
463

  
464
	@Override
465
    public UsernamePasswordAuthenticationToken getAuthenticationToken(){
433 466
		return this.authenticationToken;
434 467
	}
435 468

  
469
	/*user interaction*/
470
	public boolean isInteractWithUser() {
471
        return askUserForHelp;
472
    }
473

  
474
    public void setInteractWithUser (boolean interaction){
475
        askUserForHelp=interaction;
476
    }
477

  
436 478
}
src/main/java/eu/etaxonomy/cdm/io/specimen/UnitsGatheringArea.java
106 106
            UUID areaUUID = null;
107 107
            areaUUID = getNamedAreaDecision(namedAreaStr,config);
108 108

  
109
            if (areaUUID == null){
109
            if (areaUUID == null && config.isInteractWithUser()){
110 110
                areaUUID = askForArea(namedAreaStr, matchingTerms);
111 111
            }
112 112
            if (DEBUG) {
......
192 192
                UUID areaUUID = null;
193 193
                areaUUID = getNamedAreaDecision(fullName,config);
194 194

  
195
                if ((areaUUID == null) && (matchingTerms.keySet().size()>0)){
195
                if ((areaUUID == null) && (matchingTerms.keySet().size()>0) && config.isInteractWithUser()){
196 196
                    areaUUID = askForArea(fullName, matchingTerms);
197 197
                    logger.info("selected area: "+areaUUID);
198 198
                }
src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206ImportConfigurator.java
45 45
    private Map<String, Team> titleCacheTeam;
46 46
    private Map<String, Person> titleCachePerson;
47 47
    private String defaultAuthor="";
48
    private boolean askUserForHelp =true;
49 48
    private boolean allowReuseOtherClassifications =true;
50 49

  
51 50
    private final SpecimenUserInteraction specimenUserInteraction = new SpecimenUserInteraction();
......
75 74
     * @param b
76 75
     * @return
77 76
     */
78
    public static Abcd206ImportConfigurator NewInstance(URI uri, ICdmDataSource destination, boolean userInteraction) {
79
        return new Abcd206ImportConfigurator(uri, destination,userInteraction);
77
    public static Abcd206ImportConfigurator NewInstance(URI uri, ICdmDataSource destination, boolean interact) {
78
        return new Abcd206ImportConfigurator(uri, destination,interact);
80 79
    }
81 80

  
82 81

  
......
97 96
     * @param sourceReference
98 97
     * @param destination
99 98
     */
100
    private Abcd206ImportConfigurator(URI uri, ICdmDataSource destination, boolean userInteraction) {
99
    private Abcd206ImportConfigurator(URI uri, ICdmDataSource destination, boolean interact) {
101 100
        super(defaultTransformer);
102 101
        setSource(uri);
103 102
        setDestination(destination);
104 103
        setSourceReferenceTitle("ABCD classic");
105
        this.askUserForHelp=userInteraction;
104
        setInteractWithUser(interact);
106 105
    }
107 106

  
108 107

  
108

  
109

  
110

  
109 111
    /* (non-Javadoc)
110 112
     * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
111 113
     */
......
275 277
        return namedAreaDecisions.get(areaStr);
276 278
    }
277 279

  
278
    /**
279
     * @return
280
     */
281
    public boolean isInteractWithUser() {
282
        return askUserForHelp;
283
    }
284

  
285
    public void setInteractWithUser (boolean interaction){
286
        this.askUserForHelp=interaction;
287
    }
288 280

  
289 281
    /**
290 282
     * @return the allowReuseOtherClassifications
......
309 301

  
310 302

  
311 303

  
304

  
312 305
}
src/main/java/eu/etaxonomy/cdm/io/specimen/excel/in/SpecimenCdmExcelImportConfigurator.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
*/
......
29 29
public class SpecimenCdmExcelImportConfigurator extends ExcelImportConfiguratorBase implements IImportConfigurator {
30 30
	private static final Logger logger = Logger.getLogger(SpecimenCdmExcelImportConfigurator.class);
31 31
	private static IInputTransformer defaultTransformer = new SpecimenCdmExcelTransformer();
32
	
32

  
33 33
	//old
34 34
	private boolean doParsing = false;
35 35
	private boolean reuseMetadata = false;
36 36
	private boolean reuseTaxon = false;
37 37
	private String taxonReference = null;
38
	
38

  
39 39
	//new
40 40
	private boolean doSpecimen = true;  //reads the specimen worksheet
41 41
	private boolean doAreaLevels = true;  //reads the areaLevels worksheet
42 42
	private boolean doExtensionTypes = true;  //reads the extensionType worksheet
43
	
44
	
45
	private boolean useCountry;  //if isocountry and country is available, use country instead of isocountry 
43

  
44

  
45
	private boolean useCountry;  //if isocountry and country is available, use country instead of isocountry
46 46
	//tries to match areas by the abbreviated label
47 47
	//TODO still needs to be refined as this may hold only for certain vocabularies, levels, ...
48 48
	//there also maybe more strategies like first label, then abbreviated label, ....
49 49
	private TermMatchMode areaMatchMode = TermMatchMode.UUID_ONLY;
50
	private PersonParserFormatEnum personParserFormat = PersonParserFormatEnum.POSTFIX;  //
51
	
52
	//if true, determinations are imported also as individualAssociations	
50
	private final PersonParserFormatEnum personParserFormat = PersonParserFormatEnum.POSTFIX;  //
51

  
52
	//if true, determinations are imported also as individualAssociations
53 53
	private boolean makeIndividualAssociations = true;
54 54
	private boolean useMaterialsExaminedForIndividualsAssociations = true;
55 55
	private boolean firstDeterminationIsStoredUnder = false;
56 56
	private boolean determinationsAreDeterminationEvent = true;
57
	
57

  
58 58
	private boolean preferNameCache = true;
59 59
	private boolean createTaxonIfNotExists = false;
60 60
//	private boolean includeSynonymsForTaxonMatching = false;
61 61

  
62
		
63
	
64
	
65
	@SuppressWarnings("unchecked")
62

  
63

  
64

  
65
	@Override
66
    @SuppressWarnings("unchecked")
66 67
	protected void makeIoClassList(){
67 68
		ioClassList = new Class[]{
68 69
			NamedAreaLevelExcelImport.class,
......
70 71
			SpecimenCdmExcelImport.class
71 72
		};
72 73
	}
73
	
74

  
74 75
	public static SpecimenCdmExcelImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
75 76
		return new SpecimenCdmExcelImportConfigurator(uri, destination);
76 77
	}
77
	
78
	
78

  
79

  
80
	  /**
81
     * @param uri
82
     * @param object
83
     * @param b
84
     * @return
85
     */
86
    public static SpecimenCdmExcelImportConfigurator NewInstance(URI uri, ICdmDataSource destination, boolean interact) {
87
        return new SpecimenCdmExcelImportConfigurator(uri, destination, interact);
88
    }
89

  
79 90
	/**
80 91
	 * @param berlinModelSource
81 92
	 * @param sourceReference
......
84 95
	private SpecimenCdmExcelImportConfigurator(URI uri, ICdmDataSource destination) {
85 96
		super(uri, destination, defaultTransformer);
86 97
	}
87
	
88
	
89
	
98

  
99
	/**
100
     * @param berlinModelSource
101
     * @param sourceReference
102
     * @param destination
103
     */
104
    private SpecimenCdmExcelImportConfigurator(URI uri, ICdmDataSource destination, boolean interact) {
105
        super(uri, destination, defaultTransformer);
106
        setInteractWithUser(interact);
107
    }
108

  
109

  
110

  
90 111
	/* (non-Javadoc)
91 112
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
92 113
	 */
93
	public SpecimenCdmExcelImportState getNewState() {
114
	@Override
115
    public SpecimenCdmExcelImportState getNewState() {
94 116
		return new SpecimenCdmExcelImportState(this);
95 117
	}
96 118

  
......
108 130
		}
109 131
		return sourceReference;
110 132
	}
111
	
133

  
112 134

  
113 135

  
114 136

  
115 137
	/* (non-Javadoc)
116 138
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
117 139
	 */
118
	public String getSourceNameString() {
140
	@Override
141
    public String getSourceNameString() {
119 142
		if (this.getSource() == null){
120 143
			return null;
121 144
		}else{
122 145
			return this.getSource().toString();
123 146
		}
124 147
	}
125
	
126
// **************************** OLD ******************************************	
127
	
148

  
149
// **************************** OLD ******************************************
150

  
128 151
	public void setTaxonReference(String taxonReference) {
129 152
		this.taxonReference = taxonReference;
130 153
	}
131
	
154

  
132 155
	public Reference getTaxonReference() {
133 156
		//TODO
134 157
		if (this.taxonReference == null){
......
136 159
		}
137 160
		return sourceReference;
138 161
	}
139
	
162

  
140 163
	public void setDoAutomaticParsing(boolean doParsing){
141 164
		this.doParsing=doParsing;
142 165
	}
143
	
166

  
144 167
	public boolean getDoAutomaticParsing(){
145 168
		return this.doParsing;
146 169
	}
147
	
170

  
148 171
	public void setReUseExistingMetadata(boolean reuseMetadata){
149 172
		this.reuseMetadata = reuseMetadata;
150 173
	}
151
	
174

  
152 175
	public boolean getReUseExistingMetadata(){
153 176
		return this.reuseMetadata;
154 177
	}
155
	
178

  
156 179
	public void setReUseTaxon(boolean reuseTaxon){
157 180
		this.reuseTaxon = reuseTaxon;
158 181
	}
159
	
182

  
160 183
	public boolean getDoReUseTaxon(){
161 184
		return this.reuseTaxon;
162 185
	}
......
195 218
	public void setFirstDeterminationIsStoredUnder(boolean firstDeterminationIsStoredUnder) {
196 219
		this.firstDeterminationIsStoredUnder = firstDeterminationIsStoredUnder;
197 220
	}
198
	
221

  
199 222
	public boolean isDeterminationsAreDeterminationEvent() {
200 223
		return determinationsAreDeterminationEvent ;
201 224
	}
......
248 271
		return areaMatchMode;
249 272
	}
250 273

  
251
	
252
	
253
	
274

  
275

  
276

  
277

  
278

  
254 279
}
src/main/java/eu/etaxonomy/cdm/io/specimen/excel/in/SpecimenSynthesysExcelImportConfigurator.java
41 41
    private Map<String, Team> titleCacheTeam;
42 42
    private Map<String, Person> titleCachePerson;
43 43
    private String defaultAuthor="";
44
    
44

  
45 45
    private Map<String,UUID> namedAreaDecisions = new HashMap<String,UUID>();
46 46
    private Reference<?> dataReference;
47 47

  
......
62 62
		return new SpecimenSynthesysExcelImportConfigurator(uri, destination);
63 63
	}
64 64

  
65
	public static SpecimenSynthesysExcelImportConfigurator NewInstance(URI uri, ICdmDataSource destination, boolean interact){
66
        return new SpecimenSynthesysExcelImportConfigurator(uri, destination,interact);
67
    }
68

  
65 69

  
66 70
	/**
67 71
	 * @param berlinModelSource
......
75 79
	}
76 80

  
77 81

  
82
    /**
83
     * @param berlinModelSource
84
     * @param sourceReference
85
     * @param destination
86
     */
87
    private SpecimenSynthesysExcelImportConfigurator(URI uri, ICdmDataSource destination, boolean interact) {
88
        super(defaultTransformer);
89
        setSource(uri);
90
        setDestination(destination);
91
        setInteractWithUser(interact);
92
    }
93

  
94

  
78 95

  
79 96
	/* (non-Javadoc)
80 97
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
......
195 212
     return defaultAuthor;
196 213
    }
197 214

  
198
    
215

  
199 216
    public Map<String,UUID> getNamedAreaDecisions() {
200 217
        return namedAreaDecisions;
201 218
    }
src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXExtractor.java
83 83

  
84 84
    protected TaxonXImport importer;
85 85
    protected TaxonXImportState configState;
86
    private final Map<String,String> namesAsked = new HashMap<String, String>();
87
    private final Map<String,Rank>ranksAsked = new HashMap<String, Rank>();
86 88

  
89
    Logger logger = Logger.getLogger(this.getClass());
87 90

  
88 91
    public class MySpecimenOrObservation{
89 92
        String descr="";
......
115 118
     * @return
116 119
     */
117 120
    @SuppressWarnings({ "unused", "null", "rawtypes" })
118
    protected MySpecimenOrObservation extractSpecimenOrObservation(Node specimenObservationNode, DerivedUnitBase derivedUnitBase) {
121
    protected MySpecimenOrObservation extractSpecimenOrObservation(Node specimenObservationNode, DerivedUnitBase derivedUnitBase,
122
            DerivedUnitType defaultAssociation) {
119 123
        String country=null;
120 124
        String locality=null;
121 125
        String stateprov=null;
......
207 211
                }
208 212
            }
209 213
            if(xmldata.item(n).getNodeName().equalsIgnoreCase("#text")){
210
                descr=xmldata.item(n).getTextContent().trim();
211
                if (descr.length()>1) {
214
                descr=xmldata.item(n).getTextContent().replaceAll(";","").trim();
215
                if (descr.length()>1 && containsDistinctLetters(descr)) {
212 216
                    specimenOrObservation.setDescr(descr);
213 217
                    asso=true;
214 218
                }
215 219
            }
216 220
            if(xmldata.item(n).getNodeName().equalsIgnoreCase("tax:p")){
217
                descr=xmldata.item(n).getTextContent().trim();
218
                if (descr.length()>1) {
221
                descr=xmldata.item(n).getTextContent().replaceAll(";","").trim();
222
                if (descr.length()>1 && containsDistinctLetters(descr)) {
219 223
                    specimenOrObservation.setDescr(descr);
220 224
                    asso=true;
221 225
                }
......
225 229

  
226 230
        //            logger.info("DESCR: "+descr);
227 231
        if (!type.isEmpty()) {
228
            derivedUnitFacade = getFacade(type);
232
            if (!containsDistinctLetters(type)) {
233
                type="no description text";
234
            }
235
            derivedUnitFacade = getFacade(type.replaceAll(";",""), defaultAssociation);
229 236
            SpecimenTypeDesignation designation = SpecimenTypeDesignation.NewInstance();
230 237
            SpecimenTypeDesignationStatus stds= getSpecimenTypeDesignationStatusByKey(type);
231 238
            if (stds !=null) {
......
240 247
            //                TaxonNameBase<?,?> name = taxon.getName();
241 248
            //                name.addTypeDesignation(designation, true);
242 249
        } else {
243
            derivedUnitFacade = getFacade(descr);
250
            if (!containsDistinctLetters(descr.replaceAll(";",""))) {
251
                descr="no description text";
252
            }
253

  
254
            derivedUnitFacade = getFacade(descr.replaceAll(";",""), defaultAssociation);
244 255
            derivedUnitBase = derivedUnitFacade.innerDerivedUnit();
245 256
        }
246 257

  
......
336 347
            return null;
337 348
        }
338 349
    }
339
    protected DerivedUnitFacade getFacade(String recordBasis) {
340
        System.out.println("getFacade() for "+recordBasis);
350
    protected DerivedUnitFacade getFacade(String recordBasis, DerivedUnitType defaultAssoc) {
351
//        System.out.println("getFacade() for "+recordBasis);
341 352
        DerivedUnitType type = null;
342 353

  
343 354
        // create specimen
......
358 369
            }
359 370
            if (type == null) {
360 371
                logger.info("The basis of record does not seem to be known: *" + recordBasisL+"*");
361
                type = DerivedUnitType.DerivedUnit;
372
                type = defaultAssoc;
362 373
            }
363 374
            // TODO fossils?
364 375
        } else {
365 376
            logger.info("The basis of record is null");
366
            type = DerivedUnitType.DerivedUnit;
377
            type = defaultAssoc;
367 378
        }
368 379
        DerivedUnitFacade derivedUnitFacade = DerivedUnitFacade.NewInstance(type);
369 380
        return derivedUnitFacade;
......
388 399

  
389 400

  
390 401
    protected final static String SPLITTER = ",";
391
    Logger logger = Logger.getLogger(getClass());
402

  
392 403

  
393 404
    protected  int askQuestion(String question){
394 405
        Scanner scan = new Scanner(System.in);
......
509 520
        return s;
510 521
    }
511 522

  
523

  
524

  
512 525
    /**
513 526
     * @param name
514 527
     * @return
......
519 532
        //        logger.info("getScientificName for "+ fullname);
520 533
        //        JFrame frame = new JFrame("I have a question");
521 534
        //        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
522
        JTextArea textArea = new JTextArea("The names in the free text and in the xml tags do not match : "+fullname+
523
                ", or "+atomised+"\n"+formatNode(fullParagraph));
524
        JScrollPane scrollPane = new JScrollPane(textArea);
525
        textArea.setLineWrap(true);
526
        textArea.setWrapStyleWord(true);
527
        scrollPane.setPreferredSize( new Dimension( 700, 200 ) );
528
        String s = (String)JOptionPane.showInputDialog(
529
                null,
530
                scrollPane,
531
                "Which name do I have to use? The current classification is "+classificationName,
532
                JOptionPane.PLAIN_MESSAGE,
533
                null,
534
                null,
535
                fullname);
536
        return s;
535
        String k = fullname+"_"+atomised;
536
        if (namesAsked.containsKey(k)){
537
            return namesAsked.get(k);
538
        }
539
        else{
540
            JTextArea textArea = new JTextArea("The names in the free text and in the xml tags do not match : "+fullname+
541
                    ", or "+atomised+"\n"+formatNode(fullParagraph));
542
            JScrollPane scrollPane = new JScrollPane(textArea);
543
            textArea.setLineWrap(true);
544
            textArea.setWrapStyleWord(true);
545
            scrollPane.setPreferredSize( new Dimension( 700, 200 ) );
546
            String s = (String)JOptionPane.showInputDialog(
547
                    null,
548
                    scrollPane,
549
                    "Which name do I have to use? The current classification is "+classificationName,
550
                    JOptionPane.PLAIN_MESSAGE,
551
                    null,
552
                    null,
553
                    fullname);
554
            namesAsked.put(k, s);
555
            return s;
556
        }
537 557
    }
538 558

  
539 559

  
540 560
    protected int askAddParent(String s){
541
        boolean hack=true;
542
        if (hack) {
543
            return 1;
544
        }
561
//        boolean hack=true;
562
//        if (hack) {
563
//            return 1;
564
//        }
545 565
        JTextArea textArea = new JTextArea("If you want to add a parent taxa for "+s+", click \"Yes\"." +
546 566
                " If it is a root for this classification, click \"No\" or \"Cancel\".");
547 567
        JScrollPane scrollPane = new JScrollPane(textArea);
......
561 581
        textArea.setWrapStyleWord(true);
562 582
        scrollPane.setPreferredSize( new Dimension( 700, 200 ) );
563 583

  
564
        s = (String)JOptionPane.showInputDialog(
584
        String s2 = (String)JOptionPane.showInputDialog(
565 585
                null,
566 586
                scrollPane,
567 587
                "",
568 588
                JOptionPane.PLAIN_MESSAGE,
569 589
                null,
570 590
                null,
571
                null);
572
        return s;
591
                s);
592
        return s2;
573 593
    }
574 594

  
575 595
    protected String askRank(String s, List<String> rankListStr){
......
625 645
        //        logger.info("askForRank for "+ fullname+ ", "+rank);
626 646
        //        JFrame frame = new JFrame("I have a question");
627 647
        //        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
628
        JTextArea textArea = new JTextArea("What is the correct rank for "+fullname+"?");
629
        JScrollPane scrollPane = new JScrollPane(textArea);
630
        textArea.setLineWrap(true);
631
        textArea.setWrapStyleWord(true);
632
        scrollPane.setPreferredSize( new Dimension( 600, 50 ) );
633 648

  
634
        List<Rank> rankList = new ArrayList<Rank>();
635
        rankList = importer.getTermService().listByTermClass(Rank.class, null, null, null, null);
636

  
637
        List<String> rankListStr = new ArrayList<String>();
638
        for (Rank r:rankList) {
639
            rankListStr.add(r.toString());
649
        if (ranksAsked.containsKey(fullname)){
650
            return ranksAsked.get(fullname);
640 651
        }
641
        String s = (String)JOptionPane.showInputDialog(
642
                null,
643
                scrollPane,
644
                "The rank extracted from the TaxonX file is "+rank.toString(),
645
                JOptionPane.PLAIN_MESSAGE,
646
                null,
647
                rankListStr.toArray(),
648
                rank.toString());
652
        else{
653
            JTextArea textArea = new JTextArea("What is the correct rank for "+fullname+"?");
654
            JScrollPane scrollPane = new JScrollPane(textArea);
655
            textArea.setLineWrap(true);
656
            textArea.setWrapStyleWord(true);
657
            scrollPane.setPreferredSize( new Dimension( 600, 50 ) );
649 658

  
650
        Rank cR = null;
651
        try {
652
            cR = Rank.getRankByEnglishName(s,nomenclaturalCode,true);
653
        } catch (UnknownCdmTypeException e) {
654
            logger.warn("Unknown rank ?!"+s);
655
            logger.warn(e);
659
            List<Rank> rankList = new ArrayList<Rank>();
660
            rankList = importer.getTermService().listByTermClass(Rank.class, null, null, null, null);
661

  
662
            List<String> rankListStr = new ArrayList<String>();
663
            for (Rank r:rankList) {
664
                rankListStr.add(r.toString());
665
            }
666
            String s = (String)JOptionPane.showInputDialog(
667
                    null,
668
                    scrollPane,
669
                    "The rank extracted from the TaxonX file is "+rank.toString(),
670
                    JOptionPane.PLAIN_MESSAGE,
671
                    null,
672
                    rankListStr.toArray(),
673
                    rank.toString());
674

  
675
            Rank cR = null;
676
            try {
677
                cR = Rank.getRankByEnglishName(s,nomenclaturalCode,true);
678
            } catch (UnknownCdmTypeException e) {
679
                logger.warn("Unknown rank ?!"+s);
680
                logger.warn(e);
681
            }
682
            ranksAsked.put(fullname,cR);
683
            return cR;
656 684
        }
657
        return cR;
658 685
    }
659 686

  
660 687
    /**
......
716 743
     * @return Taxon, the parent Taxon
717 744
     */
718 745
    protected Taxon askParent(Taxon taxon,Classification classification ) {
719
              //        logger.info("ask Parent "+taxon.getTitleCache());
746
        System.out.println("ASK PARENT "+classification);
747
        //        logger.info("ask Parent "+taxon.getTitleCache());
720 748
        Set<TaxonNode> allNodes = classification.getAllNodes();
721 749
        Map<String,Taxon> nodesMap = new HashMap<String, Taxon>();
722 750

  
......
870 898
        return xmlString;
871 899
    }
872 900

  
901
    protected boolean containsDistinctLetters(String word){
902
        Set<Character> dl = new HashSet<Character>();
903
        for (char a: word.toCharArray()) {
904
            dl.add(a);
905
        }
906
        if(dl.size()>1 && word.indexOf("no description text")==-1) {
907
            return true;
908
        } else {
909
            return false;
910
        }
911
    }
912

  
873 913

  
874 914
}
875 915

  
src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXImport.java
46 46
 * @author p.kelbert 2013
47 47
 */
48 48
@Component
49
public class TaxonXImport extends
50
SpecimenImportBase<TaxonXImportConfigurator, TaxonXImportState> implements ICdmIO<TaxonXImportState> {
49
public class TaxonXImport extends SpecimenImportBase<TaxonXImportConfigurator, TaxonXImportState> implements ICdmIO<TaxonXImportState> {
51 50
    private static final Logger logger = Logger.getLogger(TaxonXImport.class);
52 51
    private static String prefix = "";
53 52

  
......
118 117
                null,
119 118
                nodeList.toArray(),
120 119
                classificationName);
121

  
122 120
        if (!classifDic.containsKey(s)){
123 121
            System.out.println("Classif inconnue ?? "+s+", "+classifDic);
124 122
            if (s.equalsIgnoreCase("Other classification - add a new one")){
......
130 128
            refreshTransaction();
131 129
        }
132 130
        else{
131
            classification = classifDic.get(s);
132
        }
133 133
            if (classification == null) {
134 134
                String name = taxonXstate.getConfig().getClassificationName();
135 135

  
......
140 140
                getClassificationService().saveOrUpdate(classification);
141 141
                refreshTransaction();
142 142
            }
143
            else{
144
                classification = classifDic.get(s);
145
            }
146
        }
147

  
148

  
149 143
    }
150 144

  
151 145
    /**
src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXModsExtractor.java
1 1
package eu.etaxonomy.cdm.io.taxonx2013;
2 2

  
3 3
import java.net.URI;
4
import java.net.URISyntaxException;
4 5
import java.util.ArrayList;
5 6
import java.util.HashMap;
6 7
import java.util.List;
......
86 87
                    }
87 88
                    if (children.item(i).getAttributes().getNamedItem("type").getNodeValue().equalsIgnoreCase("GenericHash")) {
88 89
                        ref.setIssn("GenericHash: "+content);
90
                        try {
91
                            ref.setUri(new URI("http://plazi.cs.umb.edu/GgServer/search?MODS.ModsDocID="+content));
92
                        } catch (URISyntaxException e) {
93
                            // TODO Auto-generated catch block
94
                            e.printStackTrace();
95
                        }
89 96
                    }
90 97
                }
91 98
            }
src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXTreatmentExtractor.java
24 24
import javax.xml.transform.TransformerFactoryConfigurationError;
25 25

  
26 26
import org.apache.commons.lang.StringUtils;
27
import org.apache.log4j.Logger;
28 27
import org.w3c.dom.Node;
29 28
import org.w3c.dom.NodeList;
30 29

  
31 30
import com.ibm.lsid.MalformedLSIDException;
32 31

  
33 32
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
33
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade.DerivedUnitType;
34 34
import eu.etaxonomy.cdm.model.common.CdmBase;
35 35
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
36 36
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
......
43 43
import eu.etaxonomy.cdm.model.description.TaxonDescription;
44 44
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
45 45
import eu.etaxonomy.cdm.model.description.TextData;
46
import eu.etaxonomy.cdm.model.name.BacterialName;
46 47
import eu.etaxonomy.cdm.model.name.BotanicalName;
47 48
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
48 49
import eu.etaxonomy.cdm.model.name.NonViralName;
......
74 75
 */
75 76
public class TaxonXTreatmentExtractor extends TaxonXExtractor{
76 77

  
77
    private static final Logger logger = Logger.getLogger(TaxonXTreatmentExtractor.class);
78 78
    private final NomenclaturalCode nomenclaturalCode;
79 79
    private Classification classification;
80 80

  
......
126 126
        }
127 127

  
128 128
        for (int i=0;i<children.getLength();i++){
129
            //            if(children.item(i).getNodeName().equalsIgnoreCase("tax:div")) {
130
            //                logger.info("NODE:"+children.item(i).getAttributes().getNamedItem("type").getNodeValue());
131
            //            }
132
            //            logger.info("i: "+i+", " +children.item(i).getNodeName());
129

  
133 130
            if (children.item(i).getNodeName().equalsIgnoreCase("tax:nomenclature")){
134 131
                NodeList nomenclature = children.item(i).getChildNodes();
135 132
                boolean containsName=false;
......
173 170
                    }
174 171
                    else
175 172
                        if (multiple.equalsIgnoreCase("distribution")){
176
                            extractDistribution(children.item(i),acceptedTaxon,defaultTaxon,refMods);
173
                            extractDistribution(children.item(i),acceptedTaxon,defaultTaxon,nametosave, refMods);
177 174
                        }
178 175
                        else {
179 176
                            extractSpecificFeature(children.item(i),acceptedTaxon,defaultTaxon,nametosave, refMods,multiple);
......
198 195

  
199 196
            else if(children.item(i).getNodeName().equalsIgnoreCase("tax:div") &&
200 197
                    children.item(i).getAttributes().getNamedItem("type").getNodeValue().equalsIgnoreCase("distribution") && maxRankRespected){
201
                extractDistribution(children.item(i),acceptedTaxon,defaultTaxon,refMods);
198
                extractDistribution(children.item(i),acceptedTaxon,defaultTaxon,nametosave, refMods);
202 199
            }
203 200
            else if(children.item(i).getNodeName().equalsIgnoreCase("tax:div") &&
204 201
                    children.item(i).getAttributes().getNamedItem("type").getNodeValue().equalsIgnoreCase("etymology") && maxRankRespected){
......
369 366
            }
370 367
            t.addSource(null,null,refMods,null);
371 368

  
372
            if (!identifier.isEmpty() && identifier.length()>2){
369
            if (!identifier.isEmpty() && (identifier.length()>2)){
373 370
                setLSID(identifier, t);
374 371
            }
375 372

  
376 373
            Taxon parentTaxon = askParent(t, classification);
377 374
            if (parentTaxon ==null){
378 375
                while (parentTaxon == null) {
379
                    //                    logger.info("PARENT MISSING");
380 376
                    parentTaxon = createParent(t, refMods);
381 377
                    classification.addParentChild(parentTaxon, t, refMods, null);
382 378
                }
......
394 390
        return t;
395 391
    }
396 392

  
393

  
394
    /**
395
     * @param taxons: the XML Nodegroup
396
     * @param nametosave: the list of objects to save into the CDM
397
     * @param acceptedTaxon: the current accepted Taxon
398
     * @param refMods: the current reference extracted from the MODS
399
     *
400
     * @return Taxon object built
401
     */
402
    @SuppressWarnings({ "rawtypes", "unchecked" })
403
    private TaxonNameBase getTaxonNameBaseFromXML(Node taxons, List<TaxonNameBase> nametosave, Reference<?> refMods) {
404
        //        logger.info("getTaxonFromXML");
405
        //        logger.info("acceptedTaxon: "+acceptedTaxon);
406

  
407
        TaxonNameBase nameToBeFilled = null;
408
        String name="";
409

  
410
        String[] enames = null;
411
        Rank rank = Rank.UNKNOWN_RANK();
412
        String original="";
413
        String identifier="";
414

  
415
        try {
416
            enames = extractScientificName(taxons);
417
            if (enames[1].isEmpty()) {
418
                name=enames[0];
419
            } else {
420
                name=enames[1];
421
            }
422
            original=enames[0];
423
            rank = Rank.getRankByName(enames[2]);
424
            identifier = enames[3];
425
        } catch (TransformerFactoryConfigurationError e1) {
426
            logger.warn(e1);
427
        } catch (TransformerException e1) {
428
            logger.warn(e1);
429
        } catch (UnknownCdmTypeException e) {
430
            logger.warn("Rank problem!"+enames[2]);
431
            rank=Rank.UNKNOWN_RANK();
432
        }
433
        INonViralNameParser parser = NonViralNameParserImpl.NewInstance();
434

  
435
        nameToBeFilled = parser.parseFullName(name, nomenclaturalCode, rank);
436
        if (nameToBeFilled.hasProblem() &&
437
                !((nameToBeFilled.getParsingProblems().size()==1) && nameToBeFilled.getParsingProblems().contains(ParserProblem.CheckRank)) ) {
438
            //            if (nameToBeFilled.hasProblem() && nameToBeFilled.getParsingProblems().contains(ParserProblem.UnparsableNamePart)){
439
            nameToBeFilled=solveNameProblem(original, name,parser);
440
        }
441

  
442
        nameToBeFilled = getTaxonNameBase(nameToBeFilled,nametosave);
443
        return nameToBeFilled;
444

  
445
    }
446

  
447

  
397 448
    @SuppressWarnings("rawtypes")
398 449
    private TaxonNameBase getTaxonNameBase (TaxonNameBase name, List<TaxonNameBase> nametosave){
399 450
        List<TaxonNameBase> names = importer.getNameService().list(TaxonNameBase.class, null, null, null, null);
......
443 494
    }
444 495

  
445 496
    /**
497
     * @param nametosave
446 498
     * @param distribution: the XML node group
447 499
     * @param acceptedTaxon: the current accepted Taxon
448 500
     * @param defaultTaxon: the current defaultTaxon, only used if there is no accepted name
449 501
     * @param refMods: the current reference extracted from the MODS
450 502
     */
451 503
    @SuppressWarnings("rawtypes")
452
    private void extractDistribution(Node distribution, Taxon acceptedTaxon, Taxon defaultTaxon, Reference<?> refMods) {
504
    private void extractDistribution(Node distribution, Taxon acceptedTaxon, Taxon defaultTaxon, List<TaxonNameBase> nametosave, Reference<?> refMods) {
453 505
        //        logger.info("DISTRIBUTION");
454 506
        //        logger.info("acceptedTaxon: "+acceptedTaxon);
455 507
        NodeList children = distribution.getChildNodes();
......
457 509
        Map<Integer,String> descriptionsFulltext = new HashMap<Integer,String>();
458 510

  
459 511
        for (int i=0;i<children.getLength();i++){
460
            specimenOrObservations = new HashMap<Integer, List<MySpecimenOrObservation>>();
461
            descriptionsFulltext = new HashMap<Integer,String>();
462 512
            if (children.item(i).getNodeName().equalsIgnoreCase("tax:p")){
463 513
                NodeList paragraph = children.item(i).getChildNodes();
464 514
                for (int j=0;j<paragraph.getLength();j++){
465 515
                    if (paragraph.item(j).getNodeName().equalsIgnoreCase("#text")){
466 516
                        if(!paragraph.item(j).getTextContent().trim().isEmpty()) {
467
                            descriptionsFulltext.put(i,paragraph.item(j).getTextContent().trim());
517
                            String s =paragraph.item(j).getTextContent().trim();
518
                            if (descriptionsFulltext.get(i) !=null){
519
                                s = descriptionsFulltext.get(i)+" "+s;
520
                            }
521
                            descriptionsFulltext.put(i, s);
468 522
                        }
469 523
                    }
524
                    else if (paragraph.item(j).getNodeName().equalsIgnoreCase("tax:name")){
525
                        String s =getTaxonNameBaseFromXML(paragraph.item(j),nametosave,refMods).toString().split("sec.")[0];
526
                        if (descriptionsFulltext.get(i) !=null){
527
                            s = descriptionsFulltext.get(i)+" "+s;
528
                        }
529
                        descriptionsFulltext.put(i, s);
530
                    }
470 531
                    else if (paragraph.item(j).getNodeName().equalsIgnoreCase("tax:collection_event")){
471 532
                        MySpecimenOrObservation specimenOrObservation = new MySpecimenOrObservation();
472 533
                        DerivedUnitBase derivedUnitBase = null;
473
                        specimenOrObservation = extractSpecimenOrObservation(paragraph.item(j), derivedUnitBase);
534
                        specimenOrObservation = extractSpecimenOrObservation(paragraph.item(j), derivedUnitBase, DerivedUnitType.DerivedUnit);
474 535
                        List<MySpecimenOrObservation> speObsList = specimenOrObservations.get(i);
475 536
                        if (speObsList == null) {
476 537
                            speObsList=new ArrayList<MySpecimenOrObservation>();
477 538
                        }
478 539
                        speObsList.add(specimenOrObservation);
479 540
                        specimenOrObservations.put(i,speObsList);
480
                    }
481
                }
482 541

  
542
                        String s = specimenOrObservation.getDerivedUnitBase().toString();
543
                        if (descriptionsFulltext.get(i) !=null){
544
                            s = descriptionsFulltext.get(i)+" "+s;
545
                        }
546
                        descriptionsFulltext.put(i, s);
547
                    }
483 548

  
484
            }
485
            //            if (!descriptionsFulltext.isEmpty()) {
486
            //                logger.info("descriptionsFulltext: "+descriptionsFulltext);
487
            //            }
488
            //            if(!specimenOrObservations.isEmpty()) {
489
            //                logger.info("specimenOrObservations: "+specimenOrObservations);
490
            //            }
491

  
492
            int m=0;
493
            for (int k:descriptionsFulltext.keySet()) {
494
                if (k>m) {
495
                    m=k;
496 549
                }
497 550
            }
498
            for (int k:specimenOrObservations.keySet()) {
499
                if (k>m) {
500
                    m=k;
501
                }
551
        }
552

  
553
        int m=0;
554
        for (int k:descriptionsFulltext.keySet()) {
555
            if (k>m) {
556
                m=k;
502 557
            }
558
        }
559
        for (int k:specimenOrObservations.keySet()) {
560
            if (k>m) {
561
                m=k;
562
            }
563
        }
503 564

  
504 565

  
505
            TaxonDescription td =importer.getTaxonDescription(acceptedTaxon, false, true);
506
            Feature currentFeature = Feature.DISTRIBUTION();
507
            for (int k=0;k<=m;k++){
508
                if (descriptionsFulltext.keySet().contains(k)){
509
                    if (!descriptionsFulltext.get(k).isEmpty() && (descriptionsFulltext.get(k).startsWith("Hab.") || descriptionsFulltext.get(k).startsWith("Habitat"))){
510
                        setParticularDescription(descriptionsFulltext.get(k),acceptedTaxon,defaultTaxon, refMods, Feature.HABITAT());
511
                        break;
512
                    }
513
                    else{
514
                        TextData textData = TextData.NewInstance();
566
        TaxonDescription td =importer.getTaxonDescription(acceptedTaxon, false, true);
567
        Feature currentFeature = Feature.DISTRIBUTION();
568
        DerivedUnitBase derivedUnitBase=null;
569
        String descr="";
570
        for (int k=0;k<=m;k++){
571
            if(specimenOrObservations.keySet().contains(k)){
572
                for (MySpecimenOrObservation soo:specimenOrObservations.get(k) ) {
573
                    derivedUnitBase = soo.getDerivedUnitBase();
574
                    descr=soo.getDescr();
515 575

  
516
                        textData.setFeature(currentFeature);
517
                        textData.putText(Language.UNKNOWN_LANGUAGE(), descriptionsFulltext.get(k));
518
                        textData.addSource(null, null, refMods, null);
576
                    derivedUnitBase.addSource(null,null,refMods,null);
519 577

  
520
                        td.addElement(textData);
521
                    }
522
                }
523
                if(specimenOrObservations.keySet().contains(k)){
524
                    for (MySpecimenOrObservation soo:specimenOrObservations.get(k) ) {
525
                        td.addDescribedSpecimenOrObservation(soo.getDerivedUnitBase());
578
                    importer.getOccurrenceService().saveOrUpdate(derivedUnitBase);
579

  
580
                    TaxonDescription taxonDescription = importer.getTaxonDescription(acceptedTaxon, false, true);
581
                    acceptedTaxon.addDescription(taxonDescription);
582

  
583

  
584
                    IndividualsAssociation indAssociation = IndividualsAssociation.NewInstance();
585

  
586
                    Feature feature=null;
587
                        feature = makeFeature(derivedUnitBase);
588
                    if(!StringUtils.isEmpty(descr)) {
589
                        derivedUnitBase.setTitleCache(descr, true);
526 590
                    }
527
                }
591
                    indAssociation.setAssociatedSpecimenOrObservation(derivedUnitBase);
592
                    indAssociation.setFeature(feature);
593
                    indAssociation.addSource(null, null, refMods, null);
594

  
595
                    taxonDescription.addElement(indAssociation);
596
                    taxonDescription.setTaxon(acceptedTaxon);
597
                    taxonDescription.addSource(null,null,refMods,null);
528 598

  
529
                if (descriptionsFulltext.keySet().contains(k) || specimenOrObservations.keySet().contains(k)){
530
                    td.addSource(null,null,refMods,null);
531
                    acceptedTaxon.addDescription(td);
532
                    importer.getDescriptionService().saveOrUpdate(td);
599
                    importer.getDescriptionService().saveOrUpdate(taxonDescription);
533 600
                    importer.getTaxonService().saveOrUpdate(acceptedTaxon);
601
                    td.addDescribedSpecimenOrObservation(soo.getDerivedUnitBase());
534 602
                }
603
            }
535 604

  
605
            if (descriptionsFulltext.keySet().contains(k)){
606
                if (!descriptionsFulltext.get(k).isEmpty() && (descriptionsFulltext.get(k).startsWith("Hab.") || descriptionsFulltext.get(k).startsWith("Habitat"))){
607
                    setParticularDescription(descriptionsFulltext.get(k),acceptedTaxon,defaultTaxon, refMods, Feature.HABITAT());
608
                    break;
... 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)