aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-12-09 20:06:15 +0200
committerIttay Stern <ittay.stern@att.com>2019-12-09 21:18:49 +0200
commit5540d178ab3203ab2994b21ee3434cca73318aa3 (patch)
treea156a4c63e5f0ce1846ee1a20c5dd4fa12c626fd /vid-app-common/src/main/java/org
parent299190fbe78defb71a717e446c0f394ea7404dfe (diff)
Join ExistingElementsCounterMaps with ServiceInstantiation
This new pretty creature is called "ServiceInstantiationTemplate" :-) Issue-ID: VID-724 Change-Id: I1437d76e79512920079b574844b19368c07f501f Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ExistingElementsCounterMaps.java34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiationTemplate.java81
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/InstantiationTemplatesService.java67
7 files changed, 196 insertions, 12 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
index c46266790..96e777a13 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
@@ -36,6 +36,7 @@ import org.onap.vid.properties.Features;
import org.onap.vid.roles.RoleProvider;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
import org.onap.vid.services.AuditService;
+import org.onap.vid.services.InstantiationTemplatesService;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -55,6 +56,7 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
public static final String ASYNC_INSTANTIATION = "asyncInstantiation";
protected final AsyncInstantiationBusinessLogic asyncInstantiationBL;
+ protected final InstantiationTemplatesService instantiationTemplates;
protected final AsyncInstantiationRepository asyncInstantiationRepository;
private final SystemPropertiesWrapper systemPropertiesWrapper;
@@ -62,18 +64,21 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
private final FeatureManager featureManager;
- @Autowired
- protected AuditService auditService;
+ protected final AuditService auditService;
@Autowired
public AsyncInstantiationController(AsyncInstantiationBusinessLogic asyncInstantiationBL,
+ InstantiationTemplatesService instantiationTemplates,
AsyncInstantiationRepository asyncInstantiationRepository, RoleProvider roleProvider,
- FeatureManager featureManager, SystemPropertiesWrapper systemPropertiesWrapper) {
+ FeatureManager featureManager, SystemPropertiesWrapper systemPropertiesWrapper,
+ AuditService auditService) {
this.asyncInstantiationBL = asyncInstantiationBL;
+ this.instantiationTemplates = instantiationTemplates;
this.asyncInstantiationRepository = asyncInstantiationRepository;
this.roleProvider = roleProvider;
this.featureManager = featureManager;
this.systemPropertiesWrapper = systemPropertiesWrapper;
+ this.auditService = auditService;
}
/**
@@ -171,7 +176,7 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
@GetMapping("templateTopology/{jobId}")
public ServiceInstantiation getTemplateTopology(HttpServletRequest request, @PathVariable(value="jobId") UUID jobId) {
- return asyncInstantiationBL.getJobRequestAsTemplate(jobId);
+ return instantiationTemplates.getJobRequestAsTemplate(jobId);
}
@RequestMapping(value = "/auditStatusForRetry/{trackById}", method = RequestMethod.GET)
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ExistingElementsCounterMaps.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ExistingElementsCounterMaps.java
new file mode 100644
index 000000000..de63c2c94
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ExistingElementsCounterMaps.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.model.aaiTree;
+
+import java.util.Map;
+
+public interface ExistingElementsCounterMaps {
+
+ Map<String, Long> getExistingVNFCounterMap();
+
+ Map<String, Long> getExistingNetworksCounterMap();
+
+ Map<String, Long> getExistingVnfGroupCounterMap();
+
+ Map<String, Long> getExistingVRFCounterMap();
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java
index 923be132f..78afe1d45 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java
@@ -24,7 +24,7 @@ import java.util.HashMap;
import java.util.Map;
import org.onap.vid.mso.model.ModelInfo;
-public class ServiceInstance extends AbstractNode {
+public class ServiceInstance extends AbstractNode implements ExistingElementsCounterMaps {
private String globalSubscriberId;
private String subscriptionServiceType;
@@ -198,6 +198,7 @@ public class ServiceInstance extends AbstractNode {
this.validationCounter = validationCounter;
}
+ @Override
public Map<String, Long> getExistingVNFCounterMap() {
return existingVNFCounterMap;
}
@@ -206,6 +207,7 @@ public class ServiceInstance extends AbstractNode {
this.existingVNFCounterMap = existingVNFCounterMap;
}
+ @Override
public Map<String, Long> getExistingNetworksCounterMap() {
return existingNetworksCounterMap;
}
@@ -214,6 +216,7 @@ public class ServiceInstance extends AbstractNode {
this.existingNetworksCounterMap = existingNetworksCounterMap;
}
+ @Override
public Map<String, Long> getExistingVnfGroupCounterMap() {
return existingVnfGroupCounterMap;
}
@@ -230,6 +233,7 @@ public class ServiceInstance extends AbstractNode {
this.vrfs = vrfs;
}
+ @Override
public Map<String, Long> getExistingVRFCounterMap() {
return existingVRFCounterMap;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiationTemplate.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiationTemplate.java
new file mode 100644
index 000000000..17ce1bcc3
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiationTemplate.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.model.serviceInstantiation;
+
+import java.util.Map;
+import java.util.Objects;
+import org.onap.vid.model.aaiTree.ExistingElementsCounterMaps;
+
+public class ServiceInstantiationTemplate extends ServiceInstantiation implements ExistingElementsCounterMaps {
+
+ private final Map<String, Long> existingVNFCounterMap;
+ private final Map<String, Long> existingNetworksCounterMap;
+ private final Map<String, Long> existingVnfGroupCounterMap;
+ private final Map<String, Long> existingVRFCounterMap;
+
+ public ServiceInstantiationTemplate(
+ ServiceInstantiation baseService,
+ Map<String, Long> vnfCounterMap,
+ Map<String, Long> networksCounterMap,
+ Map<String, Long> vnfGroupCounterMap,
+ Map<String, Long> VRFCounterMap
+ ) {
+ super(
+ baseService.getModelInfo(), baseService.getOwningEntityId(), baseService.getOwningEntityName(),
+ baseService.getProjectName(), baseService.getGlobalSubscriberId(), baseService.getSubscriberName(),
+ baseService.getProductFamilyId(), baseService.getInstanceName(), baseService.getSubscriptionServiceType(),
+ baseService.getLcpCloudRegionId(), baseService.getLcpCloudRegionId(), baseService.getTenantId(),
+ baseService.getTenantName(), baseService.getAicZoneId(), baseService.getAicZoneName(),
+ baseService.getVnfs(), baseService.getNetworks(), baseService.getVnfGroups(), baseService.getVrfs(),
+ baseService.getInstanceParams(), baseService.isPause(), baseService.getBulkSize(),
+ baseService.isRollbackOnFailure(), baseService.isALaCarte(), baseService.getTestApi(),
+ baseService.getInstanceId(), Objects.toString(baseService.getAction(), null),
+ baseService.getTrackById(), baseService.getIsFailed(), baseService.getStatusMessage(),
+ baseService.getVidNotions()
+ );
+
+ this.existingVNFCounterMap = vnfCounterMap;
+ this.existingNetworksCounterMap = networksCounterMap;
+ this.existingVnfGroupCounterMap = vnfGroupCounterMap;
+ this.existingVRFCounterMap = VRFCounterMap;
+ }
+
+ @Override
+ public Map<String, Long> getExistingVNFCounterMap() {
+ return existingVNFCounterMap;
+ }
+
+ @Override
+ public Map<String, Long> getExistingNetworksCounterMap() {
+ return existingNetworksCounterMap;
+ }
+
+ @Override
+ public Map<String, Long> getExistingVnfGroupCounterMap() {
+ return existingVnfGroupCounterMap;
+ }
+
+ @Override
+ public Map<String, Long> getExistingVRFCounterMap() {
+ return existingVRFCounterMap;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java
index e00758aa1..bb1121339 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java
@@ -108,7 +108,5 @@ public interface AsyncInstantiationBusinessLogic {
ServiceInstantiation getBulkForRetry(UUID jobId);
- ServiceInstantiation getJobRequestAsTemplate(UUID jobId);
-
String getResumeRequestPath(String requestId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
index 86d630b2a..c77eb8230 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
@@ -534,11 +534,6 @@ public class AsyncInstantiationBusinessLogicImpl implements
}
@Override
- public ServiceInstantiation getJobRequestAsTemplate(UUID jobId) {
- return asyncInstantiationRepository.getJobRequest(jobId);
- }
-
- @Override
public void addResourceInfo(JobSharedData sharedData, Job.JobStatus jobStatus, String instanceId) {
String trackById = ((BaseResource) sharedData.getRequest()).getTrackById();
ResourceInfo resourceInfo = new ResourceInfo(trackById, sharedData.getRootJobId(), instanceId, jobStatus, null);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/InstantiationTemplatesService.java b/vid-app-common/src/main/java/org/onap/vid/services/InstantiationTemplatesService.java
new file mode 100644
index 000000000..aa0031104
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/InstantiationTemplatesService.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.services;
+
+import static java.util.Collections.emptyMap;
+import static java.util.Objects.requireNonNull;
+
+import java.util.Map;
+import java.util.UUID;
+import javax.inject.Inject;
+import org.onap.vid.dal.AsyncInstantiationRepository;
+import org.onap.vid.model.ModelUtil;
+import org.onap.vid.model.serviceInstantiation.BaseResource;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiationTemplate;
+import org.springframework.stereotype.Component;
+
+@Component
+public class InstantiationTemplatesService {
+
+ private final ModelUtil modelUtil;
+ private final AsyncInstantiationRepository asyncInstantiationRepository;
+
+ @Inject
+ public InstantiationTemplatesService(ModelUtil modelUtil,
+ AsyncInstantiationRepository asyncInstantiationRepository) {
+ this.modelUtil = modelUtil;
+ this.asyncInstantiationRepository = asyncInstantiationRepository;
+ }
+
+ public ServiceInstantiationTemplate getJobRequestAsTemplate(UUID jobId) {
+ ServiceInstantiation jobRequest = requireNonNull(asyncInstantiationRepository.getJobRequest(jobId));
+
+ return new ServiceInstantiationTemplate(
+ jobRequest,
+ counterMap(jobRequest.getVnfs()),
+ counterMap(jobRequest.getNetworks()),
+ counterMap(jobRequest.getVnfGroups()),
+ emptyMap() // model info for VRF is not stored
+ );
+ }
+
+ private <T extends BaseResource> Map<String, Long> counterMap(Map<String, T> nodesToCount) {
+ return modelUtil.getExistingCounterMap(
+ nodesToCount, BaseResource::getModelInfo
+ );
+ }
+
+}