Merge "Reorder modifiers"
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / java / org / openecomp / mso / bpmn / infrastructure / workflow / serviceTask / SdncUnderlayVpnPreprocessTask.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.mso.bpmn.infrastructure.workflow.serviceTask;
22
23 import org.apache.commons.lang3.StringUtils;
24 import org.camunda.bpm.engine.delegate.DelegateExecution;
25 import org.openecomp.mso.bpmn.core.BaseTask;
26 import org.openecomp.mso.requestsdb.RequestsDatabase;
27 import org.openecomp.mso.requestsdb.ResourceOperationStatus;
28
29 public class SdncUnderlayVpnPreprocessTask extends BaseTask {
30     public static final String RESOURCE_OPER_TYPE = "resourceOperType";
31     private RequestsDatabase requestsDB = RequestsDatabase.getInstance();
32
33     @Override
34     public void execute(DelegateExecution execution) {
35         String operType = getOperType(execution);
36         execution.setVariable(RESOURCE_OPER_TYPE, operType);
37     }
38
39     private String getOperType(DelegateExecution execution) {
40         String serviceId = (String) execution.getVariable("serviceId");
41         serviceId = StringUtils.isBlank(serviceId) ? (String) execution.getVariable("serviceInstanceId") : serviceId;
42         String operationId = (String) execution.getVariable("operationId");
43         String resourceTemplateUUID = (String) execution.getVariable("resourceTemplateUUID");
44         resourceTemplateUUID = StringUtils.isBlank(resourceTemplateUUID) ? (String) execution.getVariable("resourceTemplateId") : resourceTemplateUUID;
45         ResourceOperationStatus resourceOperationStatus = requestsDB.getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID);
46         return resourceOperationStatus.getOperType();
47     }
48 }