You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2020/06/26 09:53:26 UTC

[unomi] branch UNOMI-355-long-valuetype created (now 73ac09b)

This is an automated email from the ASF dual-hosted git repository.

shuber pushed a change to branch UNOMI-355-long-valuetype
in repository https://gitbox.apache.org/repos/asf/unomi.git.


      at 73ac09b  UNOMI - 355 Add long value type

This branch includes the following new commits:

     new 73ac09b  UNOMI - 355 Add long value type

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[unomi] 01/01: UNOMI - 355 Add long value type

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuber pushed a commit to branch UNOMI-355-long-valuetype
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit 73ac09bf44cec8e718d8318193cf48a99569250d
Author: Serge Huber <sh...@apache.org>
AuthorDate: Fri Jun 26 11:53:14 2020 +0200

    UNOMI - 355 Add long value type
---
 .../router/core/processor/LineSplitProcessor.java   |  2 ++
 .../unomi/graphql/schema/GraphQLSchemaProvider.java |  3 +++
 .../unomi/graphql/schema/PropertyFilterUtils.java   | 21 +++++++++++++++++++++
 .../ElasticSearchPersistenceServiceImpl.java        | 11 +++++++++++
 .../cxs/properties/profiles/personal/age.json       |  2 +-
 .../cxs/properties/profiles/system/nbOfVisits.json  |  2 +-
 .../main/resources/META-INF/cxs/values/long.json    |  3 +++
 7 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
index 289ae39..94c60e9 100644
--- a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
+++ b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
@@ -142,6 +142,8 @@ public class LineSplitProcessor implements Processor {
                             properties.put(fieldMappingKey, new Boolean(profileData[fieldsMapping.get(fieldMappingKey)].trim()));
                         } else if (propertyType.getValueTypeId().equals("integer")) {
                             properties.put(fieldMappingKey, new Integer(profileData[fieldsMapping.get(fieldMappingKey)].trim()));
+                        } else if (propertyType.getValueTypeId().equals("long")) {
+                            properties.put(fieldMappingKey, new Long(profileData[fieldsMapping.get(fieldMappingKey)].trim()));
                         }
                     } catch (Throwable t) {
                         logger.error("Error converting profileData", t);
diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/GraphQLSchemaProvider.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/GraphQLSchemaProvider.java
index 94bd1b8..4cbd993 100644
--- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/GraphQLSchemaProvider.java
+++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/GraphQLSchemaProvider.java
@@ -706,6 +706,9 @@ public class GraphQLSchemaProvider {
             case "integer":
                 graphQLType = Scalars.GraphQLInt;
                 break;
+            case "long":
+                graphQLType = Scalars.GraphQLLong;
+                break;
             case "float":
                 graphQLType = Scalars.GraphQLFloat;
                 break;
diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyFilterUtils.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyFilterUtils.java
index 2cdf12a..436193a 100644
--- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyFilterUtils.java
+++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyFilterUtils.java
@@ -71,6 +71,27 @@ public class PropertyFilterUtils {
                     .name(propertyName + "_gte")
                     .type(Scalars.GraphQLInt)
                     .build());
+        } else if ("long".equals(propertyType.getValueTypeId())) {
+            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
+                    .name(propertyName + "_equals")
+                    .type(Scalars.GraphQLLong)
+                    .build());
+            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
+                    .name(propertyName + "_lt")
+                    .type(Scalars.GraphQLLong)
+                    .build());
+            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
+                    .name(propertyName + "_lte")
+                    .type(Scalars.GraphQLLong)
+                    .build());
+            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
+                    .name(propertyName + "_gt")
+                    .type(Scalars.GraphQLLong)
+                    .build());
+            fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
+                    .name(propertyName + "_gte")
+                    .type(Scalars.GraphQLLong)
+                    .build());
         } else if ("float".equals(propertyType.getValueTypeId())) {
 
             fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField()
diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
index b1c7654..2506fa2 100644
--- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
+++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
@@ -1190,6 +1190,15 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
     private Map<String, Object> createPropertyMapping(final String fieldName, final String fieldType) {
         final HashMap<String, Object> definition = new HashMap<>();
         definition.put("type", fieldType);
+        if ("text".equals(fieldType)) {
+            definition.put("analyzer", "folding");
+            final Map<String, Object> fields = new HashMap<>();
+            final Map<String, Object> keywordField = new HashMap<>();
+            keywordField.put("type", "keyword");
+            keywordField.put("ignore_above", 256);
+            fields.put("keyword", keywordField);
+            definition.put("fields", fields);
+        }
 
         final HashMap<String, Object> map = new HashMap<>();
         map.put(fieldName, definition);
@@ -1206,6 +1215,8 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
                 return "geo_point";
             case "integer":
                 return "integer";
+            case "long" :
+                return "long";
             case "float":
                 return "float";
             case "date":
diff --git a/services/src/main/resources/META-INF/cxs/properties/profiles/personal/age.json b/services/src/main/resources/META-INF/cxs/properties/profiles/personal/age.json
index d0ef96e..6ea67ca 100644
--- a/services/src/main/resources/META-INF/cxs/properties/profiles/personal/age.json
+++ b/services/src/main/resources/META-INF/cxs/properties/profiles/personal/age.json
@@ -8,7 +8,7 @@
       "personalProfileProperties"
     ]
   },
-  "type": "integer",
+  "type": "long",
   "defaultValue": "",
   "numericRanges": [
     {"key":"*_10", "to" : 10 },
diff --git a/services/src/main/resources/META-INF/cxs/properties/profiles/system/nbOfVisits.json b/services/src/main/resources/META-INF/cxs/properties/profiles/system/nbOfVisits.json
index 25180f1..d9a371b 100644
--- a/services/src/main/resources/META-INF/cxs/properties/profiles/system/nbOfVisits.json
+++ b/services/src/main/resources/META-INF/cxs/properties/profiles/system/nbOfVisits.json
@@ -8,7 +8,7 @@
         "systemProfileProperties"
       ]
     },
-    "type": "integer",
+    "type": "long",
     "defaultValue": "",
     "automaticMappingsFrom": [ ],
     "numericRanges": [
diff --git a/services/src/main/resources/META-INF/cxs/values/long.json b/services/src/main/resources/META-INF/cxs/values/long.json
new file mode 100644
index 0000000..2626a8e
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/values/long.json
@@ -0,0 +1,3 @@
+{
+  "id" : "long"
+}
\ No newline at end of file