Project

General

Profile

« Previous | Next » 

Revision 7691ed2a

Added by Andreas Müller almost 5 years ago

ref #8257 remove factory method for term node creation in app-import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/berlinModelImport/MTStandardlisteActivator.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
	*/
......
24 24
import eu.etaxonomy.cdm.io.common.Source;
25 25
import eu.etaxonomy.cdm.model.description.Feature;
26 26
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
27
import eu.etaxonomy.cdm.model.term.FeatureNode;
28 27
import eu.etaxonomy.cdm.model.term.FeatureTree;
29 28

  
30 29
public class MTStandardlisteActivator {
31
	
30

  
32 31

  
33 32

  
34 33
	/**
35 34
	 * TODO add the following to a wiki page:
36
	 * HINT: If you are about to import into a mysql data base running under windows and if you wish to dump and restore the resulting data bas under another operation systen 
35
	 * HINT: If you are about to import into a mysql data base running under windows and if you wish to dump and restore the resulting data bas under another operation systen
37 36
	 * you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
38
	 * 
39
	 * 
37
	 *
38
	 *
40 39
	 * @author a.mueller
41 40
	 *
42 41
	 */
......
48 47
		static final Source berlinModelSource = BerlinModelSources.MT_Standardliste();
49 48
		static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_test_mysql_standardliste();
50 49
//		static final ICdmDataSource cdmDestination = CdmDestinations.cdm_mt_standardliste();
51
		
50

  
52 51
		static final UUID treeUuid = UUID.fromString("70549f1a-3d30-42ae-8257-c8367e2703b0");
53 52
		static final int sourceSecId = 7331;
54 53
		static final UUID sourceRefUuid = UUID.fromString("33baaf62-f5c4-4260-aacb-090fe4d24206");
55
		
54

  
56 55
		static final UUID featureTreeUuid = UUID.fromString("2b592057-de3a-4782-a6f3-90a87e2a004d");
57
		static final Object[] featureKeyList = new Integer[]{7,201,202,203,204,205,206,207}; 
58
		
59
		static final boolean includeFlatClassifications = true; 
56
		static final Object[] featureKeyList = new Integer[]{7,201,202,203,204,205,206,207};
57

  
58
		static final boolean includeFlatClassifications = true;
59

  
60 60

  
61
		
62 61
		//check - import
63 62
		static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
64 63

  
65
		
64

  
66 65

  
67 66
		//NomenclaturalCode
68 67
		static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICNAFP;
69 68

  
70 69
	// ****************** ALL *****************************************
71
		
70

  
72 71
		//authors
73 72
		static final boolean doAuthors = true;
74 73
		//references
......
77 76
		static final boolean doTaxonNames = true;
78 77
		static final boolean doRelNames = true;
79 78
		static final boolean doNameStatus = false;
80
		static final boolean doTypes = false;  
81
		static final boolean doNameFacts = false;   
82
		
79
		static final boolean doTypes = false;
80
		static final boolean doNameFacts = false;
81

  
83 82
		//taxa
84 83
		static final boolean doTaxa = true;
85 84
		static final boolean doRelTaxa = true;
......
91 90

  
92 91

  
93 92
	// ************************ NONE **************************************** //
94
		
93

  
95 94
//		//authors
96 95
//		static final boolean doAuthors = false;
97 96
//		//references
......
102 101
//		static final boolean doNameStatus = false;
103 102
//		static final boolean doTypes = false;
104 103
//		static final boolean doNameFacts = false;
105
	//	
104
	//
106 105
//		//taxa
107 106
//		static final boolean doTaxa = false;
108 107
//		static final boolean doRelTaxa = false;
109 108
//		static final boolean doFacts = false;
110 109
//		static final boolean doOccurences = false;
111 110
//		static final boolean doCommonNames = false;
112
		
113
		
111

  
112

  
114 113
		public void invoke(String[] args){
115 114
			System.out.println("Start import from BerlinModel("+ berlinModelSource.getDatabase() + ") ...");
116 115
			logger.debug("Start");
117 116
			//make BerlinModel Source
118 117
			Source source = berlinModelSource;
119 118
			ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
120
			
119

  
121 120
			BerlinModelImportConfigurator config = BerlinModelImportConfigurator.NewInstance(source,  destination);
122
			
121

  
123 122
			config.setClassificationUuid(treeUuid);
124 123
			config.setSourceSecId(sourceSecId);
125 124
			config.setNomenclaturalCode(nomenclaturalCode);
......
131 130
			config.setDoNameStatus(doNameStatus);
132 131
			config.setDoTypes(doTypes);
133 132
			config.setDoNameFacts(doNameFacts);
134
			
133

  
135 134
			config.setDoTaxa(doTaxa);
136 135
			config.setDoRelTaxa(doRelTaxa);
137 136
			config.setDoFacts(doFacts);
138 137
			config.setDoOccurrence(doOccurences);
139 138
			config.setDoCommonNames(doCommonNames);
140 139
			config.setSourceRefUuid(sourceRefUuid);
141
			
140

  
142 141
			config.setDbSchemaValidation(hbm2dll);
143 142
			config.setIncludeFlatClassifications(includeFlatClassifications);
144 143
			config.setIncludeAllNonMisappliedRelatedClassifications(includeAllNonMisappliedRelatedClassifications);
145 144

  
146 145
			config.setCheck(check);
147
			
146

  
148 147
			// invoke import
149 148
			CdmDefaultImport<BerlinModelImportConfigurator> bmImport = new CdmDefaultImport<BerlinModelImportConfigurator>();
150 149
			bmImport.invoke(config);
151 150

  
152 151
			if (doFacts && (config.getCheck().equals(CHECK.CHECK_AND_IMPORT)  || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) )   ){
153 152
				ICdmRepository app = bmImport.getCdmAppController();
154
				
153

  
155 154
				//make feature tree
156
				FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, config.getFeatureMap(), featureKeyList);
157
				FeatureNode imageNode = FeatureNode.NewInstance(Feature.IMAGE());
158
				tree.getRoot().addChild(imageNode);
159
				FeatureNode distributionNode = FeatureNode.NewInstance(Feature.DISTRIBUTION());
160
				tree.getRoot().addChild(distributionNode, 2); 
155
				FeatureTree<Feature> tree = TreeCreator.flatTree(featureTreeUuid, config.getFeatureMap(), featureKeyList);
156
				tree.getRoot().addChild(Feature.IMAGE());
157
				tree.getRoot().addChild(Feature.DISTRIBUTION(), 2);
161 158
				app.getFeatureTreeService().saveOrUpdate(tree);
162 159
			}
163
			
164
			
160

  
161

  
165 162
			System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")...");
166 163
		}
167
		
168
		
164

  
165

  
169 166
		/**
170 167
		 * @param args
171 168
		 */

Also available in: Unified diff