Skip to content

Commit

Permalink
eat(content analytics) fixes #30521 : Allow users to pass down simple…
Browse files Browse the repository at this point in the history
… Strings to query for Content Analytics data
  • Loading branch information
jcastro-dotcms committed Dec 9, 2024
1 parent 8c6f422 commit 3449b9e
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ public Builder timeDimensions(final String timeDimensions) {
}
final String[] timeParams = timeDimensions.split(COMMA);
final Map<String, String> timeDimensionsData = new HashMap<>();
timeDimensionsData.put(TIME_DIMENSIONS_DIMENSION_ATTR, addScheme(timeParams[0]));
timeDimensionsData.put(TIME_DIMENSIONS_DIMENSION_ATTR, addScheme(timeParams[0].trim()));
if (timeParams.length > 1) {
final String[] granularityAndRange = timeParams[1].split(COLON);
if (granularityAndRange.length > 1) {
timeDimensionsData.put(GRANULARITY_ATTR, granularityAndRange[0]);
timeDimensionsData.put(DATE_RANGE_ATTR, granularityAndRange[1]);
timeDimensionsData.put(GRANULARITY_ATTR, granularityAndRange[0].trim());
timeDimensionsData.put(DATE_RANGE_ATTR, granularityAndRange[1].trim());
} else {
timeDimensionsData.put(DATE_RANGE_ATTR, granularityAndRange[0]);
timeDimensionsData.put(DATE_RANGE_ATTR, granularityAndRange[0].trim());
}
} else {
timeDimensionsData.put(DATE_RANGE_ATTR, DEFAULT_DATE_RANGE);
Expand All @@ -262,11 +262,11 @@ public Builder filters(final String filters) {
}
final String[] filterArr = filters.split(COMMA);
for (final String filter : filterArr) {
final String[] filterParams = filter.split(SPACE);
final String[] filterParams = filter.trim().split(SPACE);
final Map<String, Object> filterDataMap = new HashMap<>();
filterDataMap.put(MEMBER_ATTR, addScheme(filterParams[0]));
filterDataMap.put(OPERATOR_ATTR, filterParams[1]);
final String[] filterValues = filterParams[2].split(DOUBLE_PIPE);
filterDataMap.put(MEMBER_ATTR, addScheme(filterParams[0].trim()));
filterDataMap.put(OPERATOR_ATTR, filterParams[1].trim());
final String[] filterValues = filterParams[2].trim().split(DOUBLE_PIPE);
filterDataMap.put(VALUES_ATTR, filterValues);
this.filters.add(filterDataMap);
}
Expand All @@ -290,9 +290,9 @@ public Builder order(final String order) {
}
final Set<String> orderCriteria = Set.of(order.split(COMMA));
for (final String orderCriterion : orderCriteria) {
final String[] orderParams = orderCriterion.split(SPACE);
final String[] orderParams = orderCriterion.trim().split(SPACE);
if (orderParams.length > 1) {
this.order.add(new String[]{addScheme(orderParams[0]), orderParams[1]});
this.order.add(new String[]{ addScheme(orderParams[0]), orderParams[1].trim() });
} else {
this.order.add(orderParams);
}
Expand Down Expand Up @@ -375,7 +375,7 @@ private Set<String> addScheme(final Set<String> terms) {
* @return The term with the default scheme added if it doesn't contain it.
*/
private String addScheme(final String term) {
return term.contains(PERIOD) ? term : scheme + PERIOD + term;
return UtilMethods.isSet(term) && term.contains(PERIOD) ? term.trim() : scheme + PERIOD + term.trim();
}

}
Expand Down

0 comments on commit 3449b9e

Please sign in to comment.