001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.maintenance; 017 018import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; 019import org.kuali.rice.core.framework.persistence.jpa.annotations.Sequence; 020import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; 021import org.kuali.rice.krad.service.KRADServiceLocator; 022 023import javax.persistence.Column; 024import javax.persistence.Entity; 025import javax.persistence.EntityManagerFactory; 026import javax.persistence.Id; 027import javax.persistence.PrePersist; 028import javax.persistence.Table; 029 030/** 031 * List of business objects that this maintenance document is locking (prevents two documents from being routed trying to update the same object) 032 * Most maintenance documents have only one lock, but globals have many 033 */ 034@Entity 035@Sequence(name="KRNS_MAINT_LOCK_S",property="lockId") 036@Table(name="KRNS_MAINT_LOCK_T") 037public class MaintenanceLock extends PersistableBusinessObjectBase { 038 private static final long serialVersionUID = 7766326835852387301L; 039 @Id 040 @Column(name="MAINT_LOCK_ID") 041 private String lockId; 042 @Column(name="MAINT_LOCK_REP_TXT") 043 private String lockingRepresentation; 044 @Column(name="DOC_HDR_ID") 045 private String documentNumber; 046 047 public String getLockId() { 048 return this.lockId; 049 } 050 051 public void setLockId(String lockId) { 052 this.lockId = lockId; 053 } 054 055 public String getLockingRepresentation() { 056 return lockingRepresentation; 057 } 058 059 public void setLockingRepresentation(String lockingRepresentation) { 060 this.lockingRepresentation = lockingRepresentation; 061 } 062 063 public String getDocumentNumber() { 064 return documentNumber; 065 } 066 067 public void setDocumentNumber(String documentNumber) { 068 this.documentNumber = documentNumber; 069 } 070 071 /** 072 * Uses OrmUtils to set the sequence 073 * 074 * @see org.kuali.rice.krad.bo.PersistableBusinessObjectBase#prePersist() 075 */ 076 @PrePersist 077 protected void customPrePersist() { 078 final EntityManagerFactory factory = KRADServiceLocator.getApplicationEntityManagerFactory(); 079 OrmUtils.populateAutoIncValue(this, factory.createEntityManager()); 080 081 super.prePersist(); 082 } 083 084} 085