001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/profile/tags/sakai_2-4-1/common-composite-component-data/src/java/org/sakaiproject/component/common/manager/PersistableImpl.java $
003: * $Id: PersistableImpl.java 8424 2006-04-27 20:23:44Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.component.common.manager;
021:
022: import java.util.Date;
023:
024: import org.apache.commons.logging.Log;
025: import org.apache.commons.logging.LogFactory;
026: import org.sakaiproject.api.common.manager.Persistable;
027:
028: /**
029: * @author <a href="mailto:lance@indiana.edu">Lance Speelmon</a>
030: */
031: public abstract class PersistableImpl implements Persistable {
032: private static final Log LOG = LogFactory
033: .getLog(PersistableImpl.class);
034:
035: protected Long id;
036:
037: protected Integer version;
038:
039: protected String uuid;
040:
041: protected String lastModifiedBy;
042:
043: protected Date lastModifiedDate;
044:
045: protected String createdBy;
046:
047: protected Date createdDate;
048:
049: /**
050: * @return Returns the id surrogateKey.
051: */
052: public Long getId() {
053: LOG.trace("getId()");
054:
055: return id;
056: }
057:
058: /**
059: * @param id
060: * The id surrogateKey to set.
061: */
062: public void setId(Long id) {
063: if (LOG.isDebugEnabled()) {
064: LOG.debug("setId(Long " + id + ")");
065: }
066: if (id == null)
067: throw new IllegalArgumentException(
068: "Illegal id argument passed!");
069:
070: this .id = id;
071: }
072:
073: /**
074: * @return Returns the version (optimistic lock).
075: */
076: public Integer getVersion() {
077: LOG.trace("getVersion()");
078:
079: return version;
080: }
081:
082: /**
083: * @param version
084: * The version (optimistic lock) to set.
085: */
086: public void setVersion(Integer version) {
087: if (LOG.isDebugEnabled()) {
088: LOG.debug("setVersion(Integer " + version + ")");
089: }
090: ; // validation removed to enable hibernate's reflection optimizer
091:
092: this .version = version;
093: }
094:
095: /**
096: * @see org.sakaiproject.api.common.manager.Persistable#getUuid()
097: */
098: public String getUuid() {
099: LOG.trace("getUuid()");
100:
101: return uuid;
102: }
103:
104: public void setUuid(String uuid) {
105: if (LOG.isDebugEnabled()) {
106: LOG.debug("setUuid(String " + uuid + ")");
107: }
108: if (uuid == null || uuid.length() < 1)
109: throw new IllegalArgumentException(
110: "Illegal uuid argument passed!");
111:
112: this .uuid = uuid;
113: }
114:
115: /**
116: * @see org.sakaiproject.api.common.manager.Persistable#getLastModifiedBy()
117: */
118: public String getLastModifiedBy() {
119: LOG.trace("getLastModifiedBy()");
120:
121: return lastModifiedBy;
122: }
123:
124: public void setLastModifiedBy(String lastModifiedBy) {
125: if (LOG.isDebugEnabled()) {
126: LOG.debug("setLastModifiedBy(String " + lastModifiedBy
127: + ")");
128: }
129: // FIXME
130: // if (lastModifiedBy == null || lastModifiedBy.length() < 1)
131: // throw new IllegalArgumentException(
132: // "Illegal lastModifiedBy argument passed!");
133:
134: this .lastModifiedBy = lastModifiedBy;
135: }
136:
137: /**
138: * @see org.sakaiproject.api.common.manager.Persistable#getLastModifiedDate()
139: */
140: public Date getLastModifiedDate() {
141: LOG.trace("getLastModifiedDate()");
142:
143: return lastModifiedDate;
144: }
145:
146: public void setLastModifiedDate(Date lastModifiedDate) {
147: if (LOG.isDebugEnabled()) {
148: LOG.debug("setLastModifiedDate(Date " + lastModifiedDate
149: + ")");
150: }
151: // FIXME
152: // if (lastModifiedDate == null)
153: // throw new IllegalArgumentException(
154: // "Illegal lastModifiedDate argument passed!");
155:
156: this .lastModifiedDate = lastModifiedDate;
157: }
158:
159: /**
160: * @see org.sakaiproject.api.common.manager.Persistable#getCreatedBy()
161: */
162: public String getCreatedBy() {
163: LOG.trace("getCreatedBy()");
164:
165: return createdBy;
166: }
167:
168: public void setCreatedBy(String createdBy) {
169: if (LOG.isDebugEnabled()) {
170: LOG.debug("setCreatedBy(String " + createdBy + ")");
171: }
172: // FIXME
173: // if (createdBy == null || createdBy.length() < 1)
174: // throw new IllegalArgumentException("Illegal createdBy argument passed!");
175:
176: this .createdBy = createdBy;
177: }
178:
179: /**
180: * @see org.sakaiproject.api.common.manager.Persistable#getCreatedDate()
181: */
182: public Date getCreatedDate() {
183: LOG.trace("getCreatedDate()");
184:
185: return createdDate;
186: }
187:
188: public void setCreatedDate(Date createdDate) {
189: if (LOG.isDebugEnabled()) {
190: LOG.debug("setCreatedDate(Date " + createdDate + ")");
191: }
192: // FIXME
193: // if (createdDate == null)
194: // throw new IllegalArgumentException("Illegal createdDate argument passed!");
195:
196: this .createdDate = createdDate;
197: }
198:
199: /**
200: * @see java.lang.Object#toString()
201: */
202: public String toString() {
203: LOG.trace("toString()");
204:
205: StringBuffer sb = new StringBuffer();
206: sb.append("{id=");
207: sb.append(id);
208: sb.append(", lastModifiedBy=");
209: sb.append(lastModifiedBy);
210: sb.append(", lastModifiedDate=");
211: sb.append(lastModifiedDate);
212: sb.append(", createdBy=");
213: sb.append(createdBy);
214: sb.append(", createdDate=");
215: sb.append(createdDate);
216: sb.append(", uuid=");
217: sb.append(uuid);
218: sb.append(", version=");
219: sb.append(version);
220: return sb.toString();
221: }
222: }
|