You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by GitBox <gi...@apache.org> on 2020/06/24 15:49:01 UTC

[GitHub] [unomi] pmi opened a new pull request #168: UNOMI-346 Analyze/study event type registration system

pmi opened a new pull request #168:
URL: https://github.com/apache/unomi/pull/168


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] sergehuber commented on a change in pull request #168: UNOMI-352 Implement event type registry for GraphQL

Posted by GitBox <gi...@apache.org>.
sergehuber commented on a change in pull request #168:
URL: https://github.com/apache/unomi/pull/168#discussion_r445637522



##########
File path: services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java
##########
@@ -160,7 +170,7 @@ private void processBundleStop(BundleContext bundleContext) {
         if (bundleContext == null) {
             return;
         }
-        List<PluginType> types = pluginTypes.get(bundleContext.getBundle().getBundleId());
+        List<PluginType> types = pluginTypes.remove(bundleContext.getBundle().getBundleId());

Review comment:
       ok sorry didn't realize that :) 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] pmi commented on a change in pull request #168: UNOMI-352 Implement event type registry for GraphQL

Posted by GitBox <gi...@apache.org>.
pmi commented on a change in pull request #168:
URL: https://github.com/apache/unomi/pull/168#discussion_r445624607



##########
File path: services/src/main/resources/META-INF/cxs/events/common.json
##########
@@ -0,0 +1,34 @@
+{
+  "propertyTypes": [
+    {
+      "itemId": "id",
+      "type": "id"
+    },
+    {
+      "itemId": "cdp_source"

Review comment:
       Removed common.json completely




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] sergehuber commented on a change in pull request #168: UNOMI-352 Implement event type registry for GraphQL

Posted by GitBox <gi...@apache.org>.
sergehuber commented on a change in pull request #168:
URL: https://github.com/apache/unomi/pull/168#discussion_r445637800



##########
File path: services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
##########
@@ -211,10 +226,61 @@ private void getEventProperties(Map<String, Map<String, Object>> mappings, List<
         }
     }
 
+    private List<PropertyType> getEventPropertyTypes() {
+        Map<String, Map<String, Object>> mappings = persistenceService.getPropertiesMapping(Event.ITEM_TYPE);
+        return new ArrayList<>(getEventPropertyTypes(mappings));
+    }
+
+    @SuppressWarnings("unchecked")
+    private Set<PropertyType> getEventPropertyTypes(Map<String, Map<String, Object>> mappings) {
+        Set<PropertyType> properties = new LinkedHashSet<>();
+        for (Map.Entry<String, Map<String, Object>> e : mappings.entrySet()) {
+            Set<PropertyType> childProperties = null;
+            Metadata propertyMetadata = new Metadata(null, e.getKey(), e.getKey(), null);
+            Set<String> systemTags = new HashSet<>();
+            propertyMetadata.setSystemTags(systemTags);
+            PropertyType propertyType = new PropertyType(propertyMetadata);
+            propertyType.setTarget("event");
+            ValueType valueType = null;
+            if (e.getValue().get("properties") != null) {
+                childProperties = getEventPropertyTypes((Map<String, Map<String, Object>>) e.getValue().get("properties"));
+                valueType = definitionsService.getValueType("set");
+                if (childProperties != null && childProperties.size() > 0) {
+                    propertyType.setChildPropertyTypes(childProperties);
+                }
+            } else {
+                valueType = mappingTypeToValueType( (String) e.getValue().get("type"));
+            }
+            propertyType.setValueTypeId(valueType.getId());
+            propertyType.setValueType(valueType);
+            properties.add(propertyType);
+        }
+        return properties;
+    }
+
+    private ValueType mappingTypeToValueType(String mappingType) {
+        if ("text".equals(mappingType)) {
+            return definitionsService.getValueType("string");
+        } else if ("date".equals(mappingType)) {
+            return definitionsService.getValueType("date");
+        } else if ("long".equals(mappingType)) {

Review comment:
       agreed but we will need to remember it somehow




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] sergehuber commented on a change in pull request #168: UNOMI-346 Analyze/study event type registration system

Posted by GitBox <gi...@apache.org>.
sergehuber commented on a change in pull request #168:
URL: https://github.com/apache/unomi/pull/168#discussion_r445377071



##########
File path: api/src/main/java/org/apache/unomi/api/services/EventTypeRegistry.java
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.unomi.api.services;
+
+import org.apache.unomi.api.EventType;
+
+import java.util.Collection;
+
+public interface EventTypeRegistry {

Review comment:
       Please add basic documentation on this class

##########
File path: api/src/main/java/org/apache/unomi/api/services/EventService.java
##########
@@ -82,9 +79,19 @@
      * Retrieves the list of available event properties.
      *
      * @return a list of available event properties
+     * Retrieves an event type

Review comment:
       Is this a typo maybe ?

##########
File path: services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java
##########
@@ -160,7 +170,7 @@ private void processBundleStop(BundleContext bundleContext) {
         if (bundleContext == null) {
             return;
         }
-        List<PluginType> types = pluginTypes.get(bundleContext.getBundle().getBundleId());
+        List<PluginType> types = pluginTypes.remove(bundleContext.getBundle().getBundleId());

Review comment:
       Is this a bug fix ?

##########
File path: services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java
##########
@@ -59,7 +59,17 @@
 
     private BundleContext bundleContext;
     public DefinitionsServiceImpl() {
-
+        // let's add the built-in value types

Review comment:
       I wonder if we should add all the built-in value types programmatically like this or move them all to JSON files. But having a mixture of this doesn't seem coherent.

##########
File path: services/src/main/resources/META-INF/cxs/events/common.json
##########
@@ -0,0 +1,34 @@
+{
+  "propertyTypes": [
+    {
+      "itemId": "id",
+      "type": "id"
+    },
+    {
+      "itemId": "cdp_source"

Review comment:
       Should we really have the cdp fields here ? I thought we would have the Event.class fields here and then create a layer to translate them to cdp in the GraphQL code which would seem more coherent.

##########
File path: services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
##########
@@ -211,10 +226,61 @@ private void getEventProperties(Map<String, Map<String, Object>> mappings, List<
         }
     }
 
+    private List<PropertyType> getEventPropertyTypes() {
+        Map<String, Map<String, Object>> mappings = persistenceService.getPropertiesMapping(Event.ITEM_TYPE);
+        return new ArrayList<>(getEventPropertyTypes(mappings));
+    }
+
+    @SuppressWarnings("unchecked")
+    private Set<PropertyType> getEventPropertyTypes(Map<String, Map<String, Object>> mappings) {
+        Set<PropertyType> properties = new LinkedHashSet<>();
+        for (Map.Entry<String, Map<String, Object>> e : mappings.entrySet()) {
+            Set<PropertyType> childProperties = null;
+            Metadata propertyMetadata = new Metadata(null, e.getKey(), e.getKey(), null);
+            Set<String> systemTags = new HashSet<>();
+            propertyMetadata.setSystemTags(systemTags);
+            PropertyType propertyType = new PropertyType(propertyMetadata);
+            propertyType.setTarget("event");
+            ValueType valueType = null;
+            if (e.getValue().get("properties") != null) {
+                childProperties = getEventPropertyTypes((Map<String, Map<String, Object>>) e.getValue().get("properties"));
+                valueType = definitionsService.getValueType("set");
+                if (childProperties != null && childProperties.size() > 0) {
+                    propertyType.setChildPropertyTypes(childProperties);
+                }
+            } else {
+                valueType = mappingTypeToValueType( (String) e.getValue().get("type"));
+            }
+            propertyType.setValueTypeId(valueType.getId());
+            propertyType.setValueType(valueType);
+            properties.add(propertyType);
+        }
+        return properties;
+    }
+
+    private ValueType mappingTypeToValueType(String mappingType) {
+        if ("text".equals(mappingType)) {
+            return definitionsService.getValueType("string");
+        } else if ("date".equals(mappingType)) {
+            return definitionsService.getValueType("date");
+        } else if ("long".equals(mappingType)) {

Review comment:
       I'm not sure whether we should translate long to integer or introduce a "long" in Unomi. I've been playing with the second idea.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] pmi commented on a change in pull request #168: UNOMI-346 Analyze/study event type registration system

Posted by GitBox <gi...@apache.org>.
pmi commented on a change in pull request #168:
URL: https://github.com/apache/unomi/pull/168#discussion_r445612672



##########
File path: services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java
##########
@@ -160,7 +170,7 @@ private void processBundleStop(BundleContext bundleContext) {
         if (bundleContext == null) {
             return;
         }
-        List<PluginType> types = pluginTypes.get(bundleContext.getBundle().getBundleId());
+        List<PluginType> types = pluginTypes.remove(bundleContext.getBundle().getBundleId());

Review comment:
       That was done by you in UNOMI-286 that I based my work on, so I can only guess :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] pmi commented on a change in pull request #168: UNOMI-352 Implement event type registry for GraphQL

Posted by GitBox <gi...@apache.org>.
pmi commented on a change in pull request #168:
URL: https://github.com/apache/unomi/pull/168#discussion_r445625167



##########
File path: api/src/main/java/org/apache/unomi/api/services/EventTypeRegistry.java
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.unomi.api.services;
+
+import org.apache.unomi.api.EventType;
+
+import java.util.Collection;
+
+public interface EventTypeRegistry {

Review comment:
       Done

##########
File path: api/src/main/java/org/apache/unomi/api/services/EventService.java
##########
@@ -82,9 +79,19 @@
      * Retrieves the list of available event properties.
      *
      * @return a list of available event properties
+     * Retrieves an event type

Review comment:
       Fixed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] pmi commented on a change in pull request #168: UNOMI-346 Analyze/study event type registration system

Posted by GitBox <gi...@apache.org>.
pmi commented on a change in pull request #168:
URL: https://github.com/apache/unomi/pull/168#discussion_r445614930



##########
File path: services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
##########
@@ -211,10 +226,61 @@ private void getEventProperties(Map<String, Map<String, Object>> mappings, List<
         }
     }
 
+    private List<PropertyType> getEventPropertyTypes() {
+        Map<String, Map<String, Object>> mappings = persistenceService.getPropertiesMapping(Event.ITEM_TYPE);
+        return new ArrayList<>(getEventPropertyTypes(mappings));
+    }
+
+    @SuppressWarnings("unchecked")
+    private Set<PropertyType> getEventPropertyTypes(Map<String, Map<String, Object>> mappings) {
+        Set<PropertyType> properties = new LinkedHashSet<>();
+        for (Map.Entry<String, Map<String, Object>> e : mappings.entrySet()) {
+            Set<PropertyType> childProperties = null;
+            Metadata propertyMetadata = new Metadata(null, e.getKey(), e.getKey(), null);
+            Set<String> systemTags = new HashSet<>();
+            propertyMetadata.setSystemTags(systemTags);
+            PropertyType propertyType = new PropertyType(propertyMetadata);
+            propertyType.setTarget("event");
+            ValueType valueType = null;
+            if (e.getValue().get("properties") != null) {
+                childProperties = getEventPropertyTypes((Map<String, Map<String, Object>>) e.getValue().get("properties"));
+                valueType = definitionsService.getValueType("set");
+                if (childProperties != null && childProperties.size() > 0) {
+                    propertyType.setChildPropertyTypes(childProperties);
+                }
+            } else {
+                valueType = mappingTypeToValueType( (String) e.getValue().get("type"));
+            }
+            propertyType.setValueTypeId(valueType.getId());
+            propertyType.setValueType(valueType);
+            properties.add(propertyType);
+        }
+        return properties;
+    }
+
+    private ValueType mappingTypeToValueType(String mappingType) {
+        if ("text".equals(mappingType)) {
+            return definitionsService.getValueType("string");
+        } else if ("date".equals(mappingType)) {
+            return definitionsService.getValueType("date");
+        } else if ("long".equals(mappingType)) {

Review comment:
       Yeah, but maybe it's better to do it as a separate task ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] sergehuber merged pull request #168: UNOMI-352 Implement event type registry for GraphQL

Posted by GitBox <gi...@apache.org>.
sergehuber merged pull request #168:
URL: https://github.com/apache/unomi/pull/168


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] sergehuber commented on pull request #168: UNOMI-352 Implement event type registry for GraphQL

Posted by GitBox <gi...@apache.org>.
sergehuber commented on pull request #168:
URL: https://github.com/apache/unomi/pull/168#issuecomment-649618976


   Thanks for the PR, I just merged it !


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] pmi commented on a change in pull request #168: UNOMI-346 Analyze/study event type registration system

Posted by GitBox <gi...@apache.org>.
pmi commented on a change in pull request #168:
URL: https://github.com/apache/unomi/pull/168#discussion_r445613618



##########
File path: services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java
##########
@@ -59,7 +59,17 @@
 
     private BundleContext bundleContext;
     public DefinitionsServiceImpl() {
-
+        // let's add the built-in value types

Review comment:
       That came from UNOMI-286 that I based my work on, but I will remove that, as we have set property type defined in json. Don't think we need _unknown_ though.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [unomi] sergehuber commented on a change in pull request #168: UNOMI-352 Implement event type registry for GraphQL

Posted by GitBox <gi...@apache.org>.
sergehuber commented on a change in pull request #168:
URL: https://github.com/apache/unomi/pull/168#discussion_r445637317



##########
File path: services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java
##########
@@ -59,7 +59,17 @@
 
     private BundleContext bundleContext;
     public DefinitionsServiceImpl() {
-
+        // let's add the built-in value types

Review comment:
       Ok yes unknown is not needed let's get rid of it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org