2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.enrichment.impl;
23 import org.openecomp.core.enrichment.types.EntityInfo;
24 import org.openecomp.sdc.datatypes.error.ErrorMessage;
25 import org.openecomp.sdc.datatypes.model.AsdcModel;
26 import org.openecomp.sdc.enrichment.EnrichmentInfo;
27 import org.openecomp.sdc.enrichment.impl.external.artifact.ExternalArtifactEnricher;
28 import org.openecomp.sdc.enrichment.impl.tosca.ToscaEnricher;
29 import org.openecomp.sdc.enrichment.inter.Enricher;
30 import org.openecomp.sdc.enrichment.inter.EnricherHandler;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 import java.util.ArrayList;
35 import java.util.HashMap;
36 import java.util.List;
40 * The type Enricher handler.
42 public class EnricherHandlerImpl implements EnricherHandler {
44 private static Logger logger = LoggerFactory.getLogger(EnricherHandlerImpl.class);
45 private EnrichmentInfo input;
46 private AsdcModel model;
49 public List<Enricher> getEnrichers() {
50 List<Enricher> enricherList = new ArrayList<>();
51 enricherList.add(new ToscaEnricher());
52 enricherList.add(new ExternalArtifactEnricher());
57 public Map<String, List<ErrorMessage>> enrich() {
58 Map<String, List<ErrorMessage>> errors = new HashMap<>();
59 Map<String, List<ErrorMessage>> enricherResponse;
60 for (Enricher enricher : getEnrichers()) {
61 enricher.setInput(this.input);
62 enricher.setModel(this.model);
63 enricherResponse = enricher.enrich();
64 errors.putAll(enricherResponse);
70 * Adds additional input.
75 public void addAdditionalInput(String key, Object input) {
76 if (!this.input.getAdditionalInfo().containsKey(key)) {
77 this.input.getAdditionalInfo().put(key, new ArrayList<>());
79 this.input.getAdditionalInfo().get(key).add(input);
82 public void addEntityInfo(String entityId, EntityInfo entityInfo) {
83 this.input.getEntityInfo().put(entityId, entityInfo);
86 public void setModel(AsdcModel model) {