Project

General

Profile

« Previous | Next » 

Revision eec1cd2d

Added by Andreas Müller about 7 years ago

ref #6410 add NepenthaceaeActivator

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/edaphobase/EdaphobaseActivator.java
37 37
    //database validation status (create, update, validate ...)
38 38
    static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.CREATE;
39 39

  
40
    static final Source edaphoSource = CdmImportSources.EDAPHOBASE2();
40
    static final Source edaphoSource = CdmImportSources.EDAPHOBASE();
41 41

  
42 42
//    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
43 43
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_edaphobase();
app-import/src/main/java/eu/etaxonomy/cdm/app/redlist/GermanSLActivator.java
36 36

  
37 37
//    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
38 38
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
39
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_germanSL_preview();
40
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_germanSL_production();
39
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_germanSL_preview();
40
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_germanSL_production();
41 41

  
42 42
    static String versionString = "version_1_3_4";
43 43

  
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraSpecimenImportBase.java
343 343
	protected abstract String getFieldObservationNameSpace();
344 344

  
345 345

  
346
	protected DescriptionBase getFieldObservationDescription(DerivedUnitFacade facade) {
347
		Set<DescriptionBase> descriptions = facade.innerFieldUnit().getDescriptions();
348
		for (DescriptionBase desc : descriptions){
346
	protected DescriptionBase<?> getFieldObservationDescription(DerivedUnitFacade facade) {
347
		Set<DescriptionBase<?>> descriptions = (Set)facade.innerFieldUnit().getDescriptions();
348
		for (DescriptionBase<?> desc : descriptions){
349 349
			if (desc.isImageGallery() == false){
350 350
				return desc;
351 351
			}
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseImportTransformer.java
55 55
        else if (key.equals("Form")){return Rank.FORM();}
56 56
        else if (key.equals("Infraorder")){return Rank.INFRAORDER();}
57 57
//        else if (key.equals("Hyporder")){return Rank.HYPORDER();}
58
//        else if (key.equals("Group")){return Rank.GROUP();}
58
//        else if (key.equals("Group")){return Rank.GREX();}
59 59
        return null;
60 60
    }
61 61

  
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseTaxonImport.java
211 211
     */
212 212
    private void checkRankMarker(EdaphobaseImportState state, Rank rank) throws UndefinedTransformerMethodException {
213 213

  
214
        Set<Marker> markers = rank.getMarkers();
215
        if ( markers.size() == 0){  //we assume that no markers exist. at least not for markers of unused ranks
216
            UUID edaphoRankMarkerTypeUuid = state.getTransformer().getMarkerTypeUuid("EdaphoRankMarker");
217
            MarkerType marker = getMarkerType(state, edaphoRankMarkerTypeUuid, "Edaphobase rank", "Rank used in Edaphobase", "EdaRk" );
218
            Representation rep = Representation.NewInstance("Rang, verwendet in Edaphobase", "Edaphobase Rang", "EdaRg", Language.GERMAN());
219
            marker.addRepresentation(rep);
220
            rank.addMarker(Marker.NewInstance(marker, true));
221
            getTermService().saveOrUpdate(rank);
214
        if (rank != null){
215
            Set<Marker> markers = rank.getMarkers();
216
            if ( markers.size() == 0){  //we assume that no markers exist. at least not for markers of unused ranks
217
                UUID edaphoRankMarkerTypeUuid = state.getTransformer().getMarkerTypeUuid("EdaphoRankMarker");
218
                MarkerType marker = getMarkerType(state, edaphoRankMarkerTypeUuid, "Edaphobase rank", "Rank used in Edaphobase", "EdaRk" );
219
                Representation rep = Representation.NewInstance("Rang, verwendet in Edaphobase", "Edaphobase Rang", "EdaRg", Language.GERMAN());
220
                marker.addRepresentation(rep);
221
                rank.addMarker(Marker.NewInstance(marker, true));
222
                getTermService().saveOrUpdate(rank);
223
            }
224
        }else{
225
            logger.warn("Rank is null and marker can not be set");
222 226
        }
223 227
    }
224 228

  
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CdmDestinations.java
99 99
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
100 100
	}
101 101

  
102
    public static ICdmDataSource cdm_nepenthes_production(){
103
        DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
104
        String cdmServer = "160.45.63.171";
105
        String cdmDB = "cdm_production_caryo_nepenthaceae";
106
        String cdmUserName = "edit";
107
        return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
108
    }
109

  
102 110
	public static ICdmDataSource cdm_flora_malesiana_prospective_production(){
103 111
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
104 112
		String cdmServer = "160.45.63.171";
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/NepenthesActivator.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.app.eflora;
11

  
12
import java.net.URI;
13
import java.util.Arrays;
14
import java.util.HashSet;
15
import java.util.List;
16
import java.util.Set;
17
import java.util.UUID;
18

  
19
import org.apache.log4j.Logger;
20
import org.springframework.transaction.TransactionStatus;
21

  
22
import eu.etaxonomy.cdm.api.service.ITermService;
23
import eu.etaxonomy.cdm.database.DbSchemaValidation;
24
import eu.etaxonomy.cdm.database.ICdmDataSource;
25
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
26
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
27
import eu.etaxonomy.cdm.io.common.events.IIoObserver;
28
import eu.etaxonomy.cdm.io.common.events.LoggingIoObserver;
29
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
30
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
31
import eu.etaxonomy.cdm.io.eflora.floraMalesiana.FloraMalesianaTransformer;
32
import eu.etaxonomy.cdm.io.markup.MarkupImportConfigurator;
33
import eu.etaxonomy.cdm.model.description.Feature;
34
import eu.etaxonomy.cdm.model.description.FeatureNode;
35
import eu.etaxonomy.cdm.model.description.FeatureTree;
36
import eu.etaxonomy.cdm.model.description.PolytomousKey;
37
import eu.etaxonomy.cdm.model.reference.Reference;
38
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
39

  
40
/**
41
 * @author a.mueller
42
 * @created 20.06.2008
43
 */
44
public class NepenthesActivator extends EfloraActivatorBase {
45
	private static final Logger logger = Logger.getLogger(NepenthesActivator.class);
46

  
47
	//database validation status (create, update, validate ...)
48
	static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
49

  
50
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_nepenthes_production();
51
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
52
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
53
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
54

  
55
	//1775   /   16415
56
	//no syso, 5 uncovered, 2 of them epiphytic
57
//	private final boolean includeVol15 = includeBase;
58

  
59
    static final URI fmSource15 = EfloraSources.fm_15();
60

  
61
	private final boolean h2ForCheck = true;
62

  
63
	static final boolean reuseState = true;  //when running multiple imports
64

  
65
	//feature tree uuid
66
	public static final UUID featureTreeUuid = UUID.fromString("ef2e2978-1ea4-44d2-a819-4e79b372b9b7");
67
	private static final String featureTreeTitle = "Nepenthes Feature Tree";
68

  
69
	//classification
70
	static final UUID classificationUuid = UUID.fromString("a245793a-a70f-4fcf-a626-dd4aa6d2aa1c");
71
	static final String classificationTitle = "Nepenthes";
72

  
73
	//check - import
74
	static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
75

  
76
	static boolean doPrintKeys = false;
77

  
78
	//taxa
79
	static final boolean doTaxa = true;
80

  
81
	private final boolean replaceStandardKeyTitles = false;
82

  
83
	private final IIoObserver observer = new LoggingIoObserver();
84
	private final Set<IIoObserver> observerList = new HashSet<>();
85

  
86

  
87
	private void doImport(ICdmDataSource cdmDestination){
88
		observerList.add(observer);
89
		if (h2ForCheck && cdmDestination.getDatabaseType().equals(CdmDestinations.localH2().getDatabaseType())){
90
			check = CHECK.CHECK_ONLY;
91
		}
92

  
93
		//make Source
94
//		URI source = fmSource13_small;
95
		URI source = null;
96

  
97
		MarkupImportConfigurator markupConfig= MarkupImportConfigurator.NewInstance(source, cdmDestination);
98
		markupConfig.setClassificationUuid(classificationUuid);
99
		markupConfig.setClassificationName(classificationTitle);
100
		markupConfig.setDoTaxa(doTaxa);
101
		markupConfig.setCheck(check);
102
		markupConfig.setDoPrintKeys(doPrintKeys);
103
		markupConfig.setDbSchemaValidation(hbm2dll);
104
		markupConfig.setObservers(observerList);
105
		markupConfig.setReplaceStandardKeyTitles(replaceStandardKeyTitles);
106
		markupConfig.setReuseExistingState(reuseState);
107
		markupConfig.setKnownCollections(getKnownCollections());
108

  
109
		markupConfig.setSourceReference(getSourceReference("Flora Malesiana - Vol. 13"));
110

  
111
		CdmDefaultImport<MarkupImportConfigurator> myImport = new CdmDefaultImport<>();
112

  
113

  
114
		//Vol15
115
		doSource(true, fmSource15, "Flora Malesiana - vol. 15", markupConfig, myImport);
116

  
117

  
118
		makeAutomatedFeatureTree(myImport.getCdmAppController(), markupConfig.getState(),
119
				featureTreeUuid, featureTreeTitle);
120

  
121
//		makeGeoService();
122

  
123
		FeatureTree tree = makeFeatureNode(myImport.getCdmAppController().getTermService());
124
		myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);
125

  
126
		//check keys
127
		if (doPrintKeys){
128
			TransactionStatus tx = myImport.getCdmAppController().startTransaction();
129
			List<PolytomousKey> keys = myImport.getCdmAppController().getPolytomousKeyService().list(PolytomousKey.class, null, null, null, null);
130
			for(PolytomousKey key : keys){
131
				key.print(System.out);
132
				System.out.println();
133
			}
134
			myImport.getCdmAppController().commitTransaction(tx);
135
		}
136

  
137
	}
138

  
139
	/**
140
     * @return
141
     */
142
    private List<String> getKnownCollections() {
143
        List<String> result = Arrays.asList(new String[]
144
                {"Nippon Dental College","Nagoya","Sabah National Parks Herbarium"}) ;
145
        return result;
146
    }
147

  
148
    private void doSource(boolean doInclude, URI source, String sourceTitle, MarkupImportConfigurator markupConfig,
149
			CdmDefaultImport<MarkupImportConfigurator> myImport) {
150
		if (doInclude){
151
			System.out.println("\nStart import from ("+ source.toString() + ") ...");
152
			markupConfig.setSource(source);
153
			markupConfig.setSourceReference(getSourceReference(sourceTitle));
154
			myImport.invoke(markupConfig);
155
			System.out.println("End import from ("+ source.toString() + ")...");
156
		}
157
	}
158

  
159
	private Reference getSourceReference(String string) {
160
		Reference result = ReferenceFactory.newGeneric();
161
		result.setTitleCache(string, true);
162
		return result;
163
	}
164

  
165
	private FeatureTree makeFeatureNode(ITermService service){
166
		FloraMalesianaTransformer transformer = new FloraMalesianaTransformer();
167

  
168
		FeatureTree result = FeatureTree.NewInstance(UUID.randomUUID());
169
		result.setTitleCache("Flora Malesiana Presentation Feature Tree - Old", true);
170
		FeatureNode root = result.getRoot();
171
		FeatureNode newNode;
172

  
173
		newNode = FeatureNode.NewInstance(Feature.DESCRIPTION());
174
		root.addChild(newNode);
175

  
176
		addFeataureNodesByStringList(descriptionFeatureList, newNode, transformer, service);
177

  
178
		addFeataureNodesByStringList(generellDescriptionsUpToAnatomyList, root, transformer, service);
179
		newNode = FeatureNode.NewInstance(Feature.ANATOMY());
180
		addFeataureNodesByStringList(anatomySubfeatureList, newNode, transformer, service);
181

  
182
		newNode = addFeataureNodesByStringList(generellDescriptionsFromAnatomyToPhytoChemoList, root, transformer, service);
183
		addFeataureNodesByStringList(phytoChemoSubFeaturesList, newNode, transformer, service);
184

  
185
		newNode = addFeataureNodesByStringList(generellDescriptionsFromPhytoChemoList, root, transformer, service);
186

  
187

  
188
		newNode = FeatureNode.NewInstance(Feature.DISTRIBUTION());
189
		root.addChild(newNode);
190

  
191
		newNode = FeatureNode.NewInstance(Feature.ECOLOGY());
192
		root.addChild(newNode);
193
		addFeataureNodesByStringList(habitatEcologyList, root, transformer, service);
194

  
195
		newNode = FeatureNode.NewInstance(Feature.USES());
196
		root.addChild(newNode);
197

  
198
		addFeataureNodesByStringList(chomosomesList, root, transformer, service);
199

  
200
		newNode = FeatureNode.NewInstance(Feature.CITATION());
201
		root.addChild(newNode);
202

  
203
		return result;
204
	}
205

  
206
	private static String [] chomosomesList = new String[]{
207
		"Chromosomes",
208
	};
209

  
210

  
211
	private static String [] habitatEcologyList = new String[]{
212
		"Habitat",
213
		"Habitat & Ecology"
214
	};
215

  
216

  
217
	private static String [] generellDescriptionsUpToAnatomyList = new String[]{
218
		"Fossils",
219
		"Morphology and anatomy",
220
		"Morphology",
221
		"Vegetative morphology and anatomy",
222
	};
223

  
224

  
225
	private static String [] anatomySubfeatureList = new String[]{
226
		"Leaf anatomy",
227
		"Wood anatomy"
228
	};
229

  
230
	private static String [] generellDescriptionsFromAnatomyToPhytoChemoList = new String[]{
231
		"Flower morphology",
232
		"Palynology",
233
		"Pollination",
234
		"Pollen morphology",
235
		"embryology",
236
		"cytology",
237
		"Life cycle",
238
		"Fruits and embryology",
239
		"Dispersal",
240
		"Chromosome numbers",
241
		"Phytochemistry and Chemotaxonomy",
242
	};
243

  
244

  
245
	private static String [] phytoChemoSubFeaturesList = new String[]{
246
		"Alkaloids",
247
		"Iridoid glucosides",
248
		"Leaf phenolics",
249
		"Storage products of seeds",
250
		"Aluminium",
251
		"Chemotaxonomy",
252
	};
253

  
254

  
255
	private static String [] generellDescriptionsFromPhytoChemoList = new String[]{
256
		"Phytochemistry",
257
		"Taxonomy",
258
		"history",
259
		"cultivation",
260
		"Notes"
261
	};
262

  
263

  
264
	private static String [] descriptionFeatureList = new String[]{
265
		"lifeform",
266
		"Bark",
267
		//new
268
		"wood",
269
		"Indumentum",
270
		"endophytic body",
271
		"flowering buds",
272
		"Branchlets",
273
		"Branches",
274
		"Branch",
275
		"Flowering branchlets",
276
		"Trees",
277
		"Twigs",
278
		"stem",
279
		"Stems",
280
		"stem leaves",
281
		"Leaves",
282
		"flower-bearing stems",
283
		"Petiole",
284
		"Petiolules",
285
		"Leaflets",
286
		"Thyrsus",
287
		"Thyrses",
288
		"Inflorescences",
289
		"Inflorescence",
290
		"Young inflorescences",
291
		"Male inflorescences",
292
		"Female inflorescences",
293
		"Bracts",
294
		"Pedicels",
295
		"flowering buds",
296
		"scales",
297
		"Buds",
298
		"Flowers",
299
		"Flower",
300
		"Flowering",
301
		"Stigma",
302
		"perianth",
303
		"Sepals",
304
		"Sepal",
305
		"Outer Sepals",
306
		"Axillary",
307
		"cymes",
308
		"Calyx",
309
		"Petal",
310
		"Petals",
311
		"perigone",
312
		"perigone lobes",
313
		"perigone tube",
314
		"Disc",
315
		"corolla",
316
		"Stamens",
317
		"Staminodes",
318
		"Ovary",
319
		"Anthers",
320
		"anther",
321
		"Pistil",
322
		"Pistillode",
323
		"Ovules",
324
		"androecium",
325
		"gynoecium",
326
		"Filaments",
327
		"Style",
328
		"annulus",
329
		"female flowers",
330
		"Male flowers",
331
		"Female",
332
		"Infructescences",    //order not consistent (sometimes before "Flowers")
333
		"Fruit",
334
		"Fruits",
335
		"fruiting axes",
336
		"drupes",
337
		"Arillode",
338
		"seed",
339
		"Seeds",
340
		"Seedling",
341
		"flower tube",
342
		"nutlets",
343
		"pollen",
344
		"secondary xylem",
345
		"chromosome number",
346

  
347
		"figure",
348
		"fig",
349
		"figs",
350

  
351

  
352

  
353
	};
354

  
355
	public FeatureNode addFeataureNodesByStringList(String[] featureStringList, FeatureNode root, IInputTransformer transformer, ITermService termService){
356
		FeatureNode lastChild = null;
357
		try {
358
			for (String featureString : featureStringList){
359
				UUID featureUuid;
360
				featureUuid = transformer.getFeatureUuid(featureString);
361
				Feature feature = (Feature)termService.find(featureUuid);
362
				if (feature != null){
363
					FeatureNode child = FeatureNode.NewInstance(feature);
364
					root.addChild(child);
365
				}
366
			}
367

  
368
		} catch (UndefinedTransformerMethodException e) {
369
			logger.error("getFeatureUuid is not implemented in transformer. Features could not be added");
370
		}
371
		return lastChild;
372
	}
373

  
374

  
375

  
376
	/**
377
	 * @param args
378
	 */
379
	public static void main(String[] args) {
380
		NepenthesActivator me = new NepenthesActivator();
381
		me.doImport(cdmDestination);
382
		System.exit(0);
383
	}
384

  
385
}

Also available in: Unified diff