001 /*
002 *
003 * $Revision: 14589 $ $Date: 2009-01-14 15:17:28 +0100 (Wed, 14 Jan 2009) $
004 *
005 * This file is part of *** M y C o R e ***
006 * See http://www.mycore.de/ for details.
007 *
008 * This program is free software; you can use it, redistribute it
009 * and / or modify it under the terms of the GNU General Public License
010 * (GPL) as published by the Free Software Foundation; either version 2
011 * of the License or (at your option) any later version.
012 *
013 * This program is distributed in the hope that it will be useful, but
014 * WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program, in a file called gpl.txt or license.txt.
020 * If not, write to the Free Software Foundation Inc.,
021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
022 */
023
024 package org.mycore.datamodel.common;
025
026 import org.mycore.common.events.MCREvent;
027 import org.mycore.common.events.MCREventHandlerBase;
028 import org.mycore.datamodel.metadata.MCRDerivate;
029 import org.mycore.datamodel.metadata.MCRObject;
030
031 /**
032 * This class manages all operations of the XMLTables for operations of an
033 * object or derivate.
034 *
035 * @author Jens Kupferschmidt
036 */
037 public class MCRXMLTableEventHandler extends MCREventHandlerBase {
038
039 static MCRXMLTableManager mcr_xmltable = MCRXMLTableManager.instance();
040
041 /**
042 * This method add the data to SQL table of XML data via MCRXMLTableManager.
043 *
044 * @param evt
045 * the event that occured
046 * @param obj
047 * the MCRObject that caused the event
048 */
049 protected final void handleObjectCreated(MCREvent evt, MCRObject obj) {
050 org.jdom.Document doc = obj.createXML();
051 mcr_xmltable.create(obj.getId(), doc, obj.getService().getDate("modifydate"));
052 }
053
054 /**
055 * This method update the data to SQL table of XML data via
056 * MCRXMLTableManager.
057 *
058 * @param evt
059 * the event that occured
060 * @param obj
061 * the MCRObject that caused the event
062 */
063 protected final void handleObjectUpdated(MCREvent evt, MCRObject obj) {
064 mcr_xmltable.update(obj.getId(), obj.createXML(), obj.getService().getDate("modifydate"));
065 }
066
067 /**
068 * This method delete the XML data from SQL table data via
069 * MCRXMLTableManager.
070 *
071 * @param evt
072 * the event that occured
073 * @param obj
074 * the MCRObject that caused the event
075 */
076 protected final void handleObjectDeleted(MCREvent evt, MCRObject obj) {
077 mcr_xmltable.delete(obj.getId());
078 }
079
080 /**
081 * This method add the data to SQL table of XML data via MCRXMLTableManager.
082 *
083 * @param evt
084 * the event that occured
085 * @param der
086 * the MCRDerivate that caused the event
087 */
088 protected final void handleDerivateCreated(MCREvent evt, MCRDerivate der) {
089 org.jdom.Document doc = der.createXML();
090 mcr_xmltable.create(der.getId(), doc, der.getService().getDate("modifydate"));
091 }
092
093 /**
094 * This method update the data to SQL table of XML data via
095 * MCRXMLTableManager.
096 *
097 * @param evt
098 * the event that occured
099 * @param der
100 * the MCRObject that caused the event
101 */
102 protected final void handleDerivateUpdated(MCREvent evt, MCRDerivate der) {
103 mcr_xmltable.update(der.getId(), der.createXML(), der.getService().getDate("modifydate"));
104 }
105
106 /**
107 * This method delete the XML data from SQL table data via
108 * MCRXMLTableManager.
109 *
110 * @param evt
111 * the event that occured
112 * @param der
113 * the MCRObject that caused the event
114 */
115 protected final void handleDerivateDeleted(MCREvent evt, MCRDerivate der) {
116 mcr_xmltable.delete(der.getId());
117 }
118
119 }