View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.php
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.kuali.rice.kew.engine.node.var.schemes;
19  
20  import org.apache.log4j.Logger;
21  import org.kuali.rice.kew.engine.RouteContext;
22  import org.kuali.rice.kew.engine.node.BranchState;
23  import org.kuali.rice.kew.engine.node.service.BranchService;
24  import org.kuali.rice.kew.engine.node.var.Property;
25  import org.kuali.rice.kew.engine.node.var.PropertyScheme;
26  import org.kuali.rice.kew.service.KEWServiceLocator;
27  
28  
29  /**
30   * A property scheme that looks the property up in the state variable map
31   * 
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public final class VariableScheme implements PropertyScheme {
35      private static final Logger LOG = Logger.getLogger(VariableScheme.class);
36  
37      public String getName() {
38          return "variable";
39      }
40      public String getShortName() {
41          return "var";
42      }
43  
44      public Object load(Property property, RouteContext context) {
45  //        try {
46  //            return PropertyUtils.getProperty(doc.getVariables(), property.locator);
47              LOG.debug("getting variable: " + property.locator);
48              BranchService branchService = KEWServiceLocator.getBranchService();
49              String value = branchService.getScopedVariableValue(context.getNodeInstance().getBranch(), BranchState.VARIABLE_PREFIX + property.locator);
50              LOG.debug("variable '" + property.locator + "': " + value);
51              return value;
52  
53  //        } catch (NoSuchMethodException nsme) {
54  //            throw new RuntimeException("Error loading resource: " + property.locator, nsme);
55  //        } catch (InvocationTargetException ite) {
56  //            throw new RuntimeException("Error loading resource: " + property.locator, ite);
57  //        } catch (IllegalAccessException iae) {
58  //            throw new RuntimeException("Error loading resource: " + property.locator, iae);
59  //        }
60      }
61  
62      public String toString() {
63          return "[VariableScheme]";
64      }
65  }