3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.database
.update
;
12 import org
.apache
.log4j
.Logger
;
14 import eu
.etaxonomy
.cdm
.common
.DefaultProgressMonitor
;
15 import eu
.etaxonomy
.cdm
.common
.IProgressMonitor
;
16 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
23 public class CdmUpdater
{
24 private static final Logger logger
= Logger
.getLogger(CdmUpdater
.class);
30 public boolean updateToCurrentVersion(ICdmDataSource datasource
, IProgressMonitor monitor
){
31 boolean result
= true;
33 monitor
= DefaultProgressMonitor
.NewInstance();
36 ISchemaUpdater currentSchemaUpdater
= getCurrentSchemaUpdater();
37 ITermUpdater currentTermUpdater
= getCurrentTermUpdater();
39 int steps
= currentSchemaUpdater
.countSteps(datasource
);
40 steps
+= currentTermUpdater
.countSteps(datasource
);
42 String taskName
= "Update to schema version ... and to term version ... "; //+ currentSchemaUpdater.getVersion();
43 monitor
.beginTask(taskName
, steps
);
46 result
&= currentSchemaUpdater
.invoke(datasource
, monitor
);
47 result
&= currentTermUpdater
.invoke(datasource
, monitor
);
48 } catch (Exception e
) {
49 monitor
.warning("Stopped schema updater");
55 private ITermUpdater
getCurrentTermUpdater() {
56 return TermUpdater_3_0
.NewInstance();
60 * Returns the current CDM updater
63 private ISchemaUpdater
getCurrentSchemaUpdater() {
64 return SchemaUpdater_3_0
.NewInstance();
72 public static void main(String
[] args
) {
73 logger
.warn("main method not yet implemented");
74 CdmUpdater myUpdater
= new CdmUpdater();
75 // myUpdater.updateToCurrentVersion(datasource, monitor);