From 2ce511263486d6002df45920eb99aa5d0e5fb527 Mon Sep 17 00:00:00 2001 From: Jerry Flood Date: Tue, 19 Mar 2019 16:43:06 -0400 Subject: DB Upgrade code re-factoring Changed DB generated keys to UUID Issue-ID: OPTFRA-459 Change-Id: Ic9314e580478c1db76c4c39e88c577908b2f0f0e Signed-off-by: Jerry Flood --- .../java/org/onap/optf/cmso/dispatcher/CmJob.java | 7 +- .../org/onap/optf/cmso/dispatcher/DispatchJob.java | 13 +- .../optf/cmso/dispatcher/rs/DispacherService.java | 8 +- .../cmso/dispatcher/rs/DispatcherServiceImpl.java | 16 +- .../org/onap/optf/cmso/eventq/CMSQueueJob.java | 10 +- .../onap/optf/cmso/eventq/DispatchedEventList.java | 16 +- .../org/onap/optf/cmso/model/ApprovalType.java | 24 +- .../cmso/model/ChangeManagementChangeWindow.java | 49 +-- .../optf/cmso/model/ChangeManagementDetail.java | 39 ++- .../optf/cmso/model/ChangeManagementGroup.java | 48 +-- .../optf/cmso/model/ChangeManagementSchedule.java | 46 +-- .../java/org/onap/optf/cmso/model/DomainData.java | 28 +- .../java/org/onap/optf/cmso/model/HelloWorld.java | 58 ---- .../java/org/onap/optf/cmso/model/Schedule.java | 32 +- .../org/onap/optf/cmso/model/ScheduleApproval.java | 52 ++-- .../org/onap/optf/cmso/model/ScheduleEvent.java | 163 ---------- .../org/onap/optf/cmso/model/ScheduleQuery.java | 23 +- .../onap/optf/cmso/model/dao/ApprovalTypeDAO.java | 10 +- .../model/dao/ChangeManagementChangeWindowDAO.java | 18 +- .../model/dao/ChangeManagementDetailDAOImpl.java | 20 +- .../cmso/model/dao/ChangeManagementGroupDAO.java | 18 +- .../model/dao/ChangeManagementScheduleDAO.java | 27 +- .../onap/optf/cmso/model/dao/DomainDataDAO.java | 10 +- .../optf/cmso/model/dao/ScheduleApprovalDAO.java | 10 +- .../org/onap/optf/cmso/model/dao/ScheduleDAO.java | 15 +- .../onap/optf/cmso/model/dao/ScheduleEventDAO.java | 53 ---- .../optf/cmso/model/dao/ScheduleQueryDAOImpl.java | 18 +- .../optf/cmso/optimizer/CMSOptimizerClient.java | 4 +- .../optf/cmso/optimizer/OptimizerQuartzJob.java | 5 +- .../cmso/service/rs/BaseSchedulerServiceImpl.java | 27 +- .../service/rs/CMSOOptimizedScheduleService.java | 74 +++++ .../rs/CMSOOptimizedScheduleServiceImpl.java | 122 ++++++++ .../cmso/service/rs/CMSOOptimizerCallbackImpl.java | 4 +- .../onap/optf/cmso/service/rs/CMSOServiceImpl.java | 51 +-- .../optf/cmso/service/rs/CmQueryParameters.java | 342 ++++++++++----------- .../rs/models/v2/CMSOOptimizedScheduleService.java | 74 ----- .../v2/CMSOOptimizedScheduleServiceImpl.java | 122 -------- .../onap/optf/cmso/sostatus/MsoStatusClient.java | 6 +- .../org/onap/optf/cmso/sostatus/MsoStatusJob.java | 11 +- .../onap/optf/cmso/sostatus/ScheduleStatusJob.java | 15 +- .../onap/optf/cmso/ticketmgt/TmStatusClient.java | 17 +- 41 files changed, 770 insertions(+), 935 deletions(-) delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/HelloWorld.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleEventDAO.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleService.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleServiceImpl.java (limited to 'cmso-service') diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java index 880566a..f29d6c6 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java @@ -32,6 +32,7 @@ package org.onap.optf.cmso.dispatcher; import java.util.Map; +import java.util.UUID; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -103,19 +104,19 @@ public class CmJob implements Job { public void execute(JobExecutionContext context) throws JobExecutionException { Mdc.quartzJobBegin(context); debug.debug(LogMessages.CM_JOB, "Entered"); - Integer id = context.getJobDetail().getJobDataMap().getInt("key"); + String id = context.getJobDetail().getJobDataMap().getString("key"); try { // Hand this off to a transactional service loopback(id); } catch (Exception e) { log.warn("Unexpected exception", e); } finally { - dispatchedEventList.remove(id); + dispatchedEventList.remove(UUID.fromString(id)); } debug.debug(LogMessages.CM_JOB, "Exited"); } - public void loopback(Integer id) { + public void loopback(String id) { Map mdcSave = Mdc.save(); try { String url = env.getProperty("cmso.dispatch.url", "http://localhost:8089"); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java index cb8597f..60d8bdb 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,8 @@ import java.net.InetAddress; import java.util.Date; import java.util.HashSet; import java.util.Set; +import java.util.UUID; + import org.onap.optf.cmso.common.CMSStatusEnum; import org.onap.optf.cmso.common.LogMessages; import org.onap.optf.cmso.model.ChangeManagementGroup; @@ -52,6 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.att.eelf.i18n.EELFResourceManager; @@ -86,15 +89,15 @@ public class DispatchJob { @Autowired Environment env; - public void execute(Integer id) throws JobExecutionException { + public void execute(UUID id) throws JobExecutionException { debug.debug(LogMessages.CM_JOB, "Entered"); try { // No other instance can read this cmso until we are done. ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(id); cmSchedule.setDispatcherInstance(InetAddress.getLocalHost().getHostAddress()); - ChangeManagementGroup group = cmGroupDAO.findById(cmSchedule.getChangeManagementGroupsId()).orElse(null); + ChangeManagementGroup group = cmGroupDAO.findById(cmSchedule.getChangeManagementGroupUuid()).orElse(null); if (group != null) { - Schedule schedule = scheduleDAO.findById(group.getSchedulesId()).orElse(null); + Schedule schedule = scheduleDAO.findById(group.getSchedulesUuid()).orElse(null); if (schedule != null) { schedule.setStatus(CMSStatusEnum.NotificationsInitiated.toString()); if (safeToDispatch(cmSchedule, schedule)) diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java index adc3260..3c53759 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java @@ -59,7 +59,7 @@ public interface DispacherService { @ApiOperation(value = "", notes = "Does dispsatch of provided cm schedule id.", response = Integer.class) @ApiResponses( value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")}) - public Response dispatchSchedule(@ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") Integer id, + public Response dispatchSchedule(@ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") String id, @Context UriInfo uri, @Context HttpServletRequest request); // ****************************************************************** @@ -70,7 +70,7 @@ public interface DispacherService { @ApiResponses( value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")}) public Response dispatchOptimizer( - @ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") Integer id, @Context UriInfo uri, + @ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") String id, @Context UriInfo uri, @Context HttpServletRequest request); // ****************************************************************** @@ -81,7 +81,7 @@ public interface DispacherService { @ApiResponses( value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")}) public Response dispatchScheduleStatus( - @ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") Integer id, @Context UriInfo uri, + @ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") String id, @Context UriInfo uri, @Context HttpServletRequest request); // ****************************************************************** @@ -91,7 +91,7 @@ public interface DispacherService { @ApiOperation(value = "", notes = "Does dispsatch of provided cm schedule id.", response = Integer.class) @ApiResponses( value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")}) - public Response dispatchSoStatus(@ApiParam(value = "Identifier", allowMultiple = true) @PathParam("id") Integer id, + public Response dispatchSoStatus(@ApiParam(value = "Identifier", allowMultiple = true) @PathParam("id") String id, @Context UriInfo uri, @Context HttpServletRequest request); } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java index 67a69cb..feea350 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java @@ -31,6 +31,8 @@ package org.onap.optf.cmso.dispatcher.rs; +import java.util.UUID; + import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; @@ -68,10 +70,11 @@ public class DispatcherServiceImpl implements DispacherService { @Override @Transactional - public Response dispatchSchedule(Integer id, UriInfo uri, HttpServletRequest request) { + public Response dispatchSchedule(String id, UriInfo uri, HttpServletRequest request) { debug.debug("dispatchSchedule entered {}" , id); try { - dispatchJob.execute(id); + UUID uuid = UUID.fromString(id); + dispatchJob.execute(uuid); } catch (Exception e) { errors.error(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); debug.error(e.getMessage(), e); @@ -82,10 +85,11 @@ public class DispatcherServiceImpl implements DispacherService { @Override @Transactional - public Response dispatchOptimizer(Integer id, UriInfo uri, HttpServletRequest request) { + public Response dispatchOptimizer(String id, UriInfo uri, HttpServletRequest request) { debug.debug("dispatchOptimizer entered {}", id); try { - optimizerClient.scheduleOptimization(id); + UUID uuid = UUID.fromString(id); + optimizerClient.scheduleOptimization(uuid); } catch (Exception e) { errors.error(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); debug.error(e.getMessage(), e); @@ -97,7 +101,7 @@ public class DispatcherServiceImpl implements DispacherService { @Override @Transactional - public Response dispatchScheduleStatus(Integer id, UriInfo uri, HttpServletRequest request) { + public Response dispatchScheduleStatus(String id, UriInfo uri, HttpServletRequest request) { debug.debug("dispatchScheduleStatus entered {}", id); try { tmStatusClient.checkStatus(id); @@ -111,7 +115,7 @@ public class DispatcherServiceImpl implements DispacherService { @Override @Transactional - public Response dispatchSoStatus(Integer id, UriInfo uri, HttpServletRequest request) { + public Response dispatchSoStatus(String id, UriInfo uri, HttpServletRequest request) { debug.debug("dispatchSoStatus entered {}", id); try { msoStatusClient.execute(id); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java index 59df59f..0987f8b 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,9 +87,9 @@ public class CMSQueueJob { return false; for (ChangeManagementSchedule schedule : schedules) { try { - if (!dispatchedEventList.isAlreadyDispatched(schedule.getId())) { + if (!dispatchedEventList.isAlreadyDispatched(schedule.getUuid())) { scheduleCmJob(schedule); - dispatchedEventList.addToDispathcedEventList(schedule.getId()); + dispatchedEventList.addToDispathcedEventList(schedule.getUuid()); } } catch (org.quartz.SchedulerException e) { debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); @@ -118,7 +118,7 @@ public class CMSQueueJob { dispatchTime = startTime - dispatherLeadTime; JobDetail jobDetail = JobBuilder.newJob(CmJob.class).build(); - jobDetail.getJobDataMap().put("key", schedule.getId()); + jobDetail.getJobDataMap().put("key", schedule.getUuid().toString()); TriggerBuilder tb = TriggerBuilder.newTrigger().forJob(jobDetail); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/DispatchedEventList.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/DispatchedEventList.java index 0c346d3..3e02cd1 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/DispatchedEventList.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/DispatchedEventList.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,8 @@ package org.onap.optf.cmso.eventq; import java.util.HashSet; import java.util.Set; +import java.util.UUID; + import org.springframework.stereotype.Component; /** @@ -45,18 +47,18 @@ import org.springframework.stereotype.Component; @Component public class DispatchedEventList { - private Set list = new HashSet<>(); + private Set list = new HashSet<>(); - public synchronized void addToDispathcedEventList(Integer id) { + public synchronized void addToDispathcedEventList(UUID id) { list.add(id); } - public synchronized void remove(Integer id) { + public synchronized void remove(UUID id) { list.remove(id); } - public synchronized boolean isAlreadyDispatched(Integer id) { - return list.contains(id); + public synchronized boolean isAlreadyDispatched(UUID uuid) { + return list.contains(uuid); } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java index 121774b..6009040 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java @@ -32,10 +32,10 @@ package org.onap.optf.cmso.model; import java.io.Serializable; +import java.util.UUID; + import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.Table; @@ -51,8 +51,7 @@ public class ApprovalType implements Serializable { private static final long serialVersionUID = 1L; @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private Integer id; + private UUID uuid; @Column(name = "approval_count") private Integer approvalCount; @@ -66,15 +65,18 @@ public class ApprovalType implements Serializable { public ApprovalType() {} - public Integer getId() { - return this.id; - } - public void setId(Integer id) { - this.id = id; - } + public UUID getUuid() { + return uuid; + } + + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + - public Integer getApprovalCount() { + public Integer getApprovalCount() { return this.approvalCount; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java index 7224508..210e61a 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java @@ -32,17 +32,20 @@ package org.onap.optf.cmso.model; import java.io.Serializable; +import java.util.UUID; + import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Transient; + import org.joda.time.format.ISODateTimeFormat; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; + import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -59,8 +62,7 @@ public class ChangeManagementChangeWindow implements Serializable { @JsonIgnore @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private Integer id; + private UUID uuid; @JsonIgnore @Column(name = "finish_time") @@ -81,18 +83,11 @@ public class ChangeManagementChangeWindow implements Serializable { private String startTime; @JsonIgnore - @Column(name = "change_management_groups_id") - private Integer changeManagementGroupsId; + @Column(name = "change_management_group_uuid") + private UUID changeManagementGroupUuid; public ChangeManagementChangeWindow() {} - public Integer getId() { - return this.id; - } - - public void setId(Integer id) { - this.id = id; - } public String getFinishTime() { if (finishTimeMillis != null) @@ -110,15 +105,29 @@ public class ChangeManagementChangeWindow implements Serializable { public void setStartTime(String startTime) {} - public Integer getChangeManagementGroupsId() { - return changeManagementGroupsId; - } - public void setChangeManagementGroupsId(Integer changeManagementGroupsId) { - this.changeManagementGroupsId = changeManagementGroupsId; - } + public UUID getUuid() { + return uuid; + } + + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + + + public UUID getChangeManagementGroupUuid() { + return changeManagementGroupUuid; + } + + + public void setChangeManagementGroupUuid(UUID changeManagementGroupUuid) { + this.changeManagementGroupUuid = changeManagementGroupUuid; + } + - public Long getFinishTimeMillis() { + public Long getFinishTimeMillis() { return finishTimeMillis; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java index 31c4a2b..4f0e804 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java @@ -31,16 +31,19 @@ package org.onap.optf.cmso.model; +import java.util.UUID; + import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.Transient; + import org.joda.time.format.ISODateTimeFormat; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; + import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -59,8 +62,7 @@ import io.swagger.annotations.ApiModelProperty; public class ChangeManagementDetail { @Id @JsonIgnore - @GeneratedValue(strategy=GenerationType.IDENTITY) - private Integer id; + private UUID uuid; @ApiModelProperty(value = "Name of the VNF.") @Column(name = "vnf_name") @@ -168,7 +170,8 @@ public class ChangeManagementDetail { private String msoTime; @JsonIgnore - private Integer schedules_id; + @Column(name = "schedules_uuid") + private UUID schedulesUuid; public String getVnfName() { return vnfName; @@ -242,15 +245,27 @@ public class ChangeManagementDetail { this.policyId = policyId; } - public Integer getSchedulesId() { - return schedules_id; - } - public void setSchedulesId(Integer schedules_id) { - this.schedules_id = schedules_id; - } + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + + + + public UUID getSchedulesUuid() { + return schedulesUuid; + } + + public void setSchedulesUuid(UUID schedulesUuid) { + this.schedulesUuid = schedulesUuid; + } - public Long getStartTimeMillis() { + public Long getStartTimeMillis() { return startTimeMillis; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java index 6aeb325..39efb3f 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java @@ -33,17 +33,20 @@ package org.onap.optf.cmso.model; import java.io.Serializable; import java.util.List; +import java.util.UUID; + import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Transient; + import org.joda.time.format.ISODateTimeFormat; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; + import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -60,8 +63,7 @@ public class ChangeManagementGroup implements Serializable { @JsonIgnore @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private Integer id; + private UUID uuid; @JsonIgnore @Column(name = "finish_time") @@ -95,8 +97,8 @@ public class ChangeManagementGroup implements Serializable { private String startTime; @JsonIgnore - @Column(name = "schedules_id") - private Integer schedulesId; + @Column(name = "schedules_uuid") + private UUID schedulesUuid; @Column(name = "additional_duration_in_secs") @ApiModelProperty(value = "Time added to the workflow interval to allow for rollback in case of failure.") @@ -122,13 +124,6 @@ public class ChangeManagementGroup implements Serializable { public ChangeManagementGroup() {} - public Integer getId() { - return this.id; - } - - public void setId(Integer id) { - this.id = id; - } public String getFinishTime() { if (finishTimeMillis != null) @@ -162,13 +157,6 @@ public class ChangeManagementGroup implements Serializable { public void setStartTime(String startTime) {} - public Integer getSchedulesId() { - return schedulesId; - } - - public void setSchedulesId(Integer schedulesId) { - this.schedulesId = schedulesId; - } public Integer getAdditionalDurationInSecs() { return additionalDurationInSecs; @@ -234,4 +222,24 @@ public class ChangeManagementGroup implements Serializable { this.changeManagementSchedules = changeManagementSchedules; } + + public UUID getUuid() { + return uuid; + } + + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + + public UUID getSchedulesUuid() { + return schedulesUuid; + } + + + public void setSchedulesUuid(UUID schedulesUuid) { + this.schedulesUuid = schedulesUuid; + } + } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java index 9690290..680fc99 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java @@ -32,18 +32,21 @@ package org.onap.optf.cmso.model; import java.io.Serializable; +import java.util.UUID; + import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Transient; + import org.joda.time.format.ISODateTimeFormat; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; + import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -61,8 +64,7 @@ public class ChangeManagementSchedule implements Serializable { @JsonIgnore @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private Integer id; + private UUID uuid; @ApiModelProperty(value = "TM Change Id") @Column(name = "tm_change_id") @@ -107,9 +109,9 @@ public class ChangeManagementSchedule implements Serializable { @Column(name = "vnf_name") private String vnfName; - @Column(name = "change_management_groups_id") + @Column(name = "change_management_group_uuid") @JsonIgnore - private Integer changeManagementGroupsId; + private UUID changeManagementGroupUuid; @JsonIgnore @Column(name = "dispatch_time") @@ -162,14 +164,6 @@ public class ChangeManagementSchedule implements Serializable { public ChangeManagementSchedule() {} - public Integer getId() { - return this.id; - } - - public void setId(Integer id) { - this.id = id; - } - public String getFinishTime() { if (finishTimeMillis != null) return ISODateTimeFormat.dateTimeNoMillis().print(finishTimeMillis); @@ -218,15 +212,25 @@ public class ChangeManagementSchedule implements Serializable { this.tmChangeId = tmChangeId; } - public Integer getChangeManagementGroupsId() { - return changeManagementGroupsId; - } - public void setChangeManagementGroupsId(Integer changeManagementGroupsId) { - this.changeManagementGroupsId = changeManagementGroupsId; - } + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + + public UUID getChangeManagementGroupUuid() { + return changeManagementGroupUuid; + } + + public void setChangeManagementGroupUuid(UUID changeManagementGroupUuid) { + this.changeManagementGroupUuid = changeManagementGroupUuid; + } - public String getDispatchTime() { + public String getDispatchTime() { if (dispatchTimeMillis != null) return ISODateTimeFormat.dateTimeNoMillis().print(dispatchTimeMillis); return null; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java index fc86964..3bb0bea 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java @@ -32,15 +32,17 @@ package org.onap.optf.cmso.model; import java.io.Serializable; +import java.util.UUID; + import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQuery; import javax.persistence.Table; + import com.fasterxml.jackson.annotation.JsonIgnore; + import io.swagger.annotations.ApiModel; /** @@ -56,29 +58,31 @@ public class DomainData implements Serializable { @JsonIgnore @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private Integer id; + private UUID uuid; private String name; private String value; @ManyToOne(optional = true) - @JoinColumn(name = "schedules_id", nullable = false, updatable = false) + @JoinColumn(name = "schedules_uuid", nullable = false, updatable = false) @JsonIgnore private Schedule schedule; public DomainData() {} - public Integer getId() { - return this.id; - } - public void setId(Integer id) { - this.id = id; - } + public UUID getUuid() { + return uuid; + } + + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + - public String getName() { + public String getName() { return this.name; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/HelloWorld.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/HelloWorld.java deleted file mode 100644 index ed09ad7..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/HelloWorld.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - * - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * 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.optf.cmso.model; - -public class HelloWorld { - - private String message; - - public HelloWorld() { - // needed for deserializer - } - - public HelloWorld(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return "message = " + getMessage(); - } -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java index d6fe4f9..624e376 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java @@ -34,22 +34,25 @@ package org.onap.optf.cmso.model; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.UUID; + import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; + import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; import org.joda.time.format.ISODateTimeFormat; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; + import io.swagger.annotations.ApiModelProperty; /** @@ -64,8 +67,7 @@ public class Schedule implements Serializable { @JsonIgnore @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private Integer id; + private UUID uuid; @JsonIgnore @Column(name = "create_date_time") @@ -160,15 +162,23 @@ public class Schedule implements Serializable { public Schedule() {} - public Integer getId() { - return this.id; - } + public UUID getUuid() { + return uuid; + } - public void setId(Integer id) { - this.id = id; - } + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public void setDomainData(List domainData) { + this.domainData = domainData; + } + + public void setScheduleApprovals(List scheduleApprovals) { + this.scheduleApprovals = scheduleApprovals; + } - public String getCreateDateTime() { + public String getCreateDateTime() { if (createDateTimeMillis != null) return ISODateTimeFormat.dateTimeNoMillis().print(this.createDateTimeMillis); return null; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java index dee3c42..3239ae3 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java @@ -32,19 +32,22 @@ package org.onap.optf.cmso.model; import java.io.Serializable; +import java.util.UUID; + import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Transient; + import org.joda.time.format.ISODateTimeFormat; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; + import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -60,9 +63,8 @@ public class ScheduleApproval implements Serializable { private static final long serialVersionUID = 1L; @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) @JsonIgnore - private Integer id; + private UUID uuid; @JsonIgnore @Column(name = "approval_date_time") @@ -82,23 +84,16 @@ public class ScheduleApproval implements Serializable { private String userId; @ManyToOne(optional = true) - @JoinColumn(name = "schedules_id", nullable = false, updatable = false) + @JoinColumn(name = "schedules_uuid", nullable = false, updatable = false) @JsonIgnore private Schedule schedule; @JsonIgnore - @Column(name = "approval_type_id") - private Integer approvalTypeId; + @Column(name = "approval_types_uuid") + private UUID approvalTypesUuid; public ScheduleApproval() {} - public Integer getId() { - return this.id; - } - - public void setId(Integer id) { - this.id = id; - } public String getApprovalDateTime() { if (approvalDateTimeMillis != null) @@ -124,13 +119,6 @@ public class ScheduleApproval implements Serializable { this.userId = userId; } - public Integer getApprovalTypeId() { - return approvalTypeId; - } - - public void setApprovalTypeId(Integer approvalTypeId) { - this.approvalTypeId = approvalTypeId; - } public void setSchedule(Schedule schedule) { this.schedule = schedule; @@ -148,4 +136,26 @@ public class ScheduleApproval implements Serializable { this.approvalDateTimeMillis = approvalDateTimeMillis; } + + public UUID getUuid() { + return uuid; + } + + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + + public UUID getApprovalTypesUuid() { + return approvalTypesUuid; + } + + + public void setApprovalTypesUuid(UUID approvalTypesUuid) { + this.approvalTypesUuid = approvalTypesUuid; + } + + + } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java deleted file mode 100644 index 46cb46e..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - * - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * 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.optf.cmso.model; - -import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Lob; -import javax.persistence.NamedQuery; -import javax.persistence.Table; -import javax.persistence.Transient; -import org.joda.time.format.ISODateTimeFormat; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The persistent class for the schedule_events database table. - * - */ -@Entity -@Table(name = "SCHEDULE_EVENTS") -@NamedQuery(name = "ScheduleEvent.findAll", query = "SELECT s FROM ScheduleEvent s") -public class ScheduleEvent implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private Integer id; - - private String domain; - - @Lob - @Column(name = "event_text") - private String eventText; - - @JsonIgnore - @Column(name = "event_time") - private Long eventTimeMillis; - - @JsonProperty - @Transient - private String eventTime; - - @JsonIgnore - @Column(name = "reminder_time") - private Long reminderTimeMillis; - - @JsonProperty - @Transient - private String reminderTime; - - @Column(name = "schedules_id") - private Integer schedulesId; - - private String status; - - public ScheduleEvent() {} - - public Integer getId() { - return this.id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getDomain() { - return this.domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public String getEventText() { - return this.eventText; - } - - public void setEventText(String eventText) { - this.eventText = eventText; - } - - public Integer getSchedulesId() { - return this.schedulesId; - } - - public void setSchedulesId(Integer schedulesId) { - this.schedulesId = schedulesId; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Long getEventTimeMillis() { - return eventTimeMillis; - } - - public void setEventTimeMillis(Long eventTimeMillis) { - this.eventTimeMillis = eventTimeMillis; - } - - public String getEventTime() { - if (eventTimeMillis != null) - return ISODateTimeFormat.dateTimeNoMillis().print(this.eventTimeMillis); - return null; - } - - public void setEventTime(String eventTime) {} - - public Long getReminderTimeMillis() { - return reminderTimeMillis; - } - - public void setReminderTimeMillis(Long reminderTimeMillis) { - this.reminderTimeMillis = reminderTimeMillis; - } - - public String getReminderTime() { - if (reminderTimeMillis != null) - return ISODateTimeFormat.dateTimeNoMillis().print(this.reminderTimeMillis); - return null; - } - - public void setReminderTime(String reminderTime) {} - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleQuery.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleQuery.java index 84d3e5c..628fc6f 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleQuery.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleQuery.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,8 @@ package org.onap.optf.cmso.model; +import java.util.UUID; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -38,15 +40,16 @@ import javax.persistence.Id; @Entity public class ScheduleQuery { @Id - @Column(name = "id") - private Integer id; + @Column(name = "uuid") + private UUID uuid; + + public UUID getUuid() { + return uuid; + } - public Integer getId() { - return id; - } + public void setUuid(UUID uuid) { + this.uuid = uuid; + } - public void setId(Integer id) { - this.id = id; - } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java index 7eb2430..9e4b546 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,12 +33,14 @@ package org.onap.optf.cmso.model.dao; import java.util.List; import java.util.Optional; +import java.util.UUID; + import org.onap.optf.cmso.model.ApprovalType; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ApprovalTypeDAO extends PagingAndSortingRepository { - Optional findById(Integer id); +public interface ApprovalTypeDAO extends PagingAndSortingRepository { + Optional findById(UUID id); ApprovalType save(ApprovalType persisted); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java index 293209e..303be20 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,24 +33,26 @@ package org.onap.optf.cmso.model.dao; import java.util.List; import java.util.Optional; +import java.util.UUID; + import org.onap.optf.cmso.model.ChangeManagementChangeWindow; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; public interface ChangeManagementChangeWindowDAO - extends PagingAndSortingRepository { - Optional findById(Integer id); + extends PagingAndSortingRepository { + Optional findById(UUID id); ChangeManagementChangeWindow save(ChangeManagementChangeWindow persisted); void delete(ChangeManagementChangeWindow toDelete); - @Query(value = "SELECT d FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupsId = ?1") - List findByGroupsID(Integer id); + @Query(value = "SELECT d FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupUuid = ?1") + List findByGroupsUUID(UUID id); @Modifying - @Query(value = "DELETE FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupsId = ?1") - int deleteByChangeManagementGroupId(int id); + @Query(value = "DELETE FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupUuid = ?1") + int deleteByChangeManagementGroupUuid(UUID id); } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java index 2c083d6..028241c 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class ChangeManagementDetailDAOImpl implements ChangeManagementDetailDAO @Override public List searchScheduleDetails(String where, int limit) { StringBuilder sql = new StringBuilder(); - sql.append("select distinct" + " s.id as id," + " s.vnf_name as vnf_name," + " s.vnf_id as vnf_id," + sql.append("select distinct" + " s.uuid as uuid," + " s.vnf_name as vnf_name," + " s.vnf_id as vnf_id," + " s.status as status," + " s.tm_change_id as tm_change_Id," + " s.start_time as start_time," + " s.finish_time as finish_time," + " s.mso_request_id as mso_request_id," + " s.mso_status as mso_status," + " s.mso_message as mso_message," + " s.mso_time as mso_time," @@ -54,17 +54,17 @@ public class ChangeManagementDetailDAOImpl implements ChangeManagementDetailDAO + " s.status_message as status_message," + " s.tm_approval_status as tm_approval_status," + " s.tm_status as tm_status," + " g.group_id as group_id," + " g.last_instance_start_time as last_instance_start_time," + " g.policy_id as policy_id," - + " g.schedules_id as schedules_id" + + " g.schedules_uuid as schedules_uuid" // + " ss.schedule_id as scheduleId," // + " dd.name" + " from" + " CHANGE_MANAGEMENT_SCHEDULES s" - + " inner join CHANGE_MANAGEMENT_GROUPS g on s.change_management_groups_id = g.id" - + " inner join SCHEDULES ss on g.schedules_id = ss.id " - + " left outer join DOMAIN_DATA dd on ss.id = dd.schedules_id" - + " left outer join SCHEDULE_APPROVALS sa on ss.id = sa.schedules_id" - + " left outer join APPROVAL_TYPES at on sa.approval_type_id = at.id "); + + " inner join CHANGE_MANAGEMENT_GROUPS g on s.change_management_group_uuid = g.uuid" + + " inner join SCHEDULES ss on g.schedules_uuid = ss.uuid " + + " left outer join DOMAIN_DATA dd on ss.uuid = dd.schedules_uuid" + + " left outer join SCHEDULE_APPROVALS sa on ss.uuid = sa.schedules_uuid" + + " left outer join APPROVAL_TYPES at on sa.approval_types_uuid = at.uuid "); sql.append(where); - sql.append(" order by id "); + sql.append(" order by uuid "); if (limit > 0) sql.append("LIMIT " + limit); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java index 39f4baa..7acc228 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,21 +33,23 @@ package org.onap.optf.cmso.model.dao; import java.util.List; import java.util.Optional; +import java.util.UUID; + import org.onap.optf.cmso.model.ChangeManagementGroup; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ChangeManagementGroupDAO extends PagingAndSortingRepository { - Optional findById(Integer id); +public interface ChangeManagementGroupDAO extends PagingAndSortingRepository { + Optional findById(UUID id); ChangeManagementGroup save(ChangeManagementGroup persisted); void delete(ChangeManagementGroup toDelete); - @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesId = ?1") - List findBySchedulesID(Integer id); + @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesUuid = ?1") + List findBySchedulesID(UUID id); - @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesId = ?1 AND d.groupId = ?2") - ChangeManagementGroup findOneBySchedulesIDGroupID(Integer id, String groupId); + @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesUuid = ?1 AND d.groupId = ?2") + ChangeManagementGroup findOneBySchedulesIDGroupID(UUID id, String groupId); } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java index a089c2b..ad01a34 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,29 +33,32 @@ package org.onap.optf.cmso.model.dao; import java.util.List; import java.util.Optional; +import java.util.UUID; + import javax.persistence.LockModeType; + import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.springframework.data.jpa.repository.Lock; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ChangeManagementScheduleDAO extends PagingAndSortingRepository { - Optional findById(Integer id); +public interface ChangeManagementScheduleDAO extends PagingAndSortingRepository { + Optional findById(UUID id); ChangeManagementSchedule save(ChangeManagementSchedule persisted); void delete(ChangeManagementSchedule toDelete); - @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupsId = ?1") - List findByChangeManagementGroupId(Integer id); + @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1") + List findByChangeManagementGroupId(UUID id); @Modifying - @Query(value = "DELETE FROM ChangeManagementSchedule d WHERE d.changeManagementGroupsId = ?1") - public int deleteByChangeManagementGroupsId(Integer id); + @Query(value = "DELETE FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1") + public int deleteByChangeManagementGroupsId(UUID id); - @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupsId = ?1 AND d.vnfName = ?2") - ChangeManagementSchedule findOneByGroupIDAndVnfName(Integer id, String vnfName); + @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1 AND d.vnfName = ?2") + ChangeManagementSchedule findOneByGroupIDAndVnfName(UUID id, String vnfName); @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE (d.status = ?1 AND d.startTimeMillis <= ?2) or d.status = 'Scheduled Immediate' order by d.startTimeMillis") List findByStatusAndEndTime(String status, Long date); @@ -70,8 +73,8 @@ public interface ChangeManagementScheduleDAO extends PagingAndSortingRepository< @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.tmApprovalStatus = 'Pending Approval'") List findAllAwaitingTmApproval(); - @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.id = ?1") + @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.uuid = ?1") @Lock(LockModeType.PESSIMISTIC_WRITE) - ChangeManagementSchedule lockOne(Integer id); + ChangeManagementSchedule lockOne(UUID id); } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java index 9556938..75299a1 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,11 +32,13 @@ package org.onap.optf.cmso.model.dao; import java.util.Optional; +import java.util.UUID; + import org.onap.optf.cmso.model.DomainData; import org.springframework.data.repository.PagingAndSortingRepository; -public interface DomainDataDAO extends PagingAndSortingRepository { - Optional findById(Integer id); +public interface DomainDataDAO extends PagingAndSortingRepository { + Optional findById(UUID id); DomainData save(DomainData persisted); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java index d9badd0..3fabd63 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,11 +32,13 @@ package org.onap.optf.cmso.model.dao; import java.util.Optional; +import java.util.UUID; + import org.onap.optf.cmso.model.ScheduleApproval; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ScheduleApprovalDAO extends PagingAndSortingRepository { - Optional findById(Integer id); +public interface ScheduleApprovalDAO extends PagingAndSortingRepository { + Optional findById(UUID id); ScheduleApproval save(ScheduleApproval persisted); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java index f68fd22..90843c4 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,14 +33,17 @@ package org.onap.optf.cmso.model.dao; import java.util.List; import java.util.Optional; +import java.util.UUID; + import javax.persistence.LockModeType; + import org.onap.optf.cmso.model.Schedule; import org.springframework.data.jpa.repository.Lock; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ScheduleDAO extends PagingAndSortingRepository { - Optional findById(Integer id); +public interface ScheduleDAO extends PagingAndSortingRepository { + Optional findById(UUID id); Schedule save(Schedule persited); @@ -58,9 +61,9 @@ public interface ScheduleDAO extends PagingAndSortingRepository findAllInProgress(String string); - @Query(value = "SELECT d FROM Schedule d WHERE d.id = ?1") + @Query(value = "SELECT d FROM Schedule d WHERE d.uuid = ?1") @Lock(LockModeType.PESSIMISTIC_WRITE) - Schedule lockOne(Integer id); + Schedule lockOne(UUID id); @Query(value = "SELECT s FROM Schedule s WHERE s.optimizerTransactionId= ?1") @Lock(LockModeType.PESSIMISTIC_WRITE) diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleEventDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleEventDAO.java deleted file mode 100644 index c3c2483..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleEventDAO.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - * - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * 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.optf.cmso.model.dao; - -import java.util.List; -import java.util.Optional; -import org.onap.optf.cmso.model.ScheduleEvent; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface ScheduleEventDAO extends PagingAndSortingRepository { - Optional findById(Integer id); - - ScheduleEvent save(ScheduleEvent persisted); - - void delete(ScheduleEvent toDelete); - - @Query(value = "SELECT d FROM ScheduleEvent d WHERE d.schedulesId = ?1") - List findByScheduleId(Integer id); - - @Query(value = "SELECT d FROM ScheduleEvent d WHERE d.status = ?1 AND d.reminderTimeMillis <= ?2") - List findByStatusAndEndTime(String status, Long date); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java index 37fbf52..80bb7f0 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,14 +46,14 @@ public class ScheduleQueryDAOImpl implements ScheduleQueryDAO { @Override public List searchSchedules(String where, int limit) { StringBuilder sql = new StringBuilder(); - sql.append("select distinct" + " ss.id as id" + " from" + " SCHEDULES ss" - + " left outer join CHANGE_MANAGEMENT_GROUPS g on ss.id = g.schedules_id" - + " left outer join CHANGE_MANAGEMENT_SCHEDULES s on g.id = s.change_management_groups_id" - + " left outer join DOMAIN_DATA dd on ss.id = dd.schedules_id" - + " left outer join SCHEDULE_APPROVALS sa on ss.id = sa.schedules_id" - + " left outer join APPROVAL_TYPES at on sa.approval_type_id = at.id "); + sql.append("select distinct" + " ss.uuid as uuid" + " from" + " SCHEDULES ss" + + " left outer join CHANGE_MANAGEMENT_GROUPS g on ss.uuid = g.schedules_uuid" + + " left outer join CHANGE_MANAGEMENT_SCHEDULES s on g.uuid = s.change_management_group_uuid" + + " left outer join DOMAIN_DATA dd on ss.uuid = dd.schedules_uuid" + + " left outer join SCHEDULE_APPROVALS sa on ss.uuid = sa.schedules_uuid" + + " left outer join APPROVAL_TYPES at on sa.approval_types_uuid = at.uuid "); sql.append(where); - sql.append(" order by id "); + sql.append(" order by uuid "); if (limit > 0) sql.append("LIMIT " + limit); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java index 9feea2d..a773798 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java @@ -85,7 +85,7 @@ public class CMSOptimizerClient { @Autowired PropertiesManagement pm; - public boolean scheduleOptimization(Integer id) { + public boolean scheduleOptimization(UUID uuid) { Map mdcSave = Mdc.save(); try { String optimizerurl = env.getProperty("cmso.optimizer.url"); @@ -94,7 +94,7 @@ public class CMSOptimizerClient { Integer maxAttempts = env.getProperty("cmso.optimizer.maxAttempts", Integer.class, 20); // Ensure that only one cmso is requsting this call to optimizer - Schedule schedule = scheduleDAO.lockOne(id); + Schedule schedule = scheduleDAO.lockOne(uuid); if (!schedule.getStatus().equals(CMSStatusEnum.PendingSchedule.toString())) return false; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java index 39d590b..12d56f3 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java @@ -33,6 +33,8 @@ package org.onap.optf.cmso.optimizer; import java.util.List; import java.util.Map; +import java.util.UUID; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; @@ -57,6 +59,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.scheduling.quartz.QuartzJobBean; import org.springframework.stereotype.Component; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -107,7 +110,7 @@ public class OptimizerQuartzJob extends QuartzJobBean { } public void scheduleOptimization(Schedule s) { - Integer id = s.getId(); + UUID id = s.getUuid(); Map mdcSave = Mdc.save(); try { String url = env.getProperty("cmso.dispatch.url", "http://localhost:8089"); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java index 2e0cfeb..787bd60 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java @@ -35,7 +35,10 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; + import javax.ws.rs.core.Response.Status; + import org.onap.optf.cmso.common.ApprovalStatusEnum; import org.onap.optf.cmso.common.CMSStatusEnum; import org.onap.optf.cmso.common.LogMessages; @@ -54,6 +57,7 @@ import org.onap.optf.cmso.service.rs.models.ApprovalMessage; import org.onap.optf.cmso.service.rs.models.ScheduleMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -82,6 +86,7 @@ public class BaseSchedulerServiceImpl { throw new CMSAlreadyExistsException(scheduleMessage.getDomain(), scheduleMessage.getScheduleId()); } s = new Schedule(); + s.setUuid(UUID.randomUUID()); s.setUserId(scheduleMessage.getUserId()); s.setCreateDateTimeMillis(System.currentTimeMillis()); s.setDomain(scheduleMessage.getDomain()); @@ -96,6 +101,7 @@ public class BaseSchedulerServiceImpl { s.setStatus(CMSStatusEnum.PendingSchedule.toString()); scheduleDAO.save(s); for (DomainData dd : domainData) { + dd.setUuid(UUID.randomUUID()); s.addDomainData(dd); domainDataDAO.save(dd); } @@ -153,15 +159,16 @@ public class BaseSchedulerServiceImpl { if (s.getScheduleApprovals() != null) { for (ScheduleApproval scheduleApproval : s.getScheduleApprovals()) { if (scheduleApproval.getUserId().equals(approvalMessage.getApprovalUserId()) - && scheduleApproval.getApprovalTypeId().equals(approvalType.getId())) { + && scheduleApproval.getApprovalTypesUuid().equals(approvalType.getUuid())) { sa = scheduleApproval; } } } if (sa == null) { sa = new ScheduleApproval(); + sa.setUuid(UUID.randomUUID()); sa.setSchedule(s); - sa.setApprovalTypeId(approvalType.getId()); + sa.setApprovalTypesUuid(approvalType.getUuid()); sa.setUserId(approvalMessage.getApprovalUserId()); } // Ignore what time is on the message @@ -181,18 +188,18 @@ public class BaseSchedulerServiceImpl { } private boolean allApprovalsReceived(Schedule schedule, ScheduleApproval sa) { - Map requiredApprovalsByType = new HashMap(); // Approval + Map requiredApprovalsByType = new HashMap<>(); // Approval // countdown - Map approvalsByType = new HashMap(); // Just + Map approvalsByType = new HashMap<>(); // Just // for // logging List approvalTypes = approvalTypeDAO.findByDomain(schedule.getDomain()); for (ApprovalType at : approvalTypes) { - Integer type = at.getId(); + UUID type = at.getUuid(); Integer count = at.getApprovalCount(); requiredApprovalsByType.put(type, count); - approvalsByType.put(at.getId(), at); + approvalsByType.put(at.getUuid(), at); } // Account for approvals so far @@ -205,17 +212,17 @@ public class BaseSchedulerServiceImpl { } for (ScheduleApproval approval : existingApprovals) { if (approval.getStatus().equals(ApprovalStatusEnum.Accepted.toString())) { - Integer remaining = requiredApprovalsByType.get(approval.getApprovalTypeId()); + Integer remaining = requiredApprovalsByType.get(approval.getApprovalTypesUuid()); if (remaining != null) { remaining = remaining - 1; - requiredApprovalsByType.put(approval.getApprovalTypeId(), remaining); + requiredApprovalsByType.put(approval.getApprovalTypesUuid(), remaining); } else { - log.warn("Ignored Unidentified approval type {0} for domain {1}", approval.getApprovalTypeId(), + log.warn("Ignored Unidentified approval type {0} for domain {1}", approval.getApprovalTypesUuid(), schedule.getDomain()); } } } - for (Integer id : requiredApprovalsByType.keySet()) { + for (UUID id : requiredApprovalsByType.keySet()) { Integer remaining = requiredApprovalsByType.get(id); if (remaining > 0) { return false; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java new file mode 100644 index 0000000..c0806d7 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java @@ -0,0 +1,74 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.optf.cmso.service.rs; + +import javax.ws.rs.DefaultValue; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + +@Api("CMSO Optimized Schedule API") +@Path("/{apiVersion}") +@Produces({MediaType.APPLICATION_JSON}) +public interface CMSOOptimizedScheduleService { + + // ****************************************************************** + @POST + @Path("/schedules/optimized/{scheduleId}") + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "", notes = "Creates a request for an optimized schedule") + @ApiResponses( + value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."), + @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.", + response = CMSRequestError.class), + @ApiResponse(code = 500, message = "Unexpected Runtime error")}) + public Response createScheduleRequest( + @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, + @ApiParam( + value = "Schedule id to uniquely identify the schedule request being created.") @PathParam("scheduleId") String scheduleId, + @ApiParam( + value = "Data for creating a schedule request for the given schedule id") OptimizedScheduleMessage scheduleMessage); + + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java new file mode 100644 index 0000000..aa397ae --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java @@ -0,0 +1,122 @@ +/* + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.optf.cmso.service.rs; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; + +import org.onap.observations.Observation; +import org.onap.optf.cmso.common.LogMessages; +import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.eventq.CMSQueueJob; +import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; +import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ScheduleQueryDAO; +import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage; +import org.onap.optf.cmso.ticketmgt.TmClient; +import org.onap.optf.cmso.ticketmgt.bean.BuildCreateRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +@Controller +public class CMSOOptimizedScheduleServiceImpl implements CMSOOptimizedScheduleService { + private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + + @Autowired + CMSQueueJob qJob; + + @Autowired + Environment env; + + @Autowired + ChangeManagementScheduleDAO cmScheduleDAO; + + @Autowired + ChangeManagementGroupDAO cmGroupDAO; + + @Autowired + ChangeManagementChangeWindowDAO cmChangeWindowDAO; + + @Autowired + ChangeManagementDetailDAO cmDetailsDAO; + + @Autowired + ScheduleQueryDAO scheduleQueryDAO; + + @Autowired + ScheduleDAO scheduleDAO; + + @Autowired + TmClient tmClient; + + @Autowired + BuildCreateRequest buildCreateRequest; + + + @Context + HttpServletRequest request; + + @Override + @Transactional + public Response createScheduleRequest(String apiVersion, String scheduleId, OptimizedScheduleMessage scheduleMessage) + { + Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId, + scheduleMessage.toString()); + Response response = null; + try { + response = Response.accepted().build(); +// } catch (CMSException e) { +// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); +// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); +// response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); + } catch (Exception e) { + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + response = Response.serverError().build(); + } + Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, + response.getStatusInfo().toString()); + return response; + } + + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java index 679dd02..50d2ff2 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java @@ -167,7 +167,7 @@ public class CMSOOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen DateTime latestInstanceStartTime = convertDate(sniroSchedule.getLatestInstanceStartTime(), "latestInstanceStartTime"); DateTime startTime = convertDate(sniroSchedule.getStartTime(), "startTime"); - ChangeManagementGroup group = cmGroupDAO.findOneBySchedulesIDGroupID(schedule.getId(), groupId); + ChangeManagementGroup group = cmGroupDAO.findOneBySchedulesIDGroupID(schedule.getUuid(), groupId); if (group == null) { throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.CHANGE_MANAGEMENT_GROUP_NOT_FOUND, schedule.getScheduleId(), groupId); @@ -232,7 +232,7 @@ public class CMSOOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen private void processNode(Schedule schedule, ChangeManagementGroup group, String node, Map> startAndFinishTimeMap) throws CMSException { Map map = startAndFinishTimeMap.get(node); - ChangeManagementSchedule detail = cmScheduleDAO.findOneByGroupIDAndVnfName(group.getId(), node); + ChangeManagementSchedule detail = cmScheduleDAO.findOneByGroupIDAndVnfName(group.getUuid(), node); if (detail == null) { throw new CMSException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL, schedule.getScheduleId(), group.getGroupId(), node); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java index d65dd25..cc304db 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TimeZone; +import java.util.UUID; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.MultivaluedMap; @@ -143,15 +144,15 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer } Iterator iter = list.iterator(); while (iter.hasNext()) { - Schedule s = scheduleDAO.findById(iter.next().getId()).orElse(null); + Schedule s = scheduleDAO.findById(iter.next().getUuid()).orElse(null); if (s != null) { schedules.add(s); if (includeDetails) { - List groups = cmGroupDAO.findBySchedulesID(s.getId()); + List groups = cmGroupDAO.findBySchedulesID(s.getUuid()); s.setGroups(groups); for (ChangeManagementGroup g : groups) { List cmSchedules = - cmScheduleDAO.findByChangeManagementGroupId(g.getId()); + cmScheduleDAO.findByChangeManagementGroupId(g.getUuid()); g.setChangeManagementSchedules(cmSchedules); } } @@ -300,7 +301,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer CMSInfo schedulingInfo = scheduleMessage.getSchedulingInfo(); for (VnfDetailsMessage vnfDetail : schedulingInfo.getVnfDetails()) { ChangeManagementGroup cmg = new ChangeManagementGroup(); - cmg.setSchedulesId(schedule.getId()); + cmg.setUuid(UUID.randomUUID()); + cmg.setSchedulesUuid(schedule.getUuid()); cmg.setGroupId(""); if (vnfDetail.getGroupId() != null) cmg.setGroupId(vnfDetail.getGroupId()); @@ -311,7 +313,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer cmGroupDAO.save(cmg); for (ChangeWindowMessage cw : vnfDetail.getChangeWindow()) { ChangeManagementChangeWindow cmcw = new ChangeManagementChangeWindow(); - cmcw.setChangeManagementGroupsId(cmg.getId()); + cmcw.setUuid(UUID.randomUUID()); + cmcw.setChangeManagementGroupUuid(cmg.getUuid()); DateTime start = CMSOOptimizerCallbackImpl.convertISODate(cw.getStartTime(), "startTime"); DateTime end = CMSOOptimizerCallbackImpl.convertISODate(cw.getEndTime(), "startTime"); cmcw.setStartTimeMillis(start.getMillis()); @@ -321,7 +324,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer for (String vnf : vnfDetail.getNode()) { ChangeManagementSchedule cms = new ChangeManagementSchedule(); - cms.setChangeManagementGroupsId(cmg.getId()); + cms.setUuid(UUID.randomUUID()); + cms.setChangeManagementGroupUuid(cmg.getUuid()); cms.setVnfName(vnf); cms.setStatus(CMSStatusEnum.PendingSchedule.toString()); cmScheduleDAO.save(cms); @@ -333,7 +337,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer CMSInfo schedulingInfo = scheduleMessage.getSchedulingInfo(); for (VnfDetailsMessage vnfDetail : schedulingInfo.getVnfDetails()) { ChangeManagementGroup cmg = new ChangeManagementGroup(); - cmg.setSchedulesId(schedule.getId()); + cmg.setUuid(UUID.randomUUID()); + cmg.setSchedulesUuid(schedule.getUuid()); cmg.setGroupId(""); int duration = schedulingInfo.getNormalDurationInSeconds(); int backout = schedulingInfo.getAdditionalDurationInSeconds(); @@ -346,20 +351,22 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer cmGroupDAO.save(cmg); for (String vnf : vnfDetail.getNode()) { ChangeManagementSchedule cms = new ChangeManagementSchedule(); - cms.setChangeManagementGroupsId(cmg.getId()); + cms.setUuid(UUID.randomUUID()); + cms.setChangeManagementGroupUuid(cmg.getUuid()); cms.setVnfName(vnf); cms.setStatus(CMSStatusEnum.PendingApproval.toString()); cmScheduleDAO.save(cms); } schedule.setStatus(CMSStatusEnum.PendingApproval.toString()); + scheduleDAO.save(schedule); } } private void deleteChangeManagement(Schedule schedule) throws CMSException { - List cmgs = cmGroupDAO.findBySchedulesID(schedule.getId()); + List cmgs = cmGroupDAO.findBySchedulesID(schedule.getUuid()); for (ChangeManagementGroup cmg : cmgs) { - List schedules = cmScheduleDAO.findByChangeManagementGroupId(cmg.getId()); + List schedules = cmScheduleDAO.findByChangeManagementGroupId(cmg.getUuid()); for (ChangeManagementSchedule s : schedules) { CMSStatusEnum currentState = CMSStatusEnum.Completed.fromString(s.getStatus()); switch (currentState) { @@ -494,7 +501,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer private void processApproveScheduleRequest(Schedule s, ApprovalMessage approval, List domainData) throws CMSException { - s = scheduleDAO.lockOne(s.getId()); + s = scheduleDAO.lockOne(s.getUuid()); String domain = DomainsEnum.ChangeManagement.toString(); processApproval(s, domain, approval); if (s.getStatus().equals(CMSStatusEnum.Accepted.toString())) { @@ -510,10 +517,10 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer Integer max_vnfs_per_ticket = env.getProperty("tm.vnfs.per.ticket", Integer.class, 1); - List groups = cmGroupDAO.findBySchedulesID(s.getId()); + List groups = cmGroupDAO.findBySchedulesID(s.getUuid()); for (ChangeManagementGroup group : groups) { - List schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getId()); + List schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid()); List> ticketList = new ArrayList>(); List current = null; for (ChangeManagementSchedule cms : schedules) { @@ -560,9 +567,9 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer private void updateChangeManagementSchedules(Schedule s, CMSStatusEnum approvalrejected) { debug.debug("Entered updateChangeManagementSchedules"); - List groups = cmGroupDAO.findBySchedulesID(s.getId()); + List groups = cmGroupDAO.findBySchedulesID(s.getUuid()); for (ChangeManagementGroup group : groups) { - List schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getId()); + List schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid()); for (ChangeManagementSchedule schedule : schedules) { schedule.setStatus(approvalrejected.toString()); cmScheduleDAO.save(schedule); @@ -603,7 +610,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer DomainsEnum.ChangeManagement.toString(), scheduleId); } Iterator iter = list.iterator(); - Map scheduleMap = new HashMap(); + Map scheduleMap = new HashMap(); while (iter.hasNext()) { ChangeManagementDetail cms = iter.next(); CmDetailsMessage msg = buildResponse(cms, scheduleMap); @@ -636,7 +643,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer } - private CmDetailsMessage buildResponse(ChangeManagementDetail cms, Map scheduleMap) { + private CmDetailsMessage buildResponse(ChangeManagementDetail cms, Map scheduleMap) { CmDetailsMessage msg = new CmDetailsMessage(); msg.setVnfId(cms.getVnfId()); msg.setVnfName(cms.getVnfName()); @@ -656,17 +663,17 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer msg.setMsoRequestId(cms.getMsoRequestId()); msg.setMsoStatus(cms.getMsoStatus()); msg.setMsoTimeMillis(cms.getMsoTimeMillis()); - if (!scheduleMap.containsKey(cms.getSchedulesId())) { - Schedule schedule = scheduleDAO.findById(cms.getSchedulesId()).orElse(null); + if (!scheduleMap.containsKey(cms.getSchedulesUuid())) { + Schedule schedule = scheduleDAO.findById(cms.getSchedulesUuid()).orElse(null); if (schedule != null) { // DO not innclude in the results schedule.setScheduleInfo(null); // schedule.setSchedule(null); - scheduleMap.put(cms.getSchedulesId(), schedule); + scheduleMap.put(cms.getSchedulesUuid(), schedule); } } - if (scheduleMap.containsKey(cms.getSchedulesId())) { - msg.setScheduleRequest(scheduleMap.get(cms.getSchedulesId())); + if (scheduleMap.containsKey(cms.getSchedulesUuid())) { + msg.setScheduleRequest(scheduleMap.get(cms.getSchedulesUuid())); } return msg; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java index 1a9c29d..9877d33 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,188 +43,180 @@ import org.onap.optf.cmso.model.DomainData; public class CmQueryParameters { - public enum QueryColumns { - RequestScheduleId("request.scheduleId", String.class, "ss.schedule_id"), RequestScheduleName( - "request.scheduleName", String.class, - "ss.schedule_name"), RequestUserId("request.userId", String.class, "ss.user_id"), RequestStatus( - "request.status", String.class, "ss.status"), RequestCreateDateTime("request.createDateTime", - Date.class, "ss.create_date_time"), RequestOptimizerStatus("request.optimizerStatus", - String.class, "ss.optimizer_status"), RequestApprovalUserId( - "request.approvalUserId", String.class, - "sa.user_id"), RequestApprovalStatus("request.approvalStatus", - String.class, "sa.status"), RequestApprovalType( - "request.approvalType", String.class, - "at.approval_type"), WorkflowName("WorkflowName", - DomainData.class, - "dd.value"), vnfName("vnfName", String.class, - "s.vnf_name"), vnfId("vnfId", - String.class, - "s.vnf_id"), vnfStatus( - "vnfStatus", - String.class, - "s.vnf_status"), - // vnfScheduleId("vnfScheduleId", String.class, "s.id"), - startTime("startTime", Date.class, "s.start_time"), finishTime("finishTime", Date.class, - "s.finish_ime"), lastInstanceTime("lastInstanceTime", Date.class, "g.last_instance_time"), tmChangeId( - "tmChangeId", String.class, "s.tm_change_id"), concurrenyLimit("request.concurrencyLimit", - Integer.class, "g.concurrency_limit"), - // approvalUserId("approvalUserId", String.class, "approvalUserId"), - // approvalStatus("approvalStatus", String.class, "approvalStatus"), - // approvalType("approvalType", String.class, "approvalType"), - ; + public enum QueryColumns { + RequestScheduleId("request.scheduleId", String.class, "ss.schedule_id"), + RequestScheduleName("request.scheduleName", String.class, "ss.schedule_name"), + RequestUserId("request.userId", String.class, "ss.user_id"), + RequestStatus("request.status", String.class, "ss.status"), + RequestCreateDateTime("request.createDateTime", Date.class, "ss.create_date_time"), + RequestOptimizerStatus("request.optimizerStatus", String.class, "ss.optimizer_status"), + RequestApprovalUserId("request.approvalUserId", String.class, "sa.user_id"), + RequestApprovalStatus("request.approvalStatus", String.class, "sa.status"), + RequestApprovalType("request.approvalType", String.class, "at.approval_type"), + WorkflowName("WorkflowName", DomainData.class, "dd.value"), vnfName("vnfName", String.class, "s.vnf_name"), + vnfId("vnfId", String.class, "s.vnf_id"), vnfStatus("vnfStatus", String.class, "s.vnf_status"), + // vnfScheduleId("vnfScheduleId", String.class, "s.id"), + startTime("startTime", Date.class, "s.start_time"), finishTime("finishTime", Date.class, "s.finish_ime"), + lastInstanceTime("lastInstanceTime", Date.class, "g.last_instance_time"), + tmChangeId("tmChangeId", String.class, "s.tm_change_id"), + concurrenyLimit("request.concurrencyLimit", Integer.class, "g.concurrency_limit"), + // approvalUserId("approvalUserId", String.class, "approvalUserId"), + // approvalStatus("approvalStatus", String.class, "approvalStatus"), + // approvalType("approvalType", String.class, "approvalType"), + ; - private final String urlName; - private final Class type; - private final String col; + private final String urlName; + private final Class type; + private final String col; - private QueryColumns(String urlName, Class type, String col) { - this.urlName = urlName; - this.type = type; - this.col = col; - } + private QueryColumns(String urlName, Class type, String col) { + this.urlName = urlName; + this.type = type; + this.col = col; + } - } + } - public static QueryColumns getQueryColumn(String urlName) { - for (QueryColumns qc : QueryColumns.values()) { - if (qc.urlName.equals(urlName)) - return qc; - } - return null; - } + public static QueryColumns getQueryColumn(String urlName) { + for (QueryColumns qc : QueryColumns.values()) { + if (qc.urlName.equals(urlName)) + return qc; + } + return null; + } - public static String buildClause(String urlName, List values) throws CMSException { - QueryColumns qc = getQueryColumn(urlName); - if (qc == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.UNDEFINED_FILTER_ATTRIBUTE, urlName); - } - if (qc.type == Date.class) { - return formatDate(urlName, values, qc); - } - if (qc.type == DomainData.class) { - return formatDomainData(urlName, values, qc); - } - return formatString(urlName, values, qc); - } + public static String buildClause(String urlName, List values) throws CMSException { + QueryColumns qc = getQueryColumn(urlName); + if (qc == null) { + throw new CMSException(Status.BAD_REQUEST, LogMessages.UNDEFINED_FILTER_ATTRIBUTE, urlName); + } + if (qc.type == Date.class) { + return formatDate(urlName, values, qc); + } + if (qc.type == DomainData.class) { + return formatDomainData(urlName, values, qc); + } + return formatString(urlName, values, qc); + } - private static String formatString(String urlName, List values, QueryColumns qc) { - StringBuilder clause = new StringBuilder(); - List likes = new ArrayList(); - List in = new ArrayList(); - for (String value : values) { - if (value.contains("%")) - likes.add(value); - else - in.add(value); - } - String delim = "("; - if (in.size() > 0) { - clause.append(delim).append(qc.col).append(" in ('"); - String inDelim = ""; - for (String value : in) { - clause.append(inDelim).append(value).append("'"); - inDelim = ", '"; - } - clause.append(") "); - delim = " OR "; - } - if (likes.size() > 0) { - for (String value : likes) { - clause.append(delim).append(qc.col).append(" like '").append(value).append("'"); - delim = " OR "; - } - } - if (!delim.equals("(")) - clause.append(")"); - return clause.toString(); - } + private static String formatString(String urlName, List values, QueryColumns qc) { + StringBuilder clause = new StringBuilder(); + List likes = new ArrayList(); + List in = new ArrayList(); + for (String value : values) { + if (value.contains("%")) + likes.add(value); + else + in.add(value); + } + String delim = "("; + if (in.size() > 0) { + clause.append(delim).append(qc.col).append(" in ('"); + String inDelim = ""; + for (String value : in) { + clause.append(inDelim).append(value).append("'"); + inDelim = ", '"; + } + clause.append(") "); + delim = " OR "; + } + if (likes.size() > 0) { + for (String value : likes) { + clause.append(delim).append(qc.col).append(" like '").append(value).append("'"); + delim = " OR "; + } + } + if (!delim.equals("(")) + clause.append(")"); + return clause.toString(); + } - private static String formatDomainData(String urlName, List values, QueryColumns qc) { - StringBuilder clause = new StringBuilder(); - String delim = "("; - if (values.size() > 0) { - for (String value : values) { - clause.append(delim).append(" (dd.name = '").append(qc.urlName).append("' AND dd.value = '") - .append(value).append("')"); - delim = " OR "; - } - } - if (!delim.equals("(")) - clause.append(")"); - return clause.toString(); - } + private static String formatDomainData(String urlName, List values, QueryColumns qc) { + StringBuilder clause = new StringBuilder(); + String delim = "("; + if (values.size() > 0) { + for (String value : values) { + clause.append(delim).append(" (dd.name = '").append(qc.urlName).append("' AND dd.value = '") + .append(value).append("')"); + delim = " OR "; + } + } + if (!delim.equals("(")) + clause.append(")"); + return clause.toString(); + } - private static String formatDate(String urlName, List values, QueryColumns qc) throws CMSException { - List clauses = new ArrayList(); - for (String value : values) { - String dates[] = value.split(","); - switch (dates.length) { - case 2: - formatDatePair(qc, dates[0].trim(), dates[1].trim(), clauses); - break; - case 1: - formatDatePair(qc, dates[0].trim(), "", clauses); - break; - default: - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, value); - } - } - StringBuilder clause = new StringBuilder(); - String delim = "("; - for (String c : clauses) { - clause.append(delim).append(c); - delim = " OR "; - } - if (!delim.equals(")")) { - clause.append(")"); - } - return clause.toString(); - } + private static String formatDate(String urlName, List values, QueryColumns qc) throws CMSException { + List clauses = new ArrayList(); + for (String value : values) { + String dates[] = value.split(","); + switch (dates.length) { + case 2: + formatDatePair(qc, dates[0].trim(), dates[1].trim(), clauses); + break; + case 1: + formatDatePair(qc, dates[0].trim(), "", clauses); + break; + default: + throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, value); + } + } + StringBuilder clause = new StringBuilder(); + String delim = "("; + for (String c : clauses) { + clause.append(delim).append(c); + delim = " OR "; + } + if (!delim.equals(")")) { + clause.append(")"); + } + return clause.toString(); + } - private static void formatDatePair(QueryColumns qc, String lowDate, String highDate, List clauses) - throws CMSException { - StringBuilder clause = new StringBuilder(); - DateTime date1 = null; - DateTime date2 = null; - if (!lowDate.equals("")) - date1 = convertDate(lowDate, qc.urlName); - if (!highDate.equals("")) - date2 = convertDate(highDate, qc.urlName); - String delim = "("; - if (date1 != null) { - clause.append(delim).append(qc.col).append(" >= ").append(date1.getMillis()); - delim = " AND "; - } - if (date2 != null) { - clause.append(delim).append(qc.col).append(" <= ").append(date2.getMillis()); - delim = " AND "; - } - if (!delim.equals(")")) { - clause.append(")\n"); - clauses.add(clause.toString()); - } - } + private static void formatDatePair(QueryColumns qc, String lowDate, String highDate, List clauses) + throws CMSException { + StringBuilder clause = new StringBuilder(); + DateTime date1 = null; + DateTime date2 = null; + if (!lowDate.equals("")) + date1 = convertDate(lowDate, qc.urlName); + if (!highDate.equals("")) + date2 = convertDate(highDate, qc.urlName); + String delim = "("; + if (date1 != null) { + clause.append(delim).append(qc.col).append(" >= ").append(date1.getMillis()); + delim = " AND "; + } + if (date2 != null) { + clause.append(delim).append(qc.col).append(" <= ").append(date2.getMillis()); + delim = " AND "; + } + if (!delim.equals(")")) { + clause.append(")\n"); + clauses.add(clause.toString()); + } + } - private static DateTime convertDate(String utcDate, String urlName) throws CMSException { - DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate); - if (dateTime != null) - return dateTime; - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, utcDate); - } + private static DateTime convertDate(String utcDate, String urlName) throws CMSException { + DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate); + if (dateTime != null) + return dateTime; + throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, utcDate); + } - // public static void main(String argv[]) - // { - // List values = new ArrayList(); - // values.add("2017-07-08T11:12:13Z,2017-07-08T11:12:13Z"); - // values.add("2017-07-09T11:12:13Z,2017-07-09T11:12:13Z"); - // values.add(",2017-07-09T11:12:13Z"); - // values.add(" 2017-07-09T11:12:13Z"); - // try { - // System.out.println(buildClause("request.createDateTime", values)); - // } catch (SchedulerException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // - // } + // public static void main(String argv[]) + // { + // List values = new ArrayList(); + // values.add("2017-07-08T11:12:13Z,2017-07-08T11:12:13Z"); + // values.add("2017-07-09T11:12:13Z,2017-07-09T11:12:13Z"); + // values.add(",2017-07-09T11:12:13Z"); + // values.add(" 2017-07-09T11:12:13Z"); + // try { + // System.out.println(buildClause("request.createDateTime", values)); + // } catch (SchedulerException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // + // } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleService.java deleted file mode 100644 index c0806d7..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleService.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - * - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * 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.optf.cmso.service.rs; - -import javax.ws.rs.DefaultValue; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.onap.optf.cmso.common.CMSRequestError; -import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -@Api("CMSO Optimized Schedule API") -@Path("/{apiVersion}") -@Produces({MediaType.APPLICATION_JSON}) -public interface CMSOOptimizedScheduleService { - - // ****************************************************************** - @POST - @Path("/schedules/optimized/{scheduleId}") - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "", notes = "Creates a request for an optimized schedule") - @ApiResponses( - value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."), - @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.", - response = CMSRequestError.class), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - public Response createScheduleRequest( - @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, - @ApiParam( - value = "Schedule id to uniquely identify the schedule request being created.") @PathParam("scheduleId") String scheduleId, - @ApiParam( - value = "Data for creating a schedule request for the given schedule id") OptimizedScheduleMessage scheduleMessage); - - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleServiceImpl.java deleted file mode 100644 index aa397ae..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleServiceImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright © 2017-2019 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - * - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * 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.optf.cmso.service.rs; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; - -import org.onap.observations.Observation; -import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; -import org.onap.optf.cmso.eventq.CMSQueueJob; -import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleQueryDAO; -import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage; -import org.onap.optf.cmso.ticketmgt.TmClient; -import org.onap.optf.cmso.ticketmgt.bean.BuildCreateRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Controller; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.interceptor.TransactionAspectSupport; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@Controller -public class CMSOOptimizedScheduleServiceImpl implements CMSOOptimizedScheduleService { - private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); - - @Autowired - CMSQueueJob qJob; - - @Autowired - Environment env; - - @Autowired - ChangeManagementScheduleDAO cmScheduleDAO; - - @Autowired - ChangeManagementGroupDAO cmGroupDAO; - - @Autowired - ChangeManagementChangeWindowDAO cmChangeWindowDAO; - - @Autowired - ChangeManagementDetailDAO cmDetailsDAO; - - @Autowired - ScheduleQueryDAO scheduleQueryDAO; - - @Autowired - ScheduleDAO scheduleDAO; - - @Autowired - TmClient tmClient; - - @Autowired - BuildCreateRequest buildCreateRequest; - - - @Context - HttpServletRequest request; - - @Override - @Transactional - public Response createScheduleRequest(String apiVersion, String scheduleId, OptimizedScheduleMessage scheduleMessage) - { - Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId, - scheduleMessage.toString()); - Response response = null; - try { - response = Response.accepted().build(); -// } catch (CMSException e) { -// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); -// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); -// response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); - } catch (Exception e) { - Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - response = Response.serverError().build(); - } - Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, - response.getStatusInfo().toString()); - return response; - } - - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java index 7a7821e..41534f8 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java @@ -34,6 +34,7 @@ package org.onap.optf.cmso.sostatus; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; +import java.util.UUID; import javax.ws.rs.ProcessingException; import javax.ws.rs.client.Client; @@ -87,10 +88,11 @@ public class MsoStatusClient { @Autowired PropertiesManagement pm; - public void execute(Integer id) throws JobExecutionException { + public void execute(String id) throws JobExecutionException { debug.debug(LogMessages.MSO_STATUS_JOB, "Entered", id.toString()); try { - ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(id); + UUID uuid = UUID.fromString(id); + ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(uuid); if (cmSchedule == null) { Observation.report(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id.toString()); return; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java index df9f361..6c52cc3 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java @@ -31,6 +31,8 @@ package org.onap.optf.cmso.sostatus; +import java.util.UUID; + import org.onap.observations.Mdc; import org.onap.optf.cmso.common.LogMessages; import org.onap.optf.cmso.model.ChangeManagementSchedule; @@ -73,20 +75,21 @@ public class MsoStatusJob implements Job { @Override public void execute(JobExecutionContext context) throws JobExecutionException { Mdc.quartzJobBegin(context); - Integer id = context.getJobDetail().getJobDataMap().getInt(ContextKeys.scheduleId.toString()); + String id = context.getJobDetail().getJobDataMap().getString(ContextKeys.scheduleId.toString()); String requestId = context.getJobDetail().getJobDataMap().getString(ContextKeys.msoRequestId.toString()); debug.debug(LogMessages.MSO_STATUS_JOB, "Entered", requestId, id.toString()); try { - ChangeManagementSchedule cmSchedule = cmScheduleDAO.findById(id).orElse(null); + UUID uuid = UUID.fromString(id); + ChangeManagementSchedule cmSchedule = cmScheduleDAO.findById(uuid).orElse(null); if (cmSchedule == null) { - log.warn(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id.toString(), requestId); + log.warn(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id, requestId); return; } mso.poll(cmSchedule); } catch (Exception e) { errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } - debug.debug(LogMessages.MSO_STATUS_JOB, "Exited", requestId, id.toString()); + debug.debug(LogMessages.MSO_STATUS_JOB, "Exited", requestId, id); } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java index c3254aa..1c3677c 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java @@ -33,6 +33,7 @@ package org.onap.optf.cmso.sostatus; import java.util.List; import java.util.Map; +import java.util.UUID; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -93,8 +94,8 @@ public class ScheduleStatusJob implements Job { // First poll SO for WF status List list = cmScheduleDAO.findAllTriggered(); for (ChangeManagementSchedule s : list) { - debug.debug("Dispathcing to check status of CM schedule Id=" + s.getId()); - dispatchMso(s.getId()); + debug.debug("Dispathcing to check status of CM schedule Id=" + s.getUuid()); + dispatchMso(s.getUuid()); } } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); @@ -106,7 +107,7 @@ public class ScheduleStatusJob implements Job { List list = scheduleDAO.findAllInProgress(DomainsEnum.ChangeManagement.toString()); for (Schedule s : list) { debug.debug("Dispatching to check status of scheduleId=" + s.getScheduleId()); - dispatchScheduleStatusChecker(s.getId()); + dispatchScheduleStatusChecker(s.getUuid()); } } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); @@ -114,12 +115,12 @@ public class ScheduleStatusJob implements Job { debug.debug(LogMessages.SCHEDULE_STATUS_JOB, "Exited"); } - public void dispatchScheduleStatusChecker(Integer id) { + public void dispatchScheduleStatusChecker(UUID uuid) { Map mdcSave = Mdc.save(); try { String url = env.getProperty("cmso.dispatch.url", "http://localhost:8089"); String path = env.getProperty("cmso.dispatch.status.path", "/cmso/dispatch/schedulestatus/"); - url = url + path + id; + url = url + path + uuid; String user = env.getProperty("mechid.user", ""); String pass = pm.getProperty("mechid.pass", ""); Client client = ClientBuilder.newClient(); @@ -152,12 +153,12 @@ public class ScheduleStatusJob implements Job { } - public void dispatchMso(Integer id) { + public void dispatchMso(UUID uuid) { Map mdcSave = Mdc.save(); try { String url = env.getProperty("cmso.dispatch.url", "http://localhost:8089"); String path = env.getProperty("cmso.dispatch.sostatus.path", "/cmso/dispatch/sostatus/"); - url = url + path + id; + url = url + path + uuid; String user = env.getProperty("mechid.user", ""); String pass = pm.getProperty("mechid.pass", ""); Client client = ClientBuilder.newClient(); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java index e5c14b1..e327acc 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,8 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; + import javax.transaction.Transactional; import org.onap.optf.cmso.common.CMSStatusEnum; import org.onap.optf.cmso.common.LogMessages; @@ -97,11 +99,12 @@ public class TmStatusClient { TmClient tmClient; @Transactional - public void checkStatus(Integer id) { + public void checkStatus(String id) { debug.debug("Entered checkStatus id=" + id); try { // Multiple cmso instance support - re-get the record with a Schedule lock - Schedule s = scheduleDAO.lockOne(id); + UUID uuid = UUID.fromString(id); + Schedule s = scheduleDAO.lockOne(uuid); if (!s.getStatus().equals(CMSStatusEnum.NotificationsInitiated.toString())) { debug.debug(s.getScheduleId() + " is no longer in " + CMSStatusEnum.NotificationsInitiated.toString() + " : it is " + s.getStatus()); @@ -110,7 +113,7 @@ public class TmStatusClient { } Map> groupStatus = new HashMap>(); - List groups = cmGroupDAO.findBySchedulesID(id); + List groups = cmGroupDAO.findBySchedulesID(uuid); // Close tickets for completed VNFs for (ChangeManagementGroup group : groups) { @@ -155,7 +158,7 @@ public class TmStatusClient { Map> inProgress = new HashMap>(); Map> completed = new HashMap>(); Map> tmClosed = new HashMap>(); - List cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getId()); + List cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid()); for (ChangeManagementSchedule cmSchedule : cmSchedules) { String status = cmSchedule.getStatus(); String changeId = cmSchedule.getTmChangeId(); @@ -230,7 +233,7 @@ public class TmStatusClient { Set failedNames = new HashSet(); Set completedNames = new HashSet(); Long startDate = group.getStartTimeMillis(); - List cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getId()); + List cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid()); for (ChangeManagementSchedule cmSchedule : cmSchedules) { String vnfName = cmSchedule.getVnfName(); vnfNames.add(vnfName); -- cgit 1.2.3-korg