From 796799423400ef467e0087dec24c55f2925fcb4b Mon Sep 17 00:00:00 2001 From: ’zhaoyh6‘ Date: Wed, 3 Nov 2021 11:17:58 +0800 Subject: feat:Add the function of obtaining instance creation progress MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue-ID: USECASEUI-605 Signed-off-by: ’zhaoyh6‘ Change-Id: I4458ba77b61ee95ffafac6e3595421a68f2594ac --- .../server/bean/intent/CCVPNInstance.java | 161 +++++++++++++++++++++ .../server/bean/intent/IntentInstance.java | 161 --------------------- .../server/conf/intent/IntentScheduleTask.java | 2 +- .../server/controller/IntentController.java | 24 +-- .../server/service/intent/IntentApiService.java | 9 ++ .../service/intent/IntentInstanceService.java | 8 +- .../intent/impl/IntentInstanceServiceImpl.java | 140 +++++++++--------- .../server/controller/IntentControllerTest.java | 6 +- .../intent/impl/IntentInstanceServiceImplTest.java | 22 +-- .../dbscripts/postgres/uui_create_table.sql | 6 +- 10 files changed, 275 insertions(+), 264 deletions(-) create mode 100644 server/src/main/java/org/onap/usecaseui/server/bean/intent/CCVPNInstance.java delete mode 100644 server/src/main/java/org/onap/usecaseui/server/bean/intent/IntentInstance.java diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/intent/CCVPNInstance.java b/server/src/main/java/org/onap/usecaseui/server/bean/intent/CCVPNInstance.java new file mode 100644 index 00000000..f9a56b97 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/bean/intent/CCVPNInstance.java @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2021 CTC, Inc. and others. 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. + */ +package org.onap.usecaseui.server.bean.intent; +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Table(name="ccvpn_instance") +public class CCVPNInstance implements Serializable { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name = "id") + private int id; + + @Column(name = "instance_id") + private String instanceId; + + @Column(name = "job_id") + private String jobId; + + @Column(name = "progress") + private int progress; + + @Column(name = "status") + private String status; + + @Column(name = "resource_instance_id") + private String resourceInstanceId; + + @Column(name = "name") + private String name; + + @Column(name = "cloud_point_name") + private String cloudPointName; + + @Column(name = "access_point_one_name") + private String accessPointOneName; + + @Column(name = "access_point_one_band_width") + private int accessPointOneBandWidth; + + @Column(name = "line_num") + private String lineNum; + + @Column(name = "delete_state") + private int deleteState; + + public CCVPNInstance() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public int getProgress() { + return progress; + } + + public void setProgress(int progress) { + this.progress = progress; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getResourceInstanceId() { + return resourceInstanceId; + } + + public void setResourceInstanceId(String resourceInstanceId) { + this.resourceInstanceId = resourceInstanceId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCloudPointName() { + return cloudPointName; + } + + public void setCloudPointName(String cloudPointName) { + this.cloudPointName = cloudPointName; + } + + public String getAccessPointOneName() { + return accessPointOneName; + } + + public void setAccessPointOneName(String accessPointOneName) { + this.accessPointOneName = accessPointOneName; + } + + public int getAccessPointOneBandWidth() { + return accessPointOneBandWidth; + } + + public void setAccessPointOneBandWidth(int accessPointOneBandWidth) { + this.accessPointOneBandWidth = accessPointOneBandWidth; + } + + public String getLineNum() { + return lineNum; + } + + public void setLineNum(String lineNum) { + this.lineNum = lineNum; + } + + public int getDeleteState() { + return deleteState; + } + + public void setDeleteState(int deleteState) { + this.deleteState = deleteState; + } +} \ No newline at end of file diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/intent/IntentInstance.java b/server/src/main/java/org/onap/usecaseui/server/bean/intent/IntentInstance.java deleted file mode 100644 index 8676821e..00000000 --- a/server/src/main/java/org/onap/usecaseui/server/bean/intent/IntentInstance.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2021 CTC, Inc. and others. 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. - */ -package org.onap.usecaseui.server.bean.intent; -import javax.persistence.*; -import java.io.Serializable; - -@Entity -@Table(name="intent_instance") -public class IntentInstance implements Serializable { - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name = "id") - private int id; - - @Column(name = "instance_id") - private String instanceId; - - @Column(name = "job_id") - private String jobId; - - @Column(name = "progress") - private int progress; - - @Column(name = "status") - private String status; - - @Column(name = "resource_instance_id") - private String resourceInstanceId; - - @Column(name = "name") - private String name; - - @Column(name = "cloud_point_name") - private String cloudPointName; - - @Column(name = "access_point_one_name") - private String accessPointOneName; - - @Column(name = "access_point_one_band_width") - private int accessPointOneBandWidth; - - @Column(name = "line_num") - private String lineNum; - - @Column(name = "delete_state") - private int deleteState; - - public IntentInstance() { - - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getInstanceId() { - return instanceId; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } - - public int getProgress() { - return progress; - } - - public void setProgress(int progress) { - this.progress = progress; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getResourceInstanceId() { - return resourceInstanceId; - } - - public void setResourceInstanceId(String resourceInstanceId) { - this.resourceInstanceId = resourceInstanceId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCloudPointName() { - return cloudPointName; - } - - public void setCloudPointName(String cloudPointName) { - this.cloudPointName = cloudPointName; - } - - public String getAccessPointOneName() { - return accessPointOneName; - } - - public void setAccessPointOneName(String accessPointOneName) { - this.accessPointOneName = accessPointOneName; - } - - public int getAccessPointOneBandWidth() { - return accessPointOneBandWidth; - } - - public void setAccessPointOneBandWidth(int accessPointOneBandWidth) { - this.accessPointOneBandWidth = accessPointOneBandWidth; - } - - public String getLineNum() { - return lineNum; - } - - public void setLineNum(String lineNum) { - this.lineNum = lineNum; - } - - public int getDeleteState() { - return deleteState; - } - - public void setDeleteState(int deleteState) { - this.deleteState = deleteState; - } -} \ No newline at end of file diff --git a/server/src/main/java/org/onap/usecaseui/server/conf/intent/IntentScheduleTask.java b/server/src/main/java/org/onap/usecaseui/server/conf/intent/IntentScheduleTask.java index 4f168801..f84ad497 100644 --- a/server/src/main/java/org/onap/usecaseui/server/conf/intent/IntentScheduleTask.java +++ b/server/src/main/java/org/onap/usecaseui/server/conf/intent/IntentScheduleTask.java @@ -33,7 +33,7 @@ public class IntentScheduleTask { @Scheduled(cron = "0/20 * * * * ?") public void getIntentInstanceCompleteness() { - intentInstanceService.getIntentInstanceCreateStatus(); + intentInstanceService.getIntentInstanceProgress(); } @Scheduled(cron = "0/20 * * * * ?") public void getIntentInstanceBandwidth() throws IOException { diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/IntentController.java b/server/src/main/java/org/onap/usecaseui/server/controller/IntentController.java index 4dbed7bd..3dd3572c 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/IntentController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/IntentController.java @@ -24,7 +24,7 @@ import javax.annotation.Resource; import com.alibaba.fastjson.JSONArray; import org.apache.commons.collections.MapUtils; import org.onap.usecaseui.server.bean.HttpResponseResult; -import org.onap.usecaseui.server.bean.intent.IntentInstance; +import org.onap.usecaseui.server.bean.intent.CCVPNInstance; import org.onap.usecaseui.server.bean.intent.IntentModel; import org.onap.usecaseui.server.bean.intent.IntentResponseBody; import org.onap.usecaseui.server.service.csmf.SlicingService; @@ -362,16 +362,16 @@ public class IntentController { String accessPointOneName = MapUtils.getString(accessPointOne, "name"); int accessPointOneBandWidth = MapUtils.getIntValue(accessPointOne, "bandwidth"); - IntentInstance intentInstance = new IntentInstance(); - intentInstance.setInstanceId(intentInstanceId); - intentInstance.setName(name); - intentInstance.setLineNum(lineNum); - intentInstance.setCloudPointName(cloudPointName); - intentInstance.setAccessPointOneName(accessPointOneName); - intentInstance.setAccessPointOneBandWidth(accessPointOneBandWidth); - intentInstance.setStatus("0"); + CCVPNInstance instance = new CCVPNInstance(); + instance.setInstanceId(intentInstanceId); + instance.setName(name); + instance.setLineNum(lineNum); + instance.setCloudPointName(cloudPointName); + instance.setAccessPointOneName(accessPointOneName); + instance.setAccessPointOneBandWidth(accessPointOneBandWidth); + instance.setStatus("0"); - int flag = intentInstanceService.createIntentInstance(intentInstance); + int flag = intentInstanceService.createIntentInstance(instance); if(flag == 1) { return "OK"; @@ -385,9 +385,9 @@ public class IntentController { @GetMapping(value = {"/getFinishedInstanceInfo"}, produces = "application/json") public Object getFinishedInstanceInfo() { - List instanceList = intentInstanceService.getFinishedInstanceInfo(); + List instanceList = intentInstanceService.getFinishedInstanceInfo(); List> result = new ArrayList<>(); - for (IntentInstance instance : instanceList) { + for (CCVPNInstance instance : instanceList) { Map instanceInfo = new HashMap<>(); instanceInfo.put("instanceId", instance.getInstanceId()); instanceInfo.put("name", instance.getName()); diff --git a/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentApiService.java b/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentApiService.java index 62f2381a..4d526389 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentApiService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentApiService.java @@ -30,6 +30,15 @@ public interface IntentApiService { @POST("/so/infra/serviceIntent/v1/create") Call createIntentInstance(@Body RequestBody body); +// curl -X GET -H "content-type:application/json" http://so:8080/onap/so/infra/e2eServiceInstances/v3/cll-101/operations/0d698405-9109-49f2-9939-fd02ead31660 --user 'InfraPortalClient:password1$' + + @Headers({ + "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==", + "Accept: application/json" + }) + @GET("/so/infra/e2eServiceInstances/v3/{serviceId}/operations/{operationId}") + Call queryOperationProgress(@Path("serviceId") String serviceId, @Path("operationId") String operationId); + @Headers({ "X-TransactionId: 9999", "X-FromAppId: MSO", diff --git a/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentInstanceService.java b/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentInstanceService.java index ddbcb6e4..2491cc26 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentInstanceService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentInstanceService.java @@ -17,7 +17,7 @@ package org.onap.usecaseui.server.service.intent; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import org.onap.usecaseui.server.bean.intent.IntentInstance; +import org.onap.usecaseui.server.bean.intent.CCVPNInstance; import org.onap.usecaseui.server.util.Page; import java.io.IOException; @@ -25,11 +25,11 @@ import java.util.List; import java.util.Map; public interface IntentInstanceService { - Page queryIntentInstance(IntentInstance intentInstance, int currentPage, int pageSize); - int createIntentInstance(IntentInstance intentInstance); + Page queryIntentInstance(CCVPNInstance instance, int currentPage, int pageSize); + int createIntentInstance(CCVPNInstance instance); void getIntentInstanceProgress(); void getIntentInstanceCreateStatus(); - List getFinishedInstanceInfo(); + List getFinishedInstanceInfo(); void getIntentInstanceBandwidth() throws IOException; void deleteIntentInstance(String instanceId); diff --git a/server/src/main/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImpl.java index 6b1e96c9..2e3c9614 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImpl.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImpl.java @@ -23,11 +23,10 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.onap.usecaseui.server.bean.intent.InstancePerformance; -import org.onap.usecaseui.server.bean.intent.IntentInstance; +import org.onap.usecaseui.server.bean.intent.CCVPNInstance; import org.onap.usecaseui.server.service.intent.IntentApiService; import org.onap.usecaseui.server.service.intent.IntentInstanceService; import org.onap.usecaseui.server.service.lcm.domain.so.SOService; -import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation; import org.onap.usecaseui.server.util.Page; import org.onap.usecaseui.server.util.RestfulServices; import org.onap.usecaseui.server.util.UuiCommonUtil; @@ -79,33 +78,33 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { } @Override - public Page queryIntentInstance(IntentInstance intentInstance, int currentPage, int pageSize) { - Page page = new Page(); - int allRow =this.getAllCount(intentInstance,currentPage,pageSize); + public Page queryIntentInstance(CCVPNInstance instance, int currentPage, int pageSize) { + Page page = new Page(); + int allRow =this.getAllCount(instance,currentPage,pageSize); int offset = page.countOffset(currentPage, pageSize); Session session = getSession(); try{ - StringBuffer hql =new StringBuffer("from IntentInstance a where deleteState = 0"); - if (null != intentInstance) { - if(UuiCommonUtil.isNotNullOrEmpty(intentInstance.getInstanceId())) { - String ver =intentInstance.getInstanceId(); + StringBuffer hql =new StringBuffer("from CCVPNInstance a where deleteState = 0"); + if (null != instance) { + if(UuiCommonUtil.isNotNullOrEmpty(instance.getInstanceId())) { + String ver =instance.getInstanceId(); hql.append(" and a.instance_id = '"+ver+"'"); } - if(UuiCommonUtil.isNotNullOrEmpty(intentInstance.getJobId())) { - String ver =intentInstance.getJobId(); + if(UuiCommonUtil.isNotNullOrEmpty(instance.getJobId())) { + String ver =instance.getJobId(); hql.append(" and a.job_id = '"+ver+"'"); } - if(UuiCommonUtil.isNotNullOrEmpty(intentInstance.getStatus())) { - String ver =intentInstance.getStatus(); + if(UuiCommonUtil.isNotNullOrEmpty(instance.getStatus())) { + String ver =instance.getStatus(); hql.append(" and a.status = '"+ver+"'"); } } hql.append(" order by id"); - logger.info("AlarmsHeaderServiceImpl queryIntentInstance: intentInstance={}", intentInstance); + logger.info("AlarmsHeaderServiceImpl queryIntentInstance: instance={}", instance); Query query = session.createQuery(hql.toString()); query.setFirstResult(offset); query.setMaxResults(pageSize); - List list= query.list(); + List list= query.list(); page.setPageNo(currentPage); page.setPageSize(pageSize); page.setTotalRecords(allRow); @@ -120,21 +119,21 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { } - public int getAllCount(IntentInstance intentInstance,int currentPage,int pageSize) { + public int getAllCount(CCVPNInstance instance, int currentPage, int pageSize) { Session session = getSession(); try{ - StringBuffer count=new StringBuffer("select count(*) from IntentInstance a where deleteState = 0"); - if (null != intentInstance) { - if(UuiCommonUtil.isNotNullOrEmpty(intentInstance.getInstanceId())) { - String ver =intentInstance.getInstanceId(); + StringBuffer count=new StringBuffer("select count(*) from CCVPNInstance a where deleteState = 0"); + if (null != instance) { + if(UuiCommonUtil.isNotNullOrEmpty(instance.getInstanceId())) { + String ver =instance.getInstanceId(); count.append(" and a.instance_id = '"+ver+"'"); } - if(UuiCommonUtil.isNotNullOrEmpty(intentInstance.getJobId())) { - String ver =intentInstance.getJobId(); + if(UuiCommonUtil.isNotNullOrEmpty(instance.getJobId())) { + String ver =instance.getJobId(); count.append(" and a.job_id = '"+ver+"'"); } - if(UuiCommonUtil.isNotNullOrEmpty(intentInstance.getStatus())) { - String ver =intentInstance.getStatus(); + if(UuiCommonUtil.isNotNullOrEmpty(instance.getStatus())) { + String ver =instance.getStatus(); count.append(" and a.status = '"+ver+"'"); } } @@ -150,25 +149,25 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { } @Override - public int createIntentInstance(IntentInstance intentInstance) { + public int createIntentInstance(CCVPNInstance instance) { Session session = getSession(); Transaction tx = null; try{ - if (null == intentInstance){ - logger.error("intentInstance is null!"); + if (null == instance){ + logger.error("instance is null!"); return 0; } - String jobId = createIntentInstanceToSO(intentInstance); + String jobId = createIntentInstanceToSO(instance); if (null == jobId){ logger.error("create Instance error:jobId is null"); return 0; } - intentInstance.setJobId(jobId); - intentInstance.setResourceInstanceId("cll-"+intentInstance.getInstanceId()); + instance.setJobId(jobId); + instance.setResourceInstanceId("cll-"+instance.getInstanceId()); tx = session.beginTransaction(); - session.save(intentInstance); + session.save(instance); tx.commit(); return 1; } catch (Exception e) { @@ -182,9 +181,9 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { } } - private String createIntentInstanceToSO(IntentInstance intentInstance) throws IOException { + private String createIntentInstanceToSO(CCVPNInstance instance) throws IOException { Map params = new HashMap<>(); - params.put("name", intentInstance.getName()); + params.put("name", instance.getName()); params.put("modelInvariantUuid", "6790ab0e-034f-11eb-adc1-0242ac120002"); params.put("modelUuid", "6790ab0e-034f-11eb-adc1-0242ac120002"); params.put("globalSubscriberId", "IBNCustomer"); @@ -192,18 +191,18 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { params.put("serviceType", "CLL"); Map additionalProperties = new HashMap<>(); additionalProperties.put("enableSdnc", "false"); - additionalProperties.put("serviceInstanceID", "cll-" + intentInstance.getInstanceId()); + additionalProperties.put("serviceInstanceID", "cll-" + instance.getInstanceId()); List> transportNetworks = new ArrayList<>(); Map transportNetwork = new HashMap<>(); transportNetwork.put("id", ""); Map sla = new HashMap<>(); sla.put("latency", "2"); - sla.put("maxBandwidth", intentInstance.getAccessPointOneBandWidth()); + sla.put("maxBandwidth", instance.getAccessPointOneBandWidth()); List> connectionLinks = new ArrayList<>(); Map connectionLink = new HashMap<>(); connectionLink.put("name", ""); - connectionLink.put("transportEndpointA", intentInstance.getAccessPointOneName()); - connectionLink.put("transportEndpointB", intentInstance.getCloudPointName()); + connectionLink.put("transportEndpointA", instance.getAccessPointOneName()); + connectionLink.put("transportEndpointB", instance.getCloudPointName()); connectionLinks.add(connectionLink); transportNetwork.put("sla", sla); transportNetwork.put("connectionLinks", connectionLinks); @@ -221,11 +220,12 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { @Override public void getIntentInstanceProgress() { - List instanceList = getInstanceByFinishedFlag("0"); - for (IntentInstance instance: instanceList) { + List instanceList = getInstanceByFinishedFlag("0"); + for (CCVPNInstance instance: instanceList) { try { int progress = getProgressByJobId(instance); + instance.setProgress(progress); if (progress >=100) { instance.setStatus("1"); } @@ -239,8 +239,8 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { } @Override public void getIntentInstanceCreateStatus() { - List instanceList = getInstanceByFinishedFlag("0"); - for (IntentInstance instance: instanceList) { + List instanceList = getInstanceByFinishedFlag("0"); + for (CCVPNInstance instance: instanceList) { try { int flag = getCreateStatusByJobId(instance); @@ -256,7 +256,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { } - private void saveProgress(List instanceList) { + private void saveProgress(List instanceList) { if(instanceList == null || instanceList.isEmpty()) { return; } @@ -264,7 +264,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { Transaction tx = null; try { tx = session.beginTransaction(); - for (IntentInstance instance : instanceList) { + for (CCVPNInstance instance : instanceList) { session.update(instance); session.flush(); } @@ -282,16 +282,18 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { } } - private int getProgressByJobId(IntentInstance instance) throws IOException { - Response response = soService.queryOperationProgress(instance.getResourceInstanceId(), instance.getJobId()).execute(); + private int getProgressByJobId(CCVPNInstance instance) throws IOException { + Response response = intentApiService.queryOperationProgress(instance.getResourceInstanceId(), instance.getJobId()).execute(); logger.debug(response.toString()); if (response.isSuccessful()) { - return response.body().getOperationStatus().getProgress(); + if (response.body().containsKey("operation")) { + return response.body().getJSONObject("operation").getInteger("progress"); + } } return -1; } - private int getCreateStatusByJobId(IntentInstance instance) throws IOException { + private int getCreateStatusByJobId(CCVPNInstance instance) throws IOException { if (instance == null || instance.getResourceInstanceId() == null) { return -1; } @@ -308,13 +310,13 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { return -1; } - private List getInstanceByFinishedFlag(String flag) { + private List getInstanceByFinishedFlag(String flag) { Session session = getSession(); try{ - StringBuffer sql=new StringBuffer("from IntentInstance where deleteState = 0 and status = '" + flag + "'"); + StringBuffer sql=new StringBuffer("from CCVPNInstance where deleteState = 0 and status = '" + flag + "'"); Query query = session.createQuery(sql.toString()); - List q=(List) query.list(); + List q=(List) query.list(); logger.debug(q.toString()); return q; } catch (Exception e) { @@ -327,13 +329,13 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { @Override - public List getFinishedInstanceInfo() { + public List getFinishedInstanceInfo() { Session session = getSession(); try{ - StringBuffer count=new StringBuffer("from IntentInstance where status = '1' and deleteState = 0"); + StringBuffer count=new StringBuffer("from CCVPNInstance where status = '1' and deleteState = 0"); Query query = session.createQuery(count.toString()); - List q=(List) query.list(); + List q=(List) query.list(); logger.debug(q.toString()); return q; } catch (Exception e) { @@ -346,8 +348,8 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { @Override public void getIntentInstanceBandwidth() throws IOException { - List instanceList = getInstanceByFinishedFlag("1"); - for (IntentInstance instance : instanceList) { + List instanceList = getInstanceByFinishedFlag("1"); + for (CCVPNInstance instance : instanceList) { String serviceInstanceId = instance.getResourceInstanceId(); Response response = intentApiService.getInstanceNetworkInfo(serviceInstanceId).execute(); if (!response.isSuccessful()) { @@ -418,13 +420,13 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { @Override public void deleteIntentInstance(String instanceId) { - IntentInstance result = null; + CCVPNInstance result = null; Session session = getSession(); try { - result = (IntentInstance)session.createQuery("from IntentInstance where deleteState = 0 and instanceId = :instanceId") + result = (CCVPNInstance)session.createQuery("from CCVPNInstance where deleteState = 0 and instanceId = :instanceId") .setParameter("instanceId", instanceId).uniqueResult(); - logger.info("get IntentInstance OK, id=" + instanceId); + logger.info("get CCVPNInstance OK, id=" + instanceId); } catch (Exception e) { logger.error("getodel occur exception:"+e); @@ -454,7 +456,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params)); intentApiService.deleteIntentInstance(requestBody).execute(); } - private String deleteInstance(IntentInstance instance) { + private String deleteInstance(CCVPNInstance instance) { Transaction tx = null; String result="0"; Session session = getSession(); @@ -480,17 +482,17 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { @Override public void activeIntentInstance(String instanceId) { - IntentInstance instance = null; + CCVPNInstance instance = null; Session session = getSession(); Transaction tx = null; try { - instance = (IntentInstance)session.createQuery("from IntentInstance where deleteState = 0 and instanceId = :instanceId and status = :status") + instance = (CCVPNInstance)session.createQuery("from CCVPNInstance where deleteState = 0 and instanceId = :instanceId and status = :status") .setParameter("instanceId", instanceId).setParameter("status", "3").uniqueResult(); logger.info("get instance OK, id=" + instanceId); if (null == instance) { - logger.error("intentInstance is null!"); + logger.error("instance is null!"); return; } @@ -512,16 +514,16 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { } public void invalidIntentInstance(String instanceId) { - IntentInstance instance = null; + CCVPNInstance instance = null; Session session = getSession(); Transaction tx = null; try { - instance = (IntentInstance)session.createQuery("from IntentInstance where deleteState = 0 and instanceId = :instanceId") + instance = (CCVPNInstance)session.createQuery("from CCVPNInstance where deleteState = 0 and instanceId = :instanceId") .setParameter("instanceId", instanceId).uniqueResult(); logger.info("get instance OK, id=" + instanceId); if (null == instance) { - logger.error("intentInstance is null!"); + logger.error("instance is null!"); return; } deleteInstanceToSO(instance.getInstanceId()); @@ -545,7 +547,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { public Map queryInstancePerformanceData(String instanceId) { Session session = getSession(); try { - String hql = "from IntentInstance i, InstancePerformance p where i.resourceInstanceId = p.resourceInstanceId and i.instanceId = :instanceId and i.deleteState = 0 order by p.date"; + String hql = "from CCVPNInstance i, InstancePerformance p where i.resourceInstanceId = p.resourceInstanceId and i.instanceId = :instanceId and i.deleteState = 0 order by p.date"; Query query = session.createQuery(hql).setParameter("instanceId", instanceId); List queryResult= query.list(); List date = new ArrayList<>(); @@ -614,11 +616,11 @@ public class IntentInstanceServiceImpl implements IntentInstanceService { try { JSONObject result = new JSONObject(); JSONArray instanceInfos = new JSONArray(); - String hql = "from IntentInstance i where i.instanceId in (:ids)"; + String hql = "from CCVPNInstance i where i.instanceId in (:ids)"; Query query = session.createQuery(hql).setParameter("ids", ids); - List queryResult= query.list(); + List queryResult= query.list(); if (queryResult != null && queryResult.size() > 0) { - for (IntentInstance instance : queryResult) { + for (CCVPNInstance instance : queryResult) { JSONObject instanceInfo = new JSONObject(); instanceInfo.put("id", instance.getInstanceId()); instanceInfo.put("status", instance.getStatus()); diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/IntentControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/IntentControllerTest.java index 4093d56d..e82ed0af 100644 --- a/server/src/test/java/org/onap/usecaseui/server/controller/IntentControllerTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/controller/IntentControllerTest.java @@ -24,7 +24,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.onap.usecaseui.server.bean.HttpResponseResult; -import org.onap.usecaseui.server.bean.intent.IntentInstance; +import org.onap.usecaseui.server.bean.intent.CCVPNInstance; import org.onap.usecaseui.server.bean.intent.IntentModel; import org.onap.usecaseui.server.service.intent.IntentInstanceService; import org.onap.usecaseui.server.service.intent.IntentService; @@ -159,8 +159,8 @@ public class IntentControllerTest { } @Test public void getFinishedInstanceInfo() { - List instanceList = new ArrayList<>(); - IntentInstance instance = new IntentInstance(); + List instanceList = new ArrayList<>(); + CCVPNInstance instance = new CCVPNInstance(); instance.setInstanceId("instanceId"); instance.setName("name"); instanceList.add(instance); diff --git a/server/src/test/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImplTest.java index c1e7bdd1..8e591ea6 100644 --- a/server/src/test/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImplTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImplTest.java @@ -32,7 +32,7 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.onap.usecaseui.server.bean.intent.IntentInstance; +import org.onap.usecaseui.server.bean.intent.CCVPNInstance; import org.onap.usecaseui.server.bean.intent.IntentModel; import org.onap.usecaseui.server.service.intent.IntentApiService; import org.onap.usecaseui.server.service.lcm.domain.so.SOService; @@ -81,7 +81,7 @@ public class IntentInstanceServiceImplTest { @Test public void queryIntentInstance() { - IntentInstance instance = new IntentInstance(); + CCVPNInstance instance = new CCVPNInstance(); instance.setInstanceId("1"); instance.setJobId("1"); instance.setStatus("1"); @@ -95,7 +95,7 @@ public class IntentInstanceServiceImplTest { } @Test public void createIntentInstance() throws IOException { - IntentInstance instance = new IntentInstance(); + CCVPNInstance instance = new CCVPNInstance(); instance.setInstanceId("1"); instance.setJobId("1"); instance.setStatus("1"); @@ -119,9 +119,9 @@ public class IntentInstanceServiceImplTest { public void getIntentInstanceProgress() throws IOException { Query query1 = Mockito.mock(Query.class); - when(session.createQuery("from IntentInstance where deleteState = 0 and status = '0'")).thenReturn(query1); - List q = new ArrayList<>(); - IntentInstance instance = new IntentInstance(); + when(session.createQuery("from CCVPNInstance where deleteState = 0 and status = '0'")).thenReturn(query1); + List q = new ArrayList<>(); + CCVPNInstance instance = new CCVPNInstance(); instance.setInstanceId("1"); q.add(instance); when(query1.list()).thenReturn(q); @@ -155,9 +155,9 @@ public class IntentInstanceServiceImplTest { @Test public void getIntentInstanceBandwidth() throws IOException { Query query1 = Mockito.mock(Query.class); - when(session.createQuery("from IntentInstance where deleteState = 0 and status = '1'")).thenReturn(query1); - List q = new ArrayList<>(); - IntentInstance instance = new IntentInstance(); + when(session.createQuery("from CCVPNInstance where deleteState = 0 and status = '1'")).thenReturn(query1); + List q = new ArrayList<>(); + CCVPNInstance instance = new CCVPNInstance(); instance.setInstanceId("1"); instance.setResourceInstanceId("1"); q.add(instance); @@ -301,7 +301,7 @@ public class IntentInstanceServiceImplTest { @Test public void deleteIntentInstance() throws IOException { - IntentInstance instance = new IntentInstance(); + CCVPNInstance instance = new CCVPNInstance(); instance.setResourceInstanceId("1"); Query query = Mockito.mock(Query.class); @@ -324,7 +324,7 @@ public class IntentInstanceServiceImplTest { @Test public void activeIntentInstance() throws IOException { - IntentInstance instance = new IntentInstance(); + CCVPNInstance instance = new CCVPNInstance(); instance.setInstanceId("1"); instance.setJobId("1"); instance.setStatus("1"); diff --git a/standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql b/standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql index e6a4c1ed..6a3cf87c 100644 --- a/standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql +++ b/standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql @@ -164,10 +164,10 @@ CREATE TABLE instance_performance ); -- ---------------------------- --- Table structure for intent_instance +-- Table structure for ccvpn_instance -- ---------------------------- -DROP TABLE IF EXISTS intent_instance; -CREATE TABLE intent_instance +DROP TABLE IF EXISTS ccvpn_instance; +CREATE TABLE ccvpn_instance ( id serial not null constraint intent_instance_pk -- cgit 1.2.3-korg