001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-setup/org/opencms/setup/update6to7/generic/CmsUpdateDBNewTables.java,v $
003: * Date : $Date: 2008-02-27 12:05:35 $
004: * Version: $Revision: 1.2 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.setup.update6to7.generic;
033:
034: import org.opencms.setup.CmsSetupDb;
035: import org.opencms.setup.update6to7.A_CmsUpdateDBPart;
036:
037: import java.io.IOException;
038: import java.sql.SQLException;
039: import java.util.ArrayList;
040: import java.util.Iterator;
041: import java.util.List;
042:
043: /**
044: * This class creates the new tables for the database version of OpenCms 7.<p>
045: *
046: * The new tables are
047: * CMS_OFFLINE_RESOURCE_RELATIONS
048: * CMS_ONLINE_RESOURCE_RELATOINS
049: * CMS_PUBLISH_JOBS
050: * CMS_RESOURCE_LOCKS
051: * CMS_CONTENTS
052: *
053: * @author Roland Metzler
054: *
055: * @version $Revision: 1.2 $
056: *
057: * @since 7.0.0
058: */
059: public class CmsUpdateDBNewTables extends A_CmsUpdateDBPart {
060:
061: /** Constant for the SQL query properties.<p> */
062: private static final String QUERY_PROPERTY_FILE = "generic/cms_new_tables_queries.properties";
063:
064: /**
065: * Constructor.<p>
066: *
067: * @throws IOException if the sql queries properties file could not be read
068: */
069: public CmsUpdateDBNewTables() throws IOException {
070:
071: super ();
072: loadQueryProperties(QUERY_PROPERTIES_PREFIX
073: + QUERY_PROPERTY_FILE);
074: }
075:
076: /**
077: * @see org.opencms.setup.update6to7.A_CmsUpdateDBPart#internalExecute(org.opencms.setup.CmsSetupDb)
078: */
079: protected void internalExecute(CmsSetupDb dbCon)
080: throws SQLException {
081:
082: System.out.println(new Exception().getStackTrace()[0]
083: .toString());
084:
085: List elements = new ArrayList();
086: elements.add("CMS_OFFLINE_RESOURCE_RELATIONS");
087: elements.add("CMS_ONLINE_RESOURCE_RELATIONS");
088: elements.add("CMS_PUBLISH_JOBS");
089: elements.add("CMS_RESOURCE_LOCKS");
090: elements.add("CMS_CONTENTS");
091: elements.add("CMS_HISTORY_PROJECTRESOURCES");
092: elements.add("CMS_HISTORY_PROPERTYDEF");
093: elements.add("CMS_HISTORY_PROPERTIES");
094: elements.add("CMS_HISTORY_RESOURCES");
095: elements.add("CMS_HISTORY_STRUCTURE");
096:
097: for (Iterator it = elements.iterator(); it.hasNext();) {
098: String table = (String) it.next();
099: if (!dbCon.hasTableOrColumn(table, null)) {
100: String query = readQuery(table);
101: dbCon.updateSqlStatement(query, null, null);
102: } else {
103: System.out
104: .println("table " + table + " already exists");
105: }
106: }
107: }
108: }
|