1 17 18 package org.pentaho.core.solution; 19 20 import java.util.ArrayList ; 21 import java.util.List ; 22 import java.util.Map ; 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 List preExecuteAuditList; 39 40 private List postExecuteAuditList; 41 42 44 private String description; 45 46 private String author; 47 48 private String help; 49 50 private String iconUrl; 51 52 private Node componentNode; 53 54 private IComponent component; 55 56 private String componentName; 57 58 private Map actionInputDefinitions; 59 60 private Map actionInputMapping; 61 62 private Map actionOutputDefinitions; 63 64 private Map actionOutputMapping; 65 66 private Map actionResourceMapping; 67 68 private boolean hasActionResources = false; 69 70 public ActionDefinition(Node actionRootNode, ILogger logger) { 71 72 errorCode = ISequenceDefinition.ACTION_SEQUENCE_DEFINITION_OK; 73 75 actionInputDefinitions = new ListOrderedMap(); 77 actionInputMapping = new ListOrderedMap(); 78 errorCode = SequenceDefinition.parseParameters(actionRootNode, logger, "action-inputs/*", actionInputDefinitions, actionInputMapping, true); 80 actionOutputDefinitions = new ListOrderedMap(); 82 actionOutputMapping = new ListOrderedMap(); 83 errorCode = SequenceDefinition.parseParameters(actionRootNode, logger, "action-outputs/*", actionOutputDefinitions, actionOutputMapping, false); 85 actionResourceMapping = new ListOrderedMap(); 87 if ( actionRootNode.selectNodes( "action-resources/*" ).size() > 0 ) { hasActionResources = true; 89 errorCode = SequenceDefinition.parseActionResourceDefintions(actionRootNode, logger, "action-resources/*", actionResourceMapping); } 91 92 componentName = XmlHelper.getNodeText("component-name", actionRootNode); String loggingLevelString = XmlHelper.getNodeText("logging-level", actionRootNode); loggingLevel = Logger.getLogLevel(loggingLevelString); 95 96 componentNode = actionRootNode.selectSingleNode("component-definition"); if (componentNode == null) { 99 errorCode = ISequenceDefinition.ACTION_SEQUENCE_DEFINITION_INVALID_ACTION_DOC; 101 } 102 103 } 105 106 public int getErrorCode() { 107 return errorCode; 108 } 109 110 public String getMappedInputName(String name) { 111 return ((String ) actionInputMapping.get(name)); 112 } 113 114 public Map getActionInputDefinitions() { 115 return actionInputDefinitions; 116 } 117 118 public String getMappedOutputName(String name) { 119 return ((String ) actionOutputMapping.get(name)); 120 } 121 122 public Map getActionOutputDefinitions() { 123 return actionOutputDefinitions; 124 } 125 126 public String getMappedResourceName(String name) { 127 return ((String ) actionResourceMapping.get(name)); 128 } 129 130 public List getActionResourceDefinitionNames() { 131 return( new ArrayList ( 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 148 public String getComponentName() { 149 return componentName; 151 } 152 153 158 public Node getComponentSection() { 159 return componentNode; 161 } 162 163 168 public boolean getSyncPreference() { 169 return false; 171 } 172 173 public int getLoggingLevel() { 174 return loggingLevel; 175 } 176 177 public List getPostExecuteAuditList() { 178 return preExecuteAuditList; 179 } 180 181 public List 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 getIconUrl() { 194 return iconUrl; 195 } 196 197 public String getAuthor() { 198 return author; 199 } 200 201 public String getDescription() { 202 return description; 203 } 204 205 public String getHelp() { 206 return help; 207 } 208 209 } 210 | Popular Tags |