Commit 9 for Create Optimized Sched API 31/83231/1
authorJerry Flood <jflood@att.com>
Mon, 25 Mar 2019 16:25:07 +0000 (12:25 -0400)
committerJerry Flood <jflood@att.com>
Mon, 25 Mar 2019 16:53:42 +0000 (12:53 -0400)
Multiple commits required due to commit size limitation.

Change-Id: I146a9dc65738e9dea7850b3accf5d88ce44ea90f
Issue-ID: OPTFRA-458
Signed-off-by: Jerry Flood <jflood@att.com>
cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerRequest.java [new file with mode: 0644]
cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerResponse.java [new file with mode: 0644]
cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerScheduleInfo.java [new file with mode: 0644]
cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/ScheduledElement.java [new file with mode: 0644]
cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/UnScheduledElement.java [new file with mode: 0644]
cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java
cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java

diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerRequest.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerRequest.java
new file mode 100644 (file)
index 0000000..058d8c1
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * 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.optimizer.model;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.optf.cmso.service.rs.models.v2.ChangeWindow;
+import org.onap.optf.cmso.service.rs.models.v2.ElementInfo;
+import org.onap.optf.cmso.service.rs.models.v2.NameValue;
+import org.onap.optf.cmso.service.rs.models.v2.PolicyInfo;
+
+@ApiModel(value = "Optimizer Request",
+                description = "Request to provide an \"conflict free\" schedule for passed elements.")
+public class OptimizerRequest implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerRequest.class);
+
+    @ApiModelProperty(value = "Unique Id of the request")
+    private String requestId;
+
+    @ApiModelProperty(value = "Concurrency limit for this request")
+    private Integer concurrencyLimit;
+
+    @ApiModelProperty(value = "Expected duration of normal change")
+    private Integer normalDuration;
+
+    @ApiModelProperty(value = "Additional duration for failed change")
+    private Integer additionalDuration;
+
+    @ApiModelProperty(value = "Implementation specific name value pairs.")
+    private List<NameValue> commonData;
+
+    @ApiModelProperty(value = "Lists of desired change windows to schedule the elements.")
+    private List<ChangeWindow> changeWindows = new ArrayList<>();
+
+    @ApiModelProperty(value = "List of the elements to schedule.")
+    private List<ElementInfo> elements = new ArrayList<>();
+
+    @ApiModelProperty(value = "List of the policies to control optimization.")
+    private List<PolicyInfo> policies = new ArrayList<>();
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+
+    public void setRequestId(String requestId) {
+        this.requestId = requestId;
+    }
+
+
+    public List<PolicyInfo> getPolicies() {
+        return policies;
+    }
+
+
+    public void setPolicies(List<PolicyInfo> policies) {
+        this.policies = policies;
+    }
+
+
+    public List<NameValue> getCommonData() {
+        return commonData;
+    }
+
+
+    public void setCommonData(List<NameValue> commonData) {
+        this.commonData = commonData;
+    }
+
+
+    public List<ElementInfo> getElements() {
+        return elements;
+    }
+
+
+    public void setElements(List<ElementInfo> elements) {
+        this.elements = elements;
+    }
+
+
+    public List<ChangeWindow> getChangeWindows() {
+        return changeWindows;
+    }
+
+
+    public void setChangeWindows(List<ChangeWindow> changeWindows) {
+        this.changeWindows = changeWindows;
+    }
+
+
+    public Integer getConcurrencyLimit() {
+        return concurrencyLimit;
+    }
+
+
+    public void setConcurrencyLimit(Integer concurrencyLimit) {
+        this.concurrencyLimit = concurrencyLimit;
+    }
+
+
+    public Integer getNormalDuration() {
+        return normalDuration;
+    }
+
+
+    public void setNormalDuration(Integer normalDuration) {
+        this.normalDuration = normalDuration;
+    }
+
+
+    public Integer getAdditionalDuration() {
+        return additionalDuration;
+    }
+
+
+    public void setAdditionalDuration(Integer additionalDuration) {
+        this.additionalDuration = additionalDuration;
+    }
+
+
+    @Override
+    public String toString() {
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            return mapper.writeValueAsString(this);
+        } catch (JsonProcessingException e) {
+            log.debug("Error in toString()", e);
+        }
+        return "";
+    }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerResponse.java
new file mode 100644 (file)
index 0000000..9971595
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * 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.optimizer.model;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@ApiModel(value = "Optimizer Response", description = "Response to optimizer request for the requested elements.")
+public class OptimizerResponse implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerResponse.class);
+
+    public enum OptimizeScheduleStatus {
+        CREATED, PENDING_TOPOLOGY, PENDING_TICKETS, PENDING_OPTIMIZER, COMPLETED, FAILED, DELETED,
+    }
+
+    @ApiModelProperty(value = "Unique Id of the request")
+    private String requestId;
+
+    @ApiModelProperty(value = "Status of the optimization")
+    private OptimizeScheduleStatus status;
+
+    @ApiModelProperty(value = "Message for failed optimization")
+    private String errorMessage;
+
+
+    @ApiModelProperty(value = "List of schedules returned by the optimizer.")
+    private List<OptimizerScheduleInfo> schedules = new ArrayList<>();
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+    public void setRequestId(String requestId) {
+        this.requestId = requestId;
+    }
+
+
+    public List<OptimizerScheduleInfo> getSchedules() {
+        return schedules;
+    }
+
+    public void setSchedules(List<OptimizerScheduleInfo> schedules) {
+        this.schedules = schedules;
+    }
+
+    public OptimizeScheduleStatus getStatus() {
+        return status;
+    }
+
+    public void setStatus(OptimizeScheduleStatus status) {
+        this.status = status;
+    }
+
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+
+    public void setErrorMessage(String errorMessage) {
+        this.errorMessage = errorMessage;
+    }
+
+    @Override
+    public String toString() {
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            return mapper.writeValueAsString(this);
+        } catch (JsonProcessingException e) {
+            log.debug("Error in toString()", e);
+        }
+        return "";
+    }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerScheduleInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerScheduleInfo.java
new file mode 100644 (file)
index 0000000..92ce981
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * 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.optimizer.model;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@ApiModel(value = "Optimizer Schedule Info", description = "Schedule Information returned from optimizer request.")
+public class OptimizerScheduleInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerScheduleInfo.class);
+
+    @ApiModelProperty(value = "Lists of elements with start times.")
+    private List<ScheduledElement> scheduledElements = new ArrayList<>();
+
+    @ApiModelProperty(value = "Lists of elements that were not able to be scheduled.")
+    private List<UnScheduledElement> unScheduledElements = new ArrayList<>();
+
+
+    public List<ScheduledElement> getScheduledElements() {
+        return scheduledElements;
+    }
+
+
+    public void setScheduledElements(List<ScheduledElement> scheduledElements) {
+        this.scheduledElements = scheduledElements;
+    }
+
+
+    public List<UnScheduledElement> getUnScheduledElements() {
+        return unScheduledElements;
+    }
+
+
+    public void setUnScheduledElements(List<UnScheduledElement> unScheduledElements) {
+        this.unScheduledElements = unScheduledElements;
+    }
+
+
+    @Override
+    public String toString() {
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            return mapper.writeValueAsString(this);
+        } catch (JsonProcessingException e) {
+            log.debug("Error in toString()", e);
+        }
+        return "";
+    }
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/ScheduledElement.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/ScheduledElement.java
new file mode 100644 (file)
index 0000000..db92863
--- /dev/null
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * 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.optimizer.model;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.io.Serializable;
+import java.util.Date;
+import org.springframework.format.annotation.DateTimeFormat;
+
+@ApiModel(value = "Scheduled Element", description = "Scheduled element returned by the optimizer.")
+public class ScheduledElement implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private static EELFLogger log = EELFManager.getInstance().getLogger(ScheduledElement.class);
+
+    public enum ScheduleType {
+        UNKNOWN, GROUP_DISPATCH, INDIVIDUAL,
+    }
+
+    @ApiModelProperty(value = "Element identifier")
+    private String elementId;
+
+    @ApiModelProperty(value = "Group identifier")
+    private String groupId;
+
+    private ScheduleType scheduleType = ScheduleType.UNKNOWN;
+
+    @ApiModelProperty(value = "Earliest time for which changes may begin.")
+    @DateTimeFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss'Z'")
+    private Date startTime;
+
+    @ApiModelProperty(value = "Latest time by which all changes must be completed.")
+    @DateTimeFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss'Z'")
+    private Date endTime;
+
+    @ApiModelProperty(value = "Expected duration of change in seconds.")
+    private Long durationSeconds;
+
+    public String getElementId() {
+        return elementId;
+    }
+
+    public void setElementId(String elementId) {
+        this.elementId = elementId;
+    }
+
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    public ScheduleType getScheduleType() {
+        return scheduleType;
+    }
+
+    public void setScheduleType(ScheduleType scheduleType) {
+        this.scheduleType = scheduleType;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public Long getDurationSeconds() {
+        return durationSeconds;
+    }
+
+    public void setDurationSeconds(Long durationSeconds) {
+        this.durationSeconds = durationSeconds;
+    }
+
+    @Override
+    public String toString() {
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            return mapper.writeValueAsString(this);
+        } catch (JsonProcessingException e) {
+            log.debug("Error in toString()", e);
+        }
+        return "";
+    }
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/UnScheduledElement.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/UnScheduledElement.java
new file mode 100644 (file)
index 0000000..be6e89d
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * 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.optimizer.model;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@ApiModel(value = "Unscheduled Element", description = "Scheduled element returned by the optimizer.")
+public class UnScheduledElement implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private static EELFLogger log = EELFManager.getInstance().getLogger(UnScheduledElement.class);
+
+    public enum NotScheduledReason {
+        ConcurrencyConstraint, AvailabilityConstraint, Other,
+    }
+
+    @ApiModelProperty(value = "Element identifier")
+    private String elementId;
+
+    @ApiModelProperty(value = "Group identifier")
+    private String groupId;
+
+    @ApiModelProperty(value = "List of reasons not able to schedule this element.")
+    private List<NotScheduledReason> notScheduledReaons = new ArrayList<>();
+
+    @ApiModelProperty(value = "List of messages not able to schedule this element.")
+    private List<String> notScheduledMessages = new ArrayList<>();
+
+    public String getElementId() {
+        return elementId;
+    }
+
+    public void setElementId(String elementId) {
+        this.elementId = elementId;
+    }
+
+    public List<NotScheduledReason> getNotScheduledReaons() {
+        return notScheduledReaons;
+    }
+
+    public void setNotScheduledReaons(List<NotScheduledReason> notScheduledReaons) {
+        this.notScheduledReaons = notScheduledReaons;
+    }
+
+    public List<String> getNotScheduledMessages() {
+        return notScheduledMessages;
+    }
+
+    public void setNotScheduledMessages(List<String> notScheduledMessages) {
+        this.notScheduledMessages = notScheduledMessages;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    @Override
+    public String toString() {
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            return mapper.writeValueAsString(this);
+        } catch (JsonProcessingException e) {
+            log.debug("Error in toString()", e);
+        }
+        return "";
+    }
+}
index 10eedf8..6be8159 100644 (file)
 \r
 package org.onap.optf.cmso.service.rs;\r
 \r
+import io.swagger.annotations.Api;\r
+import io.swagger.annotations.ApiOperation;\r
+import io.swagger.annotations.ApiParam;\r
+import io.swagger.annotations.ApiResponse;\r
+import io.swagger.annotations.ApiResponses;\r
 import javax.ws.rs.DefaultValue;\r
 import javax.ws.rs.GET;\r
 import javax.ws.rs.Path;\r
@@ -39,12 +44,6 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;\r
 import javax.ws.rs.core.Response;\r
 \r
-import io.swagger.annotations.Api;\r
-import io.swagger.annotations.ApiOperation;\r
-import io.swagger.annotations.ApiParam;\r
-import io.swagger.annotations.ApiResponse;\r
-import io.swagger.annotations.ApiResponses;\r
-\r
 @Api("CMSO Administration")\r
 @Path("/{apiVersion}")\r
 @Produces({MediaType.APPLICATION_JSON})\r
index 8ec4f4f..fa182b4 100644 (file)
@@ -1,27 +1,27 @@
 /*\r
  * Copyright © 2017-2019 AT&T Intellectual Property.\r
  * Modifications Copyright © 2018 IBM.\r
- * \r
+ *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, software\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * \r
+ *\r
+ *\r
  * Unless otherwise specified, all documentation contained herein is licensed\r
  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
  * you may not use this documentation except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, documentation\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 \r
 package org.onap.optf.cmso.service.rs;\r
 \r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
 import javax.servlet.http.HttpServletRequest;\r
 import javax.ws.rs.core.Context;\r
 import javax.ws.rs.core.Response;\r
 import javax.ws.rs.core.UriInfo;\r
-\r
 import org.onap.optf.cmso.common.PropertiesManagement;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.stereotype.Controller;\r
 \r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
 @Controller\r
 public class AdminToolImpl implements AdminTool {\r
     private static EELFLogger log = EELFManager.getInstance().getLogger(AdminToolImpl.class);\r
 \r
-    @Context \r
+    @Context\r
     UriInfo uri;\r
-    \r
+\r
     @Context\r
     HttpServletRequest request;\r
-    \r
+\r
 \r
     @Autowired\r
     PropertiesManagement pm;\r
@@ -60,8 +58,9 @@ public class AdminToolImpl implements AdminTool {
     @Override\r
     public Response exec(String apiVersion, String id) {\r
         log.info("AdminTool.exec entered");\r
-        if (id.length() < 4)\r
+        if (id.length() < 4) {\r
             return Response.ok("").build();\r
+        }\r
         String encrypted = PropertiesManagement.getEncryptedValue(id);\r
         Response response = Response.ok(encrypted).build();\r
         return response;\r
index 787bd60..18678ff 100644 (file)
@@ -1,44 +1,39 @@
 /*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ *\r
+ *\r
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative\r
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * https://creativecommons.org/licenses/by/4.0/\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the\r
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\r
+ * express or implied. See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
+ */\r
 \r
 package org.onap.optf.cmso.service.rs;\r
 \r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.UUID;\r
-\r
 import javax.ws.rs.core.Response.Status;\r
-\r
 import org.onap.optf.cmso.common.ApprovalStatusEnum;\r
 import org.onap.optf.cmso.common.CMSStatusEnum;\r
 import org.onap.optf.cmso.common.LogMessages;\r
@@ -54,13 +49,10 @@ import org.onap.optf.cmso.model.dao.DomainDataDAO;
 import org.onap.optf.cmso.model.dao.ScheduleApprovalDAO;\r
 import org.onap.optf.cmso.model.dao.ScheduleDAO;\r
 import org.onap.optf.cmso.service.rs.models.ApprovalMessage;\r
-import org.onap.optf.cmso.service.rs.models.ScheduleMessage;\r
+import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.stereotype.Controller;\r
 \r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
 @Controller\r
 public class BaseSchedulerServiceImpl {\r
     private static EELFLogger log = EELFManager.getInstance().getLogger(BaseSchedulerServiceImpl.class);\r
@@ -77,39 +69,39 @@ public class BaseSchedulerServiceImpl {
     @Autowired\r
     ScheduleApprovalDAO scheduleApprovalDAO;\r
 \r
-    protected Schedule validateAndAddScheduleRequest(ScheduleMessage scheduleMessage, List<DomainData> domainData)\r
-            throws CMSException {\r
+    protected Schedule validateAndAddScheduleRequest(OptimizedScheduleMessage scheduleMessage,\r
+                    List<DomainData> domainData) throws CMSException {\r
         messageValidations(scheduleMessage);\r
-        Schedule s = scheduleDAO.findByDomainScheduleID(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());\r
+        Schedule sch = scheduleDAO.findByDomainScheduleID(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());\r
 \r
-        if (s != null) {\r
+        if (sch != null) {\r
             throw new CMSAlreadyExistsException(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());\r
         }\r
-        s = new Schedule();\r
-        s.setUuid(UUID.randomUUID());\r
-        s.setUserId(scheduleMessage.getUserId());\r
-        s.setCreateDateTimeMillis(System.currentTimeMillis());\r
-        s.setDomain(scheduleMessage.getDomain());\r
-        s.setScheduleId(scheduleMessage.getScheduleId());\r
-        s.setOptimizerTransactionId(s.getScheduleId()); // No reason these cannot be the same as\r
-                                                        // these\r
-                                                        // are 1<=>1 at this\r
-                                                        // point.\r
-        s.setScheduleName(scheduleMessage.getScheduleName());\r
-        s.setOptimizerAttemptsToSchedule(0);\r
-        s.setScheduleInfo(scheduleMessage.getSchedulingInfo().toString());\r
-        s.setStatus(CMSStatusEnum.PendingSchedule.toString());\r
-        scheduleDAO.save(s);\r
+        sch = new Schedule();\r
+        sch.setUuid(UUID.randomUUID());\r
+        sch.setUserId(scheduleMessage.getUserId());\r
+        sch.setCreateDateTimeMillis(System.currentTimeMillis());\r
+        sch.setDomain(scheduleMessage.getDomain());\r
+        sch.setScheduleId(scheduleMessage.getScheduleId());\r
+        sch.setOptimizerTransactionId(sch.getScheduleId()); // No reason these cannot be the same as\r
+        // these\r
+        // are 1<=>1 at this\r
+        // point.\r
+        sch.setScheduleName(scheduleMessage.getScheduleName());\r
+        sch.setOptimizerAttemptsToSchedule(0);\r
+        sch.setScheduleInfo(scheduleMessage.getSchedulingData().toString());\r
+        sch.setStatus(CMSStatusEnum.PendingSchedule.toString());\r
+        scheduleDAO.save(sch);\r
         for (DomainData dd : domainData) {\r
-               dd.setUuid(UUID.randomUUID());\r
-            s.addDomainData(dd);\r
+            dd.setUuid(UUID.randomUUID());\r
+            sch.addDomainData(dd);\r
             domainDataDAO.save(dd);\r
         }\r
-        scheduleDAO.save(s);\r
-        return s;\r
+        scheduleDAO.save(sch);\r
+        return sch;\r
     }\r
 \r
-    private void messageValidations(ScheduleMessage scheduleMessage) throws CMSException {\r
+    private void messageValidations(OptimizedScheduleMessage scheduleMessage) throws CMSException {\r
         if (scheduleMessage.getScheduleName() == null || scheduleMessage.getScheduleName().equals("")) {\r
             throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulerName", "");\r
         }\r
@@ -119,47 +111,48 @@ public class BaseSchedulerServiceImpl {
     }\r
 \r
     protected void deleteScheduleRequest(String domain, String scheduleId) throws CMSException {\r
-        Schedule s = scheduleDAO.findByDomainScheduleID(domain, scheduleId);\r
-        if (s == null) {\r
+        Schedule sch = scheduleDAO.findByDomainScheduleID(domain, scheduleId);\r
+        if (sch == null) {\r
             throw new CMSNotFoundException(domain, scheduleId);\r
         }\r
-        CMSStatusEnum currentStatus = CMSStatusEnum.Completed.fromString(s.getStatus());\r
-        s.setDeleteDateTimeMillis(System.currentTimeMillis());\r
+        CMSStatusEnum currentStatus = CMSStatusEnum.Completed.fromString(sch.getStatus());\r
+        sch.setDeleteDateTimeMillis(System.currentTimeMillis());\r
         switch (currentStatus) {\r
             case Scheduled:\r
                 // TODO CLose all tickets....\r
-                s.setStatus(CMSStatusEnum.Cancelled.toString());\r
+                sch.setStatus(CMSStatusEnum.Cancelled.toString());\r
                 break;\r
             case NotificationsInitiated:\r
                 throw new CMSException(Status.NOT_ACCEPTABLE, LogMessages.CANNOT_CANCEL_IN_PROGRESS);\r
             default:\r
-                s.setStatus(CMSStatusEnum.Deleted.toString());\r
+                sch.setStatus(CMSStatusEnum.Deleted.toString());\r
         }\r
-        scheduleDAO.save(s);\r
+        scheduleDAO.save(sch);\r
     }\r
 \r
-    protected Schedule processApproval(Schedule s, String domain, ApprovalMessage approvalMessage) throws CMSException {\r
-        String scheduleId = s.getScheduleId();\r
+    protected Schedule processApproval(Schedule sch, String domain, ApprovalMessage approvalMessage)\r
+                    throws CMSException {\r
+        String scheduleId = sch.getScheduleId();\r
         ApprovalType approvalType =\r
-                approvalTypeDAO.findByDomainAndType(domain, approvalMessage.getApprovalType().toString());\r
+                        approvalTypeDAO.findByDomainAndType(domain, approvalMessage.getApprovalType().toString());\r
         if (approvalType == null) {\r
             throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "approvalType",\r
-                    approvalMessage.getApprovalType().toString());\r
+                            approvalMessage.getApprovalType().toString());\r
         }\r
 \r
-        if (!s.getStatus().equals(CMSStatusEnum.PendingApproval.toString())) {\r
+        if (!sch.getStatus().equals(CMSStatusEnum.PendingApproval.toString())) {\r
             throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.NOT_PENDING_APPROVAL, domain, scheduleId,\r
-                    s.getStatus());\r
+                            sch.getStatus());\r
         }\r
         if (approvalMessage.getApprovalUserId() == null || approvalMessage.getApprovalUserId().equals("")) {\r
             throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId");\r
         }\r
         ScheduleApproval sa = null;\r
         // only 1 approval per user....\r
-        if (s.getScheduleApprovals() != null) {\r
-            for (ScheduleApproval scheduleApproval : s.getScheduleApprovals()) {\r
+        if (sch.getScheduleApprovals() != null) {\r
+            for (ScheduleApproval scheduleApproval : sch.getScheduleApprovals()) {\r
                 if (scheduleApproval.getUserId().equals(approvalMessage.getApprovalUserId())\r
-                        && scheduleApproval.getApprovalTypesUuid().equals(approvalType.getUuid())) {\r
+                                && scheduleApproval.getApprovalTypesUuid().equals(approvalType.getUuid())) {\r
                     sa = scheduleApproval;\r
                 }\r
             }\r
@@ -167,32 +160,33 @@ public class BaseSchedulerServiceImpl {
         if (sa == null) {\r
             sa = new ScheduleApproval();\r
             sa.setUuid(UUID.randomUUID());\r
-            sa.setSchedule(s);\r
+            sa.setSchedule(sch);\r
             sa.setApprovalTypesUuid(approvalType.getUuid());\r
             sa.setUserId(approvalMessage.getApprovalUserId());\r
         }\r
         // Ignore what time is on the message\r
         sa.setApprovalDateTimeMillis(System.currentTimeMillis());\r
         sa.setStatus(approvalMessage.getApprovalStatus().toString());\r
-        sa.setSchedule(s);\r
-        s.addScheduleApproval(sa);\r
-        scheduleDAO.save(s);\r
+        sa.setSchedule(sch);\r
+        sch.addScheduleApproval(sa);\r
+        scheduleDAO.save(sch);\r
         if (sa.getStatus().equals(ApprovalStatusEnum.Rejected.toString())) {\r
-            s.setStatus(CMSStatusEnum.Rejected.toString());\r
+            sch.setStatus(CMSStatusEnum.Rejected.toString());\r
         } else {\r
-            if (allApprovalsReceived(s, sa))\r
-                s.setStatus(CMSStatusEnum.Accepted.toString());\r
+            if (allApprovalsReceived(sch, sa)) {\r
+                sch.setStatus(CMSStatusEnum.Accepted.toString());\r
+            }\r
         }\r
-        scheduleDAO.save(s);\r
-        return s;\r
+        scheduleDAO.save(sch);\r
+        return sch;\r
     }\r
 \r
     private boolean allApprovalsReceived(Schedule schedule, ScheduleApproval sa) {\r
         Map<UUID, Integer> requiredApprovalsByType = new HashMap<>(); // Approval\r
-                                                                                         // countdown\r
+        // countdown\r
         Map<UUID, ApprovalType> approvalsByType = new HashMap<>(); // Just\r
-                                                                                           // for\r
-                                                                                           // logging\r
+        // for\r
+        // logging\r
 \r
         List<ApprovalType> approvalTypes = approvalTypeDAO.findByDomain(schedule.getDomain());\r
         for (ApprovalType at : approvalTypes) {\r
@@ -218,7 +212,7 @@ public class BaseSchedulerServiceImpl {
                     requiredApprovalsByType.put(approval.getApprovalTypesUuid(), remaining);\r
                 } else {\r
                     log.warn("Ignored Unidentified approval type {0} for domain {1}", approval.getApprovalTypesUuid(),\r
-                            schedule.getDomain());\r
+                                    schedule.getDomain());\r
                 }\r
             }\r
         }\r
@@ -230,5 +224,4 @@ public class BaseSchedulerServiceImpl {
         }\r
         return true;\r
     }\r
-\r
 }\r