diff --git a/dotCMS/src/main/java/com/dotcms/analytics/content/ContentAnalyticsQuery.java b/dotCMS/src/main/java/com/dotcms/analytics/content/ContentAnalyticsQuery.java
index 9466e308678f..4f51be9163c1 100644
--- a/dotCMS/src/main/java/com/dotcms/analytics/content/ContentAnalyticsQuery.java
+++ b/dotCMS/src/main/java/com/dotcms/analytics/content/ContentAnalyticsQuery.java
@@ -10,14 +10,49 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import static com.liferay.util.StringPool.COLON;
import static com.liferay.util.StringPool.COMMA;
+import static com.liferay.util.StringPool.PERIOD;
/**
* This class represents the parameters of a Content Analytics Query abstracting the complexity
* of the underlying JSON format. The simplified REST Endpoint and the Content Analytics ViewTool
- * use this class so that parameters can be entered in a more user-friendly way.
+ * use this class so that parameters can be entered in a more user-friendly way. Here's an example
+ * of what this simple JSON data looks like for the default {@code request} schema:
+ *
+ * {@code
+ * {
+ * "measures": "count,totalSessions",
+ * "dimensions": "host,whatAmI,url",
+ * "timeDimensions": "createdAt,day:Last month",
+ * "filters": "totalRequest gt 0,whatAmI contains PAGE||FILE",
+ * "order": "count asc,createdAt asc",
+ * "limit": 5,
+ * "offset": 0
+ * }
+ * }
+ *
+ * Under the covers, this builder will prefix the appropriate terms with the specified or default
+ * schema. If you want to provide a specific one, just add it to the JSON body:
+ *
+ * {@code
+ * {
+ * "scheme": "YOUR-SCHEME-NAME-HERE",
+ * ...
+ * ...
+ * }
+ * }
+ *
+ * Notice how there are four separator characters for different parameters. They must be used
+ * correctly for the data to be parsed correctly:
+ *
+ * - Blank space.
+ * - Comma.
+ * - Colon.
+ * - Double pipes.
+ *
*
* @author Jose Castro
* @since Nov 28th, 2024
@@ -25,6 +60,7 @@
@JsonDeserialize(builder = ContentAnalyticsQuery.Builder.class)
public class ContentAnalyticsQuery implements Serializable {
+ public static final String SCHEME_ATTR = "scheme";
public static final String MEASURES_ATTR = "measures";
public static final String DIMENSIONS_ATTR = "dimensions";
public static final String TIME_DIMENSIONS_ATTR = "timeDimensions";
@@ -39,6 +75,7 @@ public class ContentAnalyticsQuery implements Serializable {
public static final String OPERATOR_ATTR = "operator";
public static final String VALUES_ATTR = "values";
+ private final String scheme;
@JsonProperty()
private final Set measures;
@JsonProperty()
@@ -54,9 +91,13 @@ public class ContentAnalyticsQuery implements Serializable {
@JsonProperty()
private final int offset;
- private static final String SEPARATOR = COLON;
+ private static final String SPACE = "\\s+";
+ private static final String DOUBLE_PIPE = "\\|\\|";
+ private static final String DEFAULT_DATE_RANGE = "Last week";
+ private static final String DEFAULT_SCHEME = "request";
private ContentAnalyticsQuery(final Builder builder) {
+ this.scheme = builder.scheme;
this.measures = builder.measures;
this.dimensions = builder.dimensions;
this.timeDimensions = builder.timeDimensions;
@@ -66,6 +107,10 @@ private ContentAnalyticsQuery(final Builder builder) {
this.offset = builder.offset;
}
+ public String scheme() {
+ return this.scheme;
+ }
+
public Set measures() {
return this.measures;
}
@@ -101,13 +146,14 @@ public static ContentAnalyticsQuery.Builder builder() {
@Override
public String toString() {
return "ContentAnalyticsQuery{" +
- "measures='" + measures + '\'' +
- ", dimensions='" + dimensions + '\'' +
- ", timeDimensions='" + timeDimensions + '\'' +
- ", filters='" + filters + '\'' +
- ", order='" + order + '\'' +
- ", limit='" + limit + '\'' +
- ", offset='" + offset + '\'' +
+ "scheme='" + scheme + '\'' +
+ ", measures=" + measures +
+ ", dimensions=" + dimensions +
+ ", timeDimensions=" + timeDimensions +
+ ", filters=" + filters +
+ ", order=" + order +
+ ", limit=" + limit +
+ ", offset=" + offset +
'}';
}
@@ -117,6 +163,7 @@ public String toString() {
*/
public static class Builder {
+ private String scheme = DEFAULT_SCHEME;
private Set measures;
private Set dimensions;
private final List