You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jb...@apache.org on 2015/11/23 17:32:30 UTC
[21/54] [abbrv] incubator-unomi git commit: Major changes : - Rename
all packages to org.apache.*
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/rules/Rule.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/rules/Rule.java b/api/src/main/java/org/oasis_open/contextserver/api/rules/Rule.java
deleted file mode 100644
index a6d881a..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/rules/Rule.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.rules;
-
-import org.oasis_open.contextserver.api.Item;
-import org.oasis_open.contextserver.api.Metadata;
-import org.oasis_open.contextserver.api.MetadataItem;
-import org.oasis_open.contextserver.api.actions.Action;
-import org.oasis_open.contextserver.api.conditions.Condition;
-
-import java.util.List;
-
-/**
- * A conditional set of actions to be executed in response to incoming events. Triggering of rules is guarded by a condition: the rule is only triggered if the associated
- * condition ({@link #getCondition()}) is satisfied. Once a rule triggers, a list of actions ({@link #getActions()} can be performed as consequences.
- *
- * When rules trigger, a specific event is raised so that other parts of unomi can react to it accordingly. We can control how that event should be raised using
- * {@link #isRaiseEventOnlyOnceForProfile()} and {@link #isRaiseEventOnlyOnceForSession()}.
- *
- * We could also specify a priority for our rule in case it needs to be executed before other ones when similar conditions match. This is accomplished using the
- * {@link #getPriority()} property.
- */
-public class Rule extends MetadataItem {
-
- private static final long serialVersionUID = 3058739939263056507L;
-
- /**
- * The Rule ITEM_TYPE.
- *
- * @see Item for a discussion of ITEM_TYPE
- */
- public static final String ITEM_TYPE = "rule";
-
- private Condition condition;
-
- private List<Action> actions;
-
- private List<String> linkedItems;
-
- private boolean raiseEventOnlyOnceForProfile = false;
-
- private boolean raiseEventOnlyOnceForSession = false;
-
- private int priority;
-
- /**
- * Instantiates a new Rule.
- */
- public Rule() {
- }
-
- /**
- * Instantiates a new Rule with the specified {@link Metadata}.
- *
- * @param metadata the metadata
- */
- public Rule(Metadata metadata) {
- super(metadata);
- }
-
- /**
- * Retrieves the condition that, when satisfied, triggers the rule.
- *
- * @return the condition that, when satisfied, triggers the rule.
- */
- public Condition getCondition() {
- return condition;
- }
-
- /**
- * Sets the condition that, when satisfied, triggers the rule..
- *
- * @param condition the condition that, when satisfied, triggers the rule.
- */
- public void setCondition(Condition condition) {
- this.condition = condition;
- }
-
- /**
- * Retrieves the actions to be performed when this rule triggers.
- *
- * @return the actions to be performed when this rule triggers
- */
- public List<Action> getActions() {
- return actions;
- }
-
- /**
- * Sets the actions to be performed when this rule triggers.
- *
- * @param actions the actions to be performed when this rule triggers
- */
- public void setActions(List<Action> actions) {
- this.actions = actions;
- }
-
- /**
- * Retrieves the linked items.
- *
- * @return the linked items
- */
- public List<String> getLinkedItems() {
- return linkedItems;
- }
-
- /**
- * Sets the linked items.
- *
- * @param linkedItems the linked items
- */
- public void setLinkedItems(List<String> linkedItems) {
- this.linkedItems = linkedItems;
- }
-
- /**
- * Determines whether the event raised when the rule is triggered should only be raised once per {@link org.oasis_open.contextserver.api.Profile}.
- *
- * @return {@code true} if the rule-triggered event should only be raised once per profile, {@code false} otherwise
- */
- public boolean isRaiseEventOnlyOnceForProfile() {
- return raiseEventOnlyOnceForProfile;
- }
-
- /**
- * Specifies whether the event raised when the rule is triggered should only be raised once per {@link org.oasis_open.contextserver.api.Profile}.
- *
- * @param raiseEventOnlyOnceForProfile {@code true} if the rule-triggered event should only be raised once per profile, {@code false} otherwise
- */
- public void setRaiseEventOnlyOnceForProfile(boolean raiseEventOnlyOnceForProfile) {
- this.raiseEventOnlyOnceForProfile = raiseEventOnlyOnceForProfile;
- }
-
- /**
- * Determines whether the event raised when the rule is triggered should only be raised once per {@link org.oasis_open.contextserver.api.Session}.
- *
- * @return {@code true} if the rule-triggered event should only be raised once per session, {@code false} otherwise
- */
- public boolean isRaiseEventOnlyOnceForSession() {
- return raiseEventOnlyOnceForSession;
- }
-
- /**
- * Specifies whether the event raised when the rule is triggered should only be raised once per {@link org.oasis_open.contextserver.api.Session}.
- *
- * @param raiseEventOnlyOnceForSession {@code true} if the rule-triggered event should only be raised once per session, {@code false} otherwise
- */
- public void setRaiseEventOnlyOnceForSession(boolean raiseEventOnlyOnceForSession) {
- this.raiseEventOnlyOnceForSession = raiseEventOnlyOnceForSession;
- }
-
- /**
- * Retrieves the priority in case this Rule needs to be executed before other ones when similar conditions match.
- *
- * @return the priority
- */
- public int getPriority() {
- return priority;
- }
-
- /**
- * Sets the priority in case this Rule needs to be executed before other ones when similar conditions match.
- *
- * @param priority the priority
- */
- public void setPriority(int priority) {
- this.priority = priority;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/segments/Scoring.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/segments/Scoring.java b/api/src/main/java/org/oasis_open/contextserver/api/segments/Scoring.java
deleted file mode 100644
index d16089f..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/segments/Scoring.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.segments;
-
-import org.oasis_open.contextserver.api.Item;
-import org.oasis_open.contextserver.api.Metadata;
-import org.oasis_open.contextserver.api.MetadataItem;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.util.List;
-
-/**
- * A set of conditions associated with a value to assign to {@link org.oasis_open.contextserver.api.Profile}s when matching so that the associated users can be scored along that
- * dimension. Each {@link ScoringElement} is evaluated and matching profiles' scores are incremented with the associated value.
- */
-@XmlRootElement
-public class Scoring extends MetadataItem {
- private static final long serialVersionUID = 6351058906259967559L;
-
- /**
- * The Scoring ITEM_TYPE.
- *
- * @see Item for a discussion of ITEM_TYPE
- */
- public static final String ITEM_TYPE = "scoring";
-
- private List<ScoringElement> elements;
-
- /**
- * Instantiates a new Scoring.
- */
- public Scoring() {
- }
-
- /**
- * Instantiates a new Scoring with the specified metadata.
- *
- * @param metadata the metadata
- */
- public Scoring(Metadata metadata) {
- super(metadata);
- }
-
- /**
- * Retrieves the details of this Scoring.
- *
- * @return the elements
- */
- public List<ScoringElement> getElements() {
- return elements;
- }
-
- /**
- * Sets the elements.
- *
- * @param elements the elements
- */
- public void setElements(List<ScoringElement> elements) {
- this.elements = elements;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/segments/ScoringElement.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/segments/ScoringElement.java b/api/src/main/java/org/oasis_open/contextserver/api/segments/ScoringElement.java
deleted file mode 100644
index 06261d6..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/segments/ScoringElement.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.segments;
-
-import org.oasis_open.contextserver.api.conditions.Condition;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * A scoring dimension along profiles can be evaluated and associated value to be assigned.
- */
-@XmlRootElement
-public class ScoringElement {
- private Condition condition;
- private int value;
-
- /**
- * Instantiates a new Scoring element.
- */
- public ScoringElement() {
- }
-
- /**
- * Retrieves the condition.
- *
- * @return the condition
- */
- public Condition getCondition() {
- return condition;
- }
-
- /**
- * Sets the condition.
- *
- * @param condition the condition
- */
- public void setCondition(Condition condition) {
- this.condition = condition;
- }
-
- /**
- * Retrieves the value.
- *
- * @return the value
- */
- public int getValue() {
- return value;
- }
-
- /**
- * Sets the value.
- *
- * @param value the value
- */
- public void setValue(int value) {
- this.value = value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/segments/Segment.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/segments/Segment.java b/api/src/main/java/org/oasis_open/contextserver/api/segments/Segment.java
deleted file mode 100644
index 37b0994..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/segments/Segment.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.segments;
-
-import org.oasis_open.contextserver.api.Item;
-import org.oasis_open.contextserver.api.Metadata;
-import org.oasis_open.contextserver.api.MetadataItem;
-import org.oasis_open.contextserver.api.conditions.Condition;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * A dynamically evaluated group of similar profiles in order to categorize the associated users. To be considered part of a given segment, users must satisfies
- * the segment’s condition. If they match, users are automatically added to the segment. Similarly, if at any given point during, they cease to satisfy the segment’s condition,
- * they are automatically removed from it.
- */
-@XmlRootElement
-public class Segment extends MetadataItem {
-
- private static final long serialVersionUID = -1384533444860961296L;
-
- /**
- * The Segment ITEM_TYPE.
- *
- * @see Item for a discussion of ITEM_TYPE
- */
- public static final String ITEM_TYPE = "segment";
-
- private Condition condition;
-
- /**
- * Instantiates a new Segment.
- */
- public Segment() {
- }
-
- /**
- * Instantiates a new Segment with the specified metadata.
- *
- * @param metadata the metadata
- */
- public Segment(Metadata metadata) {
- super(metadata);
- }
-
- /**
- * Retrieves the condition that users' {@link org.oasis_open.contextserver.api.Profile} must satisfy in order to be considered member of this Segment.
- *
- * @return the condition that users must match
- */
- public Condition getCondition() {
- return condition;
- }
-
- /**
- * Sets the condition that users' {@link org.oasis_open.contextserver.api.Profile} must satisfy in order to be considered member of this Segment.
- *
- * @param condition the condition that users must match
- */
- public void setCondition(Condition condition) {
- this.condition = condition;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/segments/SegmentsAndScores.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/segments/SegmentsAndScores.java b/api/src/main/java/org/oasis_open/contextserver/api/segments/SegmentsAndScores.java
deleted file mode 100644
index 5201b81..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/segments/SegmentsAndScores.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.segments;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A combination of {@link Segment} and scores (usually associated with a {@link org.oasis_open.contextserver.api.Profile}).
- */
-public class SegmentsAndScores {
- private Set<String> segments;
- private Map<String,Integer> scores;
-
- /**
- * Instantiates a new SegmentsAndScores.
- *
- * @param segments the set of segment identifiers
- * @param scores the scores as a Map of scoring name - associated score pairs
- */
- public SegmentsAndScores(Set<String> segments, Map<String, Integer> scores) {
- this.segments = segments;
- this.scores = scores;
- }
-
-
- /**
- * Retrieves the segments identifiers.
- *
- * @return the segments identifiers
- */
- public Set<String> getSegments() {
- return segments;
- }
-
- /**
- * Retrieves the scores as a Map of scoring name - associated score pairs.
- *
- * @return the scores as a Map of scoring name - associated score pairs
- */
- public Map<String, Integer> getScores() {
- return scores;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/ClusterService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/ClusterService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/ClusterService.java
deleted file mode 100644
index 56981c3..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/ClusterService.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.ClusterNode;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * A service to access information about the context server's cluster.
- *
- * TODO: rename to something less specific like ContextRuntimeService?
- */
-public interface ClusterService {
-
- /**
- * Retrieves the list of available nodes for this context server instance.
- *
- * @return a list of {@link ClusterNode}
- */
- List<ClusterNode> getClusterNodes();
-
- /**
- * Removes all data before the specified date from the context server.
- *
- * @param date the Date before which all data needs to be removed
- */
- void purge(final Date date);
-
- /**
- * Removes all data associated with the provided scope.
- *
- * @param scope the scope for which we want to remove data
- */
- void purge(final String scope);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/DefinitionsService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/DefinitionsService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/DefinitionsService.java
deleted file mode 100644
index e50f9c5..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/DefinitionsService.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.PluginType;
-import org.oasis_open.contextserver.api.PropertyMergeStrategyType;
-import org.oasis_open.contextserver.api.Tag;
-import org.oasis_open.contextserver.api.ValueType;
-import org.oasis_open.contextserver.api.actions.ActionType;
-import org.oasis_open.contextserver.api.conditions.Condition;
-import org.oasis_open.contextserver.api.conditions.ConditionType;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A service to retrieve definition information about core context server entities such as conditions, actions and values.
- */
-public interface DefinitionsService {
- /**
- * Retrieves all known tags.
- *
- * @return the set of all known tags
- */
- Set<Tag> getAllTags();
-
- /**
- * Retrieves the set of all root tags from which all other tags are derived via sub-tags.
- *
- * @return the set of all root tags
- */
- Set<Tag> getRootTags();
-
- /**
- * Retrieves the tag with the specified identifier.
- *
- * @param tagId the identifier of the tag to retrieve
- * @return the tag with the specified identifier
- */
- Tag getTag(String tagId);
-
- /**
- * Retrieves all condition types.
- *
- * @return a Collection of all collection types
- */
- Collection<ConditionType> getAllConditionTypes();
-
- /**
- * Retrieves the set of condition types with the specified tag also retrieving condition types from sub-tags if so specified.
- *
- * @param tag the tag marking the condition types we want to retrieve
- * @param includeFromSubtags {@code true} if we want to also include condition types marked by sub-tags of the specified tag
- * @return the set of condition types with the specified tag (and its sub-tags, if specified)
- */
- Set<ConditionType> getConditionTypesByTag(Tag tag, boolean includeFromSubtags);
-
- /**
- * Retrieves the condition type associated with the specified identifier.
- *
- * @param id the identifier of the condition type to retrieve
- * @return the condition type associated with the specified identifier or {@code null} if no such condition type exists
- */
- ConditionType getConditionType(String id);
-
- /**
- * Retrieves all known action types.
- *
- * @return all known action types
- */
- Collection<ActionType> getAllActionTypes();
-
- /**
- * Retrieves the set of action types with the specified tag also retrieving action types from sub-tags if so specified.
- *
- * @param tag the tag marking the action types we want to retrieve
- * @param includeFromSubtags {@code true} if we want to also include action types marked by sub-tags of the specified tag
- * @return the set of action types with the specified tag (and its sub-tags, if specified)
- */
- Set<ActionType> getActionTypeByTag(Tag tag, boolean includeFromSubtags);
-
- /**
- * Retrieves the action type associated with the specified identifier.
- *
- * @param id the identifier of the action type to retrieve
- * @return the action type associated with the specified identifier or {@code null} if no such action type exists
- */
- ActionType getActionType(String id);
-
- /**
- * Retrieves all known value types.
- *
- * @return all known value types
- */
- Collection<ValueType> getAllValueTypes();
-
- /**
- * Retrieves the set of value types with the specified tag also retrieving value types from sub-tags if so specified.
- *
- * @param tag the tag marking the value types we want to retrieve
- * @param includeFromSubtags {@code true} if we want to also include value types marked by sub-tags of the specified tag
- * @return the set of value types with the specified tag (and its sub-tags, if specified)
- */
- Set<ValueType> getValueTypeByTag(Tag tag, boolean includeFromSubtags);
-
- /**
- * Retrieves the value type associated with the specified identifier.
- *
- * @param id the identifier of the value type to retrieve
- * @return the value type associated with the specified identifier or {@code null} if no such value type exists
- */
- ValueType getValueType(String id);
-
- /**
- * Retrieves a Map of plugin identifier to a list of plugin types defined by that particular plugin.
- *
- * @return a Map of plugin identifier to a list of plugin types defined by that particular plugin
- */
- Map<Long, List<PluginType>> getTypesByPlugin();
-
- /**
- * Retrieves the property merge strategy type associated with the specified identifier.
- *
- * @param id the identifier of the property merge strategy type to retrieve
- * @return the property merge strategy type associated with the specified identifier or {@code null} if no such property merge strategy type exists
- */
- PropertyMergeStrategyType getPropertyMergeStrategyType(String id);
-
- /**
- * Retrieves all conditions of the specified type from the specified root condition.
- *
- * TODO: remove?
- *
- * @param rootCondition the condition from which we want to extract all conditions with the specified type
- * @param typeId the identifier of the condition type we want conditions to extract to match
- * @return a set of conditions contained in the specified root condition and matching the specified condition type or an empty set if no such condition exists
- */
- Set<Condition> extractConditionsByType(Condition rootCondition, String typeId);
-
- /**
- * Retrieves a condition matching the specified tag identifier from the specified root condition.
- *
- * TODO: remove from API and move to a different class?
- * TODO: purpose and behavior not clear
- *
- * @param rootCondition
- * @param tagId
- * @return
- */
- Condition extractConditionByTag(Condition rootCondition, String tagId);
-
- /**
- * Resolves (if possible) the {@link ConditionType}s for the specified condition and its sub-conditions (if any) from the type identifiers existing on the specified condition
- *
- * TODO: remove from API and move to a different class?
- *
- * @param rootCondition the condition for which we want to resolve the condition types from the existing condition type identifiers
- * @return {@code true}
- */
- boolean resolveConditionType(Condition rootCondition);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/EventListenerService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/EventListenerService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/EventListenerService.java
deleted file mode 100644
index c95e8d0..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/EventListenerService.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.Event;
-
-/**
- * A service that gets notified (via {@link #onEvent(Event)}) whenever an event it can handle as decided by {@link #canHandle(Event)} occurs in the context server.
- */
-public interface EventListenerService {
-
- /**
- * Whether or not this listener can handle the specified event.
- *
- * @param event the event to be handled
- * @return {@code true} if this listener can handle the specified event, {@code false} otherwise
- */
- boolean canHandle(Event event);
-
- /**
- * Handles the specified event.
- *
- * @param event the event to be handled
- * @return the result of the event handling as combination of {@link EventService} flags, to be checked using bitwise AND (&) operator
- * @see EventService#NO_CHANGE
- * @see EventService#PROFILE_UPDATED
- * @see EventService#SESSION_UPDATED
- */
- int onEvent(Event event);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/EventService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/EventService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/EventService.java
deleted file mode 100644
index 1dec2a5..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/EventService.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.Event;
-import org.oasis_open.contextserver.api.EventProperty;
-import org.oasis_open.contextserver.api.PartialList;
-import org.oasis_open.contextserver.api.conditions.Condition;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * A service to publish events, notably issued from user interactions with tracked entities, in the context server.
- */
-public interface EventService {
-
- /**
- * No change occurred following an event being handled.
- */
- int NO_CHANGE = 0;
- /**
- * The associated session was updated following an event being handled.
- */
- int SESSION_UPDATED = 1;
- /**
- * The associated profile was updated following an event being handled.
- */
- int PROFILE_UPDATED = 2;
-
- /**
- * Propagates the specified event in the context server, notifying
- * {@link EventListenerService} instances if needed. If the event is persistent ({@link Event#isPersistent()}, it will be persisted appropriately. Once the event is
- * propagated, any {@link org.oasis_open.contextserver.api.actions.ActionPostExecutor} the event defined will be executed and the user profile updated if needed.
- *
- * @param event the Event to be propagated
- * @return the result of the event handling as combination of EventService flags, to be checked using bitwise AND (&) operator
- */
- int send(Event event);
-
- /**
- * Retrieves the list of available event properties.
- *
- * @return a list of available event properties
- */
- List<EventProperty> getEventProperties();
-
- /**
- * Retrieves the set of known event type identifiers.
- *
- * @return the set of known event type identifiers.
- */
- Set<String> getEventTypeIds();
-
- /**
- * Retrieves {@link Event}s matching the specified {@link Condition}. Events are ordered according to their time stamp ({@link Event#getTimeStamp()} and paged: only
- * {@code size} of them are retrieved, starting with the {@code offset}-th one.
- *
- * @param condition the Condition we want the Events to match to be retrieved
- * @param offset zero or a positive integer specifying the position of the first event in the total ordered collection of matching events
- * @param size a positive integer specifying how many matching events should be retrieved or {@code -1} if all of them should be retrieved
- * @return a {@link PartialList} of matching events
- */
- PartialList<Event> searchEvents(Condition condition, int offset, int size);
-
- /**
- * Retrieves {@link Event}s for the {@link org.oasis_open.contextserver.api.Session} identified by the provided session identifier, matching any of the provided event types,
- * ordered according to the specified {@code sortBy} String and paged: only {@code size} of them are retrieved, starting with the {@code offset}-th one.
- * If a {@code query} is provided, a full text search is performed on the matching events to further filter them.
- *
- * @param sessionId the identifier of the user session we're considering
- * @param eventTypes an array of event type names; the events to retrieve should at least match one of these
- * @param query a String to perform full text filtering on events matching the other conditions
- * @param offset zero or a positive integer specifying the position of the first event in the total ordered collection of matching events
- * @param size a positive integer specifying how many matching events should be retrieved or {@code -1} if all of them should be retrieved
- * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering elements according to the property order in
- * the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by
- * a column ({@code :}) and an order specifier: {@code asc} or {@code desc}.
- * @return a {@link PartialList} of matching events
- */
- PartialList<Event> searchEvents(String sessionId, String[] eventTypes, String query, int offset, int size, String sortBy);
-
- /**
- * Checks whether the specified event has already been raised either for the associated session or profile depending on the specified {@code session} parameter.
- *
- * @param event the event we want to check
- * @param session {@code true} if we want to check if the specified event has already been raised for the associated session, {@code false} if we want to check
- * whether the event has already been raised for the associated profile
- * @return {@code true} if the event has already been raised, {@code false} otherwise
- */
- boolean hasEventAlreadyBeenRaised(Event event, boolean session);
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/GoalsService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/GoalsService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/GoalsService.java
deleted file mode 100644
index e4d8dee..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/GoalsService.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.Metadata;
-import org.oasis_open.contextserver.api.PartialList;
-import org.oasis_open.contextserver.api.campaigns.Campaign;
-import org.oasis_open.contextserver.api.campaigns.CampaignDetail;
-import org.oasis_open.contextserver.api.campaigns.events.CampaignEvent;
-import org.oasis_open.contextserver.api.goals.Goal;
-import org.oasis_open.contextserver.api.goals.GoalReport;
-import org.oasis_open.contextserver.api.query.AggregateQuery;
-import org.oasis_open.contextserver.api.query.Query;
-
-import java.util.Set;
-
-/**
- * A service to interact with {@link Goal}s and {@link Campaign}s.
- */
-public interface GoalsService {
- /**
- * Retrieves the set of Metadata associated with existing goals.
- *
- * @return the set of Metadata associated with existing goals
- */
- Set<Metadata> getGoalMetadatas();
-
- /**
- * Retrieves the set of Metadata associated with existing goals matching the specified {@link Query}
- *
- * @param query the Query used to filter the Goals which metadata we want to retrieve
- * @return the set of Metadata associated with existing goals matching the specified {@link Query}
- */
- Set<Metadata> getGoalMetadatas(Query query);
-
- /**
- * Retrieves the goal associated with the specified identifier.
- *
- * @param goalId the identifier of the goal to retrieve
- * @return the goal associated with the specified identifier or {@code null} if no such goal exists
- */
- Goal getGoal(String goalId);
-
- /**
- * Saves the specified goal in the context server and creates associated {@link org.oasis_open.contextserver.api.rules.Rule}s if the goal is enabled.
- *
- * TODO: rename to saveGoal
- *
- * @param goal the Goal to be saved
- */
- void setGoal(Goal goal);
-
- /**
- * Removes the goal associated with the specified identifier, also removing associated rules if needed.
- *
- * @param goalId the identifier of the goal to be removed
- */
- void removeGoal(String goalId);
-
- /**
- * Retrieves the report for the goal identified with the specified identifier.
- *
- * @param goalId the identifier of the goal which report we want to retrieve
- * @return the report for the specified goal
- */
- GoalReport getGoalReport(String goalId);
-
- /**
- * Retrieves the report for the goal identified with the specified identifier, considering only elements determined by the specified {@link AggregateQuery}.
- *
- * @param goalId the identifier of the goal which report we want to retrieve
- * @param query an AggregateQuery to further specify which elements of the report we want
- * @return the report for the specified goal and query
- */
- GoalReport getGoalReport(String goalId, AggregateQuery query);
-
- /**
- * Retrieves the set of Metadata associated with existing campaigns.
- *
- * @return the set of Metadata associated with existing campaigns
- */
- Set<Metadata> getCampaignMetadatas();
-
- /**
- * Retrieves the set of Metadata associated with existing campaign matching the specified {@link Query}
- *
- * @param query the Query used to filter the campagins which metadata we want to retrieve
- * @return the set of Metadata associated with existing campaigns matching the specified {@link Query}
- */
- Set<Metadata> getCampaignMetadatas(Query query);
-
- /**
- * Retrieves campaign details for campaigns matching the specified query.
- *
- * @param query the query specifying which campaigns to retrieve
- * @return a {@link PartialList} of campaign details for the campaigns matching the specified query
- */
- PartialList<CampaignDetail> getCampaignDetails(Query query);
-
- /**
- * Retrieves the {@link CampaignDetail} associated with the campaign identified with the specified identifier
- *
- * @param id the identifier of the campaign for which we want to retrieve the details
- * @return the CampaignDetail for the campaign identified by the specified identifier or {@code null} if no such campaign exists
- */
- CampaignDetail getCampaignDetail(String id);
-
- /**
- * Retrieves the campaign identified by the specified identifier
- *
- * @param campaignId the identifier of the campaign we want to retrieve
- * @return the campaign associated with the specified identifier or {@code null} if no such campaign exists
- */
- Campaign getCampaign(String campaignId);
-
- /**
- * Saves the specified campaign in the context server and creates associated {@link org.oasis_open.contextserver.api.rules.Rule}s if the campaign is enabled.
- *
- * TODO: rename to saveCampaign
- *
- * @param campaign the Campaign to be saved
- */
- void setCampaign(Campaign campaign);
-
- /**
- * Removes the campaign associated with the specified identifier, also removing associated rules if needed.
- *
- * @param campaignId the identifier of the campaign to be removed
- */
- void removeCampaign(String campaignId);
-
- /**
- * Retrieves {@link CampaignEvent}s matching the specified query.
- *
- * @param query the Query specifying which CampaignEvents to retrieve
- * @return a {@link PartialList} of campaign events matching the specified query
- */
- PartialList<CampaignEvent> getEvents(Query query);
-
- /**
- * Saves the specified campaign event in the context server.
- *
- * TODO: rename to saveCampaignEvent
- *
- * @param event the CampaignEvent to be saved
- */
- void setCampaignEvent(CampaignEvent event);
-
- /**
- * Removes the campaign event associated with the specified identifier.
- *
- * @param campaignEventId the identifier of the campaign event to be removed
- */
- void removeCampaignEvent(String campaignEventId);
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/PrivacyService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/PrivacyService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/PrivacyService.java
deleted file mode 100644
index 0993896..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/PrivacyService.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.ServerInfo;
-
-import java.util.List;
-
-/**
- * Created by loom on 10.09.15.
- */
-public interface PrivacyService {
-
- public static final String GLOBAL_ANONYMOUS_PROFILE_ID = "global-anonymous-profile";
-
- ServerInfo getServerInfo();
-
- Boolean deleteProfile(String profileId);
-
- String anonymizeBrowsingData(String profileId);
-
- Boolean deleteProfileData(String profileId);
-
- Boolean setAnonymous(String profileId, boolean anonymous);
-
- Boolean isAnonymous(String profileId);
-
- List<String> getFilteredEventTypes(String profileId);
-
- Boolean setFilteredEventTypes(String profileId, List<String> eventTypes);
-
- List<String> getDeniedProperties(String profileId);
-
- Boolean setDeniedProperties(String profileId, List<String> propertyNames);
-
- List<String> getDeniedPropertyDistribution(String profileId);
-
- Boolean setDeniedPropertyDistribution(String profileId, List<String> propertyNames);
-
- Boolean removeProperty(String profileId, String propertyName);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/ProfileService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/ProfileService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/ProfileService.java
deleted file mode 100644
index dca5d40..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/ProfileService.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.*;
-import org.oasis_open.contextserver.api.conditions.Condition;
-import org.oasis_open.contextserver.api.query.Query;
-
-import java.util.*;
-
-/**
- * A service to access and operate on {@link Profile}s, {@link Session}s and {@link Persona}s.
- */
-public interface ProfileService {
-
- /**
- * Retrieves the number of unique profiles.
- *
- * @return the number of unique profiles.
- */
- long getAllProfilesCount();
-
- /**
- * Retrieves profiles or personas matching the specified query.
- *
- * @param <T> the specific sub-type of {@link Profile} to retrieve
- * @param query a {@link Query} specifying which elements to retrieve
- * @param clazz the class of elements to retrieve
- * @return a {@link PartialList} of {@code T} instances matching the specified query
- */
- <T extends Profile> PartialList<T> search(Query query, Class<T> clazz);
-
- /**
- * Creates a String containing comma-separated values (CSV) formatted version of profiles matching the specified query.
- *
- * @param query the query specifying which profiles to export
- * @return a CSV-formatted String version of the profiles matching the specified query
- */
- String exportProfilesPropertiesToCsv(Query query);
-
- /**
- * Find profiles which have the specified property with the specified value, ordered according to the specified {@code sortBy} String and paged: only
- * {@code size} of them are retrieved, starting with the {@code offset}-th one.
- *
- * TODO: replace with version using a query instead of separate parameters
- * TODO: remove as it's unused?
- *
- * @param propertyName the name of the property we're interested in
- * @param propertyValue the value of the property we want profiles to have
- * @param offset zero or a positive integer specifying the position of the first profile in the total ordered collection of matching profiles
- * @param size a positive integer specifying how many matching profiles should be retrieved or {@code -1} if all of them should be retrieved
- * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering elements according to the property order in
- * the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally
- * followed by a column ({@code :}) and an order specifier: {@code asc} or {@code desc}.
- * @return a {@link PartialList} of matching profiles
- */
- PartialList<Profile> findProfilesByPropertyValue(String propertyName, String propertyValue, int offset, int size, String sortBy);
-
- /**
- * Merges the specified profiles into the provided so-called master profile, merging properties according to the {@link PropertyMergeStrategyType} specified on their {@link
- * PropertyType}.
- *
- * @param masterProfile the profile into which the specified profiles will be merged
- * @param profilesToMerge the list of profiles to merge into the specified master profile
- * @return the merged profile
- */
- Profile mergeProfiles(Profile masterProfile, List<Profile> profilesToMerge);
-
- /**
- * Retrieves the profile identified by the specified identifier.
- *
- * @param profileId the identifier of the profile to retrieve
- * @return the profile identified by the specified identifier or {@code null} if no such profile exists
- */
- Profile load(String profileId);
-
- /**
- * Saves the specified profile in the context server.
- *
- * @param profile the profile to be saved
- * @return the newly saved profile
- */
- Profile save(Profile profile);
-
- /**
- * Removes the profile (or persona if the {@code persona} parameter is set to {@code true}) identified by the specified identifier.
- *
- * @param profileId the identifier of the profile or persona to delete
- * @param persona {@code true} if the specified identifier is supposed to refer to a persona, {@code false} if it is supposed to refer to a profile
- */
- void delete(String profileId, boolean persona);
-
- /**
- * Retrieves the sessions associated with the profile identified by the specified identifier that match the specified query (if specified), ordered according to the specified
- * {@code sortBy} String and and paged: only {@code size} of them are retrieved, starting with the {@code offset}-th one.
- *
- * TODO: use a Query object instead of distinct parameter
- *
- * @param profileId the identifier of the profile we want to retrieve sessions from
- * @param query a String of text used for fulltext filtering which sessions we are interested in or {@code null} (or an empty String) if we want to retrieve all sessions
- * @param offset zero or a positive integer specifying the position of the first session in the total ordered collection of matching sessions
- * @param size a positive integer specifying how many matching sessions should be retrieved or {@code -1} if all of them should be retrieved
- * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering elements according to the property order in the
- * String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by
- * a column ({@code :}) and an order specifier: {@code asc} or {@code desc}.
- * @return a {@link PartialList} of matching sessions
- */
- PartialList<Session> getProfileSessions(String profileId, String query, int offset, int size, String sortBy);
-
- /**
- * Retrieves the session identified by the specified identifier.
- *
- * @param sessionId the identifier of the session to be retrieved
- * @param dateHint a Date helping in identifying where the item is located
- * @return the session identified by the specified identifier
- */
- Session loadSession(String sessionId, Date dateHint);
-
- /**
- * Saves the specified session.
- *
- * @param session the session to be saved
- * @return the newly saved session
- */
- Session saveSession(Session session);
-
- /**
- * Retrieves sessions associated with the profile identified by the specified identifier.
- *
- * @param profileId the profile id for which we want to retrieve the sessions
- * @return a {@link PartialList} of the profile's sessions
- */
- PartialList<Session> findProfileSessions(String profileId);
-
- /**
- * Checks whether the specified profile and/or session satisfy the specified condition.
- *
- * @param condition the condition we're testing against which might or might not have profile- or session-specific sub-conditions
- * @param profile the profile we're testing
- * @param session the session we're testing
- * @return {@code true} if the profile and/or sessions match the specified condition, {@code false} otherwise
- */
- boolean matchCondition(Condition condition, Profile profile, Session session);
-
- /**
- * Update all profiles in batch according to the specified {@link BatchUpdate}
- *
- * @param update the batch update specification
- */
- void batchProfilesUpdate(BatchUpdate update);
-
- /**
- * Retrieves the persona identified by the specified identifier.
- *
- * @param personaId the identifier of the persona to retrieve
- * @return the persona associated with the specified identifier or {@code null} if no such persona exists.
- */
- Persona loadPersona(String personaId);
-
- /**
- * Persists the specified {@link Persona} in the context server.
- *
- * @param persona the persona to persist
- * @return the newly persisted persona
- */
- Persona savePersona(Persona persona);
-
- /**
- * Retrieves the persona identified by the specified identifier and all its associated sessions
- *
- * @param personaId the identifier of the persona to retrieve
- * @return a {@link PersonaWithSessions} instance with the persona identified by the specified identifier and all its associated sessions
- */
- PersonaWithSessions loadPersonaWithSessions(String personaId);
-
- /**
- * Creates a persona with the specified identifier and automatically creates an associated session with it.
- *
- * @param personaId the identifier to use for the new persona
- * @return the newly created persona
- */
- Persona createPersona(String personaId);
-
- /**
- * Retrieves the sessions associated with the persona identified by the specified identifier, ordered according to the specified {@code sortBy} String and and paged: only
- * {@code size} of them are retrieved, starting with the {@code offset}-th one.
- *
- * @param personaId the persona id
- * @param offset zero or a positive integer specifying the position of the first session in the total ordered collection of matching sessions
- * @param size a positive integer specifying how many matching sessions should be retrieved or {@code -1} if all of them should be retrieved
- * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering elements according to the property order in the
- * String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by
- * a column ({@code :}) and an order specifier: {@code asc} or {@code desc}.
- * @return a {@link PartialList} of sessions for the persona identified by the specified identifier
- */
- PartialList<Session> getPersonaSessions(String personaId, int offset, int size, String sortBy);
-
- /**
- * Retrieves all the property types associated with the specified target.
- *
- * TODO: move to a different class
- *
- * @param target the target for which we want to retrieve the associated property types
- * @return a collection of all the property types associated with the specified target
- */
- Collection<PropertyType> getAllPropertyTypes(String target);
-
- /**
- * Retrieves all known property types.
- *
- * TODO: move to a different class
- * TODO: use Map instead of HashMap
- *
- * @return a Map associating targets as keys to related {@link PropertyType}s
- */
- HashMap<String, Collection<PropertyType>> getAllPropertyTypes();
-
- /**
- * Retrieves all property types with the specified tag also retrieving property types with sub-tags of the specified tag if so specified.
- *
- * TODO: move to a different class
- *
- * @param tag the tag name marking property types we want to retrieve
- * @param includeFromSubtags {@code true} if sub-tags of the specified tag should also be considered, {@code false} otherwise
- * @return a Set of the property types with the specified tag
- */
- Set<PropertyType> getPropertyTypeByTag(String tag, boolean includeFromSubtags);
-
- /**
- * TODO
- */
- String getPropertyTypeMapping(String fromPropertyTypeId);
-
- /**
- * TODO
- */
- Collection<PropertyType> getPropertyTypeByMapping(String propertyName);
-
- /**
- * Retrieves the property type identified by the specified identifier.
- *
- * TODO: move to a different class
- *
- * @param id the identifier of the property type to retrieve
- * @return the property type identified by the specified identifier or {@code null} if no such property type exists
- */
- PropertyType getPropertyType(String id);
-
- /**
- * Persists the specified property type in the context server.
- *
- * TODO: move to a different class
- *
- * @param property the property type to persist
- * @return {@code true} if the property type was properly created, {@code false} otherwise (for example, if the property type already existed
- */
- boolean createPropertyType(PropertyType property);
-
- /**
- * Deletes the property type identified by the specified identifier.
- *
- * TODO: move to a different class
- *
- * @param propertyId the identifier of the property type to delete
- * @return {@code true} if the property type was properly deleted, {@code false} otherwise
- */
- boolean deletePropertyType(String propertyId);
-
- /**
- * Retrieves the existing property types for the specified type as defined by the Item subclass public field {@code ITEM_TYPE} and with the specified tag.
- *
- * TODO: move to a different class
- *
- * @param tagId the tag we're interested in
- * @param itemType the String representation of the item type we want to retrieve the count of, as defined by its class' {@code ITEM_TYPE} field
- * @return all property types defined for the specified item type and with the specified tag
- */
- Set<PropertyType> getExistingProperties(String tagId, String itemType);
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/QueryService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/QueryService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/QueryService.java
deleted file mode 100644
index b9f9c68..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/QueryService.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.Item;
-import org.oasis_open.contextserver.api.conditions.Condition;
-import org.oasis_open.contextserver.api.query.AggregateQuery;
-
-import java.util.Map;
-
-/**
- * A service to perform queries.
- */
-public interface QueryService {
-
- /**
- * Retrieves the number of items with the specified type as defined by the Item subclass public field {@code ITEM_TYPE} and aggregated by possible values of the specified
- * property.
- *
- * @param itemType the String representation of the item type we want to retrieve the count of, as defined by its class' {@code ITEM_TYPE} field
- * @param property the property we're aggregating on, i.e. for each possible value of this property, we are counting how many items of the specified type have that value
- * @return a Map associating a specific value of the property to the cardinality of items with that value
- * @see Item Item for a discussion of {@code ITEM_TYPE}
- */
- Map<String, Long> getAggregate(String itemType, String property);
-
- /**
- * TODO: rework, this method is confusing since it either behaves like {@link #getAggregate(String, String)} if query is null but completely differently if it isn't
- *
- * Retrieves the number of items with the specified type as defined by the Item subclass public field {@code ITEM_TYPE} and aggregated by possible values of the specified
- * property or, if the specified query is not {@code null}, perform that aggregate query.
- *
- * @param itemType the String representation of the item type we want to retrieve the count of, as defined by its class' {@code ITEM_TYPE} field
- * @param property the property we're aggregating on, i.e. for each possible value of this property, we are counting how many items of the specified type have that value
- * @param query the {@link AggregateQuery} specifying the aggregation that should be perfomed
- * @return a Map associating a specific value of the property to the cardinality of items with that value
- * @see Item Item for a discussion of {@code ITEM_TYPE}
- */
- Map<String, Long> getAggregate(String itemType, String property, AggregateQuery query);
-
- /**
- * Retrieves the number of items of the specified type as defined by the Item subclass public field {@code ITEM_TYPE} and matching the specified {@link Condition}.
- *
- * @param condition the condition the items must satisfy
- * @param itemType the String representation of the item type we want to retrieve the count of, as defined by its class' {@code ITEM_TYPE} field
- * @return the number of items of the specified type
- * @see Item Item for a discussion of {@code ITEM_TYPE}
- */
- long getQueryCount(String itemType, Condition condition);
-
- /**
- * Retrieves the specified metrics for the specified field of items of the specified type as defined by the Item subclass public field {@code ITEM_TYPE} and matching the
- * specified {@link Condition}.
- *
- * @param condition the condition the items must satisfy
- * @param slashConcatenatedMetrics a String specifying which metrics should be computed, separated by a slash ({@code /}) (possible values: {@code sum} for the sum of the
- * values, {@code avg} for the average of the values, {@code min} for the minimum value and {@code max} for the maximum value)
- * @param property the name of the field for which the metrics should be computed
- * @param type the String representation of the item type we want to retrieve the count of, as defined by its class' {@code ITEM_TYPE} field
- * @return a Map associating computed metric name as key to its associated value
- * @see Item Item for a discussion of {@code ITEM_TYPE}
- */
- Map<String, Double> getMetric(String type, String property, String slashConcatenatedMetrics, Condition condition);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/RulesService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/RulesService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/RulesService.java
deleted file mode 100644
index 10fbb3f..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/RulesService.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.Item;
-import org.oasis_open.contextserver.api.Metadata;
-import org.oasis_open.contextserver.api.PartialList;
-import org.oasis_open.contextserver.api.conditions.Condition;
-import org.oasis_open.contextserver.api.query.Query;
-import org.oasis_open.contextserver.api.rules.Rule;
-
-import java.util.Set;
-
-/**
- * A service to access and operate on {@link Rule}s.
- */
-public interface RulesService {
-
- /**
- * Retrieves the metadata for all known rules.
- *
- * @return the Set of known metadata
- */
- Set<Metadata> getRuleMetadatas();
-
- /**
- * Retrieves rule metadatas for rules matching the specified {@link Query}.
- *
- * @param query the query the rules which metadata we want to retrieve must match
- * @return a {@link PartialList} of rules metadata for the rules matching the specified query
- */
- PartialList<Metadata> getRuleMetadatas(Query query);
-
- /**
- * Retrieves the rule identified by the specified identifier.
- *
- * @param ruleId the identifier of the rule we want to retrieve
- * @return the rule identified by the specified identifier or {@code null} if no such rule exists.
- */
- Rule getRule(String ruleId);
-
- /**
- * Persists the specified rule to the context server.
- *
- * @param rule the rule to be persisted
- */
- void setRule(Rule rule);
-
- /**
- * Deletes the rule identified by the specified identifier.
- *
- * @param ruleId the identifier of the rule we want to delete
- */
- void removeRule(String ruleId);
-
- /**
- * Retrieves tracked conditions (rules with a condition marked with the {@code trackedCondition} tag and which {@code sourceEventCondition} matches the specified item) for the
- * specified item.
- *
- * @param item the item which tracked conditions we want to retrieve
- * @return the Set of tracked conditions for the specified item
- */
- Set<Condition> getTrackedConditions(Item item);
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/oasis_open/contextserver/api/services/SegmentService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/oasis_open/contextserver/api/services/SegmentService.java b/api/src/main/java/org/oasis_open/contextserver/api/services/SegmentService.java
deleted file mode 100644
index 59a7031..0000000
--- a/api/src/main/java/org/oasis_open/contextserver/api/services/SegmentService.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.oasis_open.contextserver.api.services;
-
-import org.oasis_open.contextserver.api.Item;
-import org.oasis_open.contextserver.api.Metadata;
-import org.oasis_open.contextserver.api.PartialList;
-import org.oasis_open.contextserver.api.Profile;
-import org.oasis_open.contextserver.api.query.Query;
-import org.oasis_open.contextserver.api.segments.Scoring;
-import org.oasis_open.contextserver.api.segments.Segment;
-import org.oasis_open.contextserver.api.segments.SegmentsAndScores;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * A service to access and operate on {@link Segment}s and {@link Scoring}s
- */
-public interface SegmentService {
-
- /**
- * Retrieves segment metadatas, ordered according to the specified {@code sortBy} String and and paged: only {@code size} of them are retrieved, starting with the {@code
- * offset}-th one.
- *
- * @param offset zero or a positive integer specifying the position of the first element in the total ordered collection of matching elements
- * @param size a positive integer specifying how many matching elements should be retrieved or {@code -1} if all of them should be retrieved
- * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering elements according to the property order in the
- * String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by
- * a column ({@code :}) and an order specifier: {@code asc} or {@code desc}.
- * @return a {@link PartialList} of segment metadata
- */
- PartialList<Metadata> getSegmentMetadatas(int offset, int size, String sortBy);
-
- /**
- * Retrieves segment metadatas for segments in the specified scope, ordered according to the specified {@code sortBy} String and and paged: only {@code size} of them are
- * retrieved, starting with the {@code offset}-th one.
- *
- * TODO: remove?
- *
- * @param scope the scope for which we want to retrieve segment metadata
- * @param offset zero or a positive integer specifying the position of the first element in the total ordered collection of matching elements
- * @param size a positive integer specifying how many matching elements should be retrieved or {@code -1} if all of them should be retrieved
- * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering elements according to the property order in the
- * String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by
- * a column ({@code :}) and an order specifier: {@code asc} or {@code desc}.
- * @return a {@link PartialList} of segment metadata
- */
- PartialList<Metadata> getSegmentMetadatas(String scope, int offset, int size, String sortBy);
-
- /**
- * Retrieves the metadata for segments matching the specified {@link Query}.
- *
- * @param query the query that the segments must match for their metadata to be retrieved
- * @return a {@link PartialList} of segment metadata
- */
- PartialList<Metadata> getSegmentMetadatas(Query query);
-
- /**
- * Retrieves the segment identified by the specified identifier.
- *
- * @param segmentId the identifier of the segment to be retrieved
- * @return the segment identified by the specified identifier or {@code null} if no such segment exists
- */
- Segment getSegmentDefinition(String segmentId);
-
- /**
- * Persists the specified segment in the context server.
- *
- * @param segment the segment to be persisted
- */
- void setSegmentDefinition(Segment segment);
-
- /**
- * Removes the segment definition identified by the specified identifier. We can specify that we want the operation to be validated beforehand so that we can
- * know if any other segment that might use the segment we're trying to delete as a condition might be impacted. If {@code validate} is set to {@code false}, no
- * validation is performed. If set to {@code true}, we will first check if any segment depends on the one we're trying to delete and if so we will not delete the
- * segment but rather return the list of the metadata of the impacted segments. If no dependents are found, then we properly delete the segment.
- *
- * @param segmentId the identifier of the segment we want to delete
- * @param validate whether or not to perform validation
- * @return a list of impacted segment metadata if any or an empty list if no such impacted segments are found or validation was skipped
- */
- List<Metadata> removeSegmentDefinition(String segmentId, boolean validate);
-
- /**
- * Retrieves the list of segment metadata of segments depending on the segment identified by the specified identifier. A segment is depending on another one if it includes
- * that segment as part of its condition for profile matching.
- *
- * TODO: Rename to something clearer, maybe getDependentSegmentMetadata?
- *
- * @param segmentId the identifier of the segment which impact we want to evaluate
- * @return a list of metadata of segments depending on the specified segment
- */
- List<Metadata> getImpactedSegmentMetadata(String segmentId);
-
- /**
- * Retrieves a list of profiles matching the conditions defined by the segment identified by the specified identifier, ordered according to the specified {@code sortBy}
- * String and and paged: only {@code size} of them are retrieved, starting with the {@code offset}-th one.
- *
- * @param segmentID the identifier of the segment for which we want to retrieve matching profiles
- * @param offset zero or a positive integer specifying the position of the first element in the total ordered collection of matching elements
- * @param size a positive integer specifying how many matching elements should be retrieved or {@code -1} if all of them should be retrieved
- * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering elements according to the property order in the
- * String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by
- * a column ({@code :}) and an order specifier: {@code asc} or {@code desc}.
- * @return a {@link PartialList} of profiles matching the specified segment
- */
- PartialList<Profile> getMatchingIndividuals(String segmentID, int offset, int size, String sortBy);
-
- /**
- * Retrieves the number of profiles matching the conditions defined by the segment identified by the specified identifier.
- *
- * @param segmentID the identifier of the segment for which we want to retrieve matching profiles
- * @return the number of profiles matching the conditions defined by the segment identified by the specified identifier
- */
- long getMatchingIndividualsCount(String segmentID);
-
- /**
- * Determines whether the specified profile is part of the segment identified by the specified identifier.
- *
- * @param profile the profile we want to check
- * @param segmentId the identifier of the segment against which we want to check the profile
- * @return {@code true} if the specified profile is in the specified segment, {@code false} otherwise
- */
- Boolean isProfileInSegment(Profile profile, String segmentId);
-
- /**
- * Retrieves the segments and scores for the specified profile.
- *
- * @param profile the profile for which we want to retrieve segments and scores
- * @return a {@link SegmentsAndScores} instance encapsulating the segments and scores for the specified profile
- */
- SegmentsAndScores getSegmentsAndScoresForProfile(Profile profile);
-
- /**
- * Retrieves the list of segment metadata for the segments the specified profile is a member of.
- *
- * @param profile the profile for which we want to retrieve the segment metadata
- * @return the (possibly empty) list of segment metadata for the segments the specified profile is a member of
- */
- List<Metadata> getSegmentMetadatasForProfile(Profile profile);
-
- /**
- * Retrieves the set of all scoring metadata.
- *
- * @return the set of all scoring metadata
- */
- PartialList<Metadata> getScoringMetadatas(int offset, int size, String sortBy);
-
- /**
- * Retrieves the set of scoring metadata for scorings matching the specified query.
- *
- * @param query the query the scorings must match for their metadata to be retrieved
- * @return the set of scoring metadata for scorings matching the specified query
- */
- PartialList<Metadata> getScoringMetadatas(Query query);
-
- /**
- * Retrieves the scoring identified by the specified identifier.
- *
- * @param scoringId the identifier of the scoring to be retrieved
- * @return the scoring identified by the specified identifier or {@code null} if no such scoring exists
- */
- Scoring getScoringDefinition(String scoringId);
-
- /**
- * Persists the specified scoring in the context server.
- *
- * @param scoring the scoring to be persisted
- */
- void setScoringDefinition(Scoring scoring);
-
- /**
- * Creates a scoring with the specified scope, identifier, name and description.
- *
- * @param scope the scope for the new scoring
- * @param scoringId the identifier for the new scoring
- * @param name the name of the new scoring
- * @param description the description of the new scoring
- * @see Item Item's description for a discussion of scope
- */
- void createScoringDefinition(String scope, String scoringId, String name, String description);
-
- /**
- * Deletes the scoring identified by the specified identifier from the context server.
- *
- * @param scoringId the identifier of the scoring to be deleted
- */
- void removeScoringDefinition(String scoringId);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/extensions/geonames/rest/src/main/java/org/apache/unomi/geonames/rest/GeonamesEndPoint.java
----------------------------------------------------------------------
diff --git a/extensions/geonames/rest/src/main/java/org/apache/unomi/geonames/rest/GeonamesEndPoint.java b/extensions/geonames/rest/src/main/java/org/apache/unomi/geonames/rest/GeonamesEndPoint.java
new file mode 100644
index 0000000..3821760
--- /dev/null
+++ b/extensions/geonames/rest/src/main/java/org/apache/unomi/geonames/rest/GeonamesEndPoint.java
@@ -0,0 +1,113 @@
+/*
+ * 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.geonames.rest;
+
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
+import org.apache.unomi.api.PartialList;
+import org.apache.unomi.geonames.services.GeonameEntry;
+import org.apache.unomi.geonames.services.GeonamesService;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.PathSegment;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+@WebService
+@Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
+@CrossOriginResourceSharing(
+ allowAllOrigins = true,
+ allowCredentials = true
+)
+public class GeonamesEndPoint {
+
+ private GeonamesService geonamesService;
+
+ public GeonamesEndPoint() {
+ System.out.println("Initializing geonames service endpoint...");
+ }
+
+ @WebMethod(exclude = true)
+ public void setGeonamesService(GeonamesService geonamesService) {
+ this.geonamesService = geonamesService;
+ }
+
+ @GET
+ @Path("/reverseGeoCode/{latlon}")
+ public List<GeonameEntry> reverseGeoCode(@PathParam("latlon") String latlon, @HeaderParam("Accept-Language") String language) {
+ String[] s = latlon.split(",");
+ List<GeonameEntry> entries = geonamesService.reverseGeoCode(s[0], s[1]);
+ translate(entries, new Locale(language));
+ return entries;
+ }
+
+ @GET
+ @Path("/entries/{items:.*}")
+ public PartialList<GeonameEntry> getChildrenEntries(@PathParam("items") List<PathSegment> items, @HeaderParam("Accept-Language") String language) {
+ List<String> l = new ArrayList<>();
+ for (PathSegment item : items) {
+ l.add(item.getPath());
+ }
+ PartialList<GeonameEntry> list = geonamesService.getChildrenEntries(l, 0, 999);
+ translate(list.getList(), new Locale(language));
+ return list;
+ }
+
+ @GET
+ @Path("/cities/{items:.*}")
+ public PartialList<GeonameEntry> getChildrenCities(@PathParam("items") List<PathSegment> items, @HeaderParam("Accept-Language") String language) {
+ List<String> l = new ArrayList<>();
+ for (PathSegment item : items) {
+ l.add(item.getPath());
+ }
+ PartialList<GeonameEntry> list = geonamesService.getChildrenCities(l, 0, 999);
+ translate(list.getList(), new Locale(language));
+ return list;
+ }
+
+ @GET
+ @Path("/hierarchy/{id}")
+ public List<GeonameEntry> getHierarchy(@PathParam("id") String id, @HeaderParam("Accept-Language") String language) {
+ List<GeonameEntry> list = geonamesService.getHierarchy(id);
+ translate(list, new Locale(language));
+ return list;
+ }
+
+ @GET
+ @Path("/capitals/{id}")
+ public List<GeonameEntry> getCapitalEntries(@PathParam("id") String id, @HeaderParam("Accept-Language") String language) {
+ List<GeonameEntry> list = geonamesService.getCapitalEntries(id);
+ translate(list, new Locale(language));
+ return list;
+ }
+
+ private void translate(List<GeonameEntry> l, Locale locale) {
+ for (GeonameEntry entry : l) {
+ if (GeonamesService.COUNTRY_FEATURE_CODES.contains(entry.getFeatureCode())) {
+ String name = new Locale("", entry.getCountryCode()).getDisplayCountry(locale);
+ if (!StringUtils.isEmpty(name) && !name.equals(entry.getCountryCode())) {
+ entry.setName(name);
+ }
+ }
+ }
+ }
+}