re base code
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / components / impl / ComponentBusinessLogicProvider.java
1 package org.openecomp.sdc.be.components.impl;
2
3 import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
4 import org.openecomp.sdc.be.config.BeEcompErrorManager;
5 import org.openecomp.sdc.be.dao.api.ActionStatus;
6 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
7 import org.springframework.stereotype.Component;
8
9 @Component
10 public class ComponentBusinessLogicProvider {
11
12     private final ResourceBusinessLogic resourceBusinessLogic;
13     private final ServiceBusinessLogic serviceBusinessLogic;
14     private final ProductBusinessLogic productBusinessLogic;
15
16     public ComponentBusinessLogicProvider(ResourceBusinessLogic resourceBusinessLogic, ServiceBusinessLogic serviceBusinessLogic, ProductBusinessLogic productBusinessLogic) {
17         this.resourceBusinessLogic = resourceBusinessLogic;
18         this.serviceBusinessLogic = serviceBusinessLogic;
19         this.productBusinessLogic = productBusinessLogic;
20     }
21
22     public ComponentBusinessLogic getInstance(ComponentTypeEnum componentTypeEnum) {
23         switch (componentTypeEnum) {
24             case SERVICE:
25                return serviceBusinessLogic;
26             case PRODUCT:
27                return productBusinessLogic;
28             case RESOURCE:
29             case RESOURCE_INSTANCE:
30                return resourceBusinessLogic;
31             default:
32                 BeEcompErrorManager.getInstance().logBeSystemError("getComponentBL");
33                 throw new ComponentException(ActionStatus.INVALID_CONTENT_PARAM, componentTypeEnum.getValue());
34         }
35     }
36
37 }