Project

General

Profile

« Previous | Next » 

Revision 79276af0

Added by Andreas Müller over 4 years ago

cleanup

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/PesiExportActivatorERMS.java
57 57
	boolean doInferredSynonyms = false; //only with doTaxa
58 58
	boolean doRelTaxa = false;
59 59
	boolean doAdditionalTaxonSource = false;
60
	boolean doDescriptions = false;
61
	boolean doEcology = true;
60
	boolean doDescriptions = true;
61
	boolean doEcologyAndLink = doDescriptions;
62 62

  
63 63
	static boolean doPureNames = false;  //ERMS has no pure names
64 64

  
......
86 86
		config.setDoRelTaxa(doRelTaxa);
87 87
		config.setDoAdditionalTaxonSource(doAdditionalTaxonSource);
88 88
		config.setDoDescription(doDescriptions);
89
		config.setDoEcology(doEcology);
89
		config.setDoEcologyAndLink(doEcologyAndLink);
90 90

  
91 91
//		config.setDoOccurrence(doOccurrence);
92 92
//		config.setDoOccurrenceSource(doOccurrenceSource);
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportState.java
84 84
	 * @return
85 85
	 * @throws RuntimeException
86 86
	 **/
87
	public Rank getRank (int rankId, int  kingdomId){
87
	public Rank getRank (int rankId, int kingdomId){
88 88
		Rank result = null;
89 89
		if (this.rankMap == null){
90 90
			throw new RuntimeException("rank map not initialized");
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportState.java
26 26
/**
27 27
 * @author a.mueller
28 28
 * @since 11.05.2009
29
 * @version 1.0
30 29
 */
31 30
public class IndexFungorumImportState extends DbImportStateBase<IndexFungorumImportConfigurator, IndexFungorumImportState>{
32 31
	@SuppressWarnings("unused")
33 32
	private static final Logger logger = Logger.getLogger(IndexFungorumImportState.class);
34 33

  
35
	Map<String, DefinedTermBase> dbCdmDefTermMap = new HashMap<String, DefinedTermBase>();
34
	Map<String, DefinedTermBase> dbCdmDefTermMap = new HashMap<>();
36 35

  
37
	Map<String, User> usernameMap = new HashMap<String, User>();
36
	Map<String, User> usernameMap = new HashMap<>();
38 37

  
39 38
	private Map<Integer, Map<Integer,Rank>> rankMap;
40 39

  
41 40
	private Map<String, TaxonBase> speciesMap;
42 41

  
43
	private List<UUID> infraspecificTaxaUUIDs = new ArrayList<UUID>();
42
	private List<UUID> infraspecificTaxaUUIDs = new ArrayList<>();
44 43

  
45 44

  
46 45

  
47

  
48
    public List<UUID> getInfraspecificTaxaUUIDs() {
49
		return infraspecificTaxaUUIDs;
50
	}
51

  
52

  
53
	public void setInfraspecificTaxaUUIDs(List<UUID> infraspecificTaxaUUIDs) {
54
		this.infraspecificTaxaUUIDs = infraspecificTaxaUUIDs;
55
	}
56

  
57

  
58 46
	public IndexFungorumImportState(IndexFungorumImportConfigurator config) {
59 47
		super(config);
60 48
	}
61 49

  
62

  
63
	/* (non-Javadoc)
64
	 * @see eu.etaxonomy.cdm.io.common.IoStateBase#initialize(eu.etaxonomy.cdm.io.common.IoConfiguratorBase)
65
	 */
66 50
	@Override
67 51
	public void initialize(IndexFungorumImportConfigurator config) {
68 52
//		super(config);
69 53
	}
70 54

  
55
    public List<UUID> getInfraspecificTaxaUUIDs() {
56
        return infraspecificTaxaUUIDs;
57
    }
58
    public void setInfraspecificTaxaUUIDs(List<UUID> infraspecificTaxaUUIDs) {
59
        this.infraspecificTaxaUUIDs = infraspecificTaxaUUIDs;
60
    }
71 61

  
72 62
	public Map<String, DefinedTermBase> getDbCdmDefinedTermMap(){
73 63
		return this.dbCdmDefTermMap;
74 64
	}
75

  
76 65
	public void putDefinedTermToMap(String tableName, String id, DefinedTermBase term){
77 66
		 this.dbCdmDefTermMap.put(tableName + "_" + id, term);
78 67
	}
79

  
80 68
	public void putDefinedTermToMap(String tableName, int id, DefinedTermBase term){
81 69
		putDefinedTermToMap(tableName, String.valueOf(id), term);
82 70
	}
......
85 73
    public User getUser(String username){
86 74
		return usernameMap.get(username);
87 75
	}
88

  
89 76
	@Override
90 77
    public void putUser(String username, User user){
91 78
		usernameMap.put(username, user);
92 79
	}
93
	/**
94
     * @return the speciesMap
95
     */
80

  
96 81
    public Map<String, TaxonBase> getSpeciesMap() {
97 82
        return speciesMap;
98 83
    }
99

  
100

  
101
    /**
102
     * @param speciesMap the speciesMap to set
103
     */
104 84
    public void setSpeciesMap(Map<String, TaxonBase> speciesMap) {
105 85
        this.speciesMap = speciesMap;
106 86
    }
107 87

  
108
	/**
109
	 * @param rankMap the rankMap to set
110
	 */
111 88
	public void setRankMap(Map<Integer, Map<Integer,Rank>> rankMap) {
112 89
		this.rankMap = rankMap;
113 90
	}
114 91

  
115
//	/**
116
//	 * @return the rankMap
117
//	 */
118
//	public Map<Integer, Map<Integer,Rank>> getRankMap() {
119
//		return rankMap;
120
//	}
121

  
122

  
123
	/**
124
	 * Returns the CDM rank depending on the ERMS rankId and the ERMS kingdomId. Returns <code>
125
	 * null</code> if the rank does not exist.
126
	 * Throws a RuntimeException if the rank map has not been initialized before.
127
	 * @param rankId
128
	 * @param kingdomId
129
	 * @return
130
	 * @throws RuntimeException
131
	 **/
132
	public Rank getRank (int rankId, int  kingdomId){
133
		Rank result = null;
134
		if (this.rankMap == null){
135
			throw new RuntimeException("rank map not initialized");
136
		}
137
		if (kingdomId == 147415 && rankId == 10){
138
			result = Rank.KINGDOM();
139
		}else{
140
			Map<Integer, Rank> kingdomMap = rankMap.get(rankId);
141
			if (kingdomMap != null){
142
				result = kingdomMap.get(kingdomId);
143
			}
144
		}
145
		return result;
146
	}
147

  
148

  
149 92
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumTransformer.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
*/
......
15 15
import eu.etaxonomy.cdm.io.common.TdwgAreaProvider;
16 16
import eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase;
17 17
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
18
import eu.etaxonomy.cdm.model.location.NamedArea;
19 18
import eu.etaxonomy.cdm.model.location.Country;
20
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
19
import eu.etaxonomy.cdm.model.location.NamedArea;
21 20
import eu.etaxonomy.cdm.model.name.Rank;
22 21

  
23 22
/**
24 23
 * @author a.mueller
25 24
 * @since 01.03.2010
26
 * @version 1.0
27 25
 */
28 26
public final class IndexFungorumTransformer extends InputTransformerBase {
29
	private static final Logger logger = Logger.getLogger(IndexFungorumTransformer.class);
30
	
31
	public static final String LSID_PREFIX = "urn:lsid:indexfungorum.org:names:";
32 27

  
33
	public static NomenclaturalCode kingdomId2NomCode(Integer kingdomId){
34
		switch (kingdomId){
35
			case 1: return null;
36
			case 2: return NomenclaturalCode.ICZN;  //Animalia
37
			case 3: return NomenclaturalCode.ICNAFP;  //Plantae
38
			case 4: return NomenclaturalCode.ICNAFP;  //Fungi
39
			case 5: return NomenclaturalCode.ICZN ;  //Protozoa
40
			case 6: return NomenclaturalCode.ICNB ;  //Bacteria
41
			case 7: return NomenclaturalCode.ICNAFP;  //Chromista
42
			case 147415: return NomenclaturalCode.ICNB;  //Monera
43
			default: return null;
44
	
45
		}
46
	}
28
    private static final long serialVersionUID = 7930365658820136180L;
29
    private static final Logger logger = Logger.getLogger(IndexFungorumTransformer.class);
47 30

  
31
	public static final String LSID_PREFIX = "urn:lsid:indexfungorum.org:names:";
48 32

  
49 33

  
50 34
	@Override
......
66 50
				logger.warn("Unhandled rank: " + rankFk);
67 51
				return null;
68 52
		}
69
		
70 53
	}
71 54

  
72 55

  
73

  
74
	/* (non-Javadoc)
75
	 * @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getNamedAreaByKey(java.lang.String)
76
	 */
77 56
	@Override
78 57
	public NamedArea getNamedAreaByKey(String key) throws UndefinedTransformerMethodException {
79 58
		if (StringUtils.isBlank(key)){
......
101 80
		}else if (key.equalsIgnoreCase("SE")){return TdwgAreaProvider.getAreaByTdwgAbbreviation("SWE-OO");
102 81
		}else if (key.equalsIgnoreCase("AM")){return TdwgAreaProvider.getAreaByTdwgAbbreviation("TCS-AR");
103 82
		}else if (key.equalsIgnoreCase("IL")){return TdwgAreaProvider.getAreaByTdwgAbbreviation("PAL-IS");
104
		
83

  
105 84
		}else if (key.equalsIgnoreCase("UK")){return Country.UNITEDKINGDOMOFGREATBRITAINANDNORTHERNIRELAND();
106 85
		}else if (key.equalsIgnoreCase("DK")){return Country.DENMARKKINGDOMOF();
107 86
		}else if (key.equalsIgnoreCase("GR")){return Country.GREECEHELLENICREPUBLIC();
......
111 90
		}else if (key.equalsIgnoreCase("UA")){return Country.UKRAINE();
112 91
		}else if (key.equalsIgnoreCase("GE")){return Country.GEORGIA();
113 92
		}else if (key.equalsIgnoreCase("TR")){return Country.TURKEYREPUBLICOF();
114
		
115
		
93

  
116 94
		} else {
117 95
			logger.warn("Area not yet mapped: " +  key);
118 96
			return null;
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiAdditionalSourceExport.java
90 90
	}
91 91

  
92 92
	//PHASE 01: Sources
93
	private boolean doPhase01(PesiExportState state, PesiExportMapping mapping) throws SQLException {
93
	private boolean doPhase01(PesiExportState state, PesiExportMapping mapping) {
94 94

  
95 95
//	    System.out.println("PHASE 1 of description import");
96 96
	    logger.info("PHASE 1...");
......
100 100
		//int limit = state.getConfig().getLimitSave();
101 101
		int limit = 1000;
102 102

  
103
		List<TaxonBase> taxonList = null;
103
		@SuppressWarnings("rawtypes")
104
        List<TaxonBase> taxonList = null;
104 105

  
105 106
		TransactionStatus txStatus = startTransaction(true);
106 107

  
107 108
		if (logger.isDebugEnabled()){
108
		    logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
109
		    logger.info("Started new transaction. Fetching some " + parentPluralString + " (max: " + limit + ") ...");
109 110
		    logger.debug("Start snapshot, before starting loop");
110 111
		    ProfilerController.memorySnapshot();
111 112
		}
......
115 116
		while ((taxonList = getNextTaxonPartition(TaxonBase.class, limit, partitionCount++, propPath )) != null   ) {
116 117

  
117 118
			if (logger.isDebugEnabled()) {
118
                logger.info("Fetched " + taxonList.size() + " " + pluralString + ". Exporting...");
119
                logger.info("Fetched " + taxonList.size() + " " + parentPluralString + ". Exporting...");
119 120
            }
120 121

  
121
			for (TaxonBase taxon : taxonList) {
122
			for (TaxonBase<?> taxon : taxonList) {
122 123
				countTaxa++;
123
				doCount(count++, modCount, pluralString);
124
				doCount(count++, modCount, parentPluralString);
124 125
				state.setCurrentTaxon(taxon);
125 126
				if (!taxon.getSources().isEmpty()){
126 127
					success &= handleSingleTaxon(taxon, mapping);
......
131 132

  
132 133
			// Commit transaction
133 134
			commitTransaction(txStatus);
134
			logger.info("Exported " + (count - pastCount) + " " + pluralString + ". Total taxa: " + count + ". Total sources " + countSources);
135
			logger.info("Exported " + (count - pastCount) + " " + parentPluralString + ". Total taxa: " + count + ". Total sources " + countSources);
135 136
			pastCount = count;
136 137
			if (logger.isDebugEnabled()) {
137 138
                ProfilerController.memorySnapshot();
......
139 140
			// Start transaction
140 141
			txStatus = startTransaction(true);
141 142
			if(logger.isDebugEnabled()) {
142
                logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") for description import ...");
143
                logger.info("Started new transaction. Fetching some " + parentPluralString + " (max: " + limit + ") for description import ...");
143 144
            }
144 145
		}
145 146

  
......
150 151
		return success;
151 152
	}
152 153

  
153
	private boolean handleSingleTaxon(TaxonBase<?> taxon, PesiExportMapping mapping) throws SQLException {
154
	private boolean handleSingleTaxon(TaxonBase<?> taxon, PesiExportMapping mapping) {
154 155

  
155 156
	    boolean success = true;
156 157

  
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiDescriptionExport.java
75 75
 * <li>Phase 2:	Export of TaxonName extensions <code>taxComment</code>, <code>fauComment</code> and <code>fauExtraCodes</code> as Notes.</ul>
76 76
 * @author e.-m.lee
77 77
 * @since 23.02.2010
78
 * @author a.mueller
78 79
 */
79 80
@Component
80 81
public class PesiDescriptionExport extends PesiExportBase {
......
90 91
	private static final String dbVernacularTableName = "CommonName";
91 92
	private static final String dbImageTableName = "Image";
92 93
	private static final String dbAdditionalSourceTableName = "AdditionalTaxonSource";
93
	private static final String pluralString = "attached infos";
94
	private static final String pluralString = "descriptions";
94 95
	private static final String parentPluralString = "Taxa";
95 96

  
96 97
	//decide where to handle them best (configurator, transformer, single method, ...)
......
190 191
		TransactionStatus txStatus = startTransaction(true);
191 192

  
192 193
		if (logger.isDebugEnabled()){
193
		    logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
194
		    logger.info("Started new transaction. Fetching some " + parentPluralString + " (max: " + limit + ") ...");
194 195
		    logger.debug("Start snapshot, before starting loop");
195 196
		    ProfilerController.memorySnapshot();
196 197
		}
......
200 201
		while ((taxonList = getNextTaxonPartition(Taxon.class, limit, partitionCount++, propPath )) != null   ) {
201 202

  
202 203
			if (logger.isDebugEnabled()) {
203
                logger.info("Fetched " + taxonList.size() + " " + pluralString + ". Exporting...");
204
                logger.info("Fetched " + taxonList.size() + " " + parentPluralString + ". Exporting...");
204 205
            }
205 206

  
206 207
			for (Taxon taxon : taxonList) {
207 208
				countTaxa++;
208
				doCount(count++, modCount, pluralString);
209
				doCount(count++, modCount, parentPluralString);
209 210
				state.setCurrentTaxon(taxon);
210 211
				if (!taxon.getDescriptions().isEmpty()){
211 212
					success &= handleSingleTaxon(taxon, state, notesMapping, occurrenceMapping, addSourceSourceMapping,
......
217 218

  
218 219
			// Commit transaction
219 220
			commitTransaction(txStatus);
220
			logger.info("Exported " + (count - pastCount) + " " + pluralString + ". Total: " + count + " (Phase 01)");
221
			logger.info("Exported " + (count - pastCount) + " " + parentPluralString + ". Total: " + count + " (Phase 01)");
221 222
			pastCount = count;
222 223
			ProfilerController.memorySnapshot();
223 224
			// Start transaction
224 225
			txStatus = startTransaction(true);
225 226
			if(logger.isDebugEnabled()) {
226
                logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") for description import ...");
227
                logger.info("Started new transaction. Fetching some " + parentPluralString + " (max: " + limit + ") for description import ...");
227 228
            }
228 229
		}
229 230

  
230
		logger.info("No " + pluralString + " left to fetch.");
231
		logger.info("No " + parentPluralString + " left to fetch.");
231 232
		logger.info("Partition: " + partitionCount);
232 233
		logger.info("Taxa: " + countTaxa);
233 234
		logger.info("Desc: " + countDescriptions);
......
304 305
			logger.info("Started new transaction. Fetching some name descriptions (max: " + limit + ") for description import ...");
305 306
		}
306 307

  
307
		logger.info("No " + pluralString + " left to fetch.");
308
		logger.info("No " + parentPluralString + " left to fetch.");
308 309
		logger.info("Partition: " + partitionCount);
309 310
		logger.info("Taxa: " + countTaxa);
310 311
		logger.info("Desc: " + countDescriptions);
......
551 552
					}
552 553
				}
553 554

  
554
				doCount(count++, modCount, pluralString);
555
				doCount(count++, modCount, parentPluralString);
555 556
			}
556 557

  
557 558
			// Commit transaction
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiEcologyAndLinkExport.java
340 340

  
341 341
    @Override
342 342
    protected boolean isIgnore(PesiExportState state) {
343
        return ! state.getConfig().isDoEcology();
343
        return ! state.getConfig().isDoEcologyAndLink();
344 344
    }
345 345
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportConfigurator.java
46 46
	private boolean doInferredSynonyms = true;
47 47
	private boolean doPureNames = true;
48 48
	private boolean doDescription = true;
49
	private boolean doEcology = true;
49
	private boolean doEcologyAndLink = true;
50 50

  
51 51
	private int nameIdStart = 10000000;
52 52

  
......
211 211
		this.doParentAndBiota = doParentAndBiota;
212 212
	}
213 213

  
214
    public boolean isDoEcology() {
215
        return doEcology;
214
    public boolean isDoEcologyAndLink() {
215
        return doEcologyAndLink;
216 216
    }
217
    public void setDoEcology(boolean doEcology) {
218
        this.doEcology = doEcology;
217
    public void setDoEcologyAndLink(boolean doEcologyAndLink) {
218
        this.doEcologyAndLink = doEcologyAndLink;
219 219
    }
220 220

  
221 221
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java
2456 2456
		//experts
2457 2457
		ExtensionType extensionTypeSpeciesExpertName = (ExtensionType)getTermService().find(PesiTransformer.uuidExtSpeciesExpertName);
2458 2458
		mapping.addMapper(DbExtensionMapper.NewInstance(extensionTypeSpeciesExpertName, "SpeciesExpertName"));
2459

  
2459 2460
		ExtensionType extensionTypeExpertName = (ExtensionType)getTermService().find(PesiTransformer.uuidExtExpertName);
2460 2461
		mapping.addMapper(DbExtensionMapper.NewInstance(extensionTypeExpertName, "ExpertName"));
2461 2462

  
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTransformer.java
102 102
	public static final UUID uuidExtTaxComment = UUID.fromString("8041a752-0479-4626-ab1b-b266b751f816");
103 103
	public static final UUID uuidExtFauComment = UUID.fromString("054f773a-41c8-4ad5-83e3-981320c1c126");
104 104
	public static final UUID uuidExtFauExtraCodes = UUID.fromString("b8c7e77d-9869-4787-bed6-b4b302dbc5f5");
105
	
105

  
106 106
	// References
107 107
	public static int REF_ARTICLE_IN_PERIODICAL = 1;
108 108
	public static int REF_PART_OF_OTHER = 2;
......
912 912
		return result;
913 913
	}
914 914

  
915

  
916 915
	/**
917 916
	 * Returns the OccurrenceStatusId for a given PresenceAbsenceTerm.
918 917
	 * @param term
......
959 958
		return result;
960 959
	}
961 960

  
962

  
963 961
	@Override
964 962
	public String getCacheByPresenceAbsenceTerm(PresenceAbsenceTerm status) throws UndefinedTransformerMethodException {
965 963
		if (status == null){
......
974 972
		return presenceAbsenceTerm2OccurrenceStatusId(status);
975 973
	}
976 974

  
977

  
978

  
979 975
	@Override
980 976
	public String getCacheByNamedArea(NamedArea namedArea) throws UndefinedTransformerMethodException {
981 977
		NamedArea area = CdmBase.deproxy(namedArea, NamedArea.class);
......
986 982
		}
987 983
	}
988 984

  
989

  
990 985
	@Override
991 986
	public Object getKeyByNamedArea(NamedArea area) throws UndefinedTransformerMethodException {
992 987
		NamedArea namedArea = CdmBase.deproxy(area, NamedArea.class);
......
1572 1567
		} else if (feature.getUuid().equals(BerlinModelTransformer.uuidFeatureConservationStatus)){
1573 1568
			return NoteCategory_Conservation_Status;
1574 1569

  
1575

  
1576 1570
		//E+M
1577 1571
		} else if (feature.getUuid().equals(BerlinModelTransformer.uuidFeatureDistrEM)){
1578 1572
			return NoteCategory_general_distribution_euromed;
......
1960 1954
			logger.warn("Name Type Designation Status not yet supported in PESI: "+ nameTypeDesignationStatus.getLabel());
1961 1955
			return null;
1962 1956
		}
1963

  
1964 1957
	}
1965 1958

  
1966 1959
	/**
......
2108 2101
		}
2109 2102
	}
2110 2103

  
2111
	/**
2112
	 *
2113
	 * @param status
2114
	 * @return
2115
	 */
2116 2104
	@Override
2117 2105
    public String getCacheByNomStatus(NomenclaturalStatusType status) {
2118 2106
		if (status == null){
......
2294 2282
		return null;
2295 2283
	}
2296 2284
	/**
2285
     * FIXME still needed?
2297 2286
     * Returns the RelTaxonQualifierFk for a TaxonRelation.
2298 2287
     * @param relation
2299 2288
     * @return

Also available in: Unified diff