Project

General

Profile

« Previous | Next » 

Revision 8422c0cd

Added by Andreas Müller almost 8 years ago

Remove generics from Reference in cdmlib-app #5830

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/caryophyllales/CaryoActivator.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
*/
......
33 33
 */
34 34
public class CaryoActivator extends SourceBase{
35 35
	private static final Logger logger = Logger.getLogger(CaryoActivator.class);
36
	
36

  
37 37
	//database validation status (create, update, validate ...)
38 38
	static final DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
39 39
	static final Source source = caryo_len61();
40 40

  
41
	
41

  
42 42
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
43 43
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
44 44
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_postgres_CdmTest();
45
	
45

  
46 46
	static final String classificationName = "Caryophyllales";
47
	
47

  
48 48
	//classification
49 49
	static final UUID classificationUuid = UUID.fromString("9edc58b5-de3b-43aa-9f31-1ede7c009c2b");
50
	
50

  
51 51
	//check - import
52 52
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
53
	
53

  
54 54
	//taxa
55 55
	static final boolean doTaxa = true;
56 56
	static final boolean doDeduplicate = true;
57
	
58
	
57

  
58

  
59 59
	private void doImport(ICdmDataSource cdmDestination){
60
		
60

  
61 61
		//make Source
62 62
		CaryoImportConfigurator config= CaryoImportConfigurator.NewInstance(source, cdmDestination);
63 63
		config.setClassificationUuid(classificationUuid);
......
66 66
		config.setDbSchemaValidation(hbm2dll);
67 67
		config.setSourceReferenceTitle("NCU - Caryophyllales, v0.4");
68 68
		config.setClassificationName(classificationName);
69
		
69

  
70 70
		CdmDefaultImport<CaryoImportConfigurator> myImport = new CdmDefaultImport<CaryoImportConfigurator>();
71 71

  
72
		
72

  
73 73
		//...
74 74
		if (true){
75 75
			System.out.println("Start import from ("+ source.toString() + ") ...");
......
77 77
			myImport.invoke(config);
78 78
			System.out.println("End import from ("+ source.toString() + ")...");
79 79
		}
80
		
81
		
82
		
80

  
81

  
82

  
83 83
		//deduplicate
84 84
		if (doDeduplicate){
85 85
			ICdmApplicationConfiguration app = myImport.getCdmAppController();
......
90 90
			count = app.getReferenceService().deduplicate(Reference.class, null, null);
91 91
			logger.warn("Deduplicated " + count + " references.");
92 92
		}
93
		
93

  
94 94
	}
95 95

  
96
	private Reference<?> getSourceReference(String string) {
97
		Reference<?> result = ReferenceFactory.newGeneric();
96
	private Reference getSourceReference(String string) {
97
		Reference result = ReferenceFactory.newGeneric();
98 98
		result.setTitleCache(string);
99 99
		return result;
100 100
	}
......
119 119
		CaryoActivator me = new CaryoActivator();
120 120
		me.doImport(cdmDestination);
121 121
	}
122
	
122

  
123 123
}
app-import/src/main/java/eu/etaxonomy/cdm/app/cuba/CubaActivator.java
25 25
import eu.etaxonomy.cdm.io.cuba.CubaImportConfigurator;
26 26
import eu.etaxonomy.cdm.io.cuba.CubaTransformer;
27 27
import eu.etaxonomy.cdm.model.agent.Person;
28
import eu.etaxonomy.cdm.model.agent.Team;
29 28
import eu.etaxonomy.cdm.model.description.Feature;
30 29
import eu.etaxonomy.cdm.model.description.FeatureNode;
31 30
import eu.etaxonomy.cdm.model.description.FeatureTree;
......
40 39
	private static final Logger logger = Logger.getLogger(CubaActivator.class);
41 40

  
42 41
	//database validation status (create, update, validate ...)
43
	static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
42
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
44 43

  
45
    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
44
//    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
46 45
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
47
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cuba_production();
46
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cuba_production();
48 47

  
49
	static boolean invers = false;
48
	static boolean invers = true;
50 49

  
51 50
    boolean doAsteraceae = include;
52 51
    boolean doConvolvulaceae = include;
......
82 81
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
83 82

  
84 83
	boolean doVocabularies = (hbm2dll == DbSchemaValidation.CREATE);
85
	static final boolean doTaxa = true;
86
	static final boolean doDeduplicate = false;
84
	static final boolean doTaxa = false;
85
	static final boolean doDeduplicate = true;
87 86

  
88 87

  
89 88
	private void doImport(ICdmDataSource cdmDestination){
......
158 157
        }
159 158

  
160 159

  
161

  
162 160
		//deduplicate
163 161
		if (doDeduplicate){
164 162
		    logger.warn("Start deduplication ...");
......
169 167
            }
170 168
			int count = app.getAgentService().deduplicate(Person.class, null, null);
171 169
			logger.warn("Deduplicated " + count + " persons.");
172
			count = app.getAgentService().deduplicate(Team.class, null, null);
173
			logger.warn("Deduplicated " + count + " teams.");
174
			count = app.getReferenceService().deduplicate(Reference.class, null, null);
175
			logger.warn("Deduplicated " + count + " references.");
170
//			count = app.getAgentService().deduplicate(Team.class, null, null);
171
//			logger.warn("Deduplicated " + count + " teams.");
172
//			count = app.getReferenceService().deduplicate(Reference.class, null, null);
173
//			logger.warn("Deduplicated " + count + " references.");
176 174
		}
177 175

  
178 176
		System.exit(0);
......
205 203
        System.out.println("End import from ("+ source.toString() + ")...");
206 204
    }
207 205

  
208
    private final Reference<?> inRef = ReferenceFactory.newGeneric();
209
	private Reference<?> getSourceReference(String string) {
210
		Reference<?> result = ReferenceFactory.newGeneric();
206
    private final Reference inRef = ReferenceFactory.newGeneric();
207
	private Reference getSourceReference(String string) {
208
		Reference result = ReferenceFactory.newGeneric();
211 209
		result.setTitleCache(string, true);
212 210
		result.setInReference(inRef);
213 211
		inRef.setTitleCache(sourceReferenceTitle, true);
app-import/src/main/java/eu/etaxonomy/cdm/app/cyprus/CyprusActivator.java
109 109

  
110 110
	}
111 111

  
112
	private Reference<?> getSourceReference(String string) {
113
		Reference<?> result = ReferenceFactory.newGeneric();
112
	private Reference getSourceReference(String string) {
113
		Reference result = ReferenceFactory.newGeneric();
114 114
		result.setTitleCache(string, true);
115 115
		return result;
116 116
	}
app-import/src/main/java/eu/etaxonomy/cdm/app/cyprus/CyprusAltitudeActivator.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
*/
......
51 51
 */
52 52
public class CyprusAltitudeActivator {
53 53
	private static final Logger logger = Logger.getLogger(CyprusAltitudeActivator.class);
54
	
54

  
55 55
	//database validation status (create, update, validate ...)
56 56
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
57 57
//	static final URI source = cyprus_distribution();
58 58
	static final URI source = cyprus_altitude();
59 59

  
60
	
60

  
61 61
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
62 62
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
63 63
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_dev();
64 64
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_production();
65 65

  
66
	
66

  
67 67
	//feature tree uuid
68 68
	public static final UUID featureTreeUuid = UUID.fromString("14d1e912-5ec2-4d10-878b-828788b70a87");
69
	
69

  
70 70
	//classification
71 71
	static final UUID classificationUuid = UUID.fromString("0c2b5d25-7b15-4401-8b51-dd4be0ee5cab");
72
	
72

  
73 73
	private static final String sourceReferenceTitle = "Cyprus Excel Altitude Import";
74
	
75
	
74

  
75

  
76 76
	//TODO move to Feature vocabulary
77 77
	private static final UUID uuidAltitudeFeature = UUID.fromString("1a28ed59-e15f-4001-b5c2-ea89f0012671");
78
	
78

  
79 79
	//check - import
80 80
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
81
	
81

  
82 82
	private void doImport(ICdmDataSource cdmDestination){
83
		
84
		
83

  
84

  
85 85
		ArrayList<HashMap<String, String>> excel;
86 86
		try {
87 87
			excel = ExcelUtils.parseXLS(source, "coreTax");
......
89 89
			e.printStackTrace();
90 90
			return;
91 91
		}
92
		
92

  
93 93
		CdmApplicationController app = CdmIoApplicationController.NewInstance(cdmDestination, hbm2dll);
94 94

  
95 95
		Set<TaxonBase> taxaToSave = new HashSet<TaxonBase>();
96
	
96

  
97 97
		TransactionStatus tx = app.startTransaction();
98
		
98

  
99 99
		UUID uuidMikle77 = UUID.fromString("9f5fa7ee-538b-4ae5-bd82-2a9503fea1d6");
100 100
		UUID uuidMikle85 = UUID.fromString("994403c4-c400-413d-9a1a-8531a40bfd8c");
101
		
102
		Reference<?> mikle77 = app.getReferenceService().find(uuidMikle77);
103
		Reference<?> mikle85 = app.getReferenceService().find(uuidMikle85);
104
		
105
		
101

  
102
		Reference mikle77 = app.getReferenceService().find(uuidMikle77);
103
		Reference mikle85 = app.getReferenceService().find(uuidMikle85);
104

  
105

  
106 106
		Feature altitudeFeature = (Feature) app.getTermService().find(uuidAltitudeFeature);
107 107
		if (altitudeFeature == null){
108 108
//			altitudeFeature = Feature.NewInstance("Altitude", "Altitude", "alt.");
......
111 111
//			featureVoc.addTerm(altitudeFeature);
112 112
			throw new RuntimeException("Could not find altitudinal range feature");
113 113
		}
114
		
114

  
115 115
		MeasurementUnit meter = (MeasurementUnit)app.getTermService().find(UUID.fromString("8bef5055-789c-41e5-bea2-8dc2ea8ecdf6"));
116 116
//		NamedArea cyprus = (NamedArea)app.getTermService().find(UUID.fromString("da4cce9a-439b-4cc4-8073-85dc75bae169"));
117
	
117

  
118 118
		int count =1;
119 119
		for (HashMap<String, String> row : excel){
120 120
			count++;
121 121
			UUID baseUuid = makeUuid(row, "uuid");
122 122
			UUID acceptedUuid = makeUuid(row, "acceptedNameUuid");
123 123
			UUID parentUuid = makeUuid(row, "parentUuid");
124
			
124

  
125 125
//			String altitude = row.get("Altitude-kumuliert");
126
			
126

  
127 127
			String altitudeMin = row.get("Min");
128 128
			String altitudeMax = row.get("Max");
129 129
			String acceptedName = row.get("AcceptedName");
130
			
131
			
132
			
130

  
131

  
132

  
133 133
			String source = row.get("Source");
134
			
134

  
135 135
			if (StringUtils.isBlank(altitudeMin)){
136 136
				continue;
137 137
			}
138
			
138

  
139 139
			boolean hasAltitude = false;
140
			Reference<?> sourceRef = getSource(source, mikle77, mikle85);
140
			Reference sourceRef = getSource(source, mikle77, mikle85);
141 141
			Taxon taxon = getTaxon(app, baseUuid, acceptedUuid, parentUuid, acceptedName, count);
142 142
			if (taxon != null){
143 143
				TaxonDescription desc = getDescription(taxon, sourceRef);
144
				
144

  
145 145
				hasAltitude = makeAltitude(altitudeMin, altitudeMax, altitudeFeature, sourceRef, desc, meter, count);
146 146
//				hasAltitude = makeAltitudeOld(altitude, altitudeFeature, sourceRef, desc, meter, count);
147 147
				if (hasAltitude){
......
158 158
		}
159 159

  
160 160
		app.getTaxonService().saveOrUpdate(taxaToSave);
161
		
161

  
162 162
//		tx.setRollbackOnly();
163 163
		app.commitTransaction(tx);
164 164
	}
......
167 167
	private Taxon getTaxon(CdmApplicationController app, UUID baseUuid, UUID acceptedUuid, UUID parentUuid, String acceptedName, int row) {
168 168
		TaxonBase<?> base = app.getTaxonService().find(baseUuid);
169 169
//		TaxonBase<?> parent = app.getTaxonService().find(parentUuid);
170
		
170

  
171 171
		//TODO
172 172
		Taxon result = null;
173 173
		if (base.isInstanceOf(Taxon.class)){
......
187 187
				}else{
188 188
					logger.warn("Synonym relation has changed somehow. Row: " + row +  ", Taxon: " + base.getTitleCache());
189 189
				}
190
				
190

  
191 191
			}else{
192 192
				logger.warn("Accepted taxon not in classification. Row: " + row +  ", Taxon: " + base.getTitleCache());
193 193
			}
194 194
		}
195
		
195

  
196 196
		if (result != null){
197 197
			if (! result.getName().getTitleCache().equals(acceptedName)){
198 198
				logger.warn("AcceptedName and taxon name is not equal in " + row + ".\n" +
......
200 200
						" Taxon    Name: " + result.getName().getTitleCache());
201 201
			}
202 202
		}
203
		
203

  
204 204
		return result;
205 205
	}
206 206

  
......
218 218
//	private static final Pattern altitudePattern = Pattern.compile("\\d{1,4}(-\\d{1,4})?");
219 219

  
220 220

  
221
	private boolean makeAltitude(String altitudeMin, String altitudeMax, Feature altitudeFeature, 
222
			Reference<?> sourceRef, TaxonDescription desc, MeasurementUnit meter, int row) {
223
	
221
	private boolean makeAltitude(String altitudeMin, String altitudeMax, Feature altitudeFeature,
222
			Reference sourceRef, TaxonDescription desc, MeasurementUnit meter, int row) {
223

  
224 224
		QuantitativeData data = QuantitativeData.NewInstance(altitudeFeature);
225
		
225

  
226 226
		//Meikle
227 227
		if (source != null){
228 228
			TaxonNameBase<?,?> nameUsedInSource = null;  //TODO
......
231 231
//		//Excel   //excel source not wanted by Ralf
232 232
//		TaxonNameBase<?,?> nameUsedInSource = null;  //TODO probably we don't want this
233 233
//		data.addSource(OriginalSourceType.Import, String.valueOf(row), "row", getSourceReference(), null, nameUsedInSource, null);
234
		
234

  
235 235
		data.setUnit(meter);
236
		
236

  
237 237
		Integer min = Integer.valueOf(altitudeMin);
238 238
		StatisticalMeasurementValue minValue = StatisticalMeasurementValue.NewInstance(StatisticalMeasure.MIN(), min);
239 239
		data.addStatisticalValue(minValue);
......
241 241
		Integer max = Integer.valueOf(altitudeMax);
242 242
		StatisticalMeasurementValue maxValue = StatisticalMeasurementValue.NewInstance(StatisticalMeasure.MAX(), max);
243 243
		data.addStatisticalValue(maxValue);
244
		
244

  
245 245
		desc.addElement(data);
246 246
		return true;
247 247
	}
248
	
249
//	private boolean makeAltitudeOld(String altitudeOrig, Feature feature, Reference<?> source, TaxonDescription desc, MeasurementUnit meter, int row) {
248

  
249
//	private boolean makeAltitudeOld(String altitudeOrig, Feature feature, Reference source, TaxonDescription desc, MeasurementUnit meter, int row) {
250 250
//		String altitude = altitudeOrig.trim().replace(" ", "");
251 251
//		Matcher matcher = altitudePattern.matcher(altitude);
252
//		
252
//
253 253
//		if (matcher.matches()){
254 254
//			QuantitativeData data = QuantitativeData.NewInstance(feature);
255
//			
255
//
256 256
//			//Meikle
257 257
//			if (source != null){
258 258
//				TaxonNameBase<?,?> nameUsedInSource = null;  //TODO
......
262 262
//			TaxonNameBase<?,?> nameUsedInSource = null;  //TODO probably we don't want this
263 263
//			data.addSource(OriginalSourceType.Import, String.valueOf(row), "row", getSourceReference(), null, nameUsedInSource, null);
264 264
//			data.setUnit(meter);
265
//			
265
//
266 266
//			String[] split = altitude.split("-");
267 267
//
268 268
//			Integer min = Integer.valueOf(split[0]);
......
282 282
//		}
283 283
//	}
284 284

  
285
	private TaxonDescription getDescription(Taxon taxon, Reference<?> sourceRef) {
285
	private TaxonDescription getDescription(Taxon taxon, Reference sourceRef) {
286 286
		if (taxon != null){
287 287
			//TODO Mikle existiert derzeit nicht also Source
288
			
288

  
289 289
			TaxonDescription desc = TaxonDescription.NewInstance();
290 290
			desc.setTitleCache("Import from " + getSourceReference().getTitleCache(), true);
291 291
			desc.addSource(OriginalSourceType.PrimaryTaxonomicSource, null, null, sourceRef,null);
292 292
			desc.addSource(OriginalSourceType.Import, null, null, getSourceReference(), null);
293
			
293

  
294 294
			return desc;
295 295
		}
296 296
		return null;
297 297
	}
298 298

  
299
	private Reference<?> getSource(String source, Reference<?> m77, Reference<?> m85) {
299
	private Reference getSource(String source, Reference m77, Reference m85) {
300 300
		if(StringUtils.isNotBlank(source)){
301 301
			if (source.equals("Meikle 1977")){
302 302
				return m77;
......
325 325
//		// TODO Auto-generated method stub
326 326
//		HashMap<String, Object> = new HashM
327 327
//		row
328
//		
329
//		
328
//
329
//
330 330
//	}
331 331

  
332
	
333
	Reference<?> sourceReference;
334
	private Reference<?> getSourceReference() {
332

  
333
	Reference sourceReference;
334
	private Reference getSourceReference() {
335 335
		if (sourceReference == null){
336 336
			sourceReference = ReferenceFactory.newGeneric();
337 337
			sourceReference.setTitleCache(sourceReferenceTitle, true);
338
			
338

  
339 339
		}
340 340
		return sourceReference;
341
			
341

  
342 342
	}
343 343

  
344
	
344

  
345 345
	//Cyprus
346 346
	public static URI cyprus_altitude() {
347 347
		URI sourceUrl;
......
367 367

  
368 368
	private void testMatcher() {
369 369
//		makeAltitude("0-4400", null, null);
370
		
370

  
371 371
	}
372
	
372

  
373 373
}
app-import/src/main/java/eu/etaxonomy/cdm/app/cyprus/CyprusSpecimenActivator.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
*/
......
31 31
public class CyprusSpecimenActivator {
32 32
	@SuppressWarnings("unused")
33 33
	private static final Logger logger = Logger.getLogger(CyprusSpecimenActivator.class);
34
	
34

  
35 35
	//database validation status (create, update, validate ...)
36 36
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
37 37
	static final URI source = cyprus_specimen_local();
38 38

  
39
	
39

  
40 40
//	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
41 41
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
42 42
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_dev();
43 43
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_production();
44 44

  
45
	
45

  
46 46
	//check - import
47 47
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
48
	
48

  
49 49
	//taxa
50 50
//	static final boolean doTaxa = false;
51 51
//	static final boolean doDeduplicate = false;
52 52
//	static final boolean doDistribution = true;
53 53

  
54
	
54

  
55 55
	private void doImport(ICdmDataSource cdmDestination){
56
		
56

  
57 57
		//make Source
58 58
		SpecimenCdmExcelImportConfigurator config= SpecimenCdmExcelImportConfigurator.NewInstance(source, cdmDestination);
59 59
		config.setCheck(check);
60 60
		config.setDbSchemaValidation(hbm2dll);
61
		
61

  
62 62
		CdmDefaultImport myImport = new CdmDefaultImport();
63 63

  
64
		
64

  
65 65
		//...
66 66
		if (true){
67 67
			System.out.println("Start import from ("+ source.toString() + ") ...");
......
70 70

  
71 71
			System.out.println("End import from ("+ source.toString() + ")...");
72 72
		}
73
		
73

  
74 74
	}
75 75

  
76
	private Reference<?> getSourceReference(String string) {
77
		Reference<?> result = ReferenceFactory.newGeneric();
76
	private Reference getSourceReference(String string) {
77
		Reference result = ReferenceFactory.newGeneric();
78 78
		result.setTitleCache(string, true);
79 79
		return result;
80 80
	}
81
	
81

  
82 82
	//Cyprus
83 83
	public static URI cyprus_specimen_local() {
84 84
		URI sourceUrl;
......
91 91
		}
92 92
	}
93 93

  
94
	
94

  
95 95

  
96 96
	/**
97 97
	 * @param args
......
100 100
		CyprusSpecimenActivator me = new CyprusSpecimenActivator();
101 101
		me.doImport(cdmDestination);
102 102
	}
103
	
103

  
104 104
}
app-import/src/main/java/eu/etaxonomy/cdm/app/dwca/DwcaImportActivator.java
133 133

  
134 134
	}
135 135

  
136
	private Reference<?> getSourceReference(String string) {
137
		Reference<?> result = ReferenceFactory.newGeneric();
136
	private Reference getSourceReference(String string) {
137
		Reference result = ReferenceFactory.newGeneric();
138 138
		result.setTitleCache(string);
139 139
		return result;
140 140
	}
app-import/src/main/java/eu/etaxonomy/cdm/app/i4life/col/ColDwcaImportActivator.java
137 137

  
138 138
	}
139 139

  
140
	private Reference<?> getSourceReference(String string) {
141
		Reference<?> result = ReferenceFactory.newGeneric();
140
	private Reference getSourceReference(String string) {
141
		Reference result = ReferenceFactory.newGeneric();
142 142
		result.setTitleCache(string, true);
143 143
		return result;
144 144
	}
app-import/src/main/java/eu/etaxonomy/cdm/app/proibiosphere/SpecimenImportActivator.java
68 68

  
69 69
            //            specimenImportConfigurator.setDoCreateIndividualsAssociations(true);
70 70

  
71
            Reference<?> ref = ReferenceFactory.newBook();
71
            Reference ref = ReferenceFactory.newBook();
72 72
            ref.setUuid(UUID.fromString("98b0a618-a95b-464e-943a-25aaaef202f6"));//observations
73 73
            ref.setTitle("Chenopodium vulvaria observations from the British Isles");
74 74
            //
app-import/src/main/java/eu/etaxonomy/cdm/app/proibiosphere/SynthesysCacheActivator.java
74 74

  
75 75
            specimenImportConfigurator.setReUseTaxon(true);
76 76

  
77
            Reference<?> reference = ReferenceFactory.newGeneric();
77
            Reference reference = ReferenceFactory.newGeneric();
78 78
            reference.setTitleCache("Chenopodium vulvaria observations from the Botanical Society of the British Isles", true);
79 79
            Person p = Person.NewInstance();
80 80
            p.setFirstname("Quentin");
app-import/src/main/java/eu/etaxonomy/cdm/app/proibiosphere/TaxonXImportLauncher.java
53 53
  static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
54 54
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_piB("piB_nephrolepis");
55 55
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_piB("guianas");
56
    
56

  
57 57
    static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
58
    
58

  
59 59
    private enum FilterType{MODS, TAXON};
60 60

  
61 61

  
......
66 66

  
67 67
    public static void main(String[] args) {
68 68
    	String[] spiderModsList = new String[] {"zt03768p138","zt03750p196","zt03666p193","zt03664p068","zt03646p592","zt03507p056","zt03415p057","zt03383p038","zt03305p052","zt03228p068","zt03131p034","zt02963p068","zt02883p068","zt02814p018","zt02739p050","zt02730p043","zt02637p054","zt02593p127","zt02551p068","zt02534p036","zt02526p053","zt02427p035","zt02361p012","zt02267p068","zt02223p047","zt01826p058","zt01775p024","zt01744p040","zt01529p060","zt01004p028","zt00904","zt00872","zt00619","zt00109","DippenaarSchoeman1989Penestominae","Simon1902Cribellates","Simon1903Penestominae","Lehtinen1967CribellatePenestominae"};
69
    	
69

  
70 70
    	String[] taxonList = new String[]  {"Campylopus"}; //{"Eupolybothrus","Polybothrus"}, Chenopodium, Lactarius, Campylopus, Nephrolepis, Comaroma (spiders)
71 71
//       /*ants Anochetus*/ String[] modsList = new String[] {"3924" /*, "3743", "4375", "6757", "6752", "3481", "21401_fisher_smith_plos_2008", "2592", "4096", "6877", "6192", "8071"  */};
72 72
//        String[] modsList = new String[] {"21367", "21365", "8171", "6877", "21820", "3641", "6757"};
......
74 74
//        suite: , };//,"3540555099"};
75 75
//        modsList = new String[] {"Zapparoli-1986-Eupolybothrus-fasciatus"};
76 76
//    	taxonList = spiderModsList;
77
    	
77

  
78 78
    	FilterType filterType = FilterType.TAXON;
79
        
79

  
80 80
    	NomenclaturalCode tnomenclature = NomenclaturalCode.ICNAFP;
81 81

  
82 82
        String defaultClassification= null;// "Nephrolepis";
83 83
        boolean alwaysUseDefaultClassification = false;
84
        
84

  
85 85
        boolean useOldUnparsedSynonymExtraction = false;
86 86

  
87
        
88
        
89
        
87

  
88

  
89

  
90 90
        Map<String,List<URI>>documentMap = new HashMap<String, List<URI>>();
91 91

  
92 92
        /*HOW TO HANDLE SECUNDUM REFERENCE*/
93 93
        boolean reuseSecundum = askIfReuseSecundum();
94
        Reference<?> secundum = null;
94
        Reference secundum = null;
95 95
        if (!reuseSecundum) {
96 96
            secundum = askForSecundum();
97 97
        }
......
104 104
        ICdmDataSource destination = cdmDestination;
105 105
        TaxonXImportConfigurator config = prepareTaxonXImport(destination,reuseSecundum, secundum, tnomenclature, alwaysUseDefaultClassification);
106 106
        config.setUseOldUnparsedSynonymExtraction(useOldUnparsedSynonymExtraction);
107
        
107

  
108 108
        config.setImportClassificationName(defaultClassification);
109 109
        log.info("Start import from  TaxonX Data");
110 110

  
......
151 151
     *
152 152
     */
153 153
    private static void prepareReferenceAndSource(TaxonXImportConfigurator taxonxImportConfigurator, URI source) {
154
        Reference<?> reference = ReferenceFactory.newGeneric();
154
        Reference reference = ReferenceFactory.newGeneric();
155 155
        //            String tref = askQuestion("Import source? (ie Plazi document ID)");
156 156
        String tref="PLAZI - "+source.getPath().split("/")[source.getPath().split("/").length-1];
157 157
        reference.setTitleCache(tref,true);
158 158
        reference.setTitle(tref);
159
        
159

  
160 160
        taxonxImportConfigurator.setSourceReference(reference);
161 161
        TaxonXImportConfigurator.setSourceRef(reference);
162 162

  
163
        Reference<?> referenceUrl = ReferenceFactory.newWebPage();
163
        Reference referenceUrl = ReferenceFactory.newWebPage();
164 164
        referenceUrl.setTitleCache(source.toString(), true);
165 165
        referenceUrl.setTitle(source.toString());
166 166
        reference.setUri(source);
......
174 174
     * @param destination
175 175
     * @param reuseSecundum
176 176
     * @param secundum
177
     * @param tnomenclature 
178
     * @param alwaysUseDefaultClassification 
177
     * @param tnomenclature
178
     * @param alwaysUseDefaultClassification
179 179
     * @return
180 180
     */
181
    private static TaxonXImportConfigurator prepareTaxonXImport(ICdmDataSource destination, boolean reuseSecundum, Reference<?> secundum, NomenclaturalCode tnomenclature, boolean alwaysUseDefaultClassification) {
181
    private static TaxonXImportConfigurator prepareTaxonXImport(ICdmDataSource destination, boolean reuseSecundum, Reference secundum, NomenclaturalCode tnomenclature, boolean alwaysUseDefaultClassification) {
182 182
        TaxonXImportConfigurator taxonxImportConfigurator = TaxonXImportConfigurator.NewInstance(destination);
183 183

  
184 184
        //taxonxImportConfigurator.setClassificationName(taxonxImportConfigurator.getSourceReferenceTitle());
......
300 300
	}
301 301

  
302 302
	private static Map<String, List<String>> fillDocumentMap(FilterType filterType,
303
			String[] filterList, String urlstr) 
303
			String[] filterList, String urlstr)
304 304
					throws MalformedURLException, IOException {
305
		
305

  
306 306
		Map<String, List<String>> documents = new HashMap<String, List<String>>();
307 307
		List<String> docList;
308 308
		String inputLine;
......
327 327
		            String taxon = inputLine.split("taxon=\"")[1].split("\"")[0];
328 328
		            String docID=inputLine.split("docId=\"")[1].split("\"")[0];
329 329
		            System.out.println("docID: "+docID);
330
		            
330

  
331 331
		            String link=inputLine.split("link=\"")[1].split("\"")[0];
332 332
		            String pageStart = inputLine.split("startPage=\"")[1].split("\"")[0];
333 333
		            String pageEnd = inputLine.split("endPage=\"")[1].split("\"")[0];
......
341 341
		    }
342 342
		}
343 343
		System.out.println("documents created");
344
		
344

  
345 345
		return documents;
346 346
	}
347 347

  
......
415 415
    /**
416 416
     * @return
417 417
     */
418
    private static Reference<?> askForSecundum() {
418
    private static Reference askForSecundum() {
419 419
        //        logger.info("getFullReference for "+ name);
420 420
        JTextArea textArea = new JTextArea("Enter the secundum name");
421 421
        JScrollPane scrollPane = new JScrollPane(textArea);
......
433 433
                null,
434 434
                null,
435 435
                null);
436
        Reference<?> ref = ReferenceFactory.newGeneric();
436
        Reference ref = ReferenceFactory.newGeneric();
437 437
        ref.setTitle(s);
438 438
        return ref;
439 439
    }
app-import/src/main/java/eu/etaxonomy/cdm/app/redlist/RedListGefaesspflanzenActivator.java
61 61
		System.out.println("End import from ("+ source.toString() + ")...");
62 62
	}
63 63

  
64
	private Reference<?> getSourceReference(String string) {
65
		Reference<?> result = ReferenceFactory.newGeneric();
64
	private Reference getSourceReference(String string) {
65
		Reference result = ReferenceFactory.newGeneric();
66 66
		result.setTitleCache(string, true);
67 67
		return result;
68 68
	}
app-import/src/main/java/eu/etaxonomy/cdm/app/synthesysImport/SynthesysCacheActivator.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
 */
......
18 18
import java.util.ListIterator;
19 19

  
20 20
import org.apache.log4j.Logger;
21
import org.apache.poi.ss.usermodel.Workbook;
22 21
import org.springframework.transaction.TransactionStatus;
23 22

  
24 23
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
......
74 73
	protected ArrayList<String> identificationList = new ArrayList<String>();
75 74

  
76 75
	static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
77
	
76

  
78 77
	static ICdmDataSource desitination = CdmDestinations.localH2();
79
	
78

  
80 79

  
81 80
	public void saveUnit(HashMap<String,String> unit){
82 81
		String author = unit.get("author");
......
139 138
		TransactionStatus tx = null;
140 139

  
141 140
		app = CdmApplicationController.NewInstance(desitination, hbm2dll);
142
		
141

  
143 142
		tx = app.startTransaction();
144 143
		try {
145
			Reference<?> sec = ReferenceFactory.newDatabase();
144
			Reference sec = ReferenceFactory.newDatabase();
146 145
			sec.setTitleCache("SYNTHESYS CACHE DATA", true);
147 146

  
148 147
			/**
......
152 151
			//create specimen
153 152
			if (this.recordBasis != null){
154 153
				if (this.recordBasis.toLowerCase().startsWith("s")) {//specimen
155
					derivedThing = DerivedUnit.NewPreservedSpecimenInstance();				
154
					derivedThing = DerivedUnit.NewPreservedSpecimenInstance();
156 155
				}
157 156
				else if (this.recordBasis.toLowerCase().startsWith("o")) {//observation
158
					derivedThing = DerivedUnit.NewInstance(SpecimenOrObservationType.Observation);				
157
					derivedThing = DerivedUnit.NewInstance(SpecimenOrObservationType.Observation);
159 158
				}
160 159
				else if (this.recordBasis.toLowerCase().startsWith("l")) {//living -> fossil, herbarium sheet....???
161
					derivedThing = DerivedUnit.NewInstance(SpecimenOrObservationType.LivingSpecimen);	
160
					derivedThing = DerivedUnit.NewInstance(SpecimenOrObservationType.LivingSpecimen);
162 161
				}
163 162
			}
164 163
			if (derivedThing == null){
......
179 178
				if (this.fullScientificNameString.indexOf("_preferred_") != -1){
180 179
					scientificName = this.fullScientificNameString.split("_preferred_")[0];
181 180
					String pTmp = this.fullScientificNameString.split("_preferred_")[1];
182
					if (pTmp == "1" || pTmp.toLowerCase().indexOf("true") != -1)
183
						preferredFlag=true;
184
					else
185
						preferredFlag=false;
186
				}
187
				else scientificName = this.fullScientificNameString;
181
					if (pTmp == "1" || pTmp.toLowerCase().indexOf("true") != -1) {
182
                        preferredFlag=true;
183
                    } else {
184
                        preferredFlag=false;
185
                    }
186
				} else {
187
                    scientificName = this.fullScientificNameString;
188
                }
188 189

  
189 190
//				taxonName = nvnpi.parseFullName(this.fullScientificNameString,NomenclaturalCode.ICZN(),null);
190 191
//				if (taxonName.hasProblem()){
......
200 201
//				System.out.println("pb ICNCP");
201 202
//				}
202 203
//				}
203
//				}				
204
//				}
204 205
//				}
205 206
				taxonName = nvnpi.parseFullName(scientificName);
206 207
				if (withCdm){
......
216 217
					}
217 218
				}
218 219

  
219
				
220

  
220 221
//				tx = app.startTransaction();
221 222
				app.getNameService().saveOrUpdate(taxonName);
222 223
				taxon = Taxon.NewInstance(taxonName, sec); //TODO use real reference for sec
......
253 254
				System.out.println("Institution (agent) unknown");
254 255
				//create institution
255 256
				institution = Institution.NewInstance();
256
				institution.setCode(this.institutionCode);				
257
				institution.setCode(this.institutionCode);
257 258
			}
258 259
			else{
259 260
				System.out.println("Institution (agent) already in the db");
......
282 283
				for (int i=0; i<collections.size(); i++){
283 284
					collection = collections.get(i);
284 285
					try {
285
						if (collection.getInstitute().getCode().equalsIgnoreCase(institution.getCode())){ 
286
						if (collection.getInstitute().getCode().equalsIgnoreCase(institution.getCode())){
286 287
							//found a collection with the same code and the same institution
287 288
							collectionFound=true;
288 289
						}
......
318 319
			gatheringEvent.setExactLocation(coordinates);
319 320

  
320 321
			NamedArea area = NamedArea.NewInstance();
321
			
322

  
322 323

  
323 324
			Country country = null;
324 325
//			System.out.println("isocountry "+this.isocountry);
325
			if (this.isocountry != null)
326
				country = app.getOccurrenceService().getCountryByIso(this.isocountry);
327
			
326
			if (this.isocountry != null) {
327
                country = app.getOccurrenceService().getCountryByIso(this.isocountry);
328
            }
329

  
328 330
//			System.out.println(country.getLabel());
329 331
//			Set<Continent> cont = country.getContinents();
330
//			
332
//
331 333
//			System.out.println(cont.size());
332 334
//			Iterator<Continent> iter = cont.iterator();
333 335
//			while (iter.hasNext())
334 336
//				System.out.println(iter.next().toString());
335
			
337

  
336 338
			if (country != null){
337 339
				area.addCountry(country);
338 340
				System.out.println("country not null!");
......
385 387

  
386 388
			/**
387 389
			 * SAVE AND STORE DATA
388
			 */			
390
			 */
389 391
			//save the specimen data
390 392
			//	app.getOccurrenceService().saveSpecimenOrObservationBase(fieldObservation);
391 393
			try {
......
409 411
			e.printStackTrace();
410 412
			result = false;
411 413
		}
412
//		
414
//
413 415
		app.commitTransaction(tx);
414 416
		System.out.println("commit done");
415 417
		app.close();
416
		
418

  
417 419
		return result;
418 420
	}
419 421

  
......
432 434

  
433 435
	/**
434 436
	 * @param args
435
	 * @throws URISyntaxException 
437
	 * @throws URISyntaxException
436 438
	 */
437 439
	public static void main(String[] args) throws URISyntaxException {
438
		URI uri = CdmImportSources.SYNTHESYS_SPECIMEN();		
440
		URI uri = CdmImportSources.SYNTHESYS_SPECIMEN();
439 441
		logger.info("main method");
440 442
		SynthesysCacheActivator abcdAct = new SynthesysCacheActivator();
441
		
443

  
442 444
		ArrayList<HashMap<String, String>> units;
443 445
		try {
444 446
			units = ExcelUtils.parseXLS(uri);
......
452 454
			logger.info(unit);
453 455
			abcdAct.saveUnit(unit);//and then invoke
454 456
			abcdAct.invoke();
455
			
457

  
456 458
		}
457 459
	}
458 460

  
app-import/src/main/java/eu/etaxonomy/cdm/app/tcs/TcsRdfTestActivator.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
*/
......
35 35
 */
36 36
public class TcsRdfTestActivator {
37 37
	private static final Logger logger = Logger.getLogger(TcsRdfTestActivator.class);
38
	
38

  
39 39
	//database validation status (create, update, validate ...)
40 40
	static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
41 41
	static final String tcsSource = TcsSources.tcsRdf_test();
......
43 43

  
44 44
	static final UUID treeUuid = UUID.fromString("00000000-0c97-48ac-8d33-6099ed68345");
45 45
	static final String sourceSecId = "XXX";
46
	
46

  
47 47
	//check - import
48 48
	static final CHECK check = CHECK.CHECK_AND_IMPORT;
49
	
49

  
50 50
	//authors
51 51
	static final boolean doMetaData = true;
52 52
	//references
......
54 54
	//names
55 55
	static final boolean doTaxonNames = true;
56 56
	static final boolean doRelNames = true;
57
	
57

  
58 58
	//taxa
59 59
	static final boolean doTaxa = true;
60 60
	static final boolean doRelTaxa = true;
61 61

  
62
	
62

  
63 63
	private void doImport(){
64 64
		System.out.println("Start import from Tcs("+ tcsSource.toString() + ") ...");
65
		
65

  
66 66
		//make BerlinModel Source
67 67
		URI source;
68 68
		try {
69 69
			source = new URI(tcsSource);
70 70
			ICdmDataSource destination = cdmDestination;
71
			
71

  
72 72
			TcsRdfImportConfigurator tcsImportConfigurator = TcsRdfImportConfigurator.NewInstance(source,  destination);
73
			
73

  
74 74
			tcsImportConfigurator.setClassificationUuid(treeUuid);
75 75
			tcsImportConfigurator.setSourceSecId(sourceSecId);
76
			
76

  
77 77
			tcsImportConfigurator.setDoReferences(doReferences);
78 78
			tcsImportConfigurator.setDoTaxonNames(doTaxonNames);
79 79
			tcsImportConfigurator.setDoRelNames(doRelNames);
80
			
80

  
81 81
			tcsImportConfigurator.setDoTaxa(doTaxa);
82 82
			tcsImportConfigurator.setDoRelTaxa(doRelTaxa);
83
			
83

  
84 84
			tcsImportConfigurator.setCheck(check);
85 85
			tcsImportConfigurator.setDbSchemaValidation(hbm2dll);
86
	
86

  
87 87
			// invoke import
88 88
			CdmDefaultImport<TcsRdfImportConfigurator> tcsImport = new CdmDefaultImport<TcsRdfImportConfigurator>();
89 89
			tcsImport.invoke(tcsImportConfigurator);
90
			
91
			
90

  
91

  
92 92
			IReferenceService refService = tcsImport.getCdmAppController().getReferenceService();
93 93
			IBook book = ReferenceFactory.newBook();
94 94
			//book.setDatePublished(TimePeriod.NewInstance(1945));
95 95
			book.setDatePublished(TimePeriod.NewInstance(1945).setEndDay(12).setEndMonth(4));
96
			refService.saveOrUpdate((Reference<?>)book);
96
			refService.saveOrUpdate((Reference)book);
97 97
			logger.info("End");
98 98
			System.out.println("End import from TCS ("+ source.toString() + ")...");
99 99
		} catch (URISyntaxException e) {
100 100
			e.printStackTrace();
101 101
		}
102
		
102

  
103 103
	}
104 104

  
105 105
	/**
......
109 109
		TcsRdfTestActivator me = new TcsRdfTestActivator();
110 110
		me.doImport();
111 111
	}
112
	
112

  
113 113
}
app-import/src/main/java/eu/etaxonomy/cdm/app/util/TestDatabase.java
1 1
/**
2 2
* Copyright (C) 2008 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5 5
*/
6 6

  
......
36 36
import eu.etaxonomy.cdm.model.description.TaxonDescription;
37 37
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
38 38
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
39
import eu.etaxonomy.cdm.model.location.NamedAreaType;
40 39
import eu.etaxonomy.cdm.model.location.Country;
40
import eu.etaxonomy.cdm.model.location.NamedAreaType;
41 41
import eu.etaxonomy.cdm.model.name.BotanicalName;
42 42
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
43 43
import eu.etaxonomy.cdm.model.name.Rank;
......
65 65
	private static final Logger logger = Logger.getLogger(TestDatabase.class);
66 66

  
67 67
	public static ICdmDataSource CDM_DB(String dbname) {
68
		
68

  
69 69
		logger.info("Setting DB " + dbname);
70 70
		String password = AccountStore.readOrStorePassword(dbname, server, username, null);
71 71
		ICdmDataSource datasource = CdmDataSource.NewMySqlInstance(server, dbname, username, password, NomenclaturalCode.ICNAFP);
72 72
		return datasource;
73 73
	}
74
	
74

  
75 75
    public static CdmApplicationController initDb(ICdmDataSource db, DbSchemaValidation dbSchemaValidation, boolean omitTermLoading) {
76
    	
76

  
77 77
		logger.info("Initializing database '" + db.getName() + "'");
78
		
78

  
79 79
		CdmApplicationController appCtrInit = CdmIoApplicationController.NewInstance(db, dbSchemaValidation, omitTermLoading);
80
		
80

  
81 81
		return appCtrInit;
82 82
    }
83
    
83

  
84 84
	public static void loadTestData(String dbname, CdmApplicationController appCtr) {
85
    	
85

  
86 86
		logger.info("Loading test data into " + dbname);
87
		
87

  
88 88
		TransactionStatus txStatus = appCtr.startTransaction();
89 89
		DataSet dataSet = buildDataSet();
90
		
90

  
91 91
		appCtr.getTermService().save(dataSet.getTerms());
92 92
		appCtr.getTaxonService().save((List)dataSet.getTaxonBases());
93 93

  
94 94
		appCtr.commitTransaction(txStatus);
95 95
		appCtr.close();
96 96
    }
97
    
97

  
98 98
	/**
99 99
	 * This method constructs a small sample classification to test JAXB marshaling.
100 100
	 * The sample tree contains four taxa. The root taxon has two children taxa, and
......
105 105
		List<AgentBase> agents = new ArrayList<AgentBase>();
106 106
	    List<VersionableEntity> agentData = new ArrayList<VersionableEntity>();
107 107
	    //List<Agent> agentData = new ArrayList<Agent>();
108
	    
108

  
109 109
	    //List<TermBase> terms = new ArrayList<TermBase>();
110 110
	    List<DefinedTermBase> terms = new ArrayList<DefinedTermBase>();
111 111
	    List<Reference> references = new ArrayList<Reference>();
112 112
	    List<TaxonNameBase> taxonomicNames = new ArrayList<TaxonNameBase>();
113 113
	    List<TaxonBase> taxonBases = new ArrayList<TaxonBase>();
114
	    
114

  
115 115
	    List<Feature> features = new ArrayList<Feature>();
116
	    
116

  
117 117
	    Feature feature1 = Feature.BIOLOGY_ECOLOGY();
118
	    
118

  
119 119
	    TaxonNameDescription taxNameDescription = TaxonNameDescription.NewInstance();
120 120
//	    taxNameDescription.addFeature(feature1);    //no longer supported since v3.3
121 121
	    QuantitativeData element = QuantitativeData.NewInstance();
......
124 124
	    statisticalValue.setValue((float) 2.1);
125 125
	    element.addStatisticalValue(statisticalValue);
126 126
	    taxNameDescription.addElement(element);
127
	    
127

  
128 128
	    SpecimenOrObservationBase<?> specimen = DerivedUnit.NewPreservedSpecimenInstance();
129
	    
129

  
130 130
	    specimen.setIndividualCount(12);
131
	    
132
	    
131

  
132

  
133 133
	    Feature featureIndAss = Feature.INDIVIDUALS_ASSOCIATION();
134 134
	    TaxonNameDescription newTaxNameDesc = TaxonNameDescription.NewInstance();
135 135
//	    newTaxNameDesc.addFeature(featureIndAss);   //no longer supported since v3.3
136 136
	    IndividualsAssociation indAss = IndividualsAssociation.NewInstance();
137 137
	    indAss.setAssociatedSpecimenOrObservation(specimen);
138
	    
138

  
139 139
	    newTaxNameDesc.addElement(indAss);
140
	    
141
	    
142
	    
143
	    
140

  
141

  
142

  
143

  
144 144
//	    List<Synonym> synonyms = new ArrayList<Synonym>();
145 145
	    List<AnnotatableEntity> homotypicalGroups;
146 146

  
147
		Reference<?> citRef, sec;
147
		Reference citRef, sec;
148 148
		BotanicalName name1, name2, name21, nameRoot1, nameFree, synName11, synName12, synName2, synNameFree;
149 149
		BotanicalName nameRoot2, nameR2_1, nameR2_2;
150 150
		Taxon child1, child2, child21, root1T, root2T, freeT;
......
155 155
		Synonym syn11, syn12, syn2, synFree;
156 156
		Rank rankSpecies, rankSubspecies, rankGenus;
157 157

  
158
		// agents 
159
		// - persons, institutions 
158
		// agents
159
		// - persons, institutions
160 160

  
161 161
		Person linne = new Person("Carl", "Linne", "L.");
162 162
		linne.setTitleCache("Linne & Karl", true);
......
178 178

  
179 179
		//Contact contact1 = new Contact();
180 180
		//contact1.setEmail("someone@somewhere.org");
181
		InstitutionalMembership membership 
181
		InstitutionalMembership membership
182 182
		= new InstitutionalMembership(institute, linne, period, "Biodiversity", "Head");
183 183
		//agentData.add(contact1);
184 184

  
......
190 190
		rankSpecies = Rank.SPECIES();
191 191
		rankSubspecies = Rank.SUBSPECIES();
192 192
		rankGenus = Rank.GENUS();
193
		
193

  
194 194
//		terms.add(keyword);
195
		
195

  
196 196
        // taxonomic names
197
		
197

  
198 198
		nameRoot1 = BotanicalName.NewInstance(rankGenus,"Calendula",null,null,null,linne,null,"p.100", null);
199 199
		nameRoot1.addDescription(taxNameDescription);
200 200
		nameRoot1.addDescription(newTaxNameDesc);
201 201
		name1 = BotanicalName.NewInstance(rankSpecies,"Calendula",null,"arvensis",null,linne,null,"p.1", null);
202 202
		synName11 = BotanicalName.NewInstance(rankSpecies,"Caltha",null,"arvensis",null,linne,null,"p.11", null);
203 203
		synName12 = BotanicalName.NewInstance(rankSpecies,"Calendula",null,"sancta",null,linne,null,"p.12", null);
204
		
204

  
205 205
		name2 = BotanicalName.NewInstance(rankSpecies,"Calendula",null,"lanzae",null,linne,null,"p.2", null);
206 206
		synName2 = BotanicalName.NewInstance(rankSpecies,"Calendula",null,"echinata",null,linne,null,"p.2", null);
207
		
207

  
208 208
		name21 = BotanicalName.NewInstance(rankSubspecies,"Calendula",null,"lanzea","something",linne,null,"p.1", null);
209 209
		//name211 = BotanicalName.NewInstance(rankSpecies,"Calendula",null,"lanzea",null,linne,null,"p.1", null);
210 210
		//name212 = BotanicalName.NewInstance(rankSpecies,"Calendula",null,"lanzea",null,linne,null,"p.1", null);
211
		
212
		nameRoot2 = 
211

  
212
		nameRoot2 =
213 213
			BotanicalName.NewInstance(rankGenus,"Sonchus",null,null,null,linne,null,"p.200", null);
214 214
		nameR2_1 = BotanicalName.NewInstance(rankSpecies,"Sonchus",null,"child1",null,linne,null,"p.1", null);
215 215
		nameR2_2 = BotanicalName.NewInstance(rankSpecies,"Sonchus",null,"child2",null,linne,null,"p.2", null);
216
		
216

  
217 217
		nameFree = BotanicalName.NewInstance(rankSpecies,"Cichorium",null,"intybus",null,linne,null,"p.200", null);
218 218
		synNameFree = BotanicalName.NewInstance(rankSpecies,"Cichorium",null,"balearicum",null,linne,null,"p.2", null);
219 219

  
......
227 227
		taxonomicNames.add(nameFree);
228 228
		taxonomicNames.add(synNameFree);
229 229
		taxonomicNames.add(nameRoot2);
230
		
230

  
231 231
        // references
232 232
		sec = ReferenceFactory.newBook();
233 233
		sec.setAuthorship(linne);
234 234
		sec.setTitleCache("Plant Specification & Taxonomy", true);
235 235
		references.add(sec);
236
		
236

  
237 237
		citRef = ReferenceFactory.newDatabase();
238 238
		citRef.setAuthorship(linne);
239 239
		citRef.setTitleCache("BioCASE", true);
240 240
		references.add(citRef);
241 241

  
242 242
		// taxa
243
		
243

  
244 244
		root1T = Taxon.NewInstance(nameRoot1, sec);
245 245
		root2T = Taxon.NewInstance(nameRoot2, sec);
246 246
		freeT = Taxon.NewInstance(nameFree, sec);
......
249 249
		child21 = Taxon.NewInstance(name21, sec);
250 250
		childR2_1 = Taxon.NewInstance(nameR2_1, sec);
251 251
		childR2_2 = Taxon.NewInstance(nameR2_2, sec);
252
		
252

  
253 253
		//TaxonInteractions
254
		
254

  
255 255
		TaxonInteraction descBase = TaxonInteraction.NewInstance();
256 256
		descBase.setTaxon2(root1T);
257 257
		Feature hostplant = Feature.HOSTPLANT();
258
		
258

  
259 259
		descBase.setFeature(hostplant);
260 260
		TaxonDescription taxDesc = TaxonDescription.NewInstance();
261 261
		taxDesc.addElement(descBase);
262 262
		root2T.addDescription(taxDesc);
263
		
263

  
264 264
		//locations
265
		
265

  
266 266
		taxDesc = TaxonDescription.NewInstance();
267 267
		Feature locationFeature = Feature.DISTRIBUTION();
268 268

  
269
		
269

  
270 270
		//locationFeature.
271 271
		Country area = Country.NewInstance("", "locationTest", null);
272 272
		area.setType(NamedAreaType.NATURAL_AREA());
273
		
273

  
274 274
		//Country woC= Country.NewInstance();
275 275
		area.addCountry(Country.AFGHANISTAN());
276 276
		taxDesc.addGeoScope(area);
277 277
//		taxDesc.addFeature(locationFeature);   //no longer supported since v3.3
278 278
		root1T.addDescription(taxDesc);
279
		
280
		
279

  
280

  
281 281
		// synonyms
282
		
282

  
283 283
		synFree = Synonym.NewInstance(synNameFree, sec);
284 284
		syn11 = Synonym.NewInstance(synName11, sec);
285 285
		syn12 = Synonym.NewInstance(synName12, sec);
286 286
		syn2 = Synonym.NewInstance(synName2, sec);
287
		
287

  
288 288
		child1.addSynonym(syn11, SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF());
289 289
		child1.addSynonym(syn12, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
290 290
		child2.addSynonym(syn2, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
......
294 294
		taxonBases.add(syn11);
295 295
		taxonBases.add(syn12);
296 296
		taxonBases.add(syn2);
297
		
297

  
298 298
		// taxonomic children
299
		
299

  
300 300
		//TODO: Adapt to classification
301 301
		taxTree = Classification.NewInstance("TestTree");
302
		
302

  
303 303
		root1TNode = taxTree.addChildTaxon(root1T, sec, null);
304 304
		child1Node = root1TNode.addChildTaxon(child1, null, null);
305 305
		child2Node = root1TNode.addChildTaxon(child2, null, null);
306 306
		child21Node = child2Node.addChildTaxon(child21, null, null);
307
		
307

  
308 308
		taxTree2 = Classification.NewInstance("TestTree2");
309
		
309

  
310 310
		root2TNode = taxTree2.addChildTaxon(root2T, sec, null);
311 311
		root2TNode.addChildTaxon(child1, sec, "p.1010").setSynonymToBeUsed(syn11);
312 312
		root2TNode.addChildTaxon(child2, null, null);
313
		
313

  
314 314
		/*
315 315
		root1T.addTaxonomicChild(child1, sec, "p.1010");
316 316
		root1T.addTaxonomicChild(child2, sec, "p.1020");
317 317
		child2.addTaxonomicChild(child21, sec, "p.2000");
318
				
318

  
319 319
		root2T.addTaxonomicChild(child1, sec, "p.1010");
320 320
		root2T.addTaxonomicChild(child2, sec, "p.1020");
321 321
		*/
322 322
		//
323
		
324
		
323

  
324

  
325 325
		taxonBases.add(root1T);
326 326
		taxonBases.add(root2T);
327 327
		taxonBases.add(freeT);
......
330 330
		taxonBases.add(child21);
331 331
		taxonBases.add(childR2_1);
332 332
		taxonBases.add(childR2_2);
333
		
333

  
334 334
		DataSet dataSet = new DataSet();
335
	
335

  
336 336
		logger.warn("WARNING: TestDatabase has been commented in parts. Mainly, must be adapted to classification.");
337
		
337

  
338 338
		dataSet.setTerms(terms);
339 339
		dataSet.setAgents(agents);
340 340
//		dataSet.setAgentData(agentData); //TODO
341 341
		dataSet.setReferences(references);
342 342
		dataSet.setTaxonomicNames(taxonomicNames);
343 343
		dataSet.setTaxonBases((List)taxonBases);
344
		
345
		
344

  
345

  
346 346
		return dataSet;
347 347

  
348 348
	}
app-import/src/main/java/eu/etaxonomy/cdm/app/util/TestTransaction.java
1 1
/**
2 2
* Copyright (C) 2008 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5 5
*/
6 6

  
......
28 28
 * @created 27.10.2008
29 29
 */
30 30
public class TestTransaction {
31
	
31

  
32 32
	private static final String dbName = "cdm_test_jaxb";
33 33
    private static final int MAX_ENTRIES = 20;
34
	
34

  
35 35
	private static final ICdmDataSource db = TestDatabase.CDM_DB(dbName);
36 36
    private static final Logger logger = Logger.getLogger(TestTransaction.class);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff