Project

General

Profile

Revision 48879be4

ID48879be40de56cd6f04a436422399180a3f894bc
Parent 4ed5c440
Child 33ba11bd

Added by Andreas Müller over 4 years ago

Update BgbmInstancesUpdater

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/database/update/BgbmInstancesUpdater.java
1
/**
2
 *
3
 */
4
package eu.etaxonomy.cdm.database.update;
5

  
6
import org.apache.log4j.Logger;
7

  
8
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
9
import eu.etaxonomy.cdm.common.AccountStore;
10
import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor;
11
import eu.etaxonomy.cdm.database.CdmDataSource;
12
import eu.etaxonomy.cdm.database.DbSchemaValidation;
13
import eu.etaxonomy.cdm.database.ICdmDataSource;
14
import eu.etaxonomy.cdm.io.api.application.CdmIoApplicationController;
15
import eu.etaxonomy.cdm.model.taxon.Classification;
16

  
17
/**
18
 * @author a.mueller
19
 *
20
 */
21
public class BgbmInstancesUpdater {
22
	private static final Logger logger = Logger.getLogger(BgbmInstancesUpdater.class);
23

  
24
	private static String integrationServer = "160.45.63.201";
25
	private static String productionServer = "160.45.63.171";
26
//	private static String testServer = "160.45.63.175";
27
	private static String testServer = "edit-test.bgbm.fu-berlin.de";  //preliminary
28

  
29
	private static String[] integrationDatabases = new String[]{/**/"cdm_integration_cichorieae",
30
		"cdm_integration_cyprus", "cdm_integration_diptera",  "cdm_integration_flora_malesiana",
31
		"cdm_integration_palmae"};
32

  
33
	private static String[] testDatabases = new String[]{
34
	    "cdm_bgbm_edit_usergroup",
35
	    "cdm_campanulaceae",
36
		"cdm_campanulaceae_082014","cdm_caryo", "cdm_col","cdm_corvidae","cdm_cyprus","cdm_demo1","cdm_demo2",
37
		"cdm_demo3", "cdm_edit_algaterra","cdm_edit_cichorieae","cdm_edit_ildis","cdm_edit_flora_central_africa",
38
		"cdm_flora_guianas","cdm_flore_gabon","cdm_edit_flora_malesiana","cdm_edit_globis","cdm_edit_palmae",
39
		"cdm_ipni_Caryophyllaceae","cdm_mt_moose","cdm_mt_standardliste",
40
		"cdm_pesi_euromed", "cdm_pesi_erms","cdm_pesi_fauna_europaea",
41
		"cdm_proibiosphere_chenopodium_pilot",
42
		"cdm_rl_animalia","cdm_rl_mammalia","cdm_rl_planta",
43
		"cdm_test_eckhard","cdm_test_euromed","cdm_test_gabi",
44
		"cdm_test_norbert","cdm_test_sabine",
45
		"cdm_vibrant_index"
46
		};
47

  
48
	private static String[] testDatabasesOthers = new String[]{"cdm_caryo_amaranthaceae",
49
		"cdm_caryo_caryophyllales","cdm_flora_malesiana_prospective","cdm_pesi_all","cdm_salvador",
50
		};
51

  
52
	private static String[] productionDatabases = new String[]{
53
		"cdm_production_acantholimon","cdm_production_algaterra",
54
		"cdm_production_amaranthaceae","cdm_production_cactaceae",
55
		"cdm_production_campanulaceae","cdm_production_caryophyllales",
56
		"cdm_production_chenopodiaceae","cdm_production_cichorieae",
57
		"cdm_production_col",
58
		"cdm_production_corvidae","cdm_production_cyprus",
59
		"cdm_production_dianthus","cdm_production_diptera",
60
		"cdm_production_euromed",
61
		"cdm_production_flora_central_africa","cdm_production_flora_guianas",
62
		"cdm_production_flora_malesiana","cdm_production_flora_malesiana_prospective",
63
		"cdm_production_flore_gabon",
64
		"cdm_production_globis","cdm_production_nyctaginaceae",
65
		"cdm_production_palmae","cdm_production_piB_campylopus_pilot",
66
		"cdm_production_piB_eupolybothrus_pilot","cdm_production_piB_lactarius_pilot",
67
		"cdm_production_piB_loranthaceae","cdm_production_piB_nephrolepis_pilot",
68
		"cdm_production_piB_ants_pilot","cdm_production_piB_chenopodium_pilot",
69
		"cdm_production_piB_spiders_pilot",
70
		"cdm_production_polygonaceae",
71
		"cdm_production_rl_animalis",  //not yet filled
72
		"cdm_production_rl_armeria_demo", "cdm_production_rl_lumbricidae",
73
		"cdm_production_rl_standardliste", "cdm_production_rl_moose",
74
		"cdm_production_tamaricaceae","cdm_production_vibrant_index"
75
	    };
76

  
77

  
78
	static BgbmServer bgbmServer = BgbmServer.TEST;
79

  
80

  
81

  
82
	static String username = "edit";
83

  
84

  
85

  
86
	/**
87
	 * @param args
88
	 */
89
	public static void  main(String[] args) {
90
		DbSchemaValidation schema = DbSchemaValidation.VALIDATE;
91
    	String server = bgbmServer.server;
92
    	for (String database : bgbmServer.databases){
93
    		boolean result = true;
94
    		logger.warn("Update: " + database + " ... ");
95
    		ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
96
    		try {
97
    			CdmUpdater updater = new CdmUpdater();
98
    			result = updater.updateToCurrentVersion(dataSource, DefaultProgressMonitor.NewInstance());
99
    			CdmApplicationController appCtr = CdmIoApplicationController.NewInstance(dataSource,schema);
100
    			System.out.println(appCtr.getClassificationService().count(Classification.class));
101
    		} catch (Exception e) {
102
    			result = false;
103
    			e.printStackTrace();
104
    		}
105
    		if(!result ){
106
    			logger.warn("Problem");
107
    			break;
108
    		}
109

  
110
    		logger.warn("Update: " + database + " ... DONE ");
111
    	}
112

  
113

  
114
	}
115

  
116
	private enum BgbmServer{
117
		INTEGRATION (integrationServer, integrationDatabases),
118
		TEST(testServer,testDatabases),
119
		PRODUCTION(productionServer,productionDatabases);
120
		private final String server;
121
		private final String[] databases;
122
		private BgbmServer(String server, String[] databases){
123
			this.server = server;
124
			this.databases = databases;
125
		}
126

  
127
	}
128
}
1
/**
2
 *
3
 */
4
package eu.etaxonomy.cdm.database.update;
5

  
6
import org.apache.log4j.Logger;
7

  
8
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
9
import eu.etaxonomy.cdm.common.AccountStore;
10
import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor;
11
import eu.etaxonomy.cdm.database.CdmDataSource;
12
import eu.etaxonomy.cdm.database.DbSchemaValidation;
13
import eu.etaxonomy.cdm.database.ICdmDataSource;
14
import eu.etaxonomy.cdm.io.api.application.CdmIoApplicationController;
15
import eu.etaxonomy.cdm.model.taxon.Classification;
16

  
17
/**
18
 * @author a.mueller
19
 *
20
 */
21
public class BgbmInstancesUpdater {
22
	private static final Logger logger = Logger.getLogger(BgbmInstancesUpdater.class);
23

  
24
	private static String integrationServer = "160.45.63.201";
25
	private static String productionServer = "160.45.63.171";
26
//	private static String testServer = "160.45.63.175";
27
	private static String testServer = "edit-test.bgbm.fu-berlin.de";  //preliminary
28

  
29
	private static String[] integrationDatabases = new String[]{/**/"cdm_integration_cichorieae",
30
		"cdm_integration_cyprus", "cdm_integration_diptera",  "cdm_integration_flora_malesiana",
31
		"cdm_integration_palmae"};
32

  
33
	private static String[] testDatabases = new String[]{
34
	    "cdm_Test_Caryophyllales", "cdm_bgbm_edit_usergroup",
35
	    "cdm_campanulaceae", "cdm_campanulaceae_082014",
36
//	    "cdm_caryo_amaranthaceae", "cdm_caryo_caryophyllales",  //veraltete Versionen
37
	    "cdm_caryophyllales", "cdm_caryophyllales_tcs","cdm_caryophyllales_ws",
38
		"cdm_col","cdm_corvidae", "cdm_cyprus","cdm_edaphobase_test",
39
		"cdm_edit_algaterra", "cdm_edit_cichorieae",
40
//		"cdm_edit_diptera",    //veraltete Versionen
41
		"cdm_edit_flora_central_africa", "cdm_edit_flora_malesiana",
42
		"cdm_edit_globis", "cdm_edit_palmae",
43
		"cdm_flora_cuba", "cdm_flora_guianas",
44
//	   "cdm_flora_malesiana_prospective",    //veraltete Versionen
45
		"cdm_flore_gabon", "cdm_ipni_Caryophyllaceae",
46
		"cdm_mt_moose", "cdm_mt_standardliste",
47
		"cdm_pesi_erms", "cdm_pesi_euromed", "cdm_pesi_fauna_europaea",
48
		"cdm_proibiosphere_chenopodium_pilot",
49
		"cdm_rem_conf_ak", "cdm_rem_conf_am", "cdm_rem_conf_kl", "cdm_rem_conf_pp",
50
		"cdm_rl_animalia","cdm_rl_mammalia", "cdm_rl_plantae",
51
//		"cdm_salvador",    //leer
52
		"cdm_vibrant_index"
53
		};
54

  
55
	private static String[] testDatabasesOthers = new String[]{"cdm_caryo_amaranthaceae",
56
		"cdm_caryo_caryophyllales","cdm_flora_malesiana_prospective","cdm_pesi_all","cdm_salvador",
57
		};
58

  
59
	private static String[] productionDatabases = new String[]{
60
		"cdm_production_acantholimon","cdm_production_algaterra",
61
		"cdm_production_amaranthaceae","cdm_production_cactaceae",
62
		"cdm_production_campanulaceae","cdm_production_caryophyllales",
63
		"cdm_production_chenopodiaceae","cdm_production_cichorieae",
64
		"cdm_production_col",
65
		"cdm_production_corvidae","cdm_production_cyprus",
66
		"cdm_production_dianthus","cdm_production_diptera",
67
		"cdm_production_euromed",
68
		"cdm_production_flora_central_africa","cdm_production_flora_guianas",
69
		"cdm_production_flora_malesiana","cdm_production_flora_malesiana_prospective",
70
		"cdm_production_flore_gabon",
71
		"cdm_production_globis","cdm_production_nyctaginaceae",
72
		"cdm_production_palmae","cdm_production_piB_campylopus_pilot",
73
		"cdm_production_piB_eupolybothrus_pilot","cdm_production_piB_lactarius_pilot",
74
		"cdm_production_piB_loranthaceae","cdm_production_piB_nephrolepis_pilot",
75
		"cdm_production_piB_ants_pilot","cdm_production_piB_chenopodium_pilot",
76
		"cdm_production_piB_spiders_pilot",
77
		"cdm_production_polygonaceae",
78
		"cdm_production_rl_animalis",  //not yet filled
79
		"cdm_production_rl_armeria_demo", "cdm_production_rl_lumbricidae",
80
		"cdm_production_rl_standardliste", "cdm_production_rl_moose",
81
		"cdm_production_tamaricaceae","cdm_production_vibrant_index"
82
	    };
83

  
84

  
85
	static BgbmServer bgbmServer = BgbmServer.TEST;
86

  
87

  
88

  
89
	static String username = "edit";
90

  
91

  
92

  
93
	/**
94
	 * @param args
95
	 */
96
	public static void  main(String[] args) {
97
		DbSchemaValidation schema = DbSchemaValidation.VALIDATE;
98
    	String server = bgbmServer.server;
99
    	for (String database : bgbmServer.databases){
100
    	    boolean result = true;
101
    		logger.warn("Update: " + database + " ... ");
102
    		ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
103
    		try {
104
    			CdmUpdater updater = new CdmUpdater();
105
    			result = updater.updateToCurrentVersion(dataSource, DefaultProgressMonitor.NewInstance());
106
    			CdmApplicationController appCtr = CdmIoApplicationController.NewInstance(dataSource,schema);
107
    			System.out.println(appCtr.getClassificationService().count(Classification.class));
108
    		} catch (Exception e) {
109
    			result = false;
110
    			e.printStackTrace();
111
    		}
112
    		if(!result ){
113
    			logger.warn("Problem");
114
    			System.exit(1);
115
    		}
116

  
117
    		logger.warn("Update: " + database + " ... DONE ");
118
    	}
119
    	System.exit(0);
120
	}
121

  
122
	private enum BgbmServer{
123
		INTEGRATION (integrationServer, integrationDatabases),
124
		TEST(testServer,testDatabases),
125
		PRODUCTION(productionServer,productionDatabases);
126
		private final String server;
127
		private final String[] databases;
128
		private BgbmServer(String server, String[] databases){
129
			this.server = server;
130
			this.databases = databases;
131
		}
132

  
133
	}
134
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)