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