/*
 * Copyright 2017 EPAM Systems
 *
 *
 * This file is part of EPAM Report Portal.
 * https://github.com/reportportal/service-api
 *
 * Report Portal is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Report Portal is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.epam.ta.reportportal.entity.item.issue;

import com.epam.ta.reportportal.entity.enums.PostgreSQLEnumType;
import com.epam.ta.reportportal.entity.project.Project;
import com.fasterxml.jackson.annotation.JsonBackReference;
import org.hibernate.annotations.TypeDef;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * @author Pavel Bortnik
 */
@Entity
@TypeDef(name = "pqsql_enum", typeClass = PostgreSQLEnumType.class)
@Table(name = "issue_type", schema = "public", indexes = { @Index(name = "issue_type_pk", unique = true, columnList = "id ASC") })
public class IssueType implements Serializable {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false, precision = 32)
	private Long id;

	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinColumn(name = "issue_group_id")
	private IssueGroup issueGroup;

	@Column(name = "locator", length = 64)
	private String locator;

	@Column(name = "issue_name", length = 256)
	private String longName;

	@Column(name = "abbreviation", length = 64)
	private String shortName;

	@Column(name = "hex_color", length = 7)
	private String hexColor;

	@JsonBackReference(value = "issueTypes")
	@ManyToMany(mappedBy = "issueTypes")
	private List<Project> projects;

	public IssueType() {
	}

	public IssueType(IssueGroup issueGroup, String locator, String longName, String shortName, String hexColor) {
		this.issueGroup = issueGroup;
		this.locator = locator;
		this.longName = longName;
		this.shortName = shortName;
		this.hexColor = hexColor;
	}

	public Long getId() {
		return id;
	}

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

	public IssueGroup getIssueGroup() {
		return issueGroup;
	}

	public void setIssueGroup(IssueGroup issueGroup) {
		this.issueGroup = issueGroup;
	}

	public String getLocator() {
		return locator;
	}

	public void setLocator(String locator) {
		this.locator = locator;
	}

	public String getLongName() {
		return longName;
	}

	public void setLongName(String longName) {
		this.longName = longName;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	public String getHexColor() {
		return hexColor;
	}

	public void setHexColor(String hexColor) {
		this.hexColor = hexColor;
	}

	public List<Project> getProjects() {
		return projects;
	}

	public void setProjects(List<Project> projects) {
		this.projects = projects;
	}
}

@@ -959,67 +959,8 @@
 ct;%0A
-import com.fasterxml.jackson.annotation.JsonBackReference;%0A
 impo
@@ -1934,50 +1934,8 @@
 r;%0A%0A
-%09@JsonBackReference(value = %22issueTypes%22)%0A
 %09@Ma

Fix infinite recursion during serialization