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