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.mysql; 029 030import org.opencms.setup.CmsSetupDb; 031 032import java.io.IOException; 033import java.sql.SQLException; 034import java.util.ArrayList; 035import java.util.Collections; 036import java.util.Iterator; 037import java.util.List; 038import java.util.Map; 039 040/** 041 * This class creates the new tables for the database version of OpenCms 7.<p> 042 * 043 * The new tables are 044 * CMS_OFFLINE_RESOURCE_RELATIONS 045 * CMS_ONLINE_RESOURCE_RELATOINS 046 * CMS_PUBLISH_JOBS 047 * CMS_RESOURCE_LOCKS 048 * CMS_CONTENTS 049 */ 050public class CmsUpdateDBNewTables extends org.opencms.setup.db.update6to7.CmsUpdateDBNewTables { 051 052 /** Constant for the SQL query properties.<p> */ 053 private static final String QUERY_PROPERTY_FILE = "cms_new_tables_queries.properties"; 054 055 /** 056 * Constructor.<p> 057 * 058 * @throws IOException if the sql queries properties file could not be read 059 */ 060 public CmsUpdateDBNewTables() 061 throws IOException { 062 063 super(); 064 loadQueryProperties(getPropertyFileLocation() + QUERY_PROPERTY_FILE); 065 } 066 067 /** 068 * @see org.opencms.setup.db.A_CmsUpdateDBPart#internalExecute(org.opencms.setup.CmsSetupDb) 069 */ 070 @Override 071 protected void internalExecute(CmsSetupDb dbCon) throws SQLException { 072 073 System.out.println(new Exception().getStackTrace()[0].toString()); 074 075 List<String> elements = new ArrayList<String>(); 076 elements.add("CMS_OFFLINE_RESOURCE_RELATIONS"); 077 elements.add("CMS_ONLINE_RESOURCE_RELATIONS"); 078 elements.add("CMS_PUBLISH_JOBS"); 079 elements.add("CMS_RESOURCE_LOCKS"); 080 elements.add("CMS_CONTENTS"); 081 elements.add("CMS_HISTORY_PROJECTRESOURCES"); 082 elements.add("CMS_HISTORY_PROPERTYDEF"); 083 elements.add("CMS_HISTORY_PROPERTIES"); 084 elements.add("CMS_HISTORY_RESOURCES"); 085 elements.add("CMS_HISTORY_STRUCTURE"); 086 087 Map<String, String> replacer = Collections.singletonMap("${tableEngine}", m_poolData.get("engine")); 088 for (Iterator<String> it = elements.iterator(); it.hasNext();) { 089 String table = it.next(); 090 if (!dbCon.hasTableOrColumn(table, null)) { 091 String query = readQuery(table + "_MYSQL"); 092 dbCon.updateSqlStatement(query, replacer, null); 093 } else { 094 System.out.println("table " + table + " already exists"); 095 } 096 } 097 } 098}