Skip to content
Snippets Groups Projects
Commit 448a7cc4 authored by Zhibin Mai's avatar Zhibin Mai
Browse files

Refactor the codes

parent 13f6bd81
No related branches found
No related tags found
1 merge request!620Support flexible condition match in Index Augmenter
Pipeline #214395 failed
Pipeline: Indexer

#214396

    ......@@ -49,6 +49,7 @@ public class RelatedCondition {
    return true;
    }
    catch(PatternSyntaxException ex) {
    //The condition can be plain text, not non-regular expression
    if(propertyValue.equals(condition))
    return true;
    }
    ......@@ -62,19 +63,24 @@ public class RelatedCondition {
    relatedConditionMatches != null &&
    !relatedConditionMatches.isEmpty();
    }
    protected boolean hasValidCondition(String property) {
    if(Strings.isNullOrEmpty(property) || !this.hasCondition())
    return false;
    // If it is not nested object, it is valid in terms of syntax.
    if(!property.contains(ARRAY_SYMBOL) && !relatedConditionProperty.contains(ARRAY_SYMBOL))
    return true;
    return hasMatchNestedParts(property);
    }
    private boolean hasMatchNestedParts(String property) {
    if((property.endsWith(ARRAY_SYMBOL) || relatedConditionProperty.endsWith(ARRAY_SYMBOL)) ||
    (property.contains(ARRAY_SYMBOL) && !relatedConditionProperty.contains(ARRAY_SYMBOL)) ||
    (!property.contains(ARRAY_SYMBOL) && relatedConditionProperty.contains(ARRAY_SYMBOL)))
    return false;
    // If it is not nested object, it is valid in terms of syntax.
    if(!property.contains(ARRAY_SYMBOL) && !relatedConditionProperty.contains(ARRAY_SYMBOL))
    return true;
    property = this.getSubstringWithLastArrayField(
    PropertyUtil.removeDataPrefix(property));
    String conditionProperty = this.getSubstringWithLastArrayField(
    ......@@ -93,6 +99,7 @@ public class RelatedCondition {
    return true;
    }
    private String getSubstringWithLastArrayField(String property) {
    return property.substring(0, property.lastIndexOf(ARRAY_SYMBOL));
    }
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment