You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dr...@apache.org on 2016/07/27 11:53:52 UTC
[1/4] incubator-unomi git commit: DMF-741 : Add a rule to send email
when scoring has value been reached
Repository: incubator-unomi
Updated Branches:
refs/heads/master 6832aae60 -> 6e420d168
DMF-741 : 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/7cb59a6f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/7cb59a6f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/7cb59a6f
Branch: refs/heads/master
Commit: 7cb59a6f21cf8a9bc529569decabea856527541e
Parents: c97f922
Author: Abdelkader Midani <am...@jahia.com>
Authored: Wed Jul 20 16:31:00 2016 +0200
Committer: Abdelkader Midani <am...@jahia.com>
Committed: Mon Jul 25 16:46:08 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/7cb59a6f/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/7cb59a6f/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/7cb59a6f/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/7cb59a6f/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/7cb59a6f/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"/>
[2/4] incubator-unomi git commit: DMF-741 : Send event updatedProfile
optimization, send it also when segments are updated
Posted by dr...@apache.org.
DMF-741 : Send event updatedProfile optimization, send it also when segments are updated
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/8fb2883b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/8fb2883b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/8fb2883b
Branch: refs/heads/master
Commit: 8fb2883b35e972c7a874244a2ef1abe75f300fad
Parents: 7cb59a6
Author: Abdelkader Midani <am...@jahia.com>
Authored: Mon Jul 25 18:36:13 2016 +0200
Committer: Abdelkader Midani <am...@jahia.com>
Committed: Mon Jul 25 18:36:13 2016 +0200
----------------------------------------------------------------------
.../services/services/SegmentServiceImpl.java | 21 +++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/8fb2883b/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 1041365..744bd71 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
@@ -638,14 +638,28 @@ public class SegmentServiceImpl implements SegmentService, SynchronousBundleList
add.removeAll(previousProfiles);
previousProfiles.removeAll(newProfiles);
+ Map<String, Event> updatedProfiles = new HashMap<>();
+
for (Profile profileToAdd : add) {
profileToAdd.getSegments().add(segment.getItemId());
persistenceService.update(profileToAdd.getItemId(), null, Profile.class, "segments", profileToAdd.getSegments());
+ Event profileUpdated = new Event("profileUpdated", null, profileToAdd, null, null, profileToAdd, new Date());
+ profileUpdated.setPersistent(false);
+ updatedProfiles.put(profileToAdd.getItemId(), profileUpdated);
}
for (Profile profileToRemove : previousProfiles) {
profileToRemove.getSegments().remove(segment.getItemId());
persistenceService.update(profileToRemove.getItemId(), null, Profile.class, "segments", profileToRemove.getSegments());
+ Event profileUpdated = new Event("profileUpdated", null, profileToRemove, null, null, profileToRemove, new Date());
+ profileUpdated.setPersistent(false);
+ updatedProfiles.put(profileToRemove.getItemId(), profileUpdated);
+ }
+
+ Iterator<Map.Entry<String, Event>> entries = updatedProfiles.entrySet().iterator();
+ while (entries.hasNext()) {
+ eventService.send(entries.next().getValue());
}
+
} else {
List<Profile> previousProfiles = persistenceService.query(segmentCondition, null, Profile.class);
for (Profile profileToRemove : previousProfiles) {
@@ -672,15 +686,20 @@ public class SegmentServiceImpl implements SegmentService, SynchronousBundleList
}
if(scoring.getMetadata().isEnabled()) {
String script = "if (ctx._source.scores == null) { ctx._source.scores=[:] } ; if (ctx._source.scores.containsKey(scoringId)) { ctx._source.scores[scoringId] += scoringValue } else { ctx._source.scores[scoringId] = scoringValue }";
+ Map<String, Event> updatedProfiles = new HashMap<>();
for (ScoringElement element : scoring.getElements()) {
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);
+ updatedProfiles.put(p.getItemId(), profileUpdated);
}
}
+ Iterator<Map.Entry<String, Event>> entries = updatedProfiles.entrySet().iterator();
+ while (entries.hasNext()) {
+ eventService.send(entries.next().getValue());
+ }
}
logger.info("Profiles updated in {}", System.currentTimeMillis()-t);
}
[3/4] incubator-unomi git commit: DMF-741 : send it also when
segments are updated
Posted by dr...@apache.org.
DMF-741 : send it also when segments are updated
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/ef104b71
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/ef104b71
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/ef104b71
Branch: refs/heads/master
Commit: ef104b71b61cb7f619224e3da47a51fc7bce3fe9
Parents: 8fb2883
Author: Abdelkader Midani <am...@jahia.com>
Authored: Mon Jul 25 18:45:43 2016 +0200
Committer: Abdelkader Midani <am...@jahia.com>
Committed: Mon Jul 25 18:45:43 2016 +0200
----------------------------------------------------------------------
.../unomi/services/services/SegmentServiceImpl.java | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/ef104b71/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 744bd71..6149f62 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
@@ -638,26 +638,19 @@ public class SegmentServiceImpl implements SegmentService, SynchronousBundleList
add.removeAll(previousProfiles);
previousProfiles.removeAll(newProfiles);
- Map<String, Event> updatedProfiles = new HashMap<>();
-
for (Profile profileToAdd : add) {
profileToAdd.getSegments().add(segment.getItemId());
persistenceService.update(profileToAdd.getItemId(), null, Profile.class, "segments", profileToAdd.getSegments());
Event profileUpdated = new Event("profileUpdated", null, profileToAdd, null, null, profileToAdd, new Date());
profileUpdated.setPersistent(false);
- updatedProfiles.put(profileToAdd.getItemId(), profileUpdated);
+ eventService.send(profileUpdated);
}
for (Profile profileToRemove : previousProfiles) {
profileToRemove.getSegments().remove(segment.getItemId());
persistenceService.update(profileToRemove.getItemId(), null, Profile.class, "segments", profileToRemove.getSegments());
Event profileUpdated = new Event("profileUpdated", null, profileToRemove, null, null, profileToRemove, new Date());
profileUpdated.setPersistent(false);
- updatedProfiles.put(profileToRemove.getItemId(), profileUpdated);
- }
-
- Iterator<Map.Entry<String, Event>> entries = updatedProfiles.entrySet().iterator();
- while (entries.hasNext()) {
- eventService.send(entries.next().getValue());
+ eventService.send(profileUpdated);
}
} else {
[4/4] incubator-unomi git commit: Merge branch 'pr4'
Posted by dr...@apache.org.
Merge branch 'pr4'
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/6e420d16
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/6e420d16
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/6e420d16
Branch: refs/heads/master
Commit: 6e420d16879abedaa5c18e656af463d844e2c6a3
Parents: 6832aae ef104b7
Author: Thomas Draier <dr...@apache.org>
Authored: Wed Jul 27 13:53:14 2016 +0200
Committer: Thomas Draier <dr...@apache.org>
Committed: Wed Jul 27 13:53:14 2016 +0200
----------------------------------------------------------------------
package/pom.xml | 11 ++++++++
plugins/mail/pom.xml | 29 ++++++++++++++++++++
.../resources/org.apache.unomi.plugins.mail.cfg | 22 +++++++++++++++
.../services/services/SegmentServiceImpl.java | 22 +++++++++++++++
.../resources/OSGI-INF/blueprint/blueprint.xml | 1 +
5 files changed, 85 insertions(+)
----------------------------------------------------------------------