com.denimgroup.threadfix.data.entities.PolicyStatus Maven / Gradle / Ivy
////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2009-2016 Denim Group, Ltd.
//
// The contents of this file are subject to the Mozilla Public 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.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is ThreadFix.
//
// The Initial Developer of the Original Code is Denim Group, Ltd.
// Portions created by Denim Group, Ltd. are Copyright (C)
// Denim Group, Ltd. All Rights Reserved.
//
// Contributor(s): Denim Group, Ltd.
//
////////////////////////////////////////////////////////////////////////
package com.denimgroup.threadfix.data.entities;
import com.denimgroup.threadfix.views.AllViews;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static com.denimgroup.threadfix.CollectionUtils.map;
/**
* @author zabdisubhan
*/
@Entity
@Table(name = "PolicyStatus"
,
uniqueConstraints = {
@UniqueConstraint(name = "Application_Id", columnNames = { "`Application_Id`", "`Policy_Id`" })}
)
public class PolicyStatus extends AuditableEntity {
private Boolean passing = false;
private Application application;
private Policy policy;
private List emailLists;
private List emailAddresses;
private Boolean sendEmail = false;
private transient boolean statusChanged = false;
private Date statusLastChanged;
@ElementCollection
@Column(name = "emailAddress", length = 128)
@CollectionTable(name = "PolicyStatusEmailAddress", joinColumns = @JoinColumn(name = "PolicyStatusId"), foreignKey = @ForeignKey(name="FK416906BC6E262BC2"))
@JsonView(AllViews.PolicyPageView.class)
public List getEmailAddresses() {
return emailAddresses;
}
public void setEmailAddresses(List emailAddresses) {
this.emailAddresses = emailAddresses;
}
@ManyToMany
@JoinTable(name="PolicyStatus_EmailList_Join",
joinColumns={ @JoinColumn(name="PolicyStatus_id", foreignKey = @ForeignKey(name="fk_PSEJ_PolicyStatus_id")) },
inverseJoinColumns={ @JoinColumn(name="emailLists_id", foreignKey = @ForeignKey(name="fk_PSEJ_emailLists_id")) })
@JsonView(AllViews.PolicyPageView.class)
public List getEmailLists() {
return emailLists;
}
public void setEmailLists(List emailLists) {
this.emailLists = emailLists;
}
@Column
@JsonView({AllViews.FormInfo.class, AllViews.PolicyPageView.class})
public Boolean isPassing() {
return passing != null && passing;
}
public void setPassing(boolean passing) {
this.passing = passing;
}
@Transient
public boolean hasStatusChanged() {
return statusChanged;
}
public void setStatusChanged(boolean statusChanged) {
this.statusChanged = statusChanged;
}
@ManyToOne
@JsonIgnore
@JoinColumn(name = "`Application_Id`", nullable = false, foreignKey = @ForeignKey(name="FK96D387E47D4477DB"))
public Application getApplication() {
return application;
}
public void setApplication(Application application) {
this.application = application;
}
@Column
@JsonView(AllViews.PolicyPageView.class)
public Boolean isSendEmail() {
return sendEmail != null && sendEmail;
}
public void setSendEmail(Boolean sendEmail) {
this.sendEmail = sendEmail;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = true)
@JsonView({AllViews.FormInfo.class, AllViews.PolicyPageView.class})
public Date getStatusLastChanged() {
return statusLastChanged;
}
public void setStatusLastChanged(Date statusLastChanged) {
this.statusLastChanged = statusLastChanged;
}
@Transient
@JsonProperty("application")
@JsonView(AllViews.PolicyPageView.class)
public Map getApplicationJson() {
if(application != null) {
return map(
"id", application.getId(),
"name", application.getName(),
"team", map(
"id", application.getOrganization().getId(),
"name", application.getOrganization().getName()));
} else {
return null;
}
}
@ManyToOne
@JsonIgnore
@JoinColumn(name = "`Policy_Id`", nullable = false, foreignKey = @ForeignKey(name="FK96D387E430DFFFF9"))
public Policy getPolicy() {
return policy;
}
public void setPolicy(Policy policy) {
this.policy = policy;
}
@Transient
@JsonProperty("policy")
@JsonView({AllViews.TableRow.class, AllViews.FormInfo.class, AllViews.PolicyPageView.class})
public Map getPolicyJson() {
if(policy != null) {
return map(
"id", policy.getId(),
"name", policy.getName(),
"filterName", policy.getFilterJsonBlob() != null ? policy.getFilterJsonBlob().getName() : null);
} else {
return null;
}
}
@Transient
@JsonView({AllViews.TableRow.class, AllViews.FormInfo.class, AllViews.PolicyPageView.class})
public String getName() {
return application.getName();
}
@Transient
@JsonView({AllViews.FormInfo.class, AllViews.PolicyPageView.class})
public Date getLastEvaluated(){
return getModifiedDate();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy