KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > resources > workflow > properties > WorkflowProperty


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.workflow.properties;
20
21 import java.util.*;
22
23 import org.openharmonise.commons.dsi.AbstractDataStoreInterface;
24 import org.openharmonise.rm.*;
25 import org.openharmonise.rm.resources.lifecycle.*;
26 import org.openharmonise.rm.resources.metadata.properties.*;
27 import org.openharmonise.rm.resources.metadata.properties.domains.Domain;
28 import org.openharmonise.rm.resources.metadata.properties.ranges.*;
29 import org.openharmonise.rm.resources.workflow.properties.domains.WorkflowPropertyDomain;
30 import org.openharmonise.rm.resources.workflow.properties.ranges.WorkflowRange;
31 import org.openharmonise.rm.resources.workflow.values.WorkflowStageValueGroup;
32
33
34 /**
35  * This class represents a definition of a workflow lifecycle, containing references to
36  * workflow stages which must be completed before the workflow is completed.
37  *
38  * The class is implemented as an extension of <code>Property</code>, offering
39  * extra utility methods to manage work flow specific data. The range of this
40  * property object must always be <code>WorkflowRange</code>.
41  *
42  * @author Michael Bell
43  * @version $Revision: 1.2 $
44  *
45  */

46 public class WorkflowProperty extends Property {
47
48     public static final String JavaDoc TAG_WORKFLOW_PROPERTY = "WorkflowProperty";
49     
50     static {
51         RangeFactory.getInstance().addNewRange(
52             WorkflowRange.class.getName(),
53             WorkflowRange.class.getName());
54     }
55     
56     //initialise range
57
{
58         m_range = new WorkflowRange();
59     }
60
61     /**
62      * Basic constructor.
63      */

64     public WorkflowProperty() {
65         super();
66     }
67
68     /**
69      * Basic constructor which takes a datastore interface.
70      *
71      * @param dbintrf
72      */

73     public WorkflowProperty(AbstractDataStoreInterface dbintrf) {
74         super(dbintrf);
75
76     }
77
78     /**
79      * Constructs a specific instance of a workflow definition, defined
80      * by the given identifier.
81      *
82      * @param dbintrf
83      * @param nId
84      */

85     public WorkflowProperty(
86         AbstractDataStoreInterface dbintrf,
87         int nId) {
88         super(dbintrf, nId);
89     }
90
91     /**
92      * Constructs a specific historical workflow instance.
93      *
94      * @param dbintrf
95      * @param nId
96      * @param bIsHist
97      */

98     public WorkflowProperty(
99         AbstractDataStoreInterface dbintrf,
100         int nId,
101         int nKey,
102         boolean bIsHist) {
103         super(dbintrf, nId, nKey, bIsHist);
104
105     }
106
107     /* (non-Javadoc)
108      * @see org.openharmonise.rm.resources.metadata.properties.Property#setRange(org.openharmonise.rm.resources.metadata.properties.ranges.Range)
109      */

110     public void setRange(Range range) throws PopulateException {
111         if(range instanceof WorkflowRange) {
112             super.setRange(range);
113         } else {
114             String JavaDoc sRangeClass = null;
115             if(range != null) {
116                 sRangeClass = range.getClass().getName();
117             }
118             throw new InvalidRangeException("Range has to be instance of workflowrange, not " + sRangeClass);
119         }
120         
121     }
122     
123     public void setWorkflowValueGroup(WorkflowStageValueGroup valGrp) throws PopulateException {
124         
125         try {
126             ((WorkflowRange)m_range).addAllowedParent(valGrp.getFullPath());
127         } catch (DataAccessException e) {
128             throw new PopulateException(e.getLocalizedMessage(),e);
129         }
130     }
131
132     /* (non-Javadoc)
133      * @see org.openharmonise.rm.resources.AbstractChildObject#getParentObjectClassName()
134      */

135     public String JavaDoc getParentObjectClassName() {
136         
137         return WorkflowPropertyGroup.class.getName();
138     }
139     
140     
141     /* (non-Javadoc)
142      * @see org.openharmonise.rm.resources.metadata.properties.Property#checkDomainAndRange(org.openharmonise.rm.resources.metadata.properties.domains.Domain)
143      */

144     protected void checkDomainAndRange(Domain domain) throws EditException {
145         //do nothing as there's no point
146
}
147     
148     /* (non-Javadoc)
149      * @see org.openharmonise.rm.resources.lifecycle.Editable#changeStatus(org.openharmonise.rm.resources.lifecycle.Status)
150      */

151     public Editable changeStatus(Status status) throws EditException {
152         
153         try {
154             List domains = getDomains();
155             
156             ListIterator iter = domains.listIterator();
157             
158             while (iter.hasNext()) {
159                 Domain domain = (Domain) iter.next();
160                 
161                 if(WorkflowPropertyDomain.validate(this,domain) == false) {
162                     throw new StatusChangeNotAllowedException("Domain not valid");
163                 }
164                 
165             }
166         } catch (DataAccessException e) {
167             throw new EditException(e);
168         }
169         
170         return super.changeStatus(status);
171     }
172     
173     /* (non-Javadoc)
174      * @see org.openharmonise.rm.publishing.Publishable#getTagName()
175      */

176     public String JavaDoc getTagName() {
177         return TAG_WORKFLOW_PROPERTY;
178     }
179 }
180
Popular Tags