View Javadoc

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