KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > blog > persist > db > BlogListDatabaseTestUtils


1 /*
2  * Copyright (c) 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: BlogListDatabaseTestUtils.java,v 1.1 2007/02/01 07:31:05 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */

22
23 package org.opensubsystems.blog.persist.db;
24
25 import org.opensubsystems.blog.data.Blog;
26 import org.opensubsystems.blog.persist.BlogFactory;
27 import org.opensubsystems.core.data.DataObject;
28 import org.opensubsystems.patterns.listdata.persist.db.ListDatabaseTestUtils;
29
30 /**
31  * Utility class to enable test list pattern implementation for blogs.
32  *
33  * @version $Id: BlogListDatabaseTestUtils.java,v 1.1 2007/02/01 07:31:05 bastafidli Exp $
34  * @author Miro Halas
35  * @code.reviewer Miro Halas
36  * @code.reviewed Initial revision
37  */

38 public class BlogListDatabaseTestUtils extends ListDatabaseTestUtils
39 {
40    // Constructors /////////////////////////////////////////////////////////////
41

42    public BlogListDatabaseTestUtils(
43    )
44    {
45       super(BlogFactory.class, BlogDatabaseSchema.class,
46             Blog.ALL_COLUMNS, Blog.COL_BLOG_FOLDER, Blog.COL_BLOG_CAPTION);
47    }
48    
49    // Implemented abstract methods /////////////////////////////////////////////
50

51    /**
52     * {@inheritDoc}
53     */

54    public Object JavaDoc insertParent(
55       int iDomainId,
56       String JavaDoc str1,
57       String JavaDoc str2
58    ) throws Exception JavaDoc
59    {
60       // Blog doesnt't have parent therefore there is nothing to do
61
return null;
62    }
63
64    /**
65     * {@inheritDoc}
66     */

67    public void deleteParent(
68       Object JavaDoc parent,
69       int iDomainId
70    ) throws Exception JavaDoc
71    {
72       // Blog doesnt't have parent therefore there is nothing to do
73
}
74    
75    /**
76     * {@inheritDoc}
77     */

78    public DataObject constructData(
79       Object JavaDoc parent,
80       int iDomainId,
81       String JavaDoc str1,
82       String JavaDoc str2
83    ) throws Exception JavaDoc
84    {
85       return new Blog(DataObject.NEW_ID, iDomainId, str1, str2, str1 + str2,
86                       null, null);
87    }
88
89    /**
90     * {@inheritDoc}
91     */

92    protected void deleteData(
93       Object JavaDoc parent,
94       final int iDomainId,
95       final String JavaDoc strPrefix1,
96       final String JavaDoc strPrefix2
97    ) throws Exception JavaDoc
98    {
99       deleteData(parent, iDomainId, strPrefix1, strPrefix2,
100                  "DELETE FROM " + BlogDatabaseSchema.BLOG_TABLE_NAME
101                  + " WHERE (FOLDER LIKE '" + strPrefix1
102                  + "%' OR CAPTION LIKE '" + strPrefix2
103                  + "%') AND DOMAIN_ID = " + iDomainId,
104                  false);
105    }
106    
107    /**
108     * {@inheritDoc}
109     */

110    public String JavaDoc getColumnOneValue(
111       DataObject data
112    )
113    {
114       // In constructor we have specified that the first column is folder
115
return ((Blog)data).getFolder();
116    }
117
118    /**
119     * {@inheritDoc}
120     */

121    public String JavaDoc getColumnTwoValue(
122       DataObject data
123    )
124    {
125       // In constructor we have specified that the second column is caption
126
return ((Blog)data).getCaption();
127    }
128 }
129
Popular Tags