Commit 98288001b1f76c140b7135d394f4c04e5cf67e5a

Authored by Paulo Graça
1 parent 8203891287
Exists in master

fix: legal thesis filtering

config/validator.xml
... ... @@ -151,7 +151,7 @@
151 151 </translation>
152 152  
153 153 <preCondition refid="thesis_dc_type"/>
154   -
  154 + <preCondition refid="not_bachelorthesis_dc_type"/>
155 155  
156 156 <check refid="author_exists"/>
157 157 <check refid="description_exists"/>
... ... @@ -239,6 +239,19 @@
239 239 <value>Thesis</value>
240 240 </parameter>
241 241 </preCondition>
  242 +
  243 + <preCondition id="not_bachelorthesis_dc_type">
  244 + <class>pt.keep.metarepository.core.validator2.pre_conditions.AtLeastOneMetadataFieldByContent</class>
  245 + <parameter key="field">
  246 + <value>type</value>
  247 + </parameter>
  248 + <parameter key="operator">
  249 + <value>not_contains</value>
  250 + </parameter>
  251 + <parameter key="value">
  252 + <value>bachelorThesis</value>
  253 + </parameter>
  254 + </preCondition>
242 255  
243 256 <preCondition id="master_thesis_dc_type">
244 257 <class>pt.keep.metarepository.core.validator2.pre_conditions.AtLeastOneMetadataFieldByContent</class>
... ...
src/pt/keep/metarepository/core/validator2/pre_conditions/AtLeastOneMetadataFieldByContent.java
... ... @@ -24,7 +24,7 @@ import pt.keep.metarepository.core.validator2.registration.ValidationRequestInfo
24 24 * * matches - does regular expression validation
25 25 * </pre>
26 26 *
27   - * @author Hélder Silva <hsilva@keep.pt>
  27 + * @author Helder Silva <hsilva@keep.pt>
28 28 * */
29 29 public class AtLeastOneMetadataFieldByContent extends PreConditionInterface {
30 30 private Logger logger = Logger.getLogger(getClass());
... ... @@ -58,6 +58,12 @@ public class AtLeastOneMetadataFieldByContent extends PreConditionInterface {
58 58 logger.debug("\t\t<check>");
59 59 res = true;
60 60 break;
  61 + } else if ("not_contains".equalsIgnoreCase(checkOperator)
  62 + && StringUtils.isNotBlank(metadataValue)
  63 + && !checkValues.contains(metadataValue)) {
  64 + logger.debug("\t\t<check>");
  65 + res = true;
  66 + break;
61 67 } else if ("starts_with".equalsIgnoreCase(checkOperator)
62 68 && StringUtils.isNotBlank(metadataValue)) {
63 69 for (String checkValue : checkValues) {
... ... @@ -81,7 +87,7 @@ public class AtLeastOneMetadataFieldByContent extends PreConditionInterface {
81 87 }
82 88 if (res) {
83 89 break;
84   - }
  90 + }
85 91 } else if ("matches".equalsIgnoreCase(checkOperator)
86 92 && StringUtils.isNotBlank(metadataValue)) {
87 93 for (String checkValue : checkValues) {
... ...