1 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 46 public class WorkflowProperty extends Property { 47 48 public static final String TAG_WORKFLOW_PROPERTY = "WorkflowProperty"; 49 50 static { 51 RangeFactory.getInstance().addNewRange( 52 WorkflowRange.class.getName(), 53 WorkflowRange.class.getName()); 54 } 55 56 { 58 m_range = new WorkflowRange(); 59 } 60 61 64 public WorkflowProperty() { 65 super(); 66 } 67 68 73 public WorkflowProperty(AbstractDataStoreInterface dbintrf) { 74 super(dbintrf); 75 76 } 77 78 85 public WorkflowProperty( 86 AbstractDataStoreInterface dbintrf, 87 int nId) { 88 super(dbintrf, nId); 89 } 90 91 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 110 public void setRange(Range range) throws PopulateException { 111 if(range instanceof WorkflowRange) { 112 super.setRange(range); 113 } else { 114 String 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 135 public String getParentObjectClassName() { 136 137 return WorkflowPropertyGroup.class.getName(); 138 } 139 140 141 144 protected void checkDomainAndRange(Domain domain) throws EditException { 145 } 147 148 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 176 public String getTagName() { 177 return TAG_WORKFLOW_PROPERTY; 178 } 179 } 180 | Popular Tags |