Coverage Report - org.kuali.rice.kew.engine.node.State
 
Classes in this File Line Coverage Branch Coverage Complexity
State
0%
0/21
N/A
1
 
 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  
 package org.kuali.rice.kew.engine.node;
 18  
 
 19  
 import java.util.LinkedHashMap;
 20  
 
 21  
 import javax.persistence.GeneratedValue;
 22  
 import javax.persistence.Id;
 23  
 import javax.persistence.MappedSuperclass;
 24  
 import javax.persistence.PrePersist;
 25  
 
 26  
 import org.hibernate.annotations.GenericGenerator;
 27  
 import org.hibernate.annotations.Parameter;
 28  
 import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
 29  
 import org.kuali.rice.core.util.KeyValue;
 30  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 31  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
 32  
 
 33  
 /**
 34  
  * A KeyValuePair that adds an id fields that makes it sufficient for storing in a database.
 35  
  * 
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  */
 38  
 @MappedSuperclass
 39  
 //@Sequence(name="KREW_RTE_NODE_S", property="stateId")
 40  
 public abstract class State extends PersistableBusinessObjectBase implements KeyValue {
 41  
     @Id
 42  
     @GeneratedValue(generator="KREW_RTE_NODE_S")
 43  
         @GenericGenerator(name="KREW_RTE_NODE_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 44  
                         @Parameter(name="sequence_name",value="KREW_RTE_NODE_S"),
 45  
                         @Parameter(name="value_column",value="id")
 46  
         })
 47  
         protected String stateId;
 48  
         private String key;
 49  
     private String value;
 50  
 
 51  0
     public State() {}
 52  
     
 53  0
     public State(String key, String value) {
 54  0
             this.key = key;
 55  0
             this.value = value;
 56  0
     }
 57  
 
 58  
     @PrePersist
 59  
     public void customPrePersist(){
 60  0
         OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
 61  0
     }
 62  
 
 63  
     public String getStateId() {
 64  0
         return stateId;
 65  
     }
 66  
 
 67  
     public void setStateId(String stateId) {
 68  0
         this.stateId = stateId;
 69  0
     }
 70  
     
 71  
     @Override
 72  
     public String getKey() {
 73  0
             return key;
 74  
     }
 75  
     
 76  
     @Override
 77  
     public String getValue() {
 78  0
             return value;
 79  
     }
 80  
     
 81  
     public void setKey(String key) {
 82  0
                 this.key = key;
 83  0
         }
 84  
 
 85  
         public void setValue(String value) {
 86  0
                 this.value = value;
 87  0
         }
 88  
         
 89  
         protected LinkedHashMap<String, Object> toStringMapperFields() {
 90  0
                 final LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
 91  0
                 map.put("stateId", stateId);
 92  0
                 map.put("key", key);
 93  0
                 map.put("value", value);
 94  0
                 return map;
 95  
         }
 96  
 }