Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / java / org / onap / so / bpmn / infrastructure / pnf / delegate / PrepareConfigAssignDelegate.java
1 /*
2  * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix
3  * Foundation. ================================================================================ Licensed under the
4  * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
5  * obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
8  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9  * either express or implied. See the License for the specific language governing permissions and limitations under the
10  * License.
11  *
12  * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
13  */
14
15 package org.onap.so.bpmn.infrastructure.pnf.delegate;
16
17 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
18 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
19 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
20 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
21 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
22 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
23 import org.camunda.bpm.engine.delegate.DelegateExecution;
24 import org.camunda.bpm.engine.delegate.JavaDelegate;
25 import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
26 import org.onap.so.client.cds.beans.ConfigAssignPropertiesForPnf;
27 import org.onap.so.client.cds.beans.ConfigAssignRequestPnf;
28 import org.springframework.stereotype.Component;
29
30 /**
31  * This implementation of {@link JavaDelegate} is used to prepare for config Assign.
32  *
33  * It queries the PNF resource customization table and construct the {@link AbstractCDSPropertiesBean} as
34  * executionObject.
35  */
36 @Component
37 public class PrepareConfigAssignDelegate extends PrepareCdsCallDelegate {
38
39     public PrepareConfigAssignDelegate() {
40         this.actionName = "config-assign";
41         this.mode = "sync";
42     }
43
44     @Override
45     protected String getRequestObject(final DelegateExecution delegateExecution) {
46
47         ConfigAssignPropertiesForPnf configAssignProperties = new ConfigAssignPropertiesForPnf();
48         configAssignProperties.setServiceInstanceId((String) delegateExecution.getVariable(SERVICE_INSTANCE_ID));
49
50         /**
51          * PNF Name matches the name in AAI, i.e., correlationID as in customized workflow.
52          */
53         configAssignProperties.setPnfName((String) delegateExecution.getVariable(PNF_CORRELATION_ID));
54
55         /**
56          * PNF id match AAI entry, i.e, PNF UUID.
57          */
58         configAssignProperties.setPnfId((String) delegateExecution.getVariable(PNF_UUID));
59         configAssignProperties.setPnfCustomizationUuid((String) delegateExecution.getVariable(PRC_CUSTOMIZATION_UUID));
60         configAssignProperties.setServiceModelUuid((String) delegateExecution.getVariable(MODEL_UUID));
61
62         ConfigAssignRequestPnf configAssignRequest = new ConfigAssignRequestPnf();
63         configAssignRequest.setConfigAssignPropertiesForPnf(configAssignProperties);
64
65         /**
66          * resolution key is the same as PNF name.
67          */
68         configAssignRequest.setResolutionKey((String) delegateExecution.getVariable(PNF_CORRELATION_ID));
69
70         return configAssignRequest.toString();
71     }
72
73 }