Project

General

Profile

« Previous | Next » 

Revision b9fdd7f4

Added by unknown about 7 years ago

cleanup

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/PalmaeProtologueImport.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
*/
......
20 20
import org.springframework.stereotype.Component;
21 21

  
22 22
import eu.etaxonomy.cdm.app.images.AbstractImageImporter;
23
import eu.etaxonomy.cdm.app.images.ImageImportConfigurator;
24 23
import eu.etaxonomy.cdm.app.images.ImageImportState;
25 24
import eu.etaxonomy.cdm.common.ExcelUtils;
26 25
import eu.etaxonomy.cdm.model.description.Feature;
......
34 33
/**
35 34
 * @author n.hoffmann
36 35
 * @created 19.11.2008
37
 * @version 1.0
38 36
 */
39 37
@Component
40 38
public class PalmaeProtologueImport extends AbstractImageImporter {
41
	private static final Logger logger = Logger.getLogger(PalmaeProtologueImport.class);
39
    private static final long serialVersionUID = -7178567387220714414L;
40

  
41
    private static final Logger logger = Logger.getLogger(PalmaeProtologueImport.class);
42 42

  
43 43
	public static final String SPECIES = "Species";
44 44
	public static final String TAXONID = "Taxon ID";
45 45
	public static final String LINK_PROTO = "Link proto";
46
	
47
	/* (non-Javadoc)
48
	 * @see eu.etaxonomy.cdm.app.images.AbstractImageImporter#invokeImageImport(eu.etaxonomy.cdm.io.common.IImportConfigurator)
49
	 */
46

  
50 47
	@Override
51 48
	protected void invokeImageImport(ImageImportState state) {
52
		
49

  
53 50
		ArrayList<HashMap<String, String>> contents;
54 51
		try {
55 52
			contents = ExcelUtils.parseXLS(state.getConfig().getSource());
......
58 55
			state.setUnsuccessfull();
59 56
			return;
60 57
		}
61
		
58

  
62 59
		Set<TaxonNameBase> taxonNameStore = new HashSet<TaxonNameBase>();
63
		
60

  
64 61
		int count = 0;
65
		
62

  
66 63
		for (HashMap<String, String> row : contents){
67 64
			count++;
68
			
65

  
69 66
			TaxonNameBase taxonNameBase = null;
70 67
			String species = null;
71 68
			String taxonId = null;
......
78 75
			}catch (Exception e){
79 76
				logger.error("The row has errors: rowNumber: " +count + ", content: "  + row, e);
80 77
			}
81
			
82
				
83
			
78

  
79

  
80

  
84 81
			if(taxonNameBase == null){
85 82
				logger.warn("no taxon with this name found: " + species + ", idInSource: " + taxonId);
86 83
			}else{
87
				
84

  
88 85
				URI uri;
89 86
				try {
90 87
					uri = new URI(linkProto);
91 88
					MediaRepresentationPart representationPart = MediaRepresentationPart.NewInstance(uri, 0);
92 89
					MediaRepresentation representation = MediaRepresentation.NewInstance("text/html", null);
93 90
					representation.addRepresentationPart(representationPart);
94
					
91

  
95 92
					Media media = Media.NewInstance();
96 93
					media.addRepresentation(representation);
97
								
94

  
98 95
					TaxonNameDescription description = TaxonNameDescription.NewInstance();
99 96
					TextData protolog = TextData.NewInstance(Feature.PROTOLOGUE());
100 97
					protolog.addMedia(media);
......
105 102
					logger.error(message);
106 103
					e.printStackTrace();
107 104
				}
108
				
105

  
109 106
				taxonNameStore.add(taxonNameBase);
110 107
				if(count % 50 == 0){
111 108
					logger.info(count + " protologues processed.");
112 109
				}
113 110
			}
114 111
		}
115
		
116
		
112

  
113

  
117 114
		getNameService().save(taxonNameStore);
118 115
		logger.info(count + " protologues imported to CDM store.");
119
		
116

  
120 117
		return;
121 118
	}
122
	
119

  
123 120
}

Also available in: Unified diff