001: /*
002: * $Id: Subject.java 1296 2007-08-09 13:25:14Z 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.util.*;
017: import java.sql.Timestamp;
018:
019: /**
020: * @version $Revision: 1296 $
021: */
022: public class Subject {
023: private Integer id;
024: private int version;
025:
026: private String process;
027:
028: private String userValue;
029: private String originator;
030: private Set<SubjectLine> subjectLines;
031: private SortedSet<Enlistment> enlistments;
032: private List<Log> logs;
033: private Timestamp created;
034: private int state = org.concern.Controller.STATE_RUNNING;
035:
036: public Subject() {
037: }
038:
039: public Subject(String userValue) {
040: this .userValue = userValue;
041: this .created = new Timestamp(System.currentTimeMillis());
042: }
043:
044: public Integer getId() {
045: return id;
046: }
047:
048: public void setId(Integer id) {
049: this .id = id;
050: }
051:
052: public int getVersion() {
053: return version;
054: }
055:
056: public void setVersion(int version) {
057: this .version = version;
058: }
059:
060: public String getProcess() {
061: return process;
062: }
063:
064: public void setProcess(String process) {
065: this .process = process;
066: }
067:
068: public String getUserValue() {
069: return userValue;
070: }
071:
072: public void setUserValue(String userValue) {
073: this .userValue = userValue;
074: }
075:
076: public String getOriginator() {
077: return originator;
078: }
079:
080: public void setOriginator(String originator) {
081: this .originator = originator;
082: }
083:
084: public Set<SubjectLine> getSubjectLines() {
085: if (subjectLines == null)
086: subjectLines = new HashSet<SubjectLine>();
087: return subjectLines;
088: }
089:
090: public void setSubjectLines(Set<SubjectLine> subjectLines) {
091: this .subjectLines = subjectLines;
092: }
093:
094: public SortedSet getEnlistments() {
095: if (enlistments == null)
096: enlistments = new TreeSet<Enlistment>();
097: return enlistments;
098: }
099:
100: public void setEnlistments(SortedSet<Enlistment> enlistments) {
101: this .enlistments = enlistments;
102: }
103:
104: public List<Log> getLogs() {
105: if (logs == null)
106: logs = new LinkedList<Log>();
107: return logs;
108: }
109:
110: public void setLogs(List<Log> logs) {
111: this .logs = logs;
112: }
113:
114: public Timestamp getCreated() {
115: return created;
116: }
117:
118: public void setCreated(Timestamp created) {
119: this .created = created;
120: }
121:
122: public void setState(int state) {
123: this .state = state;
124: }
125:
126: public int getState() {
127: return state;
128: }
129:
130: public String toString() {
131: return userValue;
132: }
133:
134: public Enlistment getTimeoutEnlistment(String name) {
135: for (Iterator<Enlistment> iterator = getEnlistments()
136: .iterator(); iterator.hasNext();) {
137: Enlistment timeoutEnlistment = iterator.next();
138: if ("TIMEOUT".equals(timeoutEnlistment.getCommand())
139: && name.equals(timeoutEnlistment.getActivity()))
140: return timeoutEnlistment;
141: }
142: return null;
143: }
144: }
|