Project

General

Profile

« Previous | Next » 

Revision c483dd7e

Added by Katja Luther over 9 years ago

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.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
*/
......
26 26
	public static ICdmDataSource cdm_test_local_mysql(){
27 27
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
28 28
		String cdmServer = "127.0.0.1";
29
		String cdmDB = "cdm_test"; 
29
		String cdmDB = "cdm_test";
30 30
		String cdmUserName = "root";
31 31
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
32 32
	}
33
	
33

  
34 34
	public static ICdmDataSource cdm_test_local_faunaEu_mysql(){
35 35
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
36 36
		String cdmServer = "127.0.0.1";
37
		String cdmDB = "cdm_test"; 
37
		String cdmDB = "cdm_faunaeu_2014_07";
38 38
		String cdmUserName = "root";
39 39
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
40 40
	}
41 41

  
42
	
42

  
43 43
	public static ICdmDataSource cdm_test_local_indexFungorum(){
44 44
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
45 45
		String cdmServer = "127.0.0.1";
46
		String cdmDB = "indexFungorum"; 
46
		String cdmDB = "indexFungorum";
47 47
		String cdmUserName = "root";
48 48
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
49 49
	}
50
	
51
	
50

  
51

  
52 52
	public static ICdmDataSource cdm_test_local_mysql_erms(){
53 53
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
54 54
		String cdmServer = "127.0.0.1";
55
		String cdmDB = "erms"; 
55
		String cdmDB = "erms";
56 56
		String cdmUserName = "root";
57 57
		return CdmDestinations.makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
58 58
	}
59 59

  
60
	
60

  
61 61
	public static ICdmDataSource cdm_test_local_mysql_erms2(){
62 62
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
63 63
		String cdmServer = "127.0.0.1";
64
		String cdmDB = "erms2"; 
64
		String cdmDB = "erms2";
65 65
		String cdmUserName = "root";
66 66
		return CdmDestinations.makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
67 67
	}
68
	
69
	
68

  
69

  
70 70
	public static ICdmDataSource cdm_test_local_mysql_test(){
71 71
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
72 72
		String cdmServer = "127.0.0.1";
73
		String cdmDB = "test"; 
73
		String cdmDB = "test";
74 74
		String cdmUserName = "edit";
75 75
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
76 76
	}
......
81 81
		String cdmUserName = "edit";
82 82
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
83 83
	}
84
	
84

  
85 85
	public static ICdmDataSource cdm_portal_test_localhost2(){
86 86
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
87 87
		String cdmServer = "127.0.0.1";
......
97 97
		String cdmUserName = "edit";
98 98
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
99 99
	}
100
	
101
	
100

  
101

  
102 102
	public static ICdmDataSource NULL(){
103 103
		return null;
104 104
	}
105
	
106
	
105

  
106

  
107 107
	public static ICdmDataSource localH2(){
108 108
		return CdmDataSource.NewH2EmbeddedInstance("cdm", "sa", "");
109 109
	}
110
	
110

  
111 111
	public static ICdmDataSource localH2(String database, String username, String filePath){
112 112
		return CdmDataSource.NewH2EmbeddedInstance(database, "sa", "", filePath, null);
113 113
	}
114 114

  
115
	
115

  
116 116
	public static ICdmDataSource localH2EuroMed(){
117 117
		return CdmDataSource.NewH2EmbeddedInstance("euroMed", "sa", "");
118 118
	}
119
	
119

  
120 120
	public static ICdmDataSource localH2Erms(){
121 121
		return CdmDataSource.NewH2EmbeddedInstance("erms", "sa", "");
122 122
	}
......
124 124
	public static ICdmDataSource cdm_algaterra_preview(){
125 125
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
126 126
		String cdmServer = "160.45.63.201";
127
		String cdmDB = "cdm_edit_algaterra"; 
127
		String cdmDB = "cdm_edit_algaterra";
128 128
		String cdmUserName = "edit";
129 129
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
130 130
	}
......
133 133
	public static ICdmDataSource cdm_pesi_euroMed(){
134 134
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
135 135
		String cdmServer = "160.45.63.175";
136
		String cdmDB = "cdm_pesi_euromed"; 
136
		String cdmDB = "cdm_pesi_euromed";
137 137
		String cdmUserName = "edit";
138 138
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
139 139
	}
......
153 153
		String cdmUserName = "root";
154 154
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
155 155
	}
156
	
156

  
157 157
	public static ICdmDataSource cdm_local_euroMed3(){
158 158
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
159 159
		String cdmServer = "127.0.0.1";
......
165 165
	public static ICdmDataSource cdm_pesi_fauna_europaea(){
166 166
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
167 167
		String cdmServer = "160.45.63.175";
168
		String cdmDB = "cdm_pesi_fauna_europaea"; 
168
		String cdmDB = "cdm_pesi_fauna_europaea";
169 169
		String cdmUserName = "edit";
170 170
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
171 171
	}
172
	
172

  
173 173

  
174 174
	public static ICdmDataSource cdm_pesi_erms(){
175 175
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
176 176
		String cdmServer = "160.45.63.175";
177
		String cdmDB = "cdm_pesi_erms"; 
177
		String cdmDB = "cdm_pesi_erms";
178 178
		String cdmUserName = "edit";
179 179
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
180 180
	}
181 181

  
182
	 
182

  
183 183
	/**
184 184
	 * initializes source
185 185
	 * TODO only supports MySQL and PostgreSQL
186
	 * 
186
	 *
187 187
	 * @param dbType
188 188
	 * @param cdmServer
189 189
	 * @param cdmDB
......
197 197
		pwd = AccountStore.readOrStorePassword(cdmServer, cdmDB, cdmUserName, pwd);
198 198
		ICdmDataSource destination;
199 199
		if(dbType.equals(DatabaseTypeEnum.MySQL)){
200
			destination = CdmDataSource.NewMySqlInstance(cdmServer, cdmDB, port, cdmUserName, pwd, null);			
200
			destination = CdmDataSource.NewMySqlInstance(cdmServer, cdmDB, port, cdmUserName, pwd, null);
201 201
		} else if(dbType.equals(DatabaseTypeEnum.PostgreSQL)){
202
			destination = CdmDataSource.NewPostgreSQLInstance(cdmServer, cdmDB, port, cdmUserName, pwd, null);			
202
			destination = CdmDataSource.NewPostgreSQLInstance(cdmServer, cdmDB, port, cdmUserName, pwd, null);
203 203
		} else {
204 204
			//TODO others
205 205
			throw new RuntimeException("Unsupported DatabaseType");
......
210 210

  
211 211

  
212 212
	/**
213
	 * Accepts a string array and tries to find a method returning an ICdmDataSource with 
213
	 * Accepts a string array and tries to find a method returning an ICdmDataSource with
214 214
	 * the name of the given first string in the array
215
	 * 
215
	 *
216 216
	 * @param args
217 217
	 * @return
218 218
	 */
219 219
	public static ICdmDataSource chooseDestination(String[] args) {
220
		if(args == null)
221
			return null;
222
		
223
		if(args.length != 1)
224
			return null;
225
		
220
		if(args == null) {
221
            return null;
222
        }
223

  
224
		if(args.length != 1) {
225
            return null;
226
        }
227

  
226 228
		String possibleDestination = args[0];
227
		
229

  
228 230
		Method[] methods = CdmDestinations.class.getMethods();
229
		
231

  
230 232
		for (Method method : methods){
231 233
			if(method.getName().equals(possibleDestination)){
232 234
				try {
......
245 247
		}
246 248
		return null;
247 249
	}
248
	
250

  
249 251
}
250 252

  
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/FaunaEuropaeaActivator.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
*/
......
39 39

  
40 40
	static final Source faunaEuropaeaSource = PesiSources.mfn_faunEu_pesi3();
41 41
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_faunaEu_mysql();
42
	//static final ICdmDataSource cdmDestination = CdmDestinations.cdm_pesi_fauna_europaea();
43

  
42 44

  
43
	
44 45
	static final int limitSave = 5000;
45 46

  
46 47
//	static final CHECK check = CHECK.CHECK_AND_IMPORT;
......
51 52
	static final NomenclaturalCode nomenclaturalCode  = NomenclaturalCode.ICZN;
52 53

  
53 54
// ****************** ALL *****************************************
54
	
55

  
55 56
	// Fauna Europaea to CDM import
56 57
	static final boolean doAuthors = true;
57 58
	static final boolean doTaxa = true;
......
64 65
	static final boolean makeFeatureTree = true;
65 66
    // CDM to CDM import
66 67
	static final boolean doHeterotypicSynonymsForBasionyms = true;
67
	
68

  
68 69
// ************************ NONE **************************************** //
69
		
70

  
70 71
	// Fauna Europaea to CDM import
71 72
//	static final boolean doAuthors = false;
72 73
//	static final boolean doTaxa = false;
......
79 80
//	static final boolean makeFeatureTree = false;
80 81
//    // CDM to CDM import
81 82
//	static final boolean doHeterotypicSynonymsForBasionyms = false;
82
	
83
	
83

  
84

  
84 85
	/**
85 86
	 * @param args
86 87
	 */
87 88
	public static void main(String[] args) {
88
		
89

  
89 90
		ICdmDataSource destination = cdmDestination;
90 91
		System.out.println("Starting import from Fauna Europaea (" + faunaEuropaeaSource.getDatabase() + ") to CDM (" + destination.getDatabase() + ")...");
91 92

  
92 93
				// invoke Fauna Europaea to CDM import
93
		
94
		FaunaEuropaeaImportConfigurator fauEuImportConfigurator = 
94

  
95
		FaunaEuropaeaImportConfigurator fauEuImportConfigurator =
95 96
			FaunaEuropaeaImportConfigurator.NewInstance(faunaEuropaeaSource,  destination);
96
		
97

  
97 98
		fauEuImportConfigurator.setDbSchemaValidation(dbSchemaValidation);
98 99
		fauEuImportConfigurator.setNomenclaturalCode(nomenclaturalCode);
99 100
		fauEuImportConfigurator.setCheck(check);
......
108 109
		fauEuImportConfigurator.setDoHeterotypicSynonyms(doHeterotypicSynonyms);
109 110
		fauEuImportConfigurator.setDoHeterotypicSynonymsForBasionyms(doHeterotypicSynonymsForBasionyms);
110 111
		fauEuImportConfigurator.setSourceRefUuid(PesiTransformer.uuidSourceRefFaunaEuropaea);
111
		
112
		CdmDefaultImport<FaunaEuropaeaImportConfigurator> fauEuImport = 
112

  
113
		CdmDefaultImport<FaunaEuropaeaImportConfigurator> fauEuImport =
113 114
			new CdmDefaultImport<FaunaEuropaeaImportConfigurator>();
114 115
		try {
115 116
			fauEuImport.invoke(fauEuImportConfigurator);
......
119 120
		}
120 121

  
121 122
		// invoke CDM to CDM import
122
		
123

  
123 124
//		System.out.println("Starting import from CDM to CDM (" + destination.getDatabase() + ")...");
124
//		
125
//		CdmImportConfigurator cdmImportConfigurator = 
125
//
126
//		CdmImportConfigurator cdmImportConfigurator =
126 127
//			CdmImportConfigurator.NewInstance(destination, destination);
127
//		
128
//
128 129
//		cdmImportConfigurator.setDbSchemaValidation(DbSchemaValidation.VALIDATE);
129 130
//		cdmImportConfigurator.setNomenclaturalCode(nomenclaturalCode);
130 131
//		cdmImportConfigurator.setCheck(check);
......
136 137
//		cdmImportConfigurator.setDoOccurrence(false);
137 138
//		cdmImportConfigurator.setLimitSave(limitSave);
138 139
//
139
//		CdmDefaultImport<CdmImportConfigurator> cdmImport = 
140
//		CdmDefaultImport<CdmImportConfigurator> cdmImport =
140 141
//			new CdmDefaultImport<CdmImportConfigurator>();
141 142
//		try {
142 143
//			cdmImport.invoke(cdmImportConfigurator);
......
144 145
//			System.out.println("ERROR in CDM to CDM import");
145 146
//			e.printStackTrace();
146 147
//		}
147
		
148

  
148 149
		//make feature tree
149
		
150
		if (makeFeatureTree == true) {
150

  
151
		if (makeFeatureTree) {
151 152
			FeatureTree featureTree = FeatureTree.NewInstance(UUID.fromString("ff59b9ad-1fb8-4aa4-a8ba-79d62123d0fb"));
152 153
			FeatureNode root = featureTree.getRoot();
153 154

  
......
161 162

  
162 163
			app.getFeatureTreeService().saveOrUpdate(featureTree);
163 164
		}
164
		
165

  
165 166
		System.out.println("End importing Fauna Europaea data");
166 167
	}
167 168

  
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/PesiExportActivatorFE.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
*/
......
34 34
	//database validation status (create, update, validate ...)
35 35
	static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_FE2PESI();
36 36
//	static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_ERMS2PESI();
37
	
37

  
38 38
	static final ICdmDataSource cdmSource = CdmDestinations.cdm_test_local_faunaEu_mysql();
39 39
//	static final ICdmDataSource cdmSource = CdmDestinations.cdm_test_local_mysql();
40 40

  
41 41
	//Taxon names can't be mapped to their CDM ids as PESI Taxon table mainly holds taxa and there IDs. We ad nameIdStart to the TaxonName id to get a unique id
42 42
	static final int nameIdStart = 10000000;
43
	
43

  
44 44
	static final int partitionSize = 2000;
45
	
45

  
46 46
	//check - export
47 47
	static final CHECK check = CHECK.EXPORT_WITHOUT_CHECK;
48 48

  
49 49
	static final boolean deleteAll = true;
50
	
50

  
51 51
	static final IdType idType = IdType.CDM_ID_WITH_EXCEPTIONS;
52 52

  
53 53
// ****************** ALL *****************************************
54
	
54

  
55 55
	//references
56 56
	static final DO_REFERENCES doReferences =  DO_REFERENCES.ALL;
57
	
57

  
58 58
	//taxa
59 59
	static final boolean doTaxa = true;
60 60
	static final boolean doRelTaxa = true;
......
69 69
	static final boolean doInferredSynonyms = true;
70 70
	static final boolean doPureNames = false; // !!!
71 71
	static final boolean doDescription = true;
72
	
72

  
73 73

  
74 74
// ************************ NONE **************************************** //
75
	
75

  
76 76
//	//references
77 77
//	static final DO_REFERENCES doReferences =  DO_REFERENCES.NONE;
78
//	
78
//
79 79
//	//taxa
80 80
//	static final boolean doTaxa = false;
81 81
//	static final boolean doRelTaxa = false;
......
89 89
//	static final boolean doRank = true;
90 90
//	static final boolean doInferredSynonyms = true;
91 91
//	static final boolean doDescription = false;
92
	
93
	
92

  
93

  
94 94
	public boolean 	doExport(ICdmDataSource source){
95 95
		System.out.println("Start export to PESI ("+ pesiDestination.getDatabase() + ") ...");
96
		
96

  
97 97
		//make PESI Source
98 98
		Source destination = pesiDestination;
99 99
		PesiTransformer transformer = new PesiTransformer(destination);
100
		
100

  
101 101
		PesiExportConfigurator config = PesiExportConfigurator.NewInstance(destination, source, transformer);
102
		
102

  
103 103
		config.setDoTaxa(doTaxa);
104 104
		config.setDoRelTaxa(doRelTaxa);
105 105
		config.setDoOccurrence(doOccurrence);
......
113 113
		config.setDoInferredSynonyms(doInferredSynonyms);
114 114
		config.setDoPureNames(doPureNames);
115 115
		config.setDoDescription(doDescription);
116
		
116

  
117 117
		config.setCheck(check);
118 118
		config.setLimitSave(partitionSize);
119 119
		config.setIdType(idType);
......
121 121
		if (deleteAll){
122 122
			destination.update("EXEC sp_deleteAllData");
123 123
		}
124
		
124

  
125 125

  
126 126
		// invoke export
127 127
		CdmDefaultExport<PesiExportConfigurator> pesiExport = new CdmDefaultExport<PesiExportConfigurator>();
128
		
128

  
129 129
		boolean result = pesiExport.invoke(config);
130
		
130

  
131 131
		System.out.println("End export to PESI ("+ destination.getDatabase() + ")..." + (result? "(successful)":"(with errors)"));
132 132
		return result;
133 133
	}
134
		
134

  
135 135
	/**
136 136
	 * @param args
137 137
	 */
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/PesiExportActivatorIF.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
*/
......
33 33

  
34 34
	//database validation status (create, update, validate ...)
35 35
	static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_IF2PESI();
36
	
36

  
37 37
	static final ICdmDataSource cdmSource = CdmDestinations.cdm_test_local_indexFungorum();
38 38
//	static final ICdmDataSource cdmSource = CdmDestinations.cdm_test_local_mysql_test();
39 39

  
40 40
	static final int partitionSize = 2000;
41
	
41

  
42 42
	//check - export
43 43
	static final CHECK check = CHECK.EXPORT_WITHOUT_CHECK;
44 44

  
45 45
	static final boolean deleteAll = true;
46
	
46

  
47 47
	static final IdType idType = IdType.CDM_ID;
48 48

  
49 49
// ****************** ALL *****************************************
50
	
50

  
51 51
	//references
52 52
	static final DO_REFERENCES doReferences =  DO_REFERENCES.ALL;
53
	
53

  
54 54
	//taxa
55 55
	static final boolean doTaxa = true;
56 56
	static final boolean doRelTaxa = true;
......
65 65
	static final boolean doInferredSynonyms = false;
66 66
	static final boolean doPureNames = false; // !!!
67 67
	static final boolean doDescription = true;
68
	
68

  
69 69

  
70 70
// ************************ NONE **************************************** //
71
	
71

  
72 72
//	//references
73 73
//	static final DO_REFERENCES doReferences =  DO_REFERENCES.NONE;
74
//	
74
//
75 75
//	//taxa
76 76
//	static final boolean doTaxa = false;
77 77
//	static final boolean doRelTaxa = false;
......
85 85
//	static final boolean doRank = true;
86 86
//	static final boolean doInferredSynonyms = true;
87 87
//	static final boolean doDescription = false;
88
	
89
	
88

  
89

  
90 90
	public boolean 	doExport(ICdmDataSource source){
91 91
		System.out.println("Start export to PESI ("+ pesiDestination.getDatabase() + ") ...");
92
		
92

  
93 93
		//make PESI Source
94 94
		Source destination = pesiDestination;
95 95
		PesiTransformer transformer = new PesiTransformer(destination);
96
		
96

  
97 97
		PesiExportConfigurator config = PesiExportConfigurator.NewInstance(destination, source, transformer);
98
		
98

  
99 99
		config.setDoTaxa(doTaxa);
100 100
		config.setDoRelTaxa(doRelTaxa);
101 101
		config.setDoOccurrence(doOccurrence);
......
109 109
		config.setDoInferredSynonyms(doInferredSynonyms);
110 110
		config.setDoPureNames(doPureNames);
111 111
		config.setDoDescription(doDescription);
112
		
112

  
113 113
		config.setCheck(check);
114 114
		config.setLimitSave(partitionSize);
115 115
		config.setIdType(idType);
......
119 119

  
120 120
		// invoke export
121 121
		CdmDefaultExport<PesiExportConfigurator> pesiExport = new CdmDefaultExport<PesiExportConfigurator>();
122
		boolean result = pesiExport.invoke(config);
123
		
122

  
123
		    boolean result = pesiExport.invoke(config);
124

  
124 125
		System.out.println("End export to PESI ("+ destination.getDatabase() + ")..." + (result? "(successful)":"(with errors)"));
125 126
		return result;
126 127
	}
127
		
128

  
128 129
	/**
129 130
	 * @param args
130 131
	 */
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportBase.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
*/
......
39 39
import eu.etaxonomy.cdm.model.common.Marker;
40 40
import eu.etaxonomy.cdm.model.common.MarkerType;
41 41
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
42
import eu.etaxonomy.cdm.model.common.TimePeriod;
43 42
import eu.etaxonomy.cdm.model.name.NonViralName;
44 43
import eu.etaxonomy.cdm.model.reference.Reference;
45 44
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
......
55 54
 */
56 55
public abstract class IndexFungorumImportBase extends CdmImportBase<IndexFungorumImportConfigurator, IndexFungorumImportState> implements ICdmIO<IndexFungorumImportState>, IPartitionedIO<IndexFungorumImportState> {
57 56
	private static final Logger logger = Logger.getLogger(IndexFungorumImportBase.class);
58
	
57

  
59 58
	//NAMESPACES
60 59
	protected static final String NAMESPACE_REFERENCE = "reference";
61 60
	protected static final String NAMESPACE_TAXON = "Taxon";
62 61
	protected static final String NAMESPACE_SUPRAGENERIC_NAMES = "SupragenericNames";
63 62
	protected static final String NAMESPACE_GENERA = "Genera";
64 63
	protected static final String NAMESPACE_SPECIES = "Species";
65
	
66
	
64

  
65

  
67 66
	protected static final String INCERTAE_SEDIS = "Incertae sedis";
68 67
	protected static final String FOSSIL_FUNGI = "Fossil Fungi";
69 68

  
70 69
	protected static final String SOURCE_REFERENCE = "SOURCE_REFERENCE";
71 70

  
72 71

  
73
	
74 72

  
75
	private String pluralString;
76
	private String dbTableName;
73

  
74
	private final String pluralString;
75
	private final String dbTableName;
77 76
	//TODO needed?
78
	private Class cdmTargetClass;
77
	private final Class cdmTargetClass;
78

  
79

  
79 80

  
80
	
81
	
82 81
	/**
83 82
	 * @param dbTableName
84
	 * @param dbTableName2 
83
	 * @param dbTableName2
85 84
	 */
86 85
	public IndexFungorumImportBase(String pluralString, String dbTableName, Class cdmTargetClass) {
87 86
		this.pluralString = pluralString;
......
89 88
		this.cdmTargetClass = cdmTargetClass;
90 89
	}
91 90

  
92
	protected void doInvoke(IndexFungorumImportState state){
93
		logger.info("start make " + getPluralString() + " ...");
91
	@Override
92
    protected void doInvoke(IndexFungorumImportState state){
93
		System.out.println("start make " + getPluralString() + " ...");
94 94
		IndexFungorumImportConfigurator config = state.getConfig();
95 95
		Source source = config.getSource();
96
			
96

  
97

  
97 98
		String strIdQuery = getIdQuery();
99

  
98 100
		String strRecordQuery = getRecordQuery(config);
99 101

  
100 102
		int recordsPerTransaction = config.getRecordsPerTransaction();
......
108 110
			state.setUnsuccessfull();
109 111
			return;
110 112
		}
111
		
113

  
112 114
		logger.info("end make " + getPluralString() + " ... " + getSuccessString(true));
113 115
		return;
114 116
	}
115
	
116 117

  
117 118

  
118
	
119
	
120
	public boolean doPartition(ResultSetPartitioner partitioner, IndexFungorumImportState state) {
119

  
120

  
121

  
122

  
123

  
124
    @Override
125
    public boolean doPartition(ResultSetPartitioner partitioner, IndexFungorumImportState state) {
121 126
		boolean success = true ;
122 127
		Set objectsToSave = new HashSet<CdmBase>();
123
		
128

  
124 129
// 		DbImportMapping<?, ?> mapping = getMapping();
125 130
//		mapping.initialize(state, cdmTargetClass);
126
		
131

  
127 132
		ResultSet rs = partitioner.getResultSet();
128 133
		try{
129 134
			while (rs.next()){
......
133 138
			logger.error("SQLException:" +  e);
134 139
			return false;
135 140
		}
136
	
141

  
137 142
		partitioner.startDoSave();
138 143
		getCommonService().save(objectsToSave);
139 144
		return success;
......
145 150
	 */
146 151
	protected abstract String getRecordQuery(IndexFungorumImportConfigurator config);
147 152

  
153

  
148 154
	/**
149 155
	 * @return
150 156
	 */
......
152 158
		String result = " SELECT id FROM " + getTableName();
153 159
		return result;
154 160
	}
155
	
161

  
156 162
	/* (non-Javadoc)
157 163
	 * @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getPluralString()
158 164
	 */
159
	public String getPluralString(){
165
	@Override
166
    public String getPluralString(){
160 167
		return pluralString;
161 168
	}
162 169

  
......
167 174
		return this.dbTableName;
168 175
	}
169 176

  
170
	
177

  
171 178
	protected boolean resultSetHasColumn(ResultSet rs, String columnName){
172 179
		try {
173 180
			ResultSetMetaData metaData = rs.getMetaData();
......
182 189
            return false;
183 190
		}
184 191
	}
185
	
192

  
186 193
	protected boolean checkSqlServerColumnExists(Source source, String tableName, String columnName){
187 194
		String strQuery = "SELECT  Count(t.id) as n " +
188 195
				" FROM sysobjects AS t " +
189 196
				" INNER JOIN syscolumns AS c ON t.id = c.id " +
190
				" WHERE (t.xtype = 'U') AND " + 
191
				" (t.name = '" + tableName + "') AND " + 
197
				" WHERE (t.xtype = 'U') AND " +
198
				" (t.name = '" + tableName + "') AND " +
192 199
				" (c.name = '" + columnName + "')";
193
		ResultSet rs = source.getResultSet(strQuery) ;		
200
		ResultSet rs = source.getResultSet(strQuery) ;
194 201
		int n;
195 202
		try {
196 203
			rs.next();
......
200 207
			e.printStackTrace();
201 208
			return false;
202 209
		}
203
		
210

  
204 211
	}
205
	
212

  
206 213
	/**
207 214
	 * Returns a map that holds all values of a ResultSet. This is needed if a value needs to
208 215
	 * be accessed twice
......
242 249
			idSet.add(id);
243 250
		}
244 251
	}
245
	
252

  
246 253
	/**
247 254
	 * Returns true if i is a multiple of recordsPerTransaction
248 255
	 * @param i
......
253 260
		startTransaction();
254 261
		return (i % recordsPerLoop) == 0;
255 262
	}
256
	
263

  
257 264
	protected void doLogPerLoop(int count, int recordsPerLog, String pluralString){
258 265
		if ((count % recordsPerLog ) == 0 && count!= 0 ){ logger.info(pluralString + " handled: " + (count));}
259 266
	}
260
	
267

  
261 268

  
262 269
	protected void makeAuthorAndPublication(IndexFungorumImportState state, ResultSet rs, NonViralName name) throws SQLException {
263 270
		//authors
......
266 273
		if (StringUtils.isNotBlank(authorStr)){
267 274
			try {
268 275
				parser.parseAuthors(name, authorStr);
269
			} catch (StringNotParsableException e){ 
270
				logger.warn("Authorstring not parsable: " + authorStr);
276
			} catch (StringNotParsableException e){
277
				//logger.warn("Authorstring not parsable: " + authorStr);
271 278
				name.setAuthorshipCache(authorStr);
272 279
			}
273 280
		}
274
		
281

  
275 282
		//page
276 283
		String page = rs.getString("PAGE");
277 284
		if (StringUtils.isNotBlank(page)){
278 285
			name.setNomenclaturalMicroReference(page);
279 286
		}
280
		
287

  
281 288
		//Reference
282 289
		Reference<?> ref = ReferenceFactory.newGeneric();
283 290
		boolean hasInReference = false;
......
293 300
				logger.warn("'AUTHORS' is blank for not empty PUBLISHING_AUTHORS. This is not yet handled.");
294 301
			}
295 302
		}
296
		
303

  
297 304
		//inRef + inRefAuthor
298 305
		if (pubAuthor != null){
299 306
			Reference<?> inRef = ReferenceFactory.newGeneric();
......
301 308
			ref.setInReference(inRef);
302 309
			hasInReference = true;
303 310
		}
304
		
311

  
305 312
		//refAuthor
306 313
		TeamOrPersonBase<?> refAuthor = CdmBase.deproxy(name.getCombinationAuthorTeam(), TeamOrPersonBase.class);
307 314
		if (refAuthor == null){
......
343 350
			}
344 351
		}
345 352
		ref.setVolume(volume);
346
		
353

  
347 354
		//year
348 355
		String yearOfPubl = rs.getString("YEAR OF PUBLICATION");
349 356
		String yearOnPubl = rs.getString("YEAR ON PUBLICATION");
......
357 364
		if (year != null){
358 365
			ref.setDatePublished(TimePeriodParser.parseString(year));
359 366
		}
360
		
367

  
361 368
		//preliminary, set protected titlecache as Generic Cache Generation with in references currently doesn't fully work yet
362 369
		String titleCache = CdmUtils.concat(", ", pubAuthorStr, title);
363 370
		if  ( StringUtils.isNotBlank(pubAuthorStr)){
......
367 374
		titleCache = CdmUtils.concat(": ", titleCache, page);
368 375
		titleCache = CdmUtils.concat(". ", titleCache, year);
369 376
		ref.setTitleCache(titleCache, true);
370
		
377

  
371 378
		//set nom ref
372 379
		if (StringUtils.isNotBlank(titleCache)){
373 380
			name.setNomenclaturalReference(ref);
374 381
		}
375 382
	}
376
	
383

  
377 384

  
378 385
	protected MarkerType getNoLastActionMarkerType(IndexFungorumImportState state) {
379
		return getMarkerType(state, DbLastActionMapper.uuidMarkerTypeHasNoLastAction, 
386
		return getMarkerType(state, DbLastActionMapper.uuidMarkerTypeHasNoLastAction,
380 387
				"has no last action", "No last action information available", "no last action");
381 388
	}
382 389

  
......
388 395
		String strId = (id == null ? null : String.valueOf(id));
389 396
		IdentifiableSource source = IdentifiableSource.NewInstance(OriginalSourceType.Import, strId, namespace, sourceReference, null);
390 397
		taxon.addSource(source);
391
		
398

  
392 399
		//no last action
393 400
		MarkerType hasNoLastAction = getNoLastActionMarkerType(state);
394 401
		taxon.addMarker(Marker.NewInstance(hasNoLastAction, true));
......
415 422
		MarkerType missingGUID = getMarkerType(state, PesiTransformer.uuidMarkerGuidIsMissing, "GUID is missing", "GUID is missing", null);
416 423
		return missingGUID;
417 424
	}
418
	
425

  
419 426

  
420 427
	protected Classification getClassification(IndexFungorumImportState state) {
421 428
		Classification result;
......
425 432
			result = makeTreeMemSave(state, sourceReference);
426 433
		} else {
427 434
			result = getClassificationService().find(classificationUuid);
428
		} 
435
		}
429 436
		return result;
430 437
	}
431 438

  
432
	
433 439

  
434 440

  
435
	
441

  
442

  
436 443
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiDescriptionExport.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
*/
......
25 25
import org.springframework.stereotype.Component;
26 26
import org.springframework.transaction.TransactionStatus;
27 27

  
28
import com.microsoft.sqlserver.jdbc.SQLServerException;
29

  
28 30
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer;
29 31
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
30 32
import eu.etaxonomy.cdm.io.common.Source;
......
37 39
import eu.etaxonomy.cdm.io.common.mapping.out.DbDescriptionElementTaxonMapper;
38 40
import eu.etaxonomy.cdm.io.common.mapping.out.DbDistributionStatusMapper;
39 41
import eu.etaxonomy.cdm.io.common.mapping.out.DbExportIgnoreMapper;
40
import eu.etaxonomy.cdm.io.common.mapping.out.DbExportNotYetImplementedMapper;
41 42
import eu.etaxonomy.cdm.io.common.mapping.out.DbLanguageMapper;
42 43
import eu.etaxonomy.cdm.io.common.mapping.out.DbObjectMapper;
43 44
import eu.etaxonomy.cdm.io.common.mapping.out.DbOriginalNameMapper;
......
68 69
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
69 70
import eu.etaxonomy.cdm.model.taxon.Taxon;
70 71
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
71
import eu.etaxonomy.cdm.profiler.ProfilerController;
72 72
/**
73 73
 * The export class for {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase DescriptionElements}.<p>
74 74
 * Inserts into DataWarehouse database table <code>Note</code>.<p>
......
82 82
@Component
83 83
public class PesiDescriptionExport extends PesiExportBase {
84 84
	private static final Logger logger = Logger.getLogger(PesiDescriptionExport.class);
85
	
85

  
86 86
	private static final Class<? extends CdmBase> standardMethodParameter = DescriptionElementBase.class;
87 87

  
88 88
	private static int modCount = 1000;
......
97 97
	//decide where to handle them best (configurator, transformer, single method, ...)
98 98
	private static Set<Integer> excludedNoteCategories = new HashSet<Integer>(Arrays.asList(new Integer[]{250,251,252,253,10,11,13}));
99 99

  
100
	
100

  
101 101
	//debugging
102 102
	private static int countDescriptions;
103 103
	private static int countTaxa;
......
105 105
	private static int countAdditionalSources;
106 106
	private static int countImages;
107 107
	private static int countNotes;
108
	
108

  
109 109
	private static int countCommonName;
110 110
	private static int countOccurrence;
111 111
	private static int countOthers;
112
	
112

  
113 113
	public PesiDescriptionExport() {
114 114
		super();
115 115
	}
......
132 132

  
133 133
			// Stores whether this invoke was successful or not.
134 134
			boolean success = true;
135
	
135

  
136 136
			// Get specific mappings: (CDM) DescriptionElement -> (PESI) Note
137 137
			PesiExportMapping notesMapping = getNotesMapping();
138 138
			notesMapping.initialize(state);
......
148 148
			additionalSourceMapping.initialize(state);
149 149

  
150 150
			// Get specific mappings: (CDM) DescriptionElement -> (PESI) Additional taxon source
151

  
151 152
			PesiExportMapping vernacularMapping = getVernacularNamesMapping();
152 153
			vernacularMapping.initialize(state);
153
			
154

  
154 155
			// Get specific mappings: (CDM) DescriptionElement -> (PESI) Additional taxon source
155 156
			PesiExportMapping imageMapping = getImageMapping();
156 157
			imageMapping.initialize(state);
157
			
158

  
158 159
			// Start transaction
159 160
			success &= doPhase01(state, notesMapping, occurrenceMapping, addSourceSourceMapping, additionalSourceMapping, vernacularMapping, imageMapping);
160 161

  
161 162
			// Start transaction
162 163
			success &= doPhase01b(state, notesMapping, occurrenceMapping, addSourceSourceMapping, additionalSourceMapping, vernacularMapping, imageMapping);
163 164

  
164
			
165

  
165 166
			logger.info("PHASE 2...");
166 167
			success &= doPhase02(state);
167 168

  
168 169

  
169 170
			logger.info("*** Finished Making " + pluralString + " ..." + getSuccessString(success));
170
			
171

  
171 172
			if (!success){
172 173
				state.setUnsuccessfull();
173 174
			}
......
180 181
	}
181 182

  
182 183
	//PHASE 01: Description Elements
183
	private boolean doPhase01(PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping, PesiExportMapping addSourceSourceMapping, 
184
	private boolean doPhase01(PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping, PesiExportMapping addSourceSourceMapping,
184 185
			PesiExportMapping additionalSourceMapping, PesiExportMapping vernacularMapping, PesiExportMapping imageMapping) throws SQLException {
185
		logger.info("PHASE 1...");
186

  
187
	    System.out.println("PHASE 1 of occurence import");
188
	    logger.info("PHASE 1...");
186 189
		int count = 0;
187 190
		int pastCount = 0;
188 191
		boolean success = true;
189 192
		int limit = state.getConfig().getLimitSave();
190 193

  
191 194
		List<Taxon> taxonList = null;
192
		
195

  
193 196
		TransactionStatus txStatus = startTransaction(true);
194 197
		logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
195 198
		List<String> propPath = Arrays.asList(new String[]{"descriptions.elements.*"});
196
		
199

  
197 200
		logger.debug("Start snapshot, before starting loop");
198
		ProfilerController.memorySnapshot();
201
	//	ProfilerController.memorySnapshot();
199 202
		//taxon descriptions
200 203
		int partitionCount = 0;
201 204
		while ((taxonList = getNextTaxonPartition(Taxon.class, limit, partitionCount++, propPath )) != null   ) {
202 205

  
203 206
			logger.info("Fetched " + taxonList.size() + " " + pluralString + ". Exporting...");
204
			
207

  
205 208
			for (Taxon taxon : taxonList) {
206 209
				countTaxa++;
207 210
				doCount(count++, modCount, pluralString);
208 211
				state.setCurrentTaxon(taxon);
209
				success &= handleSingleTaxon(taxon, state, notesMapping, occurrenceMapping, addSourceSourceMapping, 
210
						additionalSourceMapping, vernacularMapping, imageMapping);	
212
				success &= handleSingleTaxon(taxon, state, notesMapping, occurrenceMapping, addSourceSourceMapping,
213
						additionalSourceMapping, vernacularMapping, imageMapping);
211 214
			}
212 215
			taxonList = null;
213 216
			state.setCurrentTaxon(null);
......
221 224
			txStatus = startTransaction(true);
222 225
			logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") for description import ...");
223 226
		}
224
		
225
	
227

  
228

  
226 229
		logger.info("No " + pluralString + " left to fetch.");
227 230
		logger.info("Partition: " + partitionCount);
228 231
		logger.info("Taxa: " + countTaxa);
......
234 237
		logger.info("Images: " + countImages);
235 238
		logger.info("Notes: " + countNotes);
236 239
		logger.info("Others: " + countOthers);
237
		
240

  
238 241
		// Commit transaction
239 242
		commitTransaction(txStatus);
240 243
		logger.debug("Committed transaction.");
241 244
		return success;
242 245
	}
243
	
246

  
244 247
	//PHASE 01b: Name Descriptions
245
	private boolean doPhase01b(PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping, PesiExportMapping addSourceSourceMapping, 
248
	private boolean doPhase01b(PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping, PesiExportMapping addSourceSourceMapping,
246 249
			PesiExportMapping additionalSourceMapping, PesiExportMapping vernacularMapping, PesiExportMapping imageMapping) throws SQLException {
247 250
		logger.info("PHASE 1b...");
248 251
		int count = 0;
249 252
		int pastCount = 0;
250 253
		boolean success = true;
251 254
		int limit = state.getConfig().getLimitSave();
252
		
255

  
253 256
		List<TaxonNameDescription> nameDescList = null;
254
		
257

  
255 258
		TransactionStatus txStatus = startTransaction(true);
256 259
		logger.info("Started new transaction. Fetching some name descriptions (max: " + limit + ") ...");
257 260
		List<String> propPath = Arrays.asList(new String[]{"descriptions.elements.*"});
258
		
261

  
259 262
		//name descriptions
260 263
		int partitionCount = 0;
261 264
		while ((nameDescList = getNextNameDescriptionPartition( limit, partitionCount++, propPath )) != null   ) {
262
			
265

  
263 266
			logger.info("Fetched " + nameDescList.size() + " name descriptions. Exporting...");
264
			
267

  
265 268
			for (TaxonNameDescription desc : nameDescList) {
266 269
				countTaxa++;
267 270
				doCount(count++, modCount, "name descriptions");
268 271
				boolean isImageGallery = desc.isImageGallery();
269
				
272

  
270 273
				TaxonNameBase<?,?> name = desc.getTaxonName();
271
				
274

  
272 275
				for (DescriptionElementBase element : desc.getElements()){
273 276
					if (isPurePesiName(name)){
274 277
						success &= handleDescriptionElement(state, notesMapping, occurrenceMapping, vernacularMapping, imageMapping,
......
298 301
			txStatus = startTransaction(true);
299 302
			logger.info("Started new transaction. Fetching some name descriptions (max: " + limit + ") for description import ...");
300 303
		}
301
		
304

  
302 305
		logger.info("No " + pluralString + " left to fetch.");
303 306
		logger.info("Partition: " + partitionCount);
304 307
		logger.info("Taxa: " + countTaxa);
......
310 313
		logger.info("Images: " + countImages);
311 314
		logger.info("Notes: " + countNotes);
312 315
		logger.info("Others: " + countOthers);
313
		
316

  
314 317
		// Commit transaction
315 318
		commitTransaction(txStatus);
316 319
		logger.debug("Committed transaction.");
......
318 321
	}
319 322

  
320 323
	private boolean handleSingleTaxon(Taxon taxon, PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping,
321
			PesiExportMapping addSourceSourceMapping, PesiExportMapping additionalSourceMapping, 
324
			PesiExportMapping addSourceSourceMapping, PesiExportMapping additionalSourceMapping,
322 325
			PesiExportMapping vernacularMapping, PesiExportMapping imageMapping) throws SQLException {
323 326
		boolean success = true;
327

  
328
		System.out.println("handle single Taxon");
324 329
		Set<DescriptionBase<?>> descriptions = new HashSet<DescriptionBase<?>>();
325 330
		descriptions.addAll(taxon.getDescriptions());
326
		
331

  
327 332
		for (DescriptionBase<?> desc : descriptions){
328 333
			countDescriptions++;
329 334

  
......
338 343
	}
339 344

  
340 345
	private boolean handleDescriptionElement(PesiExportState state, PesiExportMapping notesMapping,
341
			PesiExportMapping occurrenceMapping, PesiExportMapping vernacularMapping, PesiExportMapping imageMapping, 
346
			PesiExportMapping occurrenceMapping, PesiExportMapping vernacularMapping, PesiExportMapping imageMapping,
342 347
			PesiExportMapping addSourceSourceMapping, PesiExportMapping additionalSourceMapping, boolean isImageGallery, DescriptionElementBase element) throws SQLException {
343 348
		try {
344 349
			boolean success = true;
......
357 362
				countOccurrence++;
358 363
				Distribution distribution = CdmBase.deproxy(element, Distribution.class);
359 364
				MarkerType markerType = getUuidMarkerType(PesiTransformer.uuidMarkerTypeHasNoLastAction, state);
360
				
365

  
361 366
				distribution.addMarker(Marker.NewInstance(markerType, true));
362 367
				if (isPesiDistribution(state, distribution)){
363 368
					countDistribution++;
364
					success &=occurrenceMapping.invoke(element);
369
					try{
370
					    success &=occurrenceMapping.invoke(element);
371
					}catch(SQLServerException e){
372
					    System.err.println(element.getInDescription().getTitleCache());
373
					    e.printStackTrace();
374
					}
365 375
				}
366 376
			}else if (isAdditionalTaxonSource(element)){
367 377
				countAdditionalSources++;
......
374 384
			}else if (isPesiNote(element)){
375 385
				countNotes++;
376 386
				success &= notesMapping.invoke(element);
377
			
387

  
378 388
			}else{
379 389
				countOthers++;
380 390
				String featureTitle = element.getFeature() == null ? "no feature" :element.getFeature().getTitleCache();
......
399 409
		if (distribution.getStatus() == null){
400 410
			return false;
401 411
		}
402
		
412

  
403 413
		//...this may change in future so we keep the following code
404 414
		Integer key;
405 415
		//area filter
......
417 427
//			//Macaronesia records should not be exported to PESI
418 428
//			return false;
419 429
//		//TODO exclude Russion areas Rs*, and maybe ohters
420
		
421
		} else
422
			try {
430

  
431
		} else {
432
            try {
423 433
				if (state.getTransformer().getKeyByNamedArea(area) == null){
424 434
					String warning = "Area (%s,%s) not available in PESI transformer for taxon %S: ";
425 435
					TaxonBase<?> taxon =  state.getCurrentTaxon();
......
431 441
				logger.warn("Area not available in PESI transformer " +  area.getTitleCache());
432 442
				return false;
433 443
			}
444
        }
434 445
		return true;
435
		
436
//		
446

  
447
//
437 448
//		//status
438 449
//		PresenceAbsenceTermBase<?> status = distribution.getStatus();
439 450
//		if (status == null){
......
490 501
	private boolean doPhase02(PesiExportState state) {
491 502
		TransactionStatus txStatus;
492 503
		boolean success =  true;
493
		
504

  
494 505
		// Get the limit for objects to save within a single transaction.
495 506
		int limit = state.getConfig().getLimitSave();
496
					
507

  
497 508
		txStatus = startTransaction(true);
498 509
		ExtensionType taxCommentExtensionType = (ExtensionType)getTermService().find(PesiTransformer.taxCommentUuid);
499 510
		ExtensionType fauCommentExtensionType = (ExtensionType)getTermService().find(PesiTransformer.fauCommentUuid);
500 511
		ExtensionType fauExtraCodesExtensionType = (ExtensionType)getTermService().find(PesiTransformer.fauExtraCodesUuid);
501 512
		List<TaxonNameBase> taxonNameList = null;
502
		
513

  
503 514
		int count = 0;
504 515
		int pastCount = 0;
505 516
		Connection connection = state.getConfig().getDestination().getConnection();
......
513 524
				for (Extension extension : extensions) {
514 525
					if (extension.getType().equals(taxCommentExtensionType)) {
515 526
						String taxComment = extension.getValue();
516
						invokeNotes(taxComment, 
517
								PesiTransformer.getNoteCategoryFk(PesiTransformer.taxCommentUuid), 
527
						invokeNotes(taxComment,
528
								PesiTransformer.getNoteCategoryFk(PesiTransformer.taxCommentUuid),
518 529
								PesiTransformer.getNoteCategoryCache(PesiTransformer.taxCommentUuid),
519 530
								null, null, getTaxonKey(taxonName, state),connection);
520 531
					} else if (extension.getType().equals(fauCommentExtensionType)) {
521 532
						String fauComment = extension.getValue();
522
						invokeNotes(fauComment, 
523
								PesiTransformer.getNoteCategoryFk(PesiTransformer.fauCommentUuid), 
533
						invokeNotes(fauComment,
534
								PesiTransformer.getNoteCategoryFk(PesiTransformer.fauCommentUuid),
524 535
								PesiTransformer.getNoteCategoryCache(PesiTransformer.fauCommentUuid),
525 536
								null, null, getTaxonKey(taxonName, state),connection);
526 537
					} else if (extension.getType().equals(fauExtraCodesExtensionType)) {
527 538
						String fauExtraCodes = extension.getValue();
528
						invokeNotes(fauExtraCodes, 
529
								PesiTransformer.getNoteCategoryFk(PesiTransformer.fauExtraCodesUuid), 
539
						invokeNotes(fauExtraCodes,
540
								PesiTransformer.getNoteCategoryFk(PesiTransformer.fauExtraCodesUuid),
530 541
								PesiTransformer.getNoteCategoryCache(PesiTransformer.fauExtraCodesUuid),
531 542
								null, null, getTaxonKey(taxonName, state),connection);
532 543
					}
533 544
				}
534
				
545

  
535 546
				doCount(count++, modCount, pluralString);
536 547
			}
537 548

  
......
563 574
	 * @param object2
564 575
	 */
565 576
	private void invokeNotes(String note, Integer noteCategoryFk,
566
			String noteCategoryCache, Integer languageFk, String languageCache, 
577
			String noteCategoryCache, Integer languageFk, String languageCache,
567 578
			Integer taxonFk, Connection connection) {
568
		String notesSql = "UPDATE Note SET Note_1 = ?, NoteCategoryFk = ?, NoteCategoryCache = ?, LanguageFk = ?, LanguageCache = ? WHERE TaxonFk = ?"; 
579
		String notesSql = "UPDATE Note SET Note_1 = ?, NoteCategoryFk = ?, NoteCategoryCache = ?, LanguageFk = ?, LanguageCache = ? WHERE TaxonFk = ?";
569 580
		try {
570 581
			PreparedStatement notesStmt = connection.prepareStatement(notesSql);
571
			
582

  
572 583
			if (note != null) {
573 584
				notesStmt.setString(1, note);
574 585
			} else {
575 586
				notesStmt.setObject(1, null);
576 587
			}
577
			
588

  
578 589
			if (noteCategoryFk != null) {
579 590
				notesStmt.setInt(2, noteCategoryFk);
580 591
			} else {
581 592
				notesStmt.setObject(2, null);
582 593
			}
583
			
594

  
584 595
			if (noteCategoryCache != null) {
585 596
				notesStmt.setString(3, noteCategoryCache);
586 597
			} else {
587 598
				notesStmt.setObject(3, null);
588 599
			}
589
			
600

  
590 601
			if (languageFk != null) {
591 602
				notesStmt.setInt(4, languageFk);
592 603
			} else {
593 604
				notesStmt.setObject(4, null);
594 605
			}
595
			
606

  
596 607
			if (languageCache != null) {
597 608
				notesStmt.setString(5, languageCache);
598 609
			} else {
599 610
				notesStmt.setObject(5, null);
600 611
			}
601
			
612

  
602 613
			if (taxonFk != null) {
603 614
				notesStmt.setInt(6, taxonFk);
604 615
			} else {
605 616
				notesStmt.setObject(6, null);
606 617
			}
607
			
618

  
608 619
			notesStmt.executeUpdate();
609 620
		} catch (SQLException e) {
610 621
			logger.error("Note could not be created: " + note);
......
620 631
	 * @return Whether the delete operation was successful or not.
621 632
	 */
622 633
	protected boolean doDelete(PesiExportState state) {
623
		PesiExportConfigurator pesiConfig = (PesiExportConfigurator) state.getConfig();
624
		
634
		PesiExportConfigurator pesiConfig = state.getConfig();
635

  
625 636
		String sql;
626 637
		Source destination =  pesiConfig.getDestination();
627 638

  
......
679 690
		}
680 691
		return result;
681 692
	}
682
	
693

  
683 694
	/**
684 695
	 * Returns the <code>NoteCategoryCache</code> attribute.
685 696
	 * @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
......
690 701
	private static String getNoteCategoryCache(DescriptionElementBase descriptionElement, PesiExportState state) {
691 702
		return state.getTransformer().getCacheByFeature(descriptionElement.getFeature());
692 703
	}
693
	
694
	
704

  
705

  
695 706

  
696 707

  
697 708
	/**
......
711 722
	 * Returns the <code>LanguageCache</code> attribute.
712 723
	 * @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
713 724
	 * @return The <code>LanguageCache</code> attribute.
714
	 * @throws UndefinedTransformerMethodException 
725
	 * @throws UndefinedTransformerMethodException
715 726
	 * @see MethodMapper
716 727
	 */
717 728
	@SuppressWarnings("unused")
......
739 750
		} else {
740 751
			logger.debug("Given descriptionElement does not support languages. Hence LanguageCache could not be determined: " + descriptionElement.getUuid());
741 752
		}
742
		
753

  
743 754
		if (multilanguageText != null) {
744 755
			Set<Language> languages = multilanguageText.keySet();
745 756

  
......
764 775
//	private static String getRegion(DescriptionElementBase descriptionElement) {
765 776
//		String result = null;
766 777
//		DescriptionBase<?> inDescription = descriptionElement.getInDescription();
767
//		
778
//
768 779
//		// Area information are associated to TaxonDescriptions and Distributions.
769 780
//		if (descriptionElement.isInstanceOf(Distribution.class)) {
770 781
//			Distribution distribution = CdmBase.deproxy(descriptionElement, Distribution.class);
......
781 792
//		return result;
782 793
//	}
783 794

  
784
	
795

  
785 796
	/**
786 797
	 * Returns the TaxonFk for a given TaxonName or Taxon.
787 798
	 * @param state The {@link DbExportStateBase DbExportState}.
......
792 803
		TaxonBase<?> entity = state.getCurrentTaxon();
793 804
		return state.getDbId(entity);
794 805
	}
795
	
806

  
796 807
	/**
797 808
	 * Returns the TaxonFk for a given TaxonName.
798 809
	 * @param taxonName The {@link TaxonNameBase TaxonName}.
......
802 813
	private static Integer getTaxonKey(TaxonNameBase<?,?> taxonName, DbExportStateBase<?, PesiTransformer> state) {
803 814
		return state.getDbId(taxonName);
804 815
	}
805
	
816

  
806 817
	/**
807 818
	 * Returns the <code>FullName</code> attribute.
808 819
	 * @param taxonName The {@link NonViralName NonViralName}.
......
811 822
	 */
812 823
	@SuppressWarnings("unused")
813 824
	private static String getTaxonFullNameCache(DescriptionElementBase deb, PesiExportState state) {
814
		
825

  
815 826
		TaxonBase<?> taxon =  state.getCurrentTaxon();
816 827
		TaxonNameBase<?,?> taxonName = taxon.getName();
817 828
		NonViralName<?> nvn = CdmBase.deproxy(taxonName, NonViralName.class);
......
826 837
	 */
827 838
	private PesiExportMapping getNotesMapping() {
828 839
		PesiExportMapping mapping = new PesiExportMapping(dbNoteTableName);
829
		
840

  
830 841
		mapping.addMapper(IdMapper.NewInstance("NoteId"));
831 842
		mapping.addMapper(DbTextDataMapper.NewInstance(Language.ENGLISH(), "Note_1"));
832 843
		//TODO
833 844
		mapping.addMapper(MethodMapper.NewInstance("Note_2", this, DescriptionElementBase.class));
834 845
		mapping.addMapper(MethodMapper.NewInstance("NoteCategoryFk", this, DescriptionElementBase.class ));
835
		
846

  
836 847
		mapping.addMapper(MethodMapper.NewInstance("NoteCategoryCache", this, DescriptionElementBase.class, PesiExportState.class ));
837 848
		mapping.addMapper(MethodMapper.NewInstance("LanguageFk", this));
838 849
		mapping.addMapper(MethodMapper.NewInstance("LanguageCache", this, DescriptionElementBase.class, PesiExportState.class));
839
		
850

  
840 851
//		mapping.addMapper(MethodMapper.NewInstance("Region", this));
841 852
		mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
842
		mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
853
	//	mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
843 854
		mapping.addCollectionMapping(getNoteSourceMapping());
844 855
		return mapping;
845 856
	}
846
	
857

  
847 858
	private CollectionExportMapping<PesiExportState, PesiExportConfigurator,PesiTransformer> getNoteSourceMapping() {
848 859
		String tableName = "NoteSource";
849 860
		String collectionAttribute = "sources";
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff