diff options
author | Patrick Brady <pb071s@att.com> | 2017-12-13 11:19:06 -0800 |
---|---|---|
committer | Patrick Brady <pb071s@att.com> | 2017-12-13 11:19:17 -0800 |
commit | 781b1a6df324419c846c84ea983c18fc8362bfd3 (patch) | |
tree | 580008010dd50ca32db2ef6dc2e36628cf8c2b5b /appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp | |
parent | 161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a (diff) |
Third part of onap rename
This part of the commit changes the folder structure on all other
folders of appc.
Change-Id: I8acfa11cdfcdcd36be0e137245d1dd7324f1abd3
Signed-off-by: Patrick Brady <pb071s@att.com>
Issue-ID: APPC-13
Diffstat (limited to 'appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp')
17 files changed, 0 insertions, 844 deletions
diff --git a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/AbstractRankedAttributesResolverFactory.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/AbstractRankedAttributesResolverFactory.java deleted file mode 100644 index 99ac8a74e..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/AbstractRankedAttributesResolverFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework; - -import org.onap.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/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationEntry.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationEntry.java deleted file mode 100644 index 66c4ce7da..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationEntry.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework; - -public interface ConfigurationEntry<R> { - Object getAttributeValue(String name); - R getResult(); -} diff --git a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationSet.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationSet.java deleted file mode 100644 index 461d197e7..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/ConfigurationSet.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework; - -import java.util.Collection; - -public interface ConfigurationSet<R> { - Collection<String> getRankedAttributeNames(); - - Iterable<ConfigurationEntry<R>> getEntries(); -} diff --git a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesContext.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesContext.java deleted file mode 100644 index 09e749852..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesContext.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework; - -public interface RankedAttributesContext { - Object getAttributeValue(String name); -} diff --git a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolver.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolver.java deleted file mode 100644 index bd9da0911..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolver.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework; - -public interface RankedAttributesResolver<R> { - R resolve(RankedAttributesContext context); -} diff --git a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolverFactory.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolverFactory.java deleted file mode 100644 index 4f5a85299..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/RankedAttributesResolverFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework; - -public interface RankedAttributesResolverFactory { - <R> RankedAttributesResolver<R> create(ConfigurationSet<R> config); -} diff --git a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/BacktraceStrategy.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/BacktraceStrategy.java deleted file mode 100644 index 6523fef65..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/BacktraceStrategy.java +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework.impl; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.onap.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/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/CompositeNode.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/CompositeNode.java deleted file mode 100644 index 8d15c5632..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/CompositeNode.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.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/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Constants.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Constants.java deleted file mode 100644 index 2e4ffd8e1..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Constants.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework.impl; - -class Constants { - - private Constants() { - } - - static final String DEFAULT_MATCH = "*"; -} diff --git a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/DefaultRankedAttributesTreeFactory.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/DefaultRankedAttributesTreeFactory.java deleted file mode 100644 index 4d59735b5..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/DefaultRankedAttributesTreeFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.onap.appc.rankingframework.ConfigurationSet; -import org.onap.appc.rankingframework.RankedAttributesResolver; -import org.onap.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/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/LeafNode.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/LeafNode.java deleted file mode 100644 index c6bb97378..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/LeafNode.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.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/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Node.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Node.java deleted file mode 100644 index 940e50972..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Node.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.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/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/NodeBase.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/NodeBase.java deleted file mode 100644 index 1075cca50..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/NodeBase.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.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/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTree.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTree.java deleted file mode 100644 index f3e3191ec..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTree.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework.impl; - -import java.util.List; - -import org.onap.appc.rankingframework.RankedAttributesContext; -import org.onap.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/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTreeBuilder.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTreeBuilder.java deleted file mode 100644 index 2a7cfbfe0..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/RankedAttributesTreeBuilder.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework.impl; - -import java.util.HashMap; - -import org.onap.appc.rankingframework.ConfigurationEntry; -import org.onap.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/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Strategy.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Strategy.java deleted file mode 100644 index 36f898163..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Strategy.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.rankingframework.impl; - -import java.util.List; - -import org.onap.appc.rankingframework.RankedAttributesContext; - -interface Strategy { - <R> R resolve(CompositeNode<R> root, List<String> rankedNames, RankedAttributesContext context); -} diff --git a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Utils.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Utils.java deleted file mode 100644 index fb18377f9..000000000 --- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/openecomp/appc/rankingframework/impl/Utils.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.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; - } -} |