diff options
author | Jerry Flood <jflood@att.com> | 2019-03-28 15:41:57 -0400 |
---|---|---|
committer | Jerry Flood <jflood@att.com> | 2019-03-28 16:02:41 -0400 |
commit | fe8c1df09a3c74321831b40f6f953016d746aa61 (patch) | |
tree | eb7be4e995899ff38a385219f37e952f47e48c02 /cmso-optimizer/src/main/java/org/onap | |
parent | b49d93de48e5404b1a17ddb1b2f4c3b432de9506 (diff) |
Merge missing optimizer classes
Implement policy model.
Issue-ID: OPTFRA-458
Change-Id: Ibb7f8535af910dff3ab9ce671b62fb826899058c
Signed-off-by: Jerry Flood <jflood@att.com>
Diffstat (limited to 'cmso-optimizer/src/main/java/org/onap')
8 files changed, 771 insertions, 0 deletions
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java index ce1c389..b61b02a 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java @@ -72,6 +72,7 @@ public enum LogMessages implements ObservationInterface { TOPOLOGY_REQUEST("Topology request {0} for {1} URL: {1}", Status.OK, Level.INFO), OPTIMIZER_REQUEST("OPtimizer request {0} for {1} Command: {1}", Status.OK, Level.INFO), TICKETS_REQUEST("Tickets request {0} for {1} URL: {1}", Status.OK, Level.INFO), + UNSUPPORTED_PERIODIC_TIME("Unsupported periodic time from policy: {0}", Status.INTERNAL_SERVER_ERROR, Level.ERROR), ; private final String defaultId; diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerRequest.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerRequest.java new file mode 100644 index 0000000..0961de5 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerRequest.java @@ -0,0 +1,160 @@ +/* + * 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.service.rs.models; + +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 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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerResponse.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerResponse.java new file mode 100644 index 0000000..2f8e705 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerResponse.java @@ -0,0 +1,110 @@ +/* + * 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.service.rs.models; + +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; + } + + /** + * To string. + * + * @return the string + */ + @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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerScheduleInfo.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerScheduleInfo.java new file mode 100644 index 0000000..37bb404 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerScheduleInfo.java @@ -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.service.rs.models; + +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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/PolicyInfo.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/PolicyInfo.java new file mode 100644 index 0000000..524571a --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/PolicyInfo.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * + * 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.service.rs.models; + +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 = "Supported Policy Information", description = "Policy Information returned from get policies API.") +public class PolicyInfo implements Serializable { + private static final long serialVersionUID = 1L; + private static EELFLogger log = EELFManager.getInstance().getLogger(PolicyInfo.class); + + @ApiModelProperty(value = "Policy name") + private String policyName; + + @ApiModelProperty(value = "Policy description") + private String policyDescription; + + @ApiModelProperty(value = "Named values to modify/override policy attributes.") + public List<NameValue> policyModifiers = new ArrayList<>(); + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public String getPolicyDescription() { + return policyDescription; + } + + public void setPolicyDescription(String policyDescription) { + this.policyDescription = policyDescription; + } + + public List<NameValue> getPolicyModifiers() { + return policyModifiers; + } + + public void setPolicyModifiers(List<NameValue> policyModifiers) { + this.policyModifiers = policyModifiers; + } + + @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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ReferencedElementInfo.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ReferencedElementInfo.java new file mode 100644 index 0000000..97210b1 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ReferencedElementInfo.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * + * 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.service.rs.models; + +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 = "Topology Related Element", description = "Element Information returned from TopologyRequuest.") +public class ReferencedElementInfo implements Serializable { + private static final long serialVersionUID = 1L; + private static EELFLogger log = EELFManager.getInstance().getLogger(ReferencedElementInfo.class); + + @ApiModelProperty(value = "Element identifier") + private String elementId; + + @ApiModelProperty(value = "Location information for the element.") + private ElementLocation elementLocation; + + @ApiModelProperty(value = "Related elements only. Element ids of the element(s) ") + private List<String> referencingElements; + + @ApiModelProperty(value = "Implementation specific element data.") + public List<NameValue> elementData = new ArrayList<>(); + + public String getElementId() { + return elementId; + } + + public void setElementId(String elementId) { + this.elementId = elementId; + } + + public ElementLocation getElementLocation() { + return elementLocation; + } + + public void setElementLocation(ElementLocation elementLocation) { + this.elementLocation = elementLocation; + } + + + public List<String> getRelatedElements() { + return referencingElements; + } + + public void setRelatedElements(List<String> relatedElements) { + this.referencingElements = relatedElements; + } + + public List<NameValue> getElementData() { + return elementData; + } + + public void setElementData(List<NameValue> elementData) { + this.elementData = elementData; + } + + @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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ScheduledElement.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ScheduledElement.java new file mode 100644 index 0000000..b3561dd --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ScheduledElement.java @@ -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.service.rs.models; + +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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/UnScheduledElement.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/UnScheduledElement.java new file mode 100644 index 0000000..775c760 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/UnScheduledElement.java @@ -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.service.rs.models; + +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 ""; + } +} |