001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kew.api.rule; 017 018 import org.kuali.rice.core.api.CoreConstants; 019 import org.kuali.rice.core.api.mo.AbstractDataTransferObject; 020 import org.kuali.rice.core.api.mo.ModelBuilder; 021 import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter; 022 import org.w3c.dom.Element; 023 024 import javax.xml.bind.annotation.XmlAccessType; 025 import javax.xml.bind.annotation.XmlAccessorType; 026 import javax.xml.bind.annotation.XmlAnyElement; 027 import javax.xml.bind.annotation.XmlElement; 028 import javax.xml.bind.annotation.XmlElementWrapper; 029 import javax.xml.bind.annotation.XmlRootElement; 030 import javax.xml.bind.annotation.XmlType; 031 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 032 import java.io.Serializable; 033 import java.util.Collection; 034 import java.util.Collections; 035 import java.util.List; 036 import java.util.Map; 037 038 @XmlRootElement(name = RuleReportCriteria.Constants.ROOT_ELEMENT_NAME) 039 @XmlAccessorType(XmlAccessType.NONE) 040 @XmlType(name = RuleReportCriteria.Constants.TYPE_NAME, propOrder = { 041 RuleReportCriteria.Elements.RULE_DESCRIPTION, 042 RuleReportCriteria.Elements.DOCUMENT_TYPE_NAME, 043 RuleReportCriteria.Elements.RULE_TEMPLATE_NAME, 044 RuleReportCriteria.Elements.ACTION_REQUEST_CODES, 045 RuleReportCriteria.Elements.RESPONSIBLE_PRINCIPAL_ID, 046 RuleReportCriteria.Elements.RESPONSIBLE_GROUP_ID, 047 RuleReportCriteria.Elements.RESPONSIBLE_ROLE_NAME, 048 RuleReportCriteria.Elements.RULE_EXTENSIONS, 049 RuleReportCriteria.Elements.ACTIVE, 050 RuleReportCriteria.Elements.CONSIDER_GROUP_MEMBERSHIP, 051 RuleReportCriteria.Elements.INCLUDE_DELEGATIONS, 052 CoreConstants.CommonElements.FUTURE_ELEMENTS 053 }) 054 public final class RuleReportCriteria 055 extends AbstractDataTransferObject 056 implements RuleReportCriteriaContract 057 { 058 059 @XmlElement(name = Elements.RULE_DESCRIPTION, required = false) 060 private final String ruleDescription; 061 @XmlElement(name = Elements.DOCUMENT_TYPE_NAME, required = false) 062 private final String documentTypeName; 063 @XmlElement(name = Elements.RULE_TEMPLATE_NAME, required = false) 064 private final String ruleTemplateName; 065 @XmlElementWrapper(name = Elements.ACTION_REQUEST_CODES, required = false) 066 @XmlElement(name = Elements.ACTION_REQUEST_CODE, required = false) 067 private final List<String> actionRequestCodes; 068 @XmlElement(name = Elements.RESPONSIBLE_PRINCIPAL_ID, required = false) 069 private final String responsiblePrincipalId; 070 @XmlElement(name = Elements.RESPONSIBLE_GROUP_ID, required = false) 071 private final String responsibleGroupId; 072 @XmlElement(name = Elements.RESPONSIBLE_ROLE_NAME, required = false) 073 private final String responsibleRoleName; 074 @XmlElement(name = Elements.RULE_EXTENSIONS, required = false) 075 @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) 076 private final Map<String, String> ruleExtensions; 077 @XmlElement(name = Elements.ACTIVE, required = false) 078 private final boolean active; 079 @XmlElement(name = Elements.CONSIDER_GROUP_MEMBERSHIP, required = false) 080 private final boolean considerGroupMembership; 081 @XmlElement(name = Elements.INCLUDE_DELEGATIONS, required = false) 082 private final boolean includeDelegations; 083 @SuppressWarnings("unused") 084 @XmlAnyElement 085 private final Collection<Element> _futureElements = null; 086 087 /** 088 * Private constructor used only by JAXB. 089 * 090 */ 091 private RuleReportCriteria() { 092 this.ruleDescription = null; 093 this.documentTypeName = null; 094 this.ruleTemplateName = null; 095 this.actionRequestCodes = null; 096 this.responsiblePrincipalId = null; 097 this.responsibleGroupId = null; 098 this.responsibleRoleName = null; 099 this.ruleExtensions = null; 100 this.active = false; 101 this.considerGroupMembership = false; 102 this.includeDelegations = false; 103 } 104 105 private RuleReportCriteria(Builder builder) { 106 this.ruleDescription = builder.getRuleDescription(); 107 this.documentTypeName = builder.getDocumentTypeName(); 108 this.ruleTemplateName = builder.getRuleTemplateName(); 109 this.actionRequestCodes = builder.getActionRequestCodes(); 110 this.responsiblePrincipalId = builder.getResponsiblePrincipalId(); 111 this.responsibleGroupId = builder.getResponsibleGroupId(); 112 this.responsibleRoleName = builder.getResponsibleRoleName(); 113 this.ruleExtensions = builder.getRuleExtensions(); 114 this.active = builder.isActive(); 115 this.considerGroupMembership = builder.isConsiderGroupMembership(); 116 this.includeDelegations = builder.isIncludeDelegations(); 117 } 118 119 @Override 120 public String getRuleDescription() { 121 return this.ruleDescription; 122 } 123 124 @Override 125 public String getDocumentTypeName() { 126 return this.documentTypeName; 127 } 128 129 @Override 130 public String getRuleTemplateName() { 131 return this.ruleTemplateName; 132 } 133 134 @Override 135 public List<String> getActionRequestCodes() { 136 return this.actionRequestCodes; 137 } 138 139 @Override 140 public String getResponsiblePrincipalId() { 141 return this.responsiblePrincipalId; 142 } 143 144 @Override 145 public String getResponsibleGroupId() { 146 return this.responsibleGroupId; 147 } 148 149 @Override 150 public String getResponsibleRoleName() { 151 return this.responsibleRoleName; 152 } 153 154 @Override 155 public Map<String, String> getRuleExtensions() { 156 return this.ruleExtensions; 157 } 158 159 @Override 160 public boolean isActive() { 161 return this.active; 162 } 163 164 @Override 165 public boolean isConsiderGroupMembership() { 166 return this.considerGroupMembership; 167 } 168 169 @Override 170 public boolean isIncludeDelegations() { 171 return this.includeDelegations; 172 } 173 174 175 /** 176 * A builder which can be used to construct {@link RuleReportCriteria} instances. Enforces the constraints of the {@link RuleReportCriteriaContract}. 177 * 178 */ 179 public final static class Builder 180 implements Serializable, ModelBuilder, RuleReportCriteriaContract 181 { 182 183 private String ruleDescription; 184 private String documentTypeName; 185 private String ruleTemplateName; 186 private List<String> actionRequestCodes; 187 private String responsiblePrincipalId; 188 private String responsibleGroupId; 189 private String responsibleRoleName; 190 private Map<String, String> ruleExtensions; 191 private boolean active; 192 private boolean considerGroupMembership; 193 private boolean includeDelegations; 194 195 private Builder() { 196 setActive(true); 197 setConsiderGroupMembership(true); 198 } 199 200 public static Builder create() { 201 return new Builder(); 202 } 203 204 public static Builder create(RuleReportCriteriaContract contract) { 205 if (contract == null) { 206 throw new IllegalArgumentException("contract was null"); 207 } 208 Builder builder = create(); 209 builder.setRuleDescription(contract.getRuleDescription()); 210 builder.setDocumentTypeName(contract.getDocumentTypeName()); 211 builder.setRuleTemplateName(contract.getRuleTemplateName()); 212 builder.setActionRequestCodes(contract.getActionRequestCodes()); 213 builder.setResponsiblePrincipalId(contract.getResponsiblePrincipalId()); 214 builder.setResponsibleGroupId(contract.getResponsibleGroupId()); 215 builder.setResponsibleRoleName(contract.getResponsibleRoleName()); 216 builder.setRuleExtensions(contract.getRuleExtensions()); 217 builder.setActive(contract.isActive()); 218 builder.setConsiderGroupMembership(contract.isConsiderGroupMembership()); 219 builder.setIncludeDelegations(contract.isIncludeDelegations()); 220 return builder; 221 } 222 223 public RuleReportCriteria build() { 224 return new RuleReportCriteria(this); 225 } 226 227 @Override 228 public String getRuleDescription() { 229 return this.ruleDescription; 230 } 231 232 @Override 233 public String getDocumentTypeName() { 234 return this.documentTypeName; 235 } 236 237 @Override 238 public String getRuleTemplateName() { 239 return this.ruleTemplateName; 240 } 241 242 @Override 243 public List<String> getActionRequestCodes() { 244 return this.actionRequestCodes; 245 } 246 247 @Override 248 public String getResponsiblePrincipalId() { 249 return this.responsiblePrincipalId; 250 } 251 252 @Override 253 public String getResponsibleGroupId() { 254 return this.responsibleGroupId; 255 } 256 257 @Override 258 public String getResponsibleRoleName() { 259 return this.responsibleRoleName; 260 } 261 262 @Override 263 public Map<String, String> getRuleExtensions() { 264 return this.ruleExtensions; 265 } 266 267 @Override 268 public boolean isActive() { 269 return this.active; 270 } 271 272 @Override 273 public boolean isConsiderGroupMembership() { 274 return this.considerGroupMembership; 275 } 276 277 @Override 278 public boolean isIncludeDelegations() { 279 return this.includeDelegations; 280 } 281 282 public void setRuleDescription(String ruleDescription) { 283 284 this.ruleDescription = ruleDescription; 285 } 286 287 public void setDocumentTypeName(String documentTypeName) { 288 289 this.documentTypeName = documentTypeName; 290 } 291 292 public void setRuleTemplateName(String ruleTemplateName) { 293 294 this.ruleTemplateName = ruleTemplateName; 295 } 296 297 public void setActionRequestCodes(List<String> actionRequestCodes) { 298 299 this.actionRequestCodes = actionRequestCodes; 300 } 301 302 public void setResponsiblePrincipalId(String responsiblePrincipalId) { 303 304 this.responsiblePrincipalId = responsiblePrincipalId; 305 } 306 307 public void setResponsibleGroupId(String responsibleGroupId) { 308 309 this.responsibleGroupId = responsibleGroupId; 310 } 311 312 public void setResponsibleRoleName(String responsibleRoleName) { 313 314 this.responsibleRoleName = responsibleRoleName; 315 } 316 317 public void setRuleExtensions(Map<String, String> ruleExtensions) { 318 319 this.ruleExtensions = Collections.unmodifiableMap(ruleExtensions); 320 } 321 322 public void setActive(boolean active) { 323 324 this.active = active; 325 } 326 327 public void setConsiderGroupMembership(boolean considerGroupMembership) { 328 329 this.considerGroupMembership = considerGroupMembership; 330 } 331 332 public void setIncludeDelegations(boolean includeDelegations) { 333 334 this.includeDelegations = includeDelegations; 335 } 336 337 } 338 339 340 /** 341 * Defines some internal constants used on this class. 342 * 343 */ 344 static class Constants { 345 346 final static String ROOT_ELEMENT_NAME = "ruleReportCriteria"; 347 final static String TYPE_NAME = "RuleReportCriteriaType"; 348 349 } 350 351 352 /** 353 * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML. 354 * 355 */ 356 static class Elements { 357 358 final static String RULE_DESCRIPTION = "ruleDescription"; 359 final static String DOCUMENT_TYPE_NAME = "documentTypeName"; 360 final static String RULE_TEMPLATE_NAME = "ruleTemplateName"; 361 final static String ACTION_REQUEST_CODES = "actionRequestCodes"; 362 final static String ACTION_REQUEST_CODE = "actionRequestCode"; 363 final static String RESPONSIBLE_PRINCIPAL_ID = "responsiblePrincipalId"; 364 final static String RESPONSIBLE_GROUP_ID = "responsibleGroupId"; 365 final static String RESPONSIBLE_ROLE_NAME = "responsibleRoleName"; 366 final static String RULE_EXTENSIONS = "ruleExtensions"; 367 final static String ACTIVE = "active"; 368 final static String CONSIDER_GROUP_MEMBERSHIP = "considerGroupMembership"; 369 final static String INCLUDE_DELEGATIONS = "includeDelegations"; 370 371 } 372 373 }