1 17 package org.alfresco.web.config; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 22 import org.alfresco.config.ConfigElement; 23 import org.alfresco.config.ConfigException; 24 import org.alfresco.config.element.ConfigElementAdapter; 25 26 31 public class AdvancedSearchConfigElement extends ConfigElementAdapter 32 { 33 public static final String CONFIG_ELEMENT_ID = "advanced-search"; 34 35 private List <String > contentTypes = null; 36 private List <CustomProperty> customProps = null; 37 38 41 public AdvancedSearchConfigElement() 42 { 43 super(CONFIG_ELEMENT_ID); 44 } 45 46 51 public AdvancedSearchConfigElement(String name) 52 { 53 super(name); 54 } 55 56 59 @Override 60 public List <ConfigElement> getChildren() 61 { 62 throw new ConfigException("Reading the advanced search config via the generic interfaces is not supported"); 63 } 64 65 68 public ConfigElement combine(ConfigElement configElement) 69 { 70 AdvancedSearchConfigElement existingElement = (AdvancedSearchConfigElement)configElement; 71 AdvancedSearchConfigElement newElement = new AdvancedSearchConfigElement(); 72 73 if (this.contentTypes != null) 75 { 76 for (String type : this.contentTypes) 77 { 78 newElement.addContentType(type); 79 } 80 } 81 82 if (this.customProps != null) 83 { 84 for (CustomProperty property : this.customProps) 85 { 86 newElement.addCustomProperty(property); 87 } 88 } 89 90 if (existingElement.getContentTypes() != null) 92 { 93 for (String type : existingElement.getContentTypes()) 94 { 95 newElement.addContentType(type); 96 } 97 } 98 99 if (existingElement.getCustomProperties() != null) 100 { 101 for (CustomProperty property : existingElement.getCustomProperties()) 102 { 103 newElement.addCustomProperty(property); 104 } 105 } 106 107 return newElement; 108 } 109 110 113 public List <String > getContentTypes() 114 { 115 return this.contentTypes; 116 } 117 118 121 void setContentTypes(List <String > contentTypes) 122 { 123 this.contentTypes = contentTypes; 124 } 125 126 129 void addContentType(String contentType) 130 { 131 if (this.contentTypes == null) 132 { 133 this.contentTypes = new ArrayList <String >(3); 134 } 135 136 if (this.contentTypes.contains(contentType) == false) 137 { 138 this.contentTypes.add(contentType); 139 } 140 } 141 142 145 public List <CustomProperty> getCustomProperties() 146 { 147 return this.customProps; 148 } 149 150 153 void setCustomProperties(List <CustomProperty> customProps) 154 { 155 this.customProps = customProps; 156 } 157 158 161 void addCustomProperty(CustomProperty property) 162 { 163 if (this.customProps == null) 164 { 165 this.customProps = new ArrayList <CustomProperty>(3); 166 } 167 168 171 this.customProps.add(property); 172 } 173 174 178 public static class CustomProperty 179 { 180 CustomProperty(String type, String aspect, String property, String labelId) 181 { 182 Type = type; 183 Aspect = aspect; 184 Property = property; 185 LabelId = labelId; 186 } 187 188 public String Type; 189 public String Aspect; 190 public String Property; 191 public String LabelId; 192 } 193 } 194 | Popular Tags |