Repository: incubator-unomi
Updated Branches:
  refs/heads/master 6e420d168 -> 45d4fb092


UNOMI-47 : Add a rule to send email when scoring has value been reached


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/fbffc999
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/fbffc999
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/fbffc999

Branch: refs/heads/master
Commit: fbffc999bf39cea0e3460b5ec43ba0497b63702d
Parents: c97f922
Author: Abdelkader Midani <[email protected]>
Authored: Wed Jul 20 16:31:00 2016 +0200
Committer: Quentin Lamerand <[email protected]>
Committed: Thu Aug 4 19:01:24 2016 +0200

----------------------------------------------------------------------
 package/pom.xml                                 | 11 ++++++++
 plugins/mail/pom.xml                            | 29 ++++++++++++++++++++
 .../resources/org.apache.unomi.plugins.mail.cfg | 22 +++++++++++++++
 .../services/services/SegmentServiceImpl.java   | 10 +++++++
 .../resources/OSGI-INF/blueprint/blueprint.xml  |  1 +
 5 files changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/fbffc999/package/pom.xml
----------------------------------------------------------------------
diff --git a/package/pom.xml b/package/pom.xml
index 29ef8a6..eb6546b 100644
--- a/package/pom.xml
+++ b/package/pom.xml
@@ -192,6 +192,17 @@
                                     </outputDirectory>
                                     
<destFileName>org.apache.unomi.plugins.request.cfg</destFileName>
                                 </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.apache.unomi</groupId>
+                                    <artifactId>unomi-plugins-mail</artifactId>
+                                    <version>${project.version}</version>
+                                    <classifier>mailcfg</classifier>
+                                    <type>cfg</type>
+                                    <outputDirectory>
+                                        ${project.build.directory}/assembly/etc
+                                    </outputDirectory>
+                                    
<destFileName>org.apache.unomi.plugins.mail.cfg</destFileName>
+                                </artifactItem>
                             </artifactItems>
                             <!-- other configurations here -->
                         </configuration>

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/fbffc999/plugins/mail/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/mail/pom.xml b/plugins/mail/pom.xml
index 2a7d61e..fcc431e 100644
--- a/plugins/mail/pom.xml
+++ b/plugins/mail/pom.xml
@@ -41,4 +41,33 @@
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>
+                                        
src/main/resources/org.apache.unomi.plugins.mail.cfg
+                                    </file>
+                                    <type>cfg</type>
+                                    <classifier>mailcfg</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/fbffc999/plugins/mail/src/main/resources/org.apache.unomi.plugins.mail.cfg
----------------------------------------------------------------------
diff --git a/plugins/mail/src/main/resources/org.apache.unomi.plugins.mail.cfg 
b/plugins/mail/src/main/resources/org.apache.unomi.plugins.mail.cfg
new file mode 100644
index 0000000..d1f0d27
--- /dev/null
+++ b/plugins/mail/src/main/resources/org.apache.unomi.plugins.mail.cfg
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+
+mail.server.hostname=smtp.gmail.com
+mail.server.port=465
+mail.server.username=
+mail.server.password=
+mail.server.sslOnConnect=true

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/fbffc999/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
 
b/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
index de02645..1041365 100644
--- 
a/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
+++ 
b/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
@@ -29,6 +29,7 @@ import org.apache.unomi.api.segments.ScoringElement;
 import org.apache.unomi.api.segments.Segment;
 import org.apache.unomi.api.segments.SegmentsAndScores;
 import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.api.services.EventService;
 import org.apache.unomi.api.services.RulesService;
 import org.apache.unomi.api.services.SegmentService;
 import org.apache.unomi.persistence.spi.CustomObjectMapper;
@@ -57,6 +58,8 @@ public class SegmentServiceImpl implements SegmentService, 
SynchronousBundleList
 
     private DefinitionsService definitionsService;
 
+    private EventService eventService;
+
     private RulesService rulesService;
 
     private long taskExecutionPeriod = 24L * 60L * 60L * 1000L;
@@ -112,6 +115,10 @@ public class SegmentServiceImpl implements SegmentService, 
SynchronousBundleList
         this.definitionsService = definitionsService;
     }
 
+    public void setEventService(EventService eventService) {
+        this.eventService = eventService;
+    }
+
     public void setRulesService(RulesService rulesService) {
         this.rulesService = rulesService;
     }
@@ -669,6 +676,9 @@ public class SegmentServiceImpl implements SegmentService, 
SynchronousBundleList
                 scriptParams.put("scoringValue", element.getValue());
                 for (Profile p : 
persistenceService.query(element.getCondition(), null, Profile.class)) {
                     persistenceService.updateWithScript(p.getItemId(), null, 
Profile.class, script, scriptParams);
+                    Event profileUpdated = new Event("profileUpdated", null, 
p, null, null, p, new Date());
+                    profileUpdated.setPersistent(false);
+                    eventService.send(profileUpdated);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/fbffc999/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml 
b/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index d1b9037..5564e94 100644
--- a/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -100,6 +100,7 @@
           init-method="postConstruct" destroy-method="preDestroy">
         <property name="persistenceService" ref="persistenceService"/>
         <property name="definitionsService" ref="definitionsServiceImpl"/>
+        <property name="eventService" ref="eventServiceImpl"/>
         <property name="rulesService" ref="rulesServiceImpl"/>
         <property name="bundleContext" ref="blueprintBundleContext"/>
         <property name="taskExecutionPeriod" value="86400000"/>

Reply via email to