View Javadoc
1   /**
2    * Copyright 2005-2016 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.krad.maintenance;
17  
18  import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
19  import org.kuali.rice.core.framework.persistence.jpa.annotations.Sequence;
20  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
21  import org.kuali.rice.krad.service.KRADServiceLocator;
22  
23  import javax.persistence.Column;
24  import javax.persistence.Entity;
25  import javax.persistence.EntityManagerFactory;
26  import javax.persistence.Id;
27  import javax.persistence.PrePersist;
28  import javax.persistence.Table;
29  
30  /**
31   * List of business objects that this maintenance document is locking (prevents two documents from being routed trying to update the same object)
32   * Most maintenance documents have only one lock, but globals have many
33   */
34  @Entity
35  @Sequence(name="KRNS_MAINT_LOCK_S",property="lockId")
36  @Table(name="KRNS_MAINT_LOCK_T")
37  public class MaintenanceLock extends PersistableBusinessObjectBase {
38      private static final long serialVersionUID = 7766326835852387301L;
39  	@Id
40      @Column(name="MAINT_LOCK_ID")
41      private String lockId;
42  	@Column(name="MAINT_LOCK_REP_TXT")
43  	private String lockingRepresentation;
44      @Column(name="DOC_HDR_ID")
45  	private String documentNumber;
46  
47      public String getLockId() {
48  		return this.lockId;
49  	}
50  
51  	public void setLockId(String lockId) {
52  		this.lockId = lockId;
53  	}
54  
55  	public String getLockingRepresentation() {
56          return lockingRepresentation;
57      }
58  
59      public void setLockingRepresentation(String lockingRepresentation) {
60          this.lockingRepresentation = lockingRepresentation;
61      }
62  
63      public String getDocumentNumber() {
64          return documentNumber;
65      }
66  
67      public void setDocumentNumber(String documentNumber) {
68          this.documentNumber = documentNumber;
69      }
70  
71  	/**
72  	 * Uses OrmUtils to set the sequence
73       *
74       * @see org.kuali.rice.krad.bo.PersistableBusinessObjectBase#prePersist()
75       */
76      @PrePersist
77  	protected void customPrePersist() {
78  		final EntityManagerFactory factory = KRADServiceLocator.getApplicationEntityManagerFactory();
79  		OrmUtils.populateAutoIncValue(this, factory.createEntityManager());
80  
81  		super.prePersist();
82  	}
83  
84  }
85