| 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.collections.CollectionUtils; |
| 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.core.api.uif.AttributeField; |
| 36 | |
import org.kuali.rice.core.api.uif.RemotableAttributeField; |
| 37 | |
import org.w3c.dom.Element; |
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
@XmlRootElement(name = DocumentSearchResultSetConfiguration.Constants.ROOT_ELEMENT_NAME) |
| 46 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 47 | |
@XmlType(name = DocumentSearchResultSetConfiguration.Constants.TYPE_NAME, propOrder = { |
| 48 | |
DocumentSearchResultSetConfiguration.Elements.OVERRIDE_SEARCHABLE_ATTRIBUTES, |
| 49 | |
DocumentSearchResultSetConfiguration.Elements.CUSTOM_FIELD_NAMES_TO_ADD, |
| 50 | |
DocumentSearchResultSetConfiguration.Elements.STANDARD_RESULT_FIELDS_TO_REMOVE, |
| 51 | |
DocumentSearchResultSetConfiguration.Elements.ADDITIONAL_ATTRIBUTE_FIELDS, |
| 52 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 53 | |
}) |
| 54 | 0 | public final class DocumentSearchResultSetConfiguration extends AbstractDataTransferObject |
| 55 | |
implements DocumentSearchResultSetConfigurationContract { |
| 56 | |
|
| 57 | |
@XmlElement(name = Elements.OVERRIDE_SEARCHABLE_ATTRIBUTES, required = true) |
| 58 | |
private final boolean overrideSearchableAttributes; |
| 59 | |
|
| 60 | |
@XmlElementWrapper(name = Elements.CUSTOM_FIELD_NAMES_TO_ADD, required = false) |
| 61 | |
@XmlElement(name = Elements.CUSTOM_FIELD_NAME_TO_ADD, required = false) |
| 62 | |
private final List<String> customFieldNamesToAdd; |
| 63 | |
|
| 64 | |
@XmlElementWrapper(name = Elements.STANDARD_RESULT_FIELDS_TO_REMOVE, required = false) |
| 65 | |
@XmlElement(name = Elements.STANDARD_RESULT_FIELD_TO_REMOVE, required = false) |
| 66 | |
private final List<StandardResultField> standardResultFieldsToRemove; |
| 67 | |
|
| 68 | |
@XmlElementWrapper(name = Elements.ADDITIONAL_ATTRIBUTE_FIELDS, required = false) |
| 69 | |
@XmlElement(name = Elements.ADDITIONAL_ATTRIBUTE_FIELD, required = false) |
| 70 | |
private final List<RemotableAttributeField> additionalAttributeFields; |
| 71 | |
|
| 72 | 0 | @SuppressWarnings("unused") |
| 73 | |
@XmlAnyElement |
| 74 | |
private final Collection<Element> _futureElements = null; |
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
@SuppressWarnings("unused") |
| 80 | 0 | private DocumentSearchResultSetConfiguration() { |
| 81 | 0 | this.overrideSearchableAttributes = false; |
| 82 | 0 | this.customFieldNamesToAdd = null; |
| 83 | 0 | this.standardResultFieldsToRemove = null; |
| 84 | 0 | this.additionalAttributeFields = null; |
| 85 | 0 | } |
| 86 | |
|
| 87 | 0 | private DocumentSearchResultSetConfiguration(Builder builder) { |
| 88 | 0 | this.overrideSearchableAttributes = builder.isOverrideSearchableAttributes(); |
| 89 | 0 | this.customFieldNamesToAdd = ModelObjectUtils.createImmutableCopy(builder.getCustomFieldNamesToAdd()); |
| 90 | 0 | this.standardResultFieldsToRemove = |
| 91 | |
ModelObjectUtils.createImmutableCopy(builder.getStandardResultFieldsToRemove()); |
| 92 | 0 | this.additionalAttributeFields = ModelObjectUtils.buildImmutableCopy(builder.getAdditionalAttributeFields()); |
| 93 | 0 | } |
| 94 | |
|
| 95 | |
@Override |
| 96 | |
public boolean isOverrideSearchableAttributes() { |
| 97 | 0 | return this.overrideSearchableAttributes; |
| 98 | |
} |
| 99 | |
|
| 100 | |
@Override |
| 101 | |
public List<String> getCustomFieldNamesToAdd() { |
| 102 | 0 | return this.customFieldNamesToAdd; |
| 103 | |
} |
| 104 | |
|
| 105 | |
@Override |
| 106 | |
public List<StandardResultField> getStandardResultFieldsToRemove() { |
| 107 | 0 | return this.standardResultFieldsToRemove; |
| 108 | |
} |
| 109 | |
|
| 110 | |
@Override |
| 111 | |
public List<RemotableAttributeField> getAdditionalAttributeFields() { |
| 112 | 0 | return this.additionalAttributeFields; |
| 113 | |
} |
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | 0 | public final static class Builder implements Serializable, ModelBuilder, DocumentSearchResultSetConfigurationContract { |
| 120 | |
|
| 121 | |
private boolean overrideSearchableAttributes; |
| 122 | |
private List<String> customFieldNamesToAdd; |
| 123 | |
private List<StandardResultField> standardResultFieldsToRemove; |
| 124 | |
private List<RemotableAttributeField.Builder> additionalAttributeFields; |
| 125 | |
|
| 126 | 0 | private Builder() { |
| 127 | 0 | setOverrideSearchableAttributes(false); |
| 128 | 0 | setCustomFieldNamesToAdd(new ArrayList<String>()); |
| 129 | 0 | setStandardResultFieldsToRemove(new ArrayList<StandardResultField>()); |
| 130 | 0 | setAdditionalAttributeFields(new ArrayList<RemotableAttributeField.Builder>()); |
| 131 | 0 | } |
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
public static Builder create() { |
| 140 | 0 | return new Builder(); |
| 141 | |
} |
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
|
| 151 | |
|
| 152 | |
public static Builder create(DocumentSearchResultSetConfigurationContract contract) { |
| 153 | 0 | if (contract == null) { |
| 154 | 0 | throw new IllegalArgumentException("contract was null"); |
| 155 | |
} |
| 156 | 0 | Builder builder = create(); |
| 157 | 0 | builder.setOverrideSearchableAttributes(contract.isOverrideSearchableAttributes()); |
| 158 | 0 | if (CollectionUtils.isNotEmpty(contract.getCustomFieldNamesToAdd())) { |
| 159 | 0 | builder.setCustomFieldNamesToAdd(new ArrayList<String>(contract.getCustomFieldNamesToAdd())); |
| 160 | |
} |
| 161 | 0 | if (CollectionUtils.isNotEmpty(contract.getStandardResultFieldsToRemove())) { |
| 162 | 0 | builder.setStandardResultFieldsToRemove( |
| 163 | |
new ArrayList<StandardResultField>(contract.getStandardResultFieldsToRemove())); |
| 164 | |
} |
| 165 | 0 | if (CollectionUtils.isNotEmpty(contract.getAdditionalAttributeFields())) { |
| 166 | 0 | for (AttributeField attributeField : contract.getAdditionalAttributeFields()) { |
| 167 | 0 | builder.getAdditionalAttributeFields().add(RemotableAttributeField.Builder.create(attributeField)); |
| 168 | |
} |
| 169 | |
} |
| 170 | 0 | return builder; |
| 171 | |
} |
| 172 | |
|
| 173 | |
@Override |
| 174 | |
public DocumentSearchResultSetConfiguration build() { |
| 175 | 0 | return new DocumentSearchResultSetConfiguration(this); |
| 176 | |
} |
| 177 | |
|
| 178 | |
@Override |
| 179 | |
public boolean isOverrideSearchableAttributes() { |
| 180 | 0 | return this.overrideSearchableAttributes; |
| 181 | |
} |
| 182 | |
|
| 183 | |
@Override |
| 184 | |
public List<String> getCustomFieldNamesToAdd() { |
| 185 | 0 | return this.customFieldNamesToAdd; |
| 186 | |
} |
| 187 | |
|
| 188 | |
@Override |
| 189 | |
public List<StandardResultField> getStandardResultFieldsToRemove() { |
| 190 | 0 | return this.standardResultFieldsToRemove; |
| 191 | |
} |
| 192 | |
|
| 193 | |
@Override |
| 194 | |
public List<RemotableAttributeField.Builder> getAdditionalAttributeFields() { |
| 195 | 0 | return this.additionalAttributeFields; |
| 196 | |
} |
| 197 | |
|
| 198 | |
public void setOverrideSearchableAttributes(boolean overrideSearchableAttributes) { |
| 199 | 0 | this.overrideSearchableAttributes = overrideSearchableAttributes; |
| 200 | 0 | } |
| 201 | |
|
| 202 | |
public void setCustomFieldNamesToAdd(List<String> customFieldNamesToAdd) { |
| 203 | 0 | this.customFieldNamesToAdd = customFieldNamesToAdd; |
| 204 | 0 | } |
| 205 | |
|
| 206 | |
public void setStandardResultFieldsToRemove(List<StandardResultField> standardResultFieldsToRemove) { |
| 207 | 0 | this.standardResultFieldsToRemove = standardResultFieldsToRemove; |
| 208 | 0 | } |
| 209 | |
|
| 210 | |
public void setAdditionalAttributeFields(List<RemotableAttributeField.Builder> additionalAttributeFields) { |
| 211 | 0 | this.additionalAttributeFields = additionalAttributeFields; |
| 212 | 0 | } |
| 213 | |
|
| 214 | |
} |
| 215 | |
|
| 216 | |
|
| 217 | |
|
| 218 | |
|
| 219 | 0 | static class Constants { |
| 220 | |
final static String ROOT_ELEMENT_NAME = "documentSearchResultSetConfiguration"; |
| 221 | |
final static String TYPE_NAME = "DocumentSearchResultSetConfigurationType"; |
| 222 | |
} |
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
|
| 228 | 0 | static class Elements { |
| 229 | |
final static String OVERRIDE_SEARCHABLE_ATTRIBUTES = "overrideSearchableAttributes"; |
| 230 | |
final static String CUSTOM_FIELD_NAMES_TO_ADD = "customFieldNamesToAdd"; |
| 231 | |
final static String CUSTOM_FIELD_NAME_TO_ADD = "customFieldNameToAdd"; |
| 232 | |
final static String STANDARD_RESULT_FIELDS_TO_REMOVE = "standardResultFieldsToRemove"; |
| 233 | |
final static String STANDARD_RESULT_FIELD_TO_REMOVE = "standardResultFieldToRemove"; |
| 234 | |
final static String ADDITIONAL_ATTRIBUTE_FIELDS = "additionalAttributeFields"; |
| 235 | |
final static String ADDITIONAL_ATTRIBUTE_FIELD = "additionalAttributeField"; |
| 236 | |
} |
| 237 | |
|
| 238 | |
} |