001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: /* $Id: VersionImpl.java 571604 2007-08-31 21:44:07Z rfrovarp $ */
020:
021: package org.apache.lenya.workflow.impl;
022:
023: import java.util.Date;
024: import java.util.HashMap;
025: import java.util.Map;
026:
027: import org.apache.lenya.workflow.Version;
028:
029: /**
030: * A version of the workflow history.
031: */
032: public class VersionImpl implements Version {
033:
034: private Date date;
035: private String ipAddress;
036: private String event;
037: private String state;
038: private String userId;
039: private Map variableValues = new HashMap();
040:
041: /**
042: * @see org.apache.lenya.workflow.Version#getEvent()
043: */
044: public String getEvent() {
045: return this .event;
046: }
047:
048: /**
049: * @see org.apache.lenya.workflow.Version#getState()
050: */
051: public String getState() {
052: return this .state;
053: }
054:
055: /**
056: * Returns the date.
057: * @return A string.
058: */
059: public Date getDate() {
060: return (Date) this .date.clone();
061: }
062:
063: /**
064: * Sets the date.
065: * @param _date A date.
066: */
067: public void setDate(Date _date) {
068: this .date = (Date) _date.clone();
069: }
070:
071: /**
072: * Returns the user ID.
073: * @return A string.
074: */
075: public String getUserId() {
076: return this .userId;
077: }
078:
079: /**
080: * Sets the user ID.
081: * @param _userId A user ID.
082: */
083: public void setUserId(String _userId) {
084: this .userId = _userId;
085: }
086:
087: /**
088: * Returns the ip address.
089: * @return A string.
090: */
091: public String getIPAddress() {
092: return this .ipAddress;
093: }
094:
095: /**
096: * Sets the ip address.
097: * @param _ipaddress A ip address.
098: */
099: public void setIPAddress(String _ipaddress) {
100: this .ipAddress = _ipaddress;
101: }
102:
103: /**
104: * Ctor.
105: * @param _event The event that caused the version change.
106: * @param _state The destination state.
107: */
108: public VersionImpl(String _event, String _state) {
109: this .event = _event;
110: this .state = _state;
111: }
112:
113: /**
114: * @see org.apache.lenya.workflow.Version#getValue(java.lang.String)
115: */
116: public boolean getValue(String variableName) {
117: Boolean value = (Boolean) this .variableValues.get(variableName);
118: if (value == null) {
119: throw new RuntimeException("No value set for variable ["
120: + variableName + "]");
121: }
122: return value.booleanValue();
123: }
124:
125: /**
126: * @see org.apache.lenya.workflow.Version#setValue(java.lang.String, boolean)
127: */
128: public void setValue(String variableName, boolean value) {
129: this.variableValues.put(variableName, Boolean.valueOf(value));
130: }
131:
132: }
|