001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.rm.resources.lifecycle;
020:
021: import java.util.List;
022:
023: import org.openharmonise.rm.DataAccessException;
024: import org.openharmonise.rm.resources.users.User;
025:
026: /**
027: * The <code>Editable</code> interface provides for objects which can be edited
028: * within a versioning system.
029: *
030: * @author Michael Bell
031: * @version $Revision: 1.2 $
032: *
033: */
034: public interface Editable {
035: //lock label
036: public static final String LABEL_LOCK = "lock";
037: //unlock label
038: public static final String LABEL_UNLOCK = "unlock";
039:
040: /**
041: * Saves current data to data store. If the object being saved is a live version
042: * and data has been changed, a new unapproved version is created. This method will
043: * return the result of the save operation, i.e. if it is an unapproved object the
044: * orginal object will be returned, otherwise the newly created unapproved version
045: * will be returned.
046: *
047: * @return
048: * @throws EditException
049: */
050: public Editable save() throws EditException;
051:
052: /**
053: * Returns a new version of this editable object, if the current version is a live
054: * version, otherwise is returns the current object.
055: *
056: * @return
057: * @throws EditException
058: */
059: public Editable createNewVersion() throws EditException;
060:
061: /** Archives this object in to the store of historical objects.
062: *
063: * @return The archived object
064: */
065: public Editable archive() throws EditException;
066:
067: /**
068: * Alters the status of this object to the given status.
069: *
070: * @param nStatus The new Status
071: * @return The new version of this object of the given status
072: */
073: public Editable changeStatus(Status nStatus) throws EditException;
074:
075: /**
076: * Tests whether the object is locked.
077: *
078: * @return
079: * @throws DataAccessException
080: */
081: public boolean isLocked() throws DataAccessException;
082:
083: /**
084: * Locks this object, its unapproved versions and live version if exist.
085: * Checks that user id matches lock id, if already locked do nothing.
086: *
087: * @param nUserId
088: * @throws EditException if object locked by another user.
089: */
090: public void lock(User usr) throws EditException;
091:
092: /**
093: * Unlocks this object, its unapproved versions and parent if exist.
094: * Check that user id matches lock id or that user has permisssion to perform the
095: * unlock, if unlocked do nothing.
096: *
097: * @param nUserId
098: * @throws EditException if user id does not match lock id
099: */
100: public void unlock(User usr) throws EditException;
101:
102: /**
103: * Returns the user who owns the lock on this object if it is locked.
104: *
105: * @return
106: * @throws DataAccessException
107: */
108: public User getLockOwner() throws DataAccessException;
109:
110: /**
111: * Reactivate historical object by creating a pending version.
112: *
113: * @throws EditException
114: */
115: public Editable reactivate() throws EditException;
116:
117: /** Gets all of the unnaproved versions of this object.
118: *
119: * @return Vector All of the unapproved versions
120: */
121: public List getPendingVersions() throws DataAccessException;
122:
123: /**
124: * Returns the live/current version of this object.
125: *
126: * @return live version
127: */
128: public Editable getLiveVersion() throws DataAccessException;
129:
130: /**
131: * Tests whether this object is a live/current version.
132: *
133: * @return
134: * @throws DataAccessException
135: */
136: public boolean isLiveVersion() throws DataAccessException;
137:
138: /**
139: * Returns all of the versions for this object.
140: *
141: * @return
142: * @throws DataAccessException
143: */
144: public List getAllVersions() throws DataAccessException;
145:
146: /**
147: * Gets all of the historical versions of this object.
148: * If this is an historical document, gets all of the versions that are older than this one
149: *
150: * @return Vector All of the historical versions
151: */
152: public List getHistoricalVersions() throws DataAccessException;
153:
154: /**
155: * Returns the status of this object.
156: *
157: * @return int The current status
158: */
159: public Status getStatus() throws DataAccessException;
160:
161: /**
162: * Adds a listener to receive edit events when the object has been edited.
163: *
164: * @param listener
165: */
166: public void addEditEventListener(EditEventListener listener);
167:
168: /**
169: * Removes a edit event listener.
170: *
171: * @param listener
172: */
173: public void removeEditEventListener(EditEventListener listener);
174: }
|