KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > core > solution > ActionDefinition


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * @created Jul 21, 2005
14  * @author James Dixon
15  *
16  */

17
18 package org.pentaho.core.solution;
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Map JavaDoc;
23
24 import org.apache.commons.collections.map.ListOrderedMap;
25 import org.dom4j.Node;
26 import org.pentaho.core.component.IComponent;
27 import org.pentaho.core.util.XmlHelper;
28 import org.pentaho.util.logging.ILogger;
29 import org.pentaho.util.logging.Logger;
30
31 public class ActionDefinition implements IActionDefinition {
32
33     private int errorCode;
34
35     private int loggingLevel;
36
37     // private boolean audit;
38
private List JavaDoc preExecuteAuditList;
39
40     private List JavaDoc postExecuteAuditList;
41
42     // private ISequenceDefinition sequenceData;
43

44     private String JavaDoc description;
45
46     private String JavaDoc author;
47
48     private String JavaDoc help;
49
50     private String JavaDoc iconUrl;
51
52     private Node componentNode;
53
54     private IComponent component;
55
56     private String JavaDoc componentName;
57
58     private Map JavaDoc actionInputDefinitions;
59
60     private Map JavaDoc actionInputMapping;
61
62     private Map JavaDoc actionOutputDefinitions;
63
64     private Map JavaDoc actionOutputMapping;
65
66     private Map JavaDoc actionResourceMapping;
67     
68     private boolean hasActionResources = false;
69
70     public ActionDefinition(Node actionRootNode, ILogger logger) {
71
72         errorCode = ISequenceDefinition.ACTION_SEQUENCE_DEFINITION_OK;
73         // this.sequenceData = sequenceData;
74

75         // get the input parameter definitions
76
actionInputDefinitions = new ListOrderedMap();
77         actionInputMapping = new ListOrderedMap();
78         errorCode = SequenceDefinition.parseParameters(actionRootNode, logger, "action-inputs/*", actionInputDefinitions, actionInputMapping, true); //$NON-NLS-1$
79

80         // get the ouput definitions
81
actionOutputDefinitions = new ListOrderedMap();
82         actionOutputMapping = new ListOrderedMap();
83         errorCode = SequenceDefinition.parseParameters(actionRootNode, logger, "action-outputs/*", actionOutputDefinitions, actionOutputMapping, false); //$NON-NLS-1$
84

85         // get the resource definitions
86
actionResourceMapping = new ListOrderedMap();
87         if ( actionRootNode.selectNodes( "action-resources/*" ).size() > 0 ) { //$NON-NLS-1$
88
hasActionResources = true;
89             errorCode = SequenceDefinition.parseActionResourceDefintions(actionRootNode, logger, "action-resources/*", actionResourceMapping); //$NON-NLS-1$
90
}
91
92         componentName = XmlHelper.getNodeText("component-name", actionRootNode); //$NON-NLS-1$
93
String JavaDoc loggingLevelString = XmlHelper.getNodeText("logging-level", actionRootNode); //$NON-NLS-1$
94
loggingLevel = Logger.getLogLevel(loggingLevelString);
95
96         // get the component payload
97
componentNode = actionRootNode.selectSingleNode("component-definition"); //$NON-NLS-1$
98
if (componentNode == null) {
99             // TODO log this / surface this error
100
errorCode = ISequenceDefinition.ACTION_SEQUENCE_DEFINITION_INVALID_ACTION_DOC;
101         }
102
103         // TODO populate preExecuteAuditList and postExecuteAuditList
104
}
105
106     public int getErrorCode() {
107         return errorCode;
108     }
109
110     public String JavaDoc getMappedInputName(String JavaDoc name) {
111         return ((String JavaDoc) actionInputMapping.get(name));
112     }
113
114     public Map JavaDoc getActionInputDefinitions() {
115         return actionInputDefinitions;
116     }
117
118     public String JavaDoc getMappedOutputName(String JavaDoc name) {
119         return ((String JavaDoc) actionOutputMapping.get(name));
120     }
121
122     public Map JavaDoc getActionOutputDefinitions() {
123         return actionOutputDefinitions;
124     }
125
126     public String JavaDoc getMappedResourceName(String JavaDoc name) {
127         return ((String JavaDoc) actionResourceMapping.get(name));
128     }
129
130     public List JavaDoc getActionResourceDefinitionNames() {
131         return( new ArrayList JavaDoc( actionResourceMapping.keySet() ) );
132     }
133     
134     public boolean hasActionResources() {
135         return( hasActionResources );
136     }
137
138
139     public void setLoggingLevel(int loggingLevel) {
140         this.loggingLevel = loggingLevel;
141     }
142
143     /*
144      * (non-Javadoc)
145      *
146      * @see org.pentaho.newcode.IActionDefinition#getComponentName()
147      */

148     public String JavaDoc getComponentName() {
149         // TODO Auto-generated method stub
150
return componentName;
151     }
152
153     /*
154      * (non-Javadoc)
155      *
156      * @see org.pentaho.newcode.IActionDefinition#getComponentSection()
157      */

158     public Node getComponentSection() {
159         // TODO Auto-generated method stub
160
return componentNode;
161     }
162
163     /*
164      * (non-Javadoc)
165      *
166      * @see org.pentaho.newcode.IActionDefinition#getSyncPreference()
167      */

168     public boolean getSyncPreference() {
169         // TODO Auto-generated method stub
170
return false;
171     }
172
173     public int getLoggingLevel() {
174         return loggingLevel;
175     }
176
177     public List JavaDoc getPostExecuteAuditList() {
178         return preExecuteAuditList;
179     }
180
181     public List JavaDoc getPreExecuteAuditList() {
182         return postExecuteAuditList;
183     }
184
185     public IComponent getComponent() {
186         return component;
187     }
188
189     public void setComponent(IComponent component) {
190         this.component = component;
191     }
192
193     public String JavaDoc getIconUrl() {
194         return iconUrl;
195     }
196
197     public String JavaDoc getAuthor() {
198         return author;
199     }
200
201     public String JavaDoc getDescription() {
202         return description;
203     }
204
205     public String JavaDoc getHelp() {
206         return help;
207     }
208
209 }
210
Popular Tags