| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.api.rule; |
| 17 | |
|
| 18 | |
import java.io.Serializable; |
| 19 | |
import java.util.Collection; |
| 20 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 21 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 22 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 23 | |
import javax.xml.bind.annotation.XmlElement; |
| 24 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 25 | |
import javax.xml.bind.annotation.XmlType; |
| 26 | |
|
| 27 | |
import org.apache.commons.lang.StringUtils; |
| 28 | |
import org.kuali.rice.core.api.CoreConstants; |
| 29 | |
import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; |
| 30 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 31 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 32 | |
import org.w3c.dom.Element; |
| 33 | |
|
| 34 | |
@XmlRootElement(name = RoleName.Constants.ROOT_ELEMENT_NAME) |
| 35 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 36 | |
@XmlType(name = RoleName.Constants.TYPE_NAME, propOrder = { |
| 37 | |
RoleName.Elements.NAME, |
| 38 | |
RoleName.Elements.BASE_NAME, |
| 39 | |
RoleName.Elements.RETURN_URL, |
| 40 | |
RoleName.Elements.LABEL, |
| 41 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 42 | |
}) |
| 43 | 0 | public final class RoleName |
| 44 | |
extends AbstractDataTransferObject |
| 45 | |
implements RoleNameContract |
| 46 | |
{ |
| 47 | |
|
| 48 | |
@XmlElement(name = Elements.NAME, required = true) |
| 49 | |
private final String name; |
| 50 | |
@XmlElement(name = Elements.BASE_NAME, required = true) |
| 51 | |
private final String baseName; |
| 52 | |
@XmlElement(name = Elements.RETURN_URL, required = false) |
| 53 | |
private final String returnUrl; |
| 54 | |
@XmlElement(name = Elements.LABEL, required = true) |
| 55 | |
private final String label; |
| 56 | 0 | @SuppressWarnings("unused") |
| 57 | |
@XmlAnyElement |
| 58 | |
private final Collection<Element> _futureElements = null; |
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | 0 | private RoleName() { |
| 65 | 0 | this.name = null; |
| 66 | 0 | this.baseName = null; |
| 67 | 0 | this.returnUrl = null; |
| 68 | 0 | this.label = null; |
| 69 | 0 | } |
| 70 | |
|
| 71 | 0 | private RoleName(Builder builder) { |
| 72 | 0 | this.name = builder.getName(); |
| 73 | 0 | this.baseName = builder.getBaseName(); |
| 74 | 0 | this.returnUrl = builder.getReturnUrl(); |
| 75 | 0 | this.label = builder.getLabel(); |
| 76 | 0 | } |
| 77 | |
|
| 78 | |
public RoleName(String attributeClassName, String baseName, String label) { |
| 79 | 0 | this(RoleName.Builder.createWithClassName(attributeClassName, baseName, label)); |
| 80 | 0 | } |
| 81 | |
|
| 82 | |
@Override |
| 83 | |
public String getName() { |
| 84 | 0 | return this.name; |
| 85 | |
} |
| 86 | |
|
| 87 | |
@Override |
| 88 | |
public String getBaseName() { |
| 89 | 0 | return this.baseName; |
| 90 | |
} |
| 91 | |
|
| 92 | |
@Override |
| 93 | |
public String getReturnUrl() { |
| 94 | 0 | return this.returnUrl; |
| 95 | |
} |
| 96 | |
|
| 97 | |
@Override |
| 98 | |
public String getLabel() { |
| 99 | 0 | return this.label; |
| 100 | |
} |
| 101 | |
|
| 102 | |
public static String constructRoleValue(String attributeClassName, String roleName) { |
| 103 | 0 | return attributeClassName + "!" + roleName; |
| 104 | |
} |
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | 0 | public final static class Builder |
| 112 | |
implements Serializable, ModelBuilder, RoleNameContract |
| 113 | |
{ |
| 114 | |
|
| 115 | |
private String name; |
| 116 | |
private String baseName; |
| 117 | |
private String returnUrl; |
| 118 | |
private String label; |
| 119 | |
|
| 120 | 0 | private Builder(String name, String baseName, String label) { |
| 121 | 0 | setName(name); |
| 122 | 0 | setBaseName(baseName); |
| 123 | 0 | setLabel(label); |
| 124 | 0 | } |
| 125 | |
|
| 126 | |
public static Builder createWithClassName(String attributeClassName, String baseName, String label) { |
| 127 | 0 | return new Builder(constructRoleValue(attributeClassName, baseName), baseName, label); |
| 128 | |
} |
| 129 | |
|
| 130 | |
public static Builder create(String name, String baseName, String label) { |
| 131 | 0 | return new Builder(name, baseName, label); |
| 132 | |
} |
| 133 | |
|
| 134 | |
public static Builder create(RoleNameContract contract) { |
| 135 | 0 | if (contract == null) { |
| 136 | 0 | throw new IllegalArgumentException("contract was null"); |
| 137 | |
} |
| 138 | 0 | Builder builder = create(contract.getName(), contract.getBaseName(), contract.getLabel()); |
| 139 | 0 | builder.setReturnUrl(contract.getReturnUrl()); |
| 140 | 0 | return builder; |
| 141 | |
} |
| 142 | |
|
| 143 | |
public RoleName build() { |
| 144 | 0 | return new RoleName(this); |
| 145 | |
} |
| 146 | |
|
| 147 | |
@Override |
| 148 | |
public String getName() { |
| 149 | 0 | return this.name; |
| 150 | |
} |
| 151 | |
|
| 152 | |
@Override |
| 153 | |
public String getBaseName() { |
| 154 | 0 | return this.baseName; |
| 155 | |
} |
| 156 | |
|
| 157 | |
@Override |
| 158 | |
public String getReturnUrl() { |
| 159 | 0 | return this.returnUrl; |
| 160 | |
} |
| 161 | |
|
| 162 | |
@Override |
| 163 | |
public String getLabel() { |
| 164 | 0 | return this.label; |
| 165 | |
} |
| 166 | |
|
| 167 | |
public void setName(String name) { |
| 168 | 0 | if (StringUtils.isBlank(name)) { |
| 169 | 0 | throw new RiceIllegalArgumentException("name is blank"); |
| 170 | |
} |
| 171 | 0 | this.name = name; |
| 172 | 0 | } |
| 173 | |
|
| 174 | |
public void setBaseName(String baseName) { |
| 175 | 0 | if (StringUtils.isBlank(baseName)) { |
| 176 | 0 | throw new RiceIllegalArgumentException("baseName is blank"); |
| 177 | |
} |
| 178 | 0 | this.baseName = baseName; |
| 179 | 0 | } |
| 180 | |
|
| 181 | |
public void setReturnUrl(String returnUrl) { |
| 182 | 0 | this.returnUrl = returnUrl; |
| 183 | 0 | } |
| 184 | |
|
| 185 | |
public void setLabel(String label) { |
| 186 | 0 | if (StringUtils.isBlank(label)) { |
| 187 | 0 | throw new RiceIllegalArgumentException("label is blank"); |
| 188 | |
} |
| 189 | 0 | this.label = label; |
| 190 | 0 | } |
| 191 | |
|
| 192 | |
} |
| 193 | |
|
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | 0 | static class Constants { |
| 200 | |
|
| 201 | |
final static String ROOT_ELEMENT_NAME = "roleName"; |
| 202 | |
final static String TYPE_NAME = "RoleNameType"; |
| 203 | |
|
| 204 | |
} |
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
|
| 210 | |
|
| 211 | 0 | static class Elements { |
| 212 | |
|
| 213 | |
final static String NAME = "name"; |
| 214 | |
final static String BASE_NAME = "baseName"; |
| 215 | |
final static String RETURN_URL = "returnUrl"; |
| 216 | |
final static String LABEL = "label"; |
| 217 | |
|
| 218 | |
} |
| 219 | |
|
| 220 | |
} |