aboutsummaryrefslogtreecommitdiffstats
path: root/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org')
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/AbstractRankedAttributesResolverFactory.java35
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationEntry.java27
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationSet.java30
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesContext.java26
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolver.java26
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolverFactory.java26
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/BacktraceStrategy.java119
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/CompositeNode.java38
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Constants.java30
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/DefaultRankedAttributesTreeFactory.java49
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/LeafNode.java45
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Node.java40
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/NodeBase.java87
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTree.java45
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTreeBuilder.java100
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Strategy.java30
-rw-r--r--app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Utils.java40
17 files changed, 793 insertions, 0 deletions
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/AbstractRankedAttributesResolverFactory.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/AbstractRankedAttributesResolverFactory.java
new file mode 100644
index 000000000..75480b300
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/AbstractRankedAttributesResolverFactory.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework;
+
+import org.openecomp.appc.rankingframework.impl.DefaultRankedAttributesTreeFactory;
+
+public abstract class AbstractRankedAttributesResolverFactory implements RankedAttributesResolverFactory {
+
+ private static class ReferenceHolder {
+ private static final RankedAttributesResolverFactory INSTANCE = new DefaultRankedAttributesTreeFactory();
+ }
+
+ public static RankedAttributesResolverFactory getInstance() {
+ return ReferenceHolder.INSTANCE;
+ }
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationEntry.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationEntry.java
new file mode 100644
index 000000000..77fa8930d
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationEntry.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework;
+
+public interface ConfigurationEntry<R> {
+ Object getAttributeValue(String name);
+ R getResult();
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationSet.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationSet.java
new file mode 100644
index 000000000..2e862d9fc
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationSet.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework;
+
+import java.util.Collection;
+
+public interface ConfigurationSet<R> {
+ Collection<String> getRankedAttributeNames();
+
+ Iterable<ConfigurationEntry<R>> getEntries();
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesContext.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesContext.java
new file mode 100644
index 000000000..a8d9b71ec
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesContext.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework;
+
+public interface RankedAttributesContext {
+ Object getAttributeValue(String name);
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolver.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolver.java
new file mode 100644
index 000000000..1948ccc1f
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolver.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework;
+
+public interface RankedAttributesResolver<R> {
+ R resolve(RankedAttributesContext context);
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolverFactory.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolverFactory.java
new file mode 100644
index 000000000..7267c046c
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolverFactory.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework;
+
+public interface RankedAttributesResolverFactory {
+ <R> RankedAttributesResolver<R> create(ConfigurationSet<R> config);
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/BacktraceStrategy.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/BacktraceStrategy.java
new file mode 100644
index 000000000..1365ae834
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/BacktraceStrategy.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.openecomp.appc.rankingframework.RankedAttributesContext;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+class BacktraceStrategy implements Strategy {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(BacktraceStrategy.class);
+
+ @Override
+ public <R> R resolve(CompositeNode<R> rootNode, List<String> rankedNames, RankedAttributesContext context) {
+
+ if (logger.isDebugEnabled()) {
+ StringBuilder buff = new StringBuilder(128);
+ for (String name : rankedNames) {
+ buff.append("/{").append(name).append(" = ").append(Utils.value(context.getAttributeValue(name))).append('}');
+ }
+ logger.debug(String.format("Trying to resolve path: %s", buff));
+ }
+
+ Set<String> visited = new HashSet<>();
+
+ CompositeNode<R> parentNode = rootNode;
+ int depth = 0;
+ boolean stop = false;
+ R result = null;
+
+ String attribute = null;
+ Object value = null;
+
+ do {
+ if (value == null) {
+ attribute = rankedNames.get(depth);
+ value = Utils.value(context.getAttributeValue(attribute));
+ }
+
+ Node<R> childNode = parentNode.children().get(value);
+
+ if (childNode != null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Found matching node '%s' - checking it out", childNode));
+ }
+
+ if (!visited.add(childNode.id())) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("The matching node '%s' was checked before - ignoring it", childNode));
+ }
+ childNode = null;
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Node '%s/{%s = %s}' not found - falling back", parentNode, attribute, value != null ? value : "NULL"));
+ }
+ }
+
+ if (childNode != null) {
+ switch (childNode.type()) {
+ case COMPOSITE:
+ depth++;
+ value = null;
+ parentNode = (CompositeNode<R>) childNode;
+ break;
+ case LEAF:
+ if (logger.isDebugEnabled()) {
+ logger.debug( String.format("Result node has been resolved succesfully - '%s'", childNode));
+ }
+ result = ((LeafNode<R>) childNode).result();
+ stop = true;
+ break;
+ default:
+ throw new IllegalStateException(childNode.type().name());
+ }
+ } else {
+ if (!value.equals(Constants.DEFAULT_MATCH)) {
+ logger.debug("Exact match didn't work, trying the default option, if any");
+ value = Constants.DEFAULT_MATCH;
+ } else if (depth > 0) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Exact match didn't work and no default option available beneath '%s' - moving out", parentNode));
+ }
+ depth--;
+ value = null;
+ parentNode = parentNode.parent();
+ } else {
+ logger.debug("Didn't success to resolve the path - stopping without result");
+ stop = true;
+ }
+ }
+ } while (!stop);
+
+ return result;
+ }
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/CompositeNode.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/CompositeNode.java
new file mode 100644
index 000000000..0b5e633f3
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/CompositeNode.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+import java.util.Map;
+
+class CompositeNode<R> extends NodeBase<R> {
+
+ private final Map<Object, Node<R>> children;
+
+ CompositeNode(String name, Object value, CompositeNode<R> parent, Map<Object, Node<R>> children) {
+ super(name, value, parent, Type.COMPOSITE);
+ this.children = children;
+ }
+
+ Map<Object, Node<R>> children() {
+ return children;
+ }
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Constants.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Constants.java
new file mode 100644
index 000000000..4111131e2
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Constants.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+class Constants {
+
+ private Constants() {
+ }
+
+ static final String DEFAULT_MATCH = "*";
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/DefaultRankedAttributesTreeFactory.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/DefaultRankedAttributesTreeFactory.java
new file mode 100644
index 000000000..d7c48dae6
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/DefaultRankedAttributesTreeFactory.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.rankingframework.ConfigurationSet;
+import org.openecomp.appc.rankingframework.RankedAttributesResolver;
+import org.openecomp.appc.rankingframework.RankedAttributesResolverFactory;
+
+public final class DefaultRankedAttributesTreeFactory implements RankedAttributesResolverFactory {
+
+ private final Strategy DEFAULT_STRATEGY = new BacktraceStrategy();
+
+ @Override
+ public <R> RankedAttributesResolver<R> create(ConfigurationSet<R> config) {
+
+ CompositeNode<R> root = RankedAttributesTreeBuilder.build(config);
+ RankedAttributesResolver<R> tree = new RankedAttributesTree<R>(root, toList(config.getRankedAttributeNames()),
+ DEFAULT_STRATEGY);
+ return tree;
+ }
+
+ private static List<String> toList(Collection<String> col) {
+ return Collections.unmodifiableList(new ArrayList<>(col));
+ }
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/LeafNode.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/LeafNode.java
new file mode 100644
index 000000000..1b1dffdc8
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/LeafNode.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+class LeafNode<R> extends NodeBase<R> {
+
+ private final R result;
+
+ LeafNode(String name, Object value, CompositeNode<R> parent, R result) {
+ super(name, value, parent, Type.LEAF);
+ this.result = result;
+ }
+
+ R result() {
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer buff = new StringBuffer(128);
+ buff.append(super.toString());
+ buff.append(" --> ");
+ buff.append(result.toString());
+ return buff.toString();
+ }
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Node.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Node.java
new file mode 100644
index 000000000..c33e4d875
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Node.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+interface Node<R> {
+ enum Type {
+ LEAF, COMPOSITE
+ }
+
+ String id();
+
+ String name();
+
+ Object value();
+
+ CompositeNode<R> parent();
+
+ Type type();
+
+ boolean isDefaultMatch();
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/NodeBase.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/NodeBase.java
new file mode 100644
index 000000000..747d9cfd2
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/NodeBase.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+import java.util.UUID;
+
+abstract class NodeBase<R> implements Node<R> {
+
+ private final String name;
+ private final Object value;
+ private final Type type;
+ private final CompositeNode<R> parent;
+ private final String id = UUID.randomUUID().toString();
+
+ NodeBase(String name, Object value, CompositeNode<R> parent, Type type) {
+ this.name = name;
+ this.value = value;
+ this.parent = parent;
+ this.type = type;
+ }
+
+ @Override
+ public String id() {
+ return id;
+ }
+
+ @Override
+ public Type type() {
+ return type;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public Object value() {
+ return value;
+ }
+
+ @Override
+ public CompositeNode<R> parent() {
+ return parent;
+ }
+
+ @Override
+ public boolean isDefaultMatch() {
+ return value.equals(Constants.DEFAULT_MATCH);
+ }
+
+ @Override
+ public String toString() {
+ if (!name.equals("ROOT")) {
+ StringBuffer buff = new StringBuffer(128);
+ if (parent != null) {
+ buff.append(parent.toString());
+ }
+ buff.append("/{");
+ buff.append(name).append(" = ").append(value);
+ buff.append("}");
+
+ return buff.toString();
+ } else {
+ return "";
+ }
+ }
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTree.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTree.java
new file mode 100644
index 000000000..305af85a6
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTree.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+import java.util.List;
+
+import org.openecomp.appc.rankingframework.RankedAttributesContext;
+import org.openecomp.appc.rankingframework.RankedAttributesResolver;
+
+class RankedAttributesTree<R> implements RankedAttributesResolver<R> {
+
+ private final CompositeNode<R> root;
+ private final Strategy strategy;
+ private final List<String> rankedNames;
+
+ RankedAttributesTree(CompositeNode<R> root, List<String> rankedNames, Strategy strategy) {
+ this.root = root;
+ this.rankedNames = rankedNames;
+ this.strategy = strategy;
+ }
+
+ @Override
+ public R resolve(RankedAttributesContext context) {
+ return strategy.resolve(root, rankedNames, context);
+ }
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTreeBuilder.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTreeBuilder.java
new file mode 100644
index 000000000..16aee5607
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTreeBuilder.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+import java.util.HashMap;
+
+import org.openecomp.appc.rankingframework.ConfigurationEntry;
+import org.openecomp.appc.rankingframework.ConfigurationSet;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+class RankedAttributesTreeBuilder {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(RankedAttributesTreeBuilder.class);
+
+ private RankedAttributesTreeBuilder() {
+ }
+
+ static <R> CompositeNode<R> build(ConfigurationSet<R> config) {
+
+ Object[] names = config.getRankedAttributeNames().toArray();
+
+ CompositeNode<R> root = new CompositeNode<>("ROOT", Constants.DEFAULT_MATCH, null,
+ new HashMap<Object, Node<R>>());
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Building decision tree for ranked attributes: %s", config.getRankedAttributeNames()));
+ }
+
+ for (ConfigurationEntry<R> entry : config.getEntries()) {
+ process(entry, names, root);
+ }
+
+ return root;
+ }
+
+ private static <R> void process(ConfigurationEntry<R> entry, Object[] names, CompositeNode<R> root) {
+ CompositeNode<R> parentNode = null;
+ for (int i = 0; i < names.length; i++) {
+
+ if (i == 0) {
+ parentNode = root;
+ }
+
+ final String name = (String) names[i];
+
+ final Object value = value(entry, name);
+
+ if (i < names.length - 1) {
+ CompositeNode<R> currentNode = (CompositeNode<R>) parentNode.children().get(value);
+ if (currentNode == null) {
+ currentNode = new CompositeNode<>(name, value, parentNode, new HashMap<Object, Node<R>>());
+ parentNode.children().put(value, currentNode);
+ }
+ parentNode = currentNode;
+ } else {
+ LeafNode<R> currentNode = (LeafNode<R>) parentNode.children().get(value);
+ if (currentNode == null) {
+ currentNode = new LeafNode<R>(name, value, parentNode, entry.getResult());
+ parentNode.children().put(value, currentNode);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Branch has been created: %s", currentNode));
+ }
+ } else {
+ logger.error(
+ String.format("Duplicated configuration entry has been detected for attribute '%s' with value '%s' - the node '%s'exists already",
+ name,
+ value,
+ currentNode));
+ throw new IllegalArgumentException("Duplicated configuration entry: " + currentNode);
+ }
+ }
+ }
+ }
+
+ private static <R> Object value(ConfigurationEntry<R> entry, String name) {
+ Object value = entry.getAttributeValue(name);
+ return Utils.value(value);
+ }
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Strategy.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Strategy.java
new file mode 100644
index 000000000..121f1fb2d
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Strategy.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+import java.util.List;
+
+import org.openecomp.appc.rankingframework.RankedAttributesContext;
+
+interface Strategy {
+ <R> R resolve(CompositeNode<R> root, List<String> rankedNames, RankedAttributesContext context);
+}
diff --git a/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Utils.java b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Utils.java
new file mode 100644
index 000000000..88ca6d5f5
--- /dev/null
+++ b/app-c/appc/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Utils.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.rankingframework.impl;
+
+class Utils {
+
+ private Utils() {
+ }
+
+ static <R> Object value(Object value) {
+ if (value == null || (value instanceof String && isEmpty((String) value))) {
+ value = Constants.DEFAULT_MATCH;
+ }
+
+ return value;
+ }
+
+ private static boolean isEmpty(String str) {
+ return str == null || str.length() == 0;
+ }
+}