com.infinities.skyport.entity.TaskEventLog.java Source code

Java tutorial

Introduction

Here is the source code for com.infinities.skyport.entity.TaskEventLog.java

Source

/*******************************************************************************
 * Copyright 2015 InfinitiesSoft Solutions Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *******************************************************************************/
package com.infinities.skyport.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.infinities.skyport.compute.entity.adapter.ISO8601DateAdapter;
import com.infinities.skyport.compute.entity.serializer.ShortSelfRecursiveSerializer;
import com.infinities.skyport.view.Views;

/**
 * TaskEventLog generated by hbm2java
 */
@Entity
@Table(name = "TASKEVENTLOG")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class TaskEventLog implements java.io.Serializable {

    private static final long serialVersionUID = 1L;

    public static enum Status implements java.io.Serializable {
        Initiazing, Queueing, Executing, Success, Fail, Cancelled;
    }

    @XmlTransient
    private Long id;
    @JsonView(Views.Short.class)
    @JsonUnwrapped
    private TaskEvent taskEvent;
    @JsonView(Views.Short.class)
    @XmlJavaTypeAdapter(value = ISO8601DateAdapter.class)
    private Date logdate;
    @JsonView(Views.Basic.class)
    @Enumerated(EnumType.STRING)
    private Status status;
    @JsonView(Views.Short.class)
    private String message;
    @JsonView(Views.Basic.class)
    @JsonSerialize(using = ShortSelfRecursiveSerializer.class)
    private Serializable detail;
    @XmlTransient
    private int version;

    public TaskEventLog() {
    }

    public TaskEventLog(TaskEvent taskEvent, Date logdate, Status status, String message, Serializable detail) {
        this.taskEvent = taskEvent;
        this.logdate = logdate;
        this.status = status;
        this.message = message;
        this.detail = detail;
    }

    @XmlTransient
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "EVENTID")
    public TaskEvent getTaskEvent() {
        return this.taskEvent;
    }

    public void setTaskEvent(TaskEvent taskEvent) {
        this.taskEvent = taskEvent;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "LOGDATE", length = 30)
    public Date getLogdate() {
        return this.logdate;
    }

    public void setLogdate(Date logdate) {
        this.logdate = logdate;
    }

    @Column(name = "STATUS", length = 20)
    public Status getStatus() {
        return this.status;
    }

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

    @Column(name = "MESSAGE", length = 500)
    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Lob
    @Column(name = "DETAIL", length = 65535)
    public Serializable getDetail() {
        return this.detail;
    }

    public void setDetail(Serializable detail) {
        this.detail = detail;
    }

    @XmlTransient
    @Version
    @Column(name = "OPTLOCK")
    public int getVersion() {
        return version;
    }

    @XmlTransient
    public void setVersion(int version) {
        this.version = version;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        TaskEventLog other = (TaskEventLog) obj;
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        return true;
    }

}