001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-setup/org/opencms/setup/update6to7/postgresql/CmsUpdateDBNewTables.java,v $
003: * Date : $Date: 2008-02-27 12:05:41 $
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.postgresql;
033:
034: import java.io.IOException;
035: import java.sql.SQLException;
036: import java.util.ArrayList;
037: import java.util.HashMap;
038: import java.util.Iterator;
039: import java.util.List;
040:
041: import org.opencms.setup.CmsSetupDb;
042:
043: /**
044: * PostgreSQL implementation to create the new tables for version 7 of OpenCms.<p>
045: *
046: * @author Ivan Codarin
047: * @author Georgi Naplatanov
048: *
049: * @version $Revision: 1.2 $
050: *
051: * @since 7.0.2
052: */
053: public class CmsUpdateDBNewTables extends
054: org.opencms.setup.update6to7.generic.CmsUpdateDBNewTables {
055:
056: /** Constant for the SQL query properties.<p> */
057: private static final String QUERY_PROPERTY_FILE = "postgresql/cms_new_tables_queries.properties";
058:
059: /** Constant for the replacement in the sql query. */
060: private static final String REPLACEMENT_TABLEINDEX_SPACE = "${indexTablespace}";
061:
062: /**
063: * Constructor.<p>
064: *
065: * @throws IOException if the sql queries properties file could not be read
066: */
067: public CmsUpdateDBNewTables() throws IOException {
068:
069: super ();
070: loadQueryProperties(QUERY_PROPERTIES_PREFIX
071: + QUERY_PROPERTY_FILE);
072: }
073:
074: /**
075: * @see org.opencms.setup.update6to7.generic.CmsUpdateDBNewTables#internalExecute(org.opencms.setup.CmsSetupDb)
076: */
077: protected void internalExecute(CmsSetupDb dbCon)
078: throws SQLException {
079:
080: System.out.println(new Exception().getStackTrace()[0]
081: .toString());
082:
083: String indexTablespace = (String) m_poolData
084: .get("indexTablespace");
085:
086: List elements = new ArrayList();
087: elements.add("CMS_OFFLINE_RESOURCE_RELATIONS");
088: elements.add("CREATE_INDEX_CMS_OFFLINE_RELATIONS_01");
089: elements.add("CREATE_INDEX_CMS_OFFLINE_RELATIONS_02");
090: elements.add("CREATE_INDEX_CMS_OFFLINE_RELATIONS_03");
091: elements.add("CREATE_INDEX_CMS_OFFLINE_RELATIONS_04");
092: elements.add("CREATE_INDEX_CMS_OFFLINE_RELATIONS_05");
093:
094: elements.add("CMS_ONLINE_RESOURCE_RELATIONS");
095: elements.add("CREATE_INDEX_CMS_ONLINE_RELATIONS_01");
096: elements.add("CREATE_INDEX_CMS_ONLINE_RELATIONS_02");
097: elements.add("CREATE_INDEX_CMS_ONLINE_RELATIONS_03");
098: elements.add("CREATE_INDEX_CMS_ONLINE_RELATIONS_04");
099: elements.add("CREATE_INDEX_CMS_ONLINE_RELATIONS_05");
100:
101: elements.add("CMS_PUBLISH_JOBS");
102: elements.add("CMS_RESOURCE_LOCKS");
103:
104: elements.add("CMS_CONTENTS");
105: elements.add("CREATE_INDEX_CMS_CONTENTS_01");
106: elements.add("CREATE_INDEX_CMS_CONTENTS_02");
107: elements.add("CREATE_INDEX_CMS_CONTENTS_03");
108: elements.add("CREATE_INDEX_CMS_CONTENTS_04");
109: elements.add("CREATE_INDEX_CMS_CONTENTS_05");
110:
111: elements.add("CMS_HISTORY_PROJECTRESOURCES");
112: elements.add("CMS_HISTORY_PROPERTYDEF");
113:
114: elements.add("CMS_HISTORY_PROPERTIES");
115: elements.add("CREATE_INDEX_CMS_HISTORY_PROPERTIES_01");
116: elements.add("CREATE_INDEX_CMS_HISTORY_PROPERTIES_02");
117: elements.add("CREATE_INDEX_CMS_HISTORY_PROPERTIES_03");
118: elements.add("CREATE_INDEX_CMS_HISTORY_PROPERTIES_04");
119: elements.add("CREATE_INDEX_CMS_HISTORY_PROPERTIES_05");
120:
121: elements.add("CMS_HISTORY_RESOURCES");
122: elements.add("CREATE_INDEX_CMS_HISTORY_RESOURCES_01");
123: elements.add("CREATE_INDEX_CMS_HISTORY_RESOURCES_02");
124: elements.add("CREATE_INDEX_CMS_HISTORY_RESOURCES_03");
125: elements.add("CREATE_INDEX_CMS_HISTORY_RESOURCES_04");
126: elements.add("CREATE_INDEX_CMS_HISTORY_RESOURCES_05");
127: elements.add("CREATE_INDEX_CMS_HISTORY_RESOURCES_06");
128:
129: elements.add("CMS_HISTORY_STRUCTURE");
130: elements.add("CREATE_INDEX_CMS_HISTORY_STRUCTURE_01");
131: elements.add("CREATE_INDEX_CMS_HISTORY_STRUCTURE_02");
132: elements.add("CREATE_INDEX_CMS_HISTORY_STRUCTURE_03");
133: elements.add("CREATE_INDEX_CMS_HISTORY_STRUCTURE_04");
134: elements.add("CREATE_INDEX_CMS_HISTORY_STRUCTURE_05");
135: elements.add("CREATE_INDEX_CMS_HISTORY_STRUCTURE_06");
136: elements.add("CREATE_INDEX_CMS_HISTORY_STRUCTURE_07");
137: elements.add("CREATE_INDEX_CMS_HISTORY_STRUCTURE_08");
138:
139: for (Iterator it = elements.iterator(); it.hasNext();) {
140: String table = (String) it.next();
141: if (!dbCon.hasTableOrColumn(table, null)) {
142: String query = readQuery(table);
143: HashMap replacer = new HashMap();
144: replacer.put(REPLACEMENT_TABLEINDEX_SPACE,
145: indexTablespace);
146: dbCon.updateSqlStatement(query, replacer, null);
147: } else {
148: System.out
149: .println("table " + table + " already exists");
150: }
151: }
152: }
153: }
|