KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > resources > lifecycle > Editable


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.rm.resources.lifecycle;
20
21 import java.util.List JavaDoc;
22
23 import org.openharmonise.rm.DataAccessException;
24 import org.openharmonise.rm.resources.users.User;
25
26
27 /**
28  * The <code>Editable</code> interface provides for objects which can be edited
29  * within a versioning system.
30  *
31  * @author Michael Bell
32  * @version $Revision: 1.2 $
33  *
34  */

35 public interface Editable
36 {
37     //lock label
38
public static final String JavaDoc LABEL_LOCK = "lock";
39     //unlock label
40
public static final String JavaDoc LABEL_UNLOCK = "unlock";
41     
42     /**
43      * Saves current data to data store. If the object being saved is a live version
44      * and data has been changed, a new unapproved version is created. This method will
45      * return the result of the save operation, i.e. if it is an unapproved object the
46      * orginal object will be returned, otherwise the newly created unapproved version
47      * will be returned.
48      *
49      * @return
50      * @throws EditException
51      */

52     public Editable save() throws EditException;
53     
54     /**
55      * Returns a new version of this editable object, if the current version is a live
56      * version, otherwise is returns the current object.
57      *
58      * @return
59      * @throws EditException
60      */

61     public Editable createNewVersion() throws EditException;
62
63     /** Archives this object in to the store of historical objects.
64      *
65      * @return The archived object
66      */

67     public Editable archive() throws EditException;
68
69     /**
70      * Alters the status of this object to the given status.
71      *
72      * @param nStatus The new Status
73      * @return The new version of this object of the given status
74      */

75     public Editable changeStatus( Status nStatus ) throws EditException;
76
77     /**
78      * Tests whether the object is locked.
79      *
80      * @return
81      * @throws DataAccessException
82      */

83     public boolean isLocked() throws DataAccessException;
84     
85     /**
86     * Locks this object, its unapproved versions and live version if exist.
87     * Checks that user id matches lock id, if already locked do nothing.
88     *
89     * @param nUserId
90     * @throws EditException if object locked by another user.
91     */

92     public void lock(User usr) throws EditException;
93
94     /**
95      * Unlocks this object, its unapproved versions and parent if exist.
96      * Check that user id matches lock id or that user has permisssion to perform the
97      * unlock, if unlocked do nothing.
98      *
99      * @param nUserId
100      * @throws EditException if user id does not match lock id
101      */

102     public void unlock(User usr) throws EditException;
103
104     /**
105      * Returns the user who owns the lock on this object if it is locked.
106      *
107      * @return
108      * @throws DataAccessException
109      */

110     public User getLockOwner() throws DataAccessException;
111
112     /**
113      * Reactivate historical object by creating a pending version.
114      *
115      * @throws EditException
116      */

117     public Editable reactivate() throws EditException;
118
119     /** Gets all of the unnaproved versions of this object.
120      *
121      * @return Vector All of the unapproved versions
122      */

123     public List JavaDoc getPendingVersions() throws DataAccessException;
124
125     /**
126      * Returns the live/current version of this object.
127      *
128      * @return live version
129      */

130     public Editable getLiveVersion() throws DataAccessException;
131     
132     /**
133      * Tests whether this object is a live/current version.
134      *
135      * @return
136      * @throws DataAccessException
137      */

138     public boolean isLiveVersion() throws DataAccessException;
139
140     /**
141      * Returns all of the versions for this object.
142      *
143      * @return
144      * @throws DataAccessException
145      */

146     public List JavaDoc getAllVersions() throws DataAccessException;
147
148     /**
149      * Gets all of the historical versions of this object.
150      * If this is an historical document, gets all of the versions that are older than this one
151      *
152      * @return Vector All of the historical versions
153      */

154     public List JavaDoc getHistoricalVersions() throws DataAccessException;
155
156     /**
157      * Returns the status of this object.
158      *
159      * @return int The current status
160      */

161     public Status getStatus() throws DataAccessException;
162
163     /**
164      * Adds a listener to receive edit events when the object has been edited.
165      *
166      * @param listener
167      */

168     public void addEditEventListener(EditEventListener listener);
169     
170     /**
171      * Removes a edit event listener.
172      *
173      * @param listener
174      */

175     public void removeEditEventListener(EditEventListener listener);
176 }
177
Popular Tags