KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > resources > workflow > properties > ranges > WorkflowRange


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.ranges;
20
21 import java.util.*;
22
23 import org.openharmonise.commons.dsi.*;
24 import org.openharmonise.rm.DataAccessException;
25 import org.openharmonise.rm.dsi.DataStoreInterfaceFactory;
26 import org.openharmonise.rm.factory.*;
27 import org.openharmonise.rm.resources.*;
28 import org.openharmonise.rm.resources.metadata.properties.ranges.AbsoluteChildObjectRange;
29 import org.openharmonise.rm.resources.workflow.values.WorkflowStageValue;
30 import org.openharmonise.rm.workflow.WorkflowPropertyInstance;
31
32
33 /**
34  * Range definition for a workflow definition.
35  *
36  * @author Michael Bell
37  * @version $Revision: 1.2 $
38  *
39  */

40 public class WorkflowRange extends AbsoluteChildObjectRange {
41
42     /**
43      * Default constructor.
44      */

45     public WorkflowRange() {
46         super(WorkflowRange.class.getName());
47     }
48
49     /**
50      * @param sObjClassName
51      * @param sDetails
52      */

53     public WorkflowRange(String JavaDoc sObjClassName, String JavaDoc sDetails) {
54         super(sObjClassName, sDetails);
55     }
56
57     /**
58      * Returns the list of stage definitions associated with this range.
59      *
60      * @param dsi
61      * @return
62      * @throws DataAccessException
63      */

64     public List getStageDefinitions() throws DataAccessException {
65         return getAvailableValues();
66     }
67
68     /* (non-Javadoc)
69      * @see org.openharmonise.rm.resources.metadata.properties.ranges.Range#getPropertyInstanceClass()
70      */

71     public Class JavaDoc getPropertyInstanceClass() throws ClassNotFoundException JavaDoc {
72         return WorkflowPropertyInstance.class;
73     }
74
75     /**
76      * Returns a list of available <code>AbstractChildObject</code> instances this
77      * range defines.
78      *
79      * @return
80      * @throws DataAccessException
81      */

82     public List getAvailableValues() throws DataAccessException {
83         Vector result = new Vector();
84         try {
85             AbstractDataStoreInterface dsi =
86                 DataStoreInterfaceFactory.getDataStoreInterface();
87
88             AbstractChildObject child =
89                 (AbstractChildObject) WorkflowStageValue.class.newInstance();
90
91             String JavaDoc sParentClassName = child.getParentObjectClassName();
92
93             Iterator iter = getAllowedParents().iterator();
94
95             while (iter.hasNext()) {
96                 String JavaDoc sPath = (String JavaDoc) iter.next();
97
98                 AbstractParentObject parent =
99                     (
100                         AbstractParentObject) HarmoniseObjectFactory
101                             .instantiateHarmoniseObject(
102                         dsi,
103                         sParentClassName,
104                         sPath);
105
106                 addAllChildObjectsToList(result, parent);
107
108             }
109
110         } catch (HarmoniseFactoryException e) {
111             throw new DataAccessException(
112                 "Error occured getting parent from factory",
113                 e);
114         } catch (InstantiationException JavaDoc e) {
115             throw new DataAccessException(
116                 "Error occured getting class for child",
117                 e);
118         } catch (IllegalAccessException JavaDoc e) {
119             throw new DataAccessException(
120                 "Error occured getting class for child",
121                 e);
122         } catch (DataStoreException e) {
123             throw new DataAccessException(
124                 "Error occured getting class for child:",
125                 e);
126         }
127
128         return result;
129     }
130
131     /* (non-Javadoc)
132      * @see org.openharmonise.rm.resources.metadata.properties.ranges.Range#isValid(java.lang.Object)
133      */

134     public boolean isValid(Object JavaDoc obj) {
135         
136         return (obj instanceof WorkflowStageValue);
137     }
138
139     /* (non-Javadoc)
140      * @see org.openharmonise.rm.resources.metadata.properties.ranges.ChildObjectRange#getChildObjectValueClassName(org.openharmonise.rm.resources.AbstractChildObject)
141      */

142     public String JavaDoc getChildObjectValueClassName(AbstractChildObject child) {
143         return WorkflowStageValue.class.getName();
144     }
145
146     /* (non-Javadoc)
147      * @see org.openharmonise.rm.resources.metadata.properties.ranges.AbsoluteChildObjectRange#setObjectRestriction(java.lang.String)
148      */

149     public void setObjectRestriction(String JavaDoc sClassname) {
150         //do nothing as this can't be reset
151
}
152
153 }
154
Popular Tags