[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / lib / openecomp-sdc-enrichment-lib / openecomp-sdc-enrichment-core / src / main / java / org / openecomp / sdc / enrichment / impl / EnrichmentManagerImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.enrichment.impl;
22
23 import org.openecomp.core.enrichment.api.EnrichmentManager;
24 import org.openecomp.core.enrichment.types.EntityInfo;
25 import org.openecomp.sdc.logging.api.Logger;
26 import org.openecomp.sdc.logging.api.LoggerFactory;
27 import org.openecomp.sdc.datatypes.error.ErrorMessage;
28 import org.openecomp.sdc.enrichment.EnrichmentInfo;
29 import org.openecomp.sdc.enrichment.factory.EnricherHandlerFactory;
30 import org.openecomp.sdc.enrichment.inter.Enricher;
31 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
32 import org.openecomp.sdc.versioning.dao.types.Version;
33
34 import java.util.HashMap;
35 import java.util.List;
36 import java.util.Map;
37
38 public class EnrichmentManagerImpl implements EnrichmentManager<ToscaServiceModel> {
39
40   private static Logger logger = (Logger) LoggerFactory.getLogger(EnrichmentManagerImpl.class);
41
42   private EnrichmentInfo data = null;
43   private ToscaServiceModel model;
44
45
46   @Override
47   public Map<String, List<ErrorMessage>> enrich() {
48     Map<String, List<ErrorMessage>> enrichErrors = new HashMap<>();
49     List<Enricher> enricherList =
50         EnricherHandlerFactory.getInstance().createInterface().getEnrichers();
51     for (Enricher enricher : enricherList) {
52       enricher.setData(data);
53       enricher.setModel(model);
54       enrichErrors.putAll(enricher.enrich());
55     }
56
57     return enrichErrors;
58   }
59
60   @Override
61   public void addEntityInfo(String entityKey, EntityInfo entityInfo) {
62     this.data.addEntityInfo(entityKey, entityInfo);
63   }
64
65
66   @Override
67   public void init(String key, Version version) {
68     data = new EnrichmentInfo();
69     data.setKey(key);
70     data.setVersion(version);
71   }
72
73   @Override
74   public ToscaServiceModel getModel() {
75     return this.model;
76   }
77
78   @Override
79   public void setModel(ToscaServiceModel model) {
80     this.model = model;
81   }
82
83
84 }