You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by ql...@apache.org on 2016/06/29 14:54:18 UTC
incubator-unomi git commit: UNOMI-35: Add campaigns
choiceListInitializer
Repository: incubator-unomi
Updated Branches:
refs/heads/master b6b586548 -> c9f1bc79e
UNOMI-35: Add campaigns choiceListInitializer
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/c9f1bc79
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/c9f1bc79
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/c9f1bc79
Branch: refs/heads/master
Commit: c9f1bc79e0a00adbde3e9241a00408b40e9bef58
Parents: b6b5865
Author: Quentin Lamerand <ql...@jahia.com>
Authored: Wed Jun 29 16:54:11 2016 +0200
Committer: Quentin Lamerand <ql...@jahia.com>
Committed: Wed Jun 29 16:54:11 2016 +0200
----------------------------------------------------------------------
.../CampaignsChoiceListInitializer.java | 44 ++++++++++++++++++++
.../resources/OSGI-INF/blueprint/blueprint.xml | 9 ++++
2 files changed, 53 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c9f1bc79/services/src/main/java/org/apache/unomi/services/conditions/initializers/CampaignsChoiceListInitializer.java
----------------------------------------------------------------------
diff --git a/services/src/main/java/org/apache/unomi/services/conditions/initializers/CampaignsChoiceListInitializer.java b/services/src/main/java/org/apache/unomi/services/conditions/initializers/CampaignsChoiceListInitializer.java
new file mode 100644
index 0000000..e9ec178
--- /dev/null
+++ b/services/src/main/java/org/apache/unomi/services/conditions/initializers/CampaignsChoiceListInitializer.java
@@ -0,0 +1,44 @@
+/*
+ * 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.services.conditions.initializers;
+
+import org.apache.unomi.api.Metadata;
+import org.apache.unomi.api.conditions.initializers.ChoiceListInitializer;
+import org.apache.unomi.api.conditions.initializers.ChoiceListValue;
+import org.apache.unomi.api.services.GoalsService;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CampaignsChoiceListInitializer implements ChoiceListInitializer {
+
+ private GoalsService goalsService;
+
+ public void setGoalsService(GoalsService goalsService) {
+ this.goalsService = goalsService;
+ }
+
+ @Override
+ public List<ChoiceListValue> getValues(Object context) {
+ List<ChoiceListValue> r = new ArrayList<>();
+ for (Metadata metadata : goalsService.getCampaignMetadatas()) {
+ r.add(new ChoiceListValue(metadata.getId(), metadata.getName()));
+ }
+ return r;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c9f1bc79/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 f26ef29..11ec306 100644
--- a/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -182,6 +182,15 @@
</bean>
</service>
+ <service auto-export="interfaces">
+ <service-properties>
+ <entry key="initializerId" value="campaigns"/>
+ </service-properties>
+ <bean class="org.apache.unomi.services.conditions.initializers.CampaignsChoiceListInitializer">
+ <property name="goalsService" ref="goalsServiceImpl"/>
+ </bean>
+ </service>
+
<!-- We use a listener here because using the list directly for listening to proxies coming from the same bundle didn't seem to work -->
<reference-list id="eventListenerServices"