001: /*
002: * Copyright (c) 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
003: *
004: * Project: OpenSubsystems
005: *
006: * $Id: BlogListDatabaseTestUtils.java,v 1.1 2007/02/01 07:31:05 bastafidli Exp $
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License as published by
010: * the Free Software Foundation; either version 2 of the License, or
011: * (at your option) any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but 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; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021: */
022:
023: package org.opensubsystems.blog.persist.db;
024:
025: import org.opensubsystems.blog.data.Blog;
026: import org.opensubsystems.blog.persist.BlogFactory;
027: import org.opensubsystems.core.data.DataObject;
028: import org.opensubsystems.patterns.listdata.persist.db.ListDatabaseTestUtils;
029:
030: /**
031: * Utility class to enable test list pattern implementation for blogs.
032: *
033: * @version $Id: BlogListDatabaseTestUtils.java,v 1.1 2007/02/01 07:31:05 bastafidli Exp $
034: * @author Miro Halas
035: * @code.reviewer Miro Halas
036: * @code.reviewed Initial revision
037: */
038: public class BlogListDatabaseTestUtils extends ListDatabaseTestUtils {
039: // Constructors /////////////////////////////////////////////////////////////
040:
041: public BlogListDatabaseTestUtils() {
042: super (BlogFactory.class, BlogDatabaseSchema.class,
043: Blog.ALL_COLUMNS, Blog.COL_BLOG_FOLDER,
044: Blog.COL_BLOG_CAPTION);
045: }
046:
047: // Implemented abstract methods /////////////////////////////////////////////
048:
049: /**
050: * {@inheritDoc}
051: */
052: public Object insertParent(int iDomainId, String str1, String str2)
053: throws Exception {
054: // Blog doesnt't have parent therefore there is nothing to do
055: return null;
056: }
057:
058: /**
059: * {@inheritDoc}
060: */
061: public void deleteParent(Object parent, int iDomainId)
062: throws Exception {
063: // Blog doesnt't have parent therefore there is nothing to do
064: }
065:
066: /**
067: * {@inheritDoc}
068: */
069: public DataObject constructData(Object parent, int iDomainId,
070: String str1, String str2) throws Exception {
071: return new Blog(DataObject.NEW_ID, iDomainId, str1, str2, str1
072: + str2, null, null);
073: }
074:
075: /**
076: * {@inheritDoc}
077: */
078: protected void deleteData(Object parent, final int iDomainId,
079: final String strPrefix1, final String strPrefix2)
080: throws Exception {
081: deleteData(parent, iDomainId, strPrefix1, strPrefix2,
082: "DELETE FROM " + BlogDatabaseSchema.BLOG_TABLE_NAME
083: + " WHERE (FOLDER LIKE '" + strPrefix1
084: + "%' OR CAPTION LIKE '" + strPrefix2
085: + "%') AND DOMAIN_ID = " + iDomainId, false);
086: }
087:
088: /**
089: * {@inheritDoc}
090: */
091: public String getColumnOneValue(DataObject data) {
092: // In constructor we have specified that the first column is folder
093: return ((Blog) data).getFolder();
094: }
095:
096: /**
097: * {@inheritDoc}
098: */
099: public String getColumnTwoValue(DataObject data) {
100: // In constructor we have specified that the second column is caption
101: return ((Blog) data).getCaption();
102: }
103: }
|