KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > setup > impl > dl > DataLoaderBase


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.setup.impl.dl;
10
11 import org.jboss.portal.setup.dl.DataLoader;
12 import org.jboss.portal.setup.dl.DataLoaderConfig;
13 import org.jboss.portal.setup.PortalSetupException;
14 import org.jboss.portal.setup.PortalSetupConstants;
15 import org.jboss.portal.setup.impl.config.ConfigurationImpl;
16 import org.jboss.portal.common.util.XML;
17 import org.w3c.dom.Element JavaDoc;
18
19
20 import java.util.List JavaDoc;
21 import java.util.ArrayList JavaDoc;
22
23 /**
24  * @author <a HREF="mailto:palber@novell.com">Polina Alber</a>
25  * Date: Apr 14, 2005; Time: 3:20:33 PM
26  * @since JBoss portal 2.0
27  * Class org.jboss.portal.setup.impl.dl.DataLoaderBase
28  */

29 public abstract class DataLoaderBase extends ConfigurationImpl implements DataLoader, PortalSetupConstants
30 {
31    private DataLoaderConfig m_config = null;
32
33    /**
34     * @return Data loader configuration
35     */

36    public DataLoaderConfig getDataLoaderConfiguration()
37    {
38       return m_config;
39    }
40
41    /**
42     * @param config a DataLoaderConfig
43     */

44    public void setDataLoaderConfiguration(DataLoaderConfig config) throws PortalSetupException
45    {
46       m_config = (DataLoaderConfig)config.getConfiguration();
47    }
48
49    /**
50     * @see DataLoader#loadData(org.w3c.dom.Element)
51     */

52    public boolean loadData(Element JavaDoc action) throws PortalSetupException
53    {
54       boolean retVal = false;
55       if (null != action)
56       {
57
58          List JavaDoc statementsList = new ArrayList JavaDoc();
59          List JavaDoc statements = XML.getChildren(action, STATEMENT);
60          if (statements != null)
61          {
62             statementsList = new ArrayList JavaDoc();
63             for (int i = 0; i < statements.size(); i++)
64             {
65                statementsList.add(parseStatement((Element JavaDoc)statements.get(i)));
66             }
67             retVal = executeStatements(statementsList);
68
69          }
70       }
71       return retVal;
72    }
73
74    /**
75     * @param stmtElmt a statement element
76     * @return a statement metadata
77     * @throws PortalSetupException upon errors in meta data creation
78     */

79    protected abstract StatementMetaData parseStatement(Element JavaDoc stmtElmt) throws PortalSetupException;
80
81
82    /**
83     * @param stmtList a list of statement metadata objects
84     * @return a boolean flag, when true means that execution succedded
85     * @throws PortalSetupException upon errors in execution statements
86     */

87    protected abstract boolean executeStatements(List JavaDoc stmtList) throws PortalSetupException;
88
89 }
90
Popular Tags