/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 * only, as published by the Free Software Foundation. * * OpenOffice.org is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License version 3 for more details * (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ package stats; import share.LogWriter; import share.DescEntry; import java.util.Hashtable; /** * * @author sg128468 */ public abstract class DataBaseOutProducer implements LogWriter { protected Hashtable mSqlInput = null; protected Hashtable mSqlOutput = null; protected String[] mWriteableEntryTypes = null; protected SQLExecution mSqlExec; protected boolean m_bDebug = false; /** Creates a new instance of DataBaseOutProducer * @param param The Hashtable with test parameters */ public DataBaseOutProducer(Hashtable param) { mSqlInput = new Hashtable(); mSqlInput.putAll(param); Object o = param.get("DebugIsActive"); String debug = null; if (o instanceof String) debug = (String)o; else debug = o.toString(); if (debug != null && (debug.equalsIgnoreCase("true") || debug.equalsIgnoreCase("yes"))) { m_bDebug = true; } // set default for writeable entries: method setWriteableEntryTypes(new String[]{"method"}); } /** initialization * */ public boolean initialize(DescEntry entry, boolean active) { if (entry.UserDefinedParams != null) mSqlInput.putAll(entry.UserDefinedParams); String jdbcClass = (String)mSqlInput.get("JDBC"); if (jdbcClass == null) jdbcClass = "org.gjt.mm.mysql.Driver"; String dbURL = (String)mSqlInput.get("DataBaseURL"); String user = (String)mSqlInput.get("User"); String password = (String)mSqlInput.get("Password"); if (user == null) user = (String)mSqlInput.get("OperatingSystem"); if (password == null) password = user; mSqlExec = new SQLExecution(jdbcClass, dbURL, user, password, m_bDebug); mSqlExec.openConnection(); prepareDataBase(entry.Logger); return true; } /** * * */ public boolean summary(DescEntry entry) { mSqlExec.openConnection(); findTypeInEntryTree(entry, entry.Logger); // checkDataBase(entry.Logger); mSqlExec.closeConnection(); return true; } /** * Step recursively through the entry tree: write all entries of the * defined types to the database. * @param entry The description entry that is take as root * @param log The log writer */ protected boolean findTypeInEntryTree(DescEntry entry, LogWriter log) { boolean returnVal = true; if (isWriteableEntryType(entry)) { returnVal &= insertEntry(entry, log); } if (entry.SubEntryCount >0) { for (int i=0; i