| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.framework.document.search; |
| 17 | |
|
| 18 | |
import java.io.Serializable; |
| 19 | |
import java.util.ArrayList; |
| 20 | |
import java.util.Collection; |
| 21 | |
import java.util.List; |
| 22 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 23 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 24 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 25 | |
import javax.xml.bind.annotation.XmlElement; |
| 26 | |
import javax.xml.bind.annotation.XmlElementWrapper; |
| 27 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 28 | |
import javax.xml.bind.annotation.XmlType; |
| 29 | |
|
| 30 | |
import org.apache.commons.lang.StringUtils; |
| 31 | |
import org.kuali.rice.core.api.CoreConstants; |
| 32 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 33 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 34 | |
import org.kuali.rice.core.api.mo.ModelObjectUtils; |
| 35 | |
import org.kuali.rice.kew.api.document.attribute.DocumentAttribute; |
| 36 | |
import org.kuali.rice.kew.api.document.attribute.DocumentAttributeContract; |
| 37 | |
import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory; |
| 38 | |
import org.w3c.dom.Element; |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
@XmlRootElement(name = DocumentSearchResultValue.Constants.ROOT_ELEMENT_NAME) |
| 47 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 48 | |
@XmlType(name = DocumentSearchResultValue.Constants.TYPE_NAME, propOrder = { |
| 49 | |
DocumentSearchResultValue.Elements.DOCUMENT_ID, |
| 50 | |
DocumentSearchResultValue.Elements.DOCUMENT_ATTRIBUTES, |
| 51 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 52 | |
}) |
| 53 | 0 | public final class DocumentSearchResultValue extends AbstractDataTransferObject |
| 54 | |
implements DocumentSearchResultValueContract { |
| 55 | |
|
| 56 | |
@XmlElement(name = Elements.DOCUMENT_ID, required = true) |
| 57 | |
private final String documentId; |
| 58 | |
|
| 59 | |
@XmlElementWrapper(name = Elements.DOCUMENT_ATTRIBUTES, required = false) |
| 60 | |
@XmlElement(name = Elements.DOCUMENT_ATTRIBUTE, required = false) |
| 61 | |
private final List<DocumentAttribute> documentAttributes; |
| 62 | |
|
| 63 | 0 | @SuppressWarnings("unused") |
| 64 | |
@XmlAnyElement |
| 65 | |
private final Collection<Element> _futureElements = null; |
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
@SuppressWarnings("unused") |
| 71 | 0 | private DocumentSearchResultValue() { |
| 72 | 0 | this.documentId = null; |
| 73 | 0 | this.documentAttributes = null; |
| 74 | 0 | } |
| 75 | |
|
| 76 | 0 | private DocumentSearchResultValue(Builder builder) { |
| 77 | 0 | this.documentId = builder.getDocumentId(); |
| 78 | 0 | this.documentAttributes = ModelObjectUtils.buildImmutableCopy(builder.getDocumentAttributes()); |
| 79 | 0 | } |
| 80 | |
|
| 81 | |
@Override |
| 82 | |
public String getDocumentId() { |
| 83 | 0 | return this.documentId; |
| 84 | |
} |
| 85 | |
|
| 86 | |
@Override |
| 87 | |
public List<DocumentAttribute> getDocumentAttributes() { |
| 88 | 0 | return this.documentAttributes; |
| 89 | |
} |
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | 0 | public final static class Builder implements Serializable, ModelBuilder, DocumentSearchResultValueContract { |
| 96 | |
|
| 97 | |
private String documentId; |
| 98 | |
private List<DocumentAttribute.AbstractBuilder<?>> documentAttributes; |
| 99 | |
|
| 100 | 0 | private Builder(String documentId) { |
| 101 | 0 | setDocumentId(documentId); |
| 102 | 0 | setDocumentAttributes(new ArrayList<DocumentAttribute.AbstractBuilder<?>>()); |
| 103 | 0 | } |
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
public static Builder create(String documentId) { |
| 115 | 0 | return new Builder(documentId); |
| 116 | |
} |
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
public static Builder create(DocumentSearchResultValueContract contract) { |
| 128 | 0 | if (contract == null) { |
| 129 | 0 | throw new IllegalArgumentException("contract was null"); |
| 130 | |
} |
| 131 | 0 | Builder builder = create(contract.getDocumentId()); |
| 132 | 0 | if (contract.getDocumentAttributes() != null) { |
| 133 | 0 | for (DocumentAttributeContract documentAttribute : contract.getDocumentAttributes()) { |
| 134 | 0 | builder.getDocumentAttributes().add(DocumentAttributeFactory.loadContractIntoBuilder(documentAttribute)); |
| 135 | |
} |
| 136 | |
} |
| 137 | 0 | return builder; |
| 138 | |
} |
| 139 | |
|
| 140 | |
@Override |
| 141 | |
public DocumentSearchResultValue build() { |
| 142 | 0 | return new DocumentSearchResultValue(this); |
| 143 | |
} |
| 144 | |
|
| 145 | |
@Override |
| 146 | |
public String getDocumentId() { |
| 147 | 0 | return this.documentId; |
| 148 | |
} |
| 149 | |
|
| 150 | |
@Override |
| 151 | |
public List<DocumentAttribute.AbstractBuilder<?>> getDocumentAttributes() { |
| 152 | 0 | return this.documentAttributes; |
| 153 | |
} |
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
public void setDocumentId(String documentId) { |
| 164 | 0 | if (StringUtils.isBlank(documentId)) { |
| 165 | 0 | throw new IllegalArgumentException("documentId was null or blank"); |
| 166 | |
} |
| 167 | 0 | this.documentId = documentId; |
| 168 | 0 | } |
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
public void setDocumentAttributes(List<DocumentAttribute.AbstractBuilder<?>> documentAttributes) { |
| 176 | 0 | this.documentAttributes = documentAttributes; |
| 177 | 0 | } |
| 178 | |
|
| 179 | |
} |
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | 0 | static class Constants { |
| 185 | |
final static String ROOT_ELEMENT_NAME = "documentSearchResultValue"; |
| 186 | |
final static String TYPE_NAME = "DocumentSearchResultValueType"; |
| 187 | |
} |
| 188 | |
|
| 189 | |
|
| 190 | |
|
| 191 | |
|
| 192 | |
|
| 193 | 0 | static class Elements { |
| 194 | |
final static String DOCUMENT_ID = "documentId"; |
| 195 | |
final static String DOCUMENT_ATTRIBUTES = "documentAttributes"; |
| 196 | |
final static String DOCUMENT_ATTRIBUTE = "documentAttribute"; |
| 197 | |
} |
| 198 | |
|
| 199 | |
} |