001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-setup/org/opencms/setup/update6to7/oracle/CmsUpdateDBContentTables.java,v $
003: * Date : $Date: 2008-02-27 12:05:48 $
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.oracle;
033:
034: import org.opencms.setup.CmsSetupDb;
035:
036: import java.io.IOException;
037: import java.sql.SQLException;
038: import java.util.Collections;
039: import java.util.HashMap;
040: import java.util.Map;
041:
042: /**
043: * Oracle implementation of the generic update of the contents tables.<p>
044: *
045: * @author Roland Metzler
046: * @author Peter Bonrad
047: *
048: * @version $Revision: 1.2 $
049: *
050: * @since 7.0.0
051: */
052: public class CmsUpdateDBContentTables extends
053: org.opencms.setup.update6to7.generic.CmsUpdateDBContentTables {
054:
055: /** Constant for the sql query to transfer the online contents.<p> */
056: protected static final String QUERY_UPDATE_ONLINE_CONTENTS_PUBLISH_TAG_FROM = "Q_UPDATE_ONLINE_CONTENTS_PUBLISH_TAG_FROM";
057:
058: /** Constant for the sql query to transfer the online contents.<p> */
059: protected static final String QUERY_UPDATE_ONLINE_CONTENTS_PUBLISH_TAG_FROM2 = "Q_UPDATE_ONLINE_CONTENTS_PUBLISH_TAG_FROM2";
060:
061: /** Constant for the sql query to transfer the online contents.<p> */
062: protected static final String QUERY_UPDATE_ONLINE_CONTENTS_PUBLISH_TAG_TO = "Q_UPDATE_ONLINE_CONTENTS_PUBLISH_TAG_TO";
063:
064: /** Constant for the SQL query properties.<p> */
065: private static final String QUERY_PROPERTY_FILE = "oracle/cms_content_table_queries.properties";
066:
067: /** Constant for the replacement in the sql query. */
068: private static final String REPLACEMENT_TABLEINDEX_SPACE = "${indexTablespace}";
069:
070: /**
071: * Constructor.<p>
072: *
073: * @throws IOException if the sql queries properties file could not be read
074: */
075: public CmsUpdateDBContentTables() throws IOException {
076:
077: super ();
078: loadQueryProperties(QUERY_PROPERTIES_PREFIX
079: + QUERY_PROPERTY_FILE);
080: }
081:
082: /**
083: * @see org.opencms.setup.update6to7.generic.CmsUpdateDBContentTables#createContentsTable(org.opencms.setup.CmsSetupDb)
084: */
085: protected void createContentsTable(CmsSetupDb dbCon)
086: throws SQLException {
087:
088: String indexTablespace = (String) m_poolData
089: .get("indexTablespace");
090:
091: System.out.println(new Exception().getStackTrace()[0]
092: .toString());
093: if (!dbCon.hasTableOrColumn(TABLE_CMS_CONTENTS, null)) {
094: String query = readQuery(QUERY_CREATE_CMS_CONTENTS_TABLE);
095:
096: HashMap replacer = new HashMap();
097: replacer.put(REPLACEMENT_TABLEINDEX_SPACE, indexTablespace);
098:
099: dbCon.updateSqlStatement(query, null, null);
100: } else {
101: System.out.println("table " + TABLE_CMS_CONTENTS
102: + " already exists");
103: }
104: }
105:
106: /**
107: * @see org.opencms.setup.update6to7.generic.CmsUpdateDBContentTables#transferOnlineContents(org.opencms.setup.CmsSetupDb, int)
108: */
109: protected void transferOnlineContents(CmsSetupDb dbCon, int pubTag)
110: throws SQLException {
111:
112: String query = readQuery(QUERY_TRANSFER_ONLINE_CONTENTS);
113: Map replacer = Collections.singletonMap("${pubTag}", ""
114: + pubTag);
115: dbCon.updateSqlStatement(query, replacer, null);
116:
117: query = readQuery(QUERY_UPDATE_ONLINE_CONTENTS_PUBLISH_TAG_FROM);
118: dbCon.updateSqlStatement(query, null, null);
119:
120: query = readQuery(QUERY_UPDATE_ONLINE_CONTENTS_PUBLISH_TAG_FROM2);
121: dbCon.updateSqlStatement(query, null, Collections
122: .singletonList(new Integer(pubTag)));
123:
124: query = readQuery(QUERY_UPDATE_ONLINE_CONTENTS_PUBLISH_TAG_TO);
125: dbCon.updateSqlStatement(query, null, null);
126: }
127: }
|