001: /*
002: * $Id: ArchiveLog.java 562 2005-10-24 19:03:40Z hengels $
003: * (c) Copyright 2004 con:cern development team.
004: *
005: * This file is part of con:cern (http://concern.sf.net).
006: *
007: * con:cern is free software; you can redistribute it and/or modify
008: * it under the terms of the GNU Lesser General Public License
009: * as published by the Free Software Foundation; either version 2.1
010: * of the License, or (at your option) any later version.
011: *
012: * Please see COPYING for the complete licence.
013: */
014: package org.concern.controller;
015:
016: import java.sql.Timestamp;
017: import java.util.Map;
018:
019: /**
020: * @hibernate.class
021: *
022: * @hibernate.query name="archive.byUserValue"
023: * query="FROM org.concern.controller.ArchiveLog AS archive WHERE archive.userValue = :userValue"
024: */
025: public class ArchiveLog implements Comparable {
026: private Integer id;
027: private ArchiveSubject subject;
028:
029: private String activity;
030: private boolean success;
031: private String message;
032: private String details;
033: private Map /* <String, String> */annotations;
034: private Timestamp timestamp;
035:
036: public ArchiveLog() {
037: }
038:
039: public ArchiveLog(String activity) {
040: this .activity = activity;
041: this .timestamp = new Timestamp(System.currentTimeMillis());
042: }
043:
044: public ArchiveLog(String activity, String message) {
045: this .activity = activity;
046: this .message = message;
047: this .timestamp = new Timestamp(System.currentTimeMillis());
048: }
049:
050: public ArchiveLog(String activity, String message, String details) {
051: this .activity = activity;
052: this .message = message;
053: setDetails(details);
054: this .timestamp = new Timestamp(System.currentTimeMillis());
055: }
056:
057: ArchiveLog(String activity, Timestamp timestamp) {
058: this .activity = activity;
059: this .timestamp = timestamp;
060: }
061:
062: /**
063: * @hibernate.id
064: * unsaved-value="null"
065: * generator-class="native"
066: */
067: public Integer getId() {
068: return id;
069: }
070:
071: public void setId(Integer id) {
072: this .id = id;
073: }
074:
075: public ArchiveSubject getSubject() {
076: return subject;
077: }
078:
079: public void setSubject(final ArchiveSubject subject) {
080: this .subject = subject;
081: }
082:
083: /**
084: * @hibernate.property length="64"
085: */
086: public String getActivity() {
087: return activity;
088: }
089:
090: public void setActivity(String activity) {
091: this .activity = activity;
092: }
093:
094: /**
095: * @hibernate.property length="512"
096: */
097: public String getMessage() {
098: return message;
099: }
100:
101: public void setMessage(String message) {
102: this .message = message;
103: }
104:
105: /**
106: * @hibernate.property length="2048"
107: */
108: public String getDetails() {
109: return details;
110: }
111:
112: public void setDetails(String details) {
113: this .details = details;
114: }
115:
116: /**
117: * @hibernate.property
118: */
119: public boolean isSuccess() {
120: return success;
121: }
122:
123: public void setSuccess(boolean success) {
124: this .success = success;
125: }
126:
127: public Map getAnnotations() {
128: return annotations;
129: }
130:
131: public void setAnnotations(final Map annotations) {
132: this .annotations = annotations;
133: }
134:
135: /**
136: * @hibernate.property
137: */
138: public Timestamp getTimestamp() {
139: return timestamp;
140: }
141:
142: public void setTimestamp(Timestamp timestamp) {
143: this .timestamp = timestamp;
144: }
145:
146: public int compareTo(Object o) {
147: ArchiveLog log = (ArchiveLog) o;
148: int diff = activity.compareTo(log.activity);
149: if (diff != 0)
150: return diff;
151: return timestamp.compareTo(log.timestamp);
152: }
153:
154: public String toString() {
155: return (success ? "+ " : "- ") + activity + " " + message;
156: }
157:
158: public boolean equals(Object o) {
159: if (this == o)
160: return true;
161: if (!(o instanceof Log))
162: return false;
163:
164: final ArchiveLog log = (ArchiveLog) o;
165:
166: if (!activity.equals(log.activity))
167: return false;
168: if (!timestamp.equals(log.timestamp))
169: return false;
170:
171: return true;
172: }
173:
174: public int hashCode() {
175: int result;
176: result = activity.hashCode();
177: result = 29 * result + timestamp.hashCode();
178: return result;
179: }
180: }
|