Skip to content

UNOMI-400 Refactoring of hardcoded property accessors#218

Merged
sergehuber merged 2 commits intomasterfrom
UNOMI-400-hardcodedpropertyaccessors-refactoring
Nov 18, 2020
Merged

UNOMI-400 Refactoring of hardcoded property accessors#218
sergehuber merged 2 commits intomasterfrom
UNOMI-400-hardcodedpropertyaccessors-refactoring

Conversation

@sergehuber
Copy link
Contributor

In this PR we externalize the hardcoded property accessors and make better use of polymorphism to make the code cleaner and easier to understand and maintain.

Copy link
Contributor

@jkevan jkevan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, it's way much cleaner like that.
And I like the Generics to avoid too much casting.

I think there is a missing case if expression is ["foo"]
Take a look at the first comment.

Also I propose 2 code improvements

Comment on lines 63 to 70
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

["foo"].bar is covered
["foo"] is not covered

Also could be great to cover this function with unit test, since it's covering a lot of cases, and it should not be that complicated todo.

Comment on lines 76 to 81
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the two else if seem's unecessary if we do:
dotlookupNameEndPos > lookupNameBeginPos || squareBracketlookupNameEndPos > lookupNameBeginPos
in the first condition

Comment on lines 95 to 101
Copy link
Contributor

@jkevan jkevan Nov 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is duplicated in the 3 cases, we could move it out of the tree cases and just calculated the lookupNameBeginPos, lookupNameEndPos. inside the 3 cases, then do this code only once at the end.

@sergehuber
Copy link
Contributor Author

Ok thanks for the feedback Kevan. I've updated this branch with fixes for all the points you raised. Thanks for checking them out.

@sergehuber sergehuber merged commit 5de4cab into master Nov 18, 2020
@sergehuber sergehuber deleted the UNOMI-400-hardcodedpropertyaccessors-refactoring branch November 18, 2020 13:54
asfgit pushed a commit that referenced this pull request Nov 18, 2020
* UNOMI-400 Refactoring of hardcoded property accessors

* UNOMI-400 More refactoring on property accessors & added unit test

(cherry picked from commit 5de4cab)
asfgit pushed a commit that referenced this pull request Nov 18, 2020
* UNOMI-400 Refactoring of hardcoded property accessors

* UNOMI-400 More refactoring on property accessors & added unit test

(cherry picked from commit 5de4cab)
sergehuber pushed a commit to Jahia/unomi that referenced this pull request Nov 18, 2020
* UNOMI-400 Refactoring of hardcoded property accessors

* UNOMI-400 More refactoring on property accessors & added unit test

(cherry picked from commit 5de4cab)
giladw pushed a commit to YotpoLtd/unomi-releases that referenced this pull request Dec 1, 2020
* master: (26 commits)
  Fix typos &
  Fix Jenkins files
  Add branch information in main README
  UNOMI-400 Update documentation to reflect the latest config changes (apache#221)
  UNOMI-400 Fix class hierarchy lookup for property condition evaluator (apache#220)
  Return error to the client when exception is thrown from Elasticsearch impl (apache#202)
  UNOMI-366: Implement increment interest event type & action (apache#201)
  UNOMI-400 Refactoring of hardcoded property accessors (apache#218)
  UNOMI-401 Fix missing base class in SecureFilteringClassLoader (apache#219)
  UNOMI-399: Provide doc inside the custom.system.properties for scripting allow/forbid mechanism (apache#217)
  UNOMI-400 Fix typo bug in PropertyConditionEvaluator & improve unit test (apache#216)
  UNOMI-400 More complete hardcoded property accessor implementation (apache#214)
  UNOMI-401: correctly set ClassLoader before MVEL script execute (apache#215)
  UNOMI-399: load allow/forbid script from files instead of configuration property to avoid script code conflicting with property value parsing (apache#213)
  UNOMI-399: fix the loading of MVEL allowed script pattern from config, and return null during script execution if the script is filtered out (apache#211)
  Add documentation to new security configuration parameters.
  Add documentation to new security configuration parameters.
  Remove eslint & dependencies as it is not used.
  UNOMI-379_support_addValues (apache#207)
  feat(geo location condition): add support for getting location path f… (#61) (apache#210)
  ...

# Conflicts:
#	persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
#	persistence-elasticsearch/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
#	persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg
#	services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments