/*
Onix Config Manager - Copyright (c) 2018-2019 by www.gatblau.org

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.

Contributors to this project, hereby assign copyright in their code to the
project, to be licensed under the same terms as the rest of the code.
*/

package org.gatblau.onix.data;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.json.simple.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@ApiModel
public class ItemData implements Serializable {
    private static final long serialVersionUID = 1L;

    private String key;
    private String name;
    private String description;
    private String type;
    private String typeName;
    private Short status;
    private JSONObject meta;
    private boolean metaEnc;
    private String txt;
    private boolean txtEnc;
    private short encKeyIx;
    private JSONObject attribute;
    private List<String> tag;
    private List<LinkData> fromLinks = new ArrayList<>();
    private List<LinkData> toLinks = new ArrayList<>();
    private String created;
    private String updated;
    private Integer version;
    private String changedBy;
    private String partition;

    public ItemData() {
    }

    public ItemData(String key) {
      this.key = key;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    @ApiModelProperty(
            position = 1,
            required = true,
            value = "The human readable name of the configuration item.")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @ApiModelProperty(
            position = 2,
            required = false,
            value = "The configuration item description.")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @ApiModelProperty(
            position = 3,
            required = true,
            value = "The natural key defining the type of this configuration item.")
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @ApiModelProperty(
            position = 4,
            required = false,
            value = "A number indicating the status of the configuration item. " +
                    "Its value is arbitrary and depends on the specific implementation.",
            allowEmptyValue = true
    )
    public Integer getStatus() {
        if (status == null) {
            status = 0;
        }
        return Integer.valueOf(status);
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    @ApiModelProperty(
            position = 5,
            required = false,
            value = "An arbitrary JSON object containing configuration data about the item. " +
                    "If a JSON Schema is defined by the item type for this item, then this attribute " +
                    "is validated against such schema.",
            allowEmptyValue = true
    )
    public JSONObject getMeta() {
        return meta;
    }

    public void setMeta(JSONObject meta) {
        this.meta = meta;
    }

    @ApiModelProperty(
            position = 6,
            required = false,
            value = "A text containing configuration data about the item. ",
            allowEmptyValue = true
    )
    public String getTxt() {
        return txt;
    }

    public void setTxt(String txt) {
        this.txt = txt;
    }

    @ApiModelProperty(
            position = 7,
            required = false,
            value = "An array of strings used as tags for filtering search results. " +
                    "The value of each tag is arbitrary and depends on how searches on the item will be made.",
            example = "[ 'VM', 'AMD64', 'EUROPE' ]",
            allowEmptyValue = true
    )
    public List<String> getTag() {
        return tag;
    }

    public void setTag(List<String> tag) {
        this.tag = tag;
    }
    @ApiModelProperty(
            position = 8,
            required = false,
            value = "The date on which the item was created.",
            notes = "This value is always autogenerated by the service upon item creation and does not need to be specified. " +
                    "It is subsequently retrieved every time item information is requested.",
            allowEmptyValue = true
    )
    public String getCreated() {
        return created;
    }

    public void setCreated(String created) {
        this.created = created;
    }

    @ApiModelProperty(
            position = 9,
            required = false,
            value = "The date on which the item was last updated.",
            notes = "This value is always autogenerated by the service upon item updates and does not need to be specified. " +
                    "It is subsequently retrieved every time item information is requested."
    )
    public String getUpdated() {
        return updated;
    }

    public void setUpdated(String updated) {
        this.updated = updated;
    }

    @ApiModelProperty(
            position = 10,
            required = false,
            value = "The item version.",
            notes = "This value is always autogenerated by the service upon item creation or updates. " +
                    "It only needs to be specified if optimistic concurrency is required, for example by a user interface service."
    )
    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @ApiModelProperty(
            position = 11,
            required = false,
            value = "A list of links that depart from this item.",
            notes = "This value does not need to be specified. " +
                    "It is only used in queries to retrieve links associated with the item without having to issue " +
                    "a separate query."
    )
    public List<LinkData> getFromLinks() {
        return fromLinks;
    }

    public void setFromLinks(List<LinkData> links) {
        this.fromLinks = links;
    }

    @ApiModelProperty(
            position = 12,
            required = false,
            value = "A list of links that arrive to this item.",
            notes = "This value does not need to be specified. " +
                    "It is only used in queries to retrieve links associated with the item without having to issue " +
                    "a separate query."
    )
    public List<LinkData> getToLinks() {
        return toLinks;
    }

    public void setToLinks(List<LinkData> links) {
        this.toLinks = links;
    }

    public JSONObject getAttribute() {
        return attribute;
    }

    public void setAttribute(JSONObject attribute) {
        this.attribute = attribute;
    }

    public String getChangedBy() {
        return changedBy;
    }

    public void setChangedBy(String changedBy) {
        this.changedBy = changedBy;
    }

    public String getPartition() {
        return partition;
    }

    public void setPartition(String partition) {
        this.partition = partition;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public boolean isMetaEnc() {
        return metaEnc;
    }

    public void setMetaEnc(boolean metaEnc) {
        this.metaEnc = metaEnc;
    }

    public boolean isTxtEnc() {
        return txtEnc;
    }

    public void setTxtEnc(boolean txtEnc) {
        this.txtEnc = txtEnc;
    }

    public short getEncKeyIx() {
        return encKeyIx;
    }

    public void setEncKeyIx(short encKeyIx) {
        this.encKeyIx = encKeyIx;
    }
}
