package ubic.gemma.model.common.auditAndSecurity.curation;

import ubic.gemma.model.common.auditAndSecurity.AuditEvent;

import java.util.Date;

/**
 * Created by tesarst on 07/03/17.
 *
 * Abstract curatable value object that provides variables and methods for data stored in CurationDetails objects on
 * curatable objects.
 */
public abstract class AbstractCuratableValueObject {

    protected Date lastUpdated;

    protected Boolean troubled;

    protected AuditEvent lastTroubledEvent;

    protected Boolean needsAttention;

    protected AuditEvent lastNeedsAttentionEvent;

    protected String curationNote;

    protected AuditEvent lastCurationNoteEvent;

    public AbstractCuratableValueObject() {
    }

    public AbstractCuratableValueObject( Date lastUpdated, Boolean troubled, AuditEvent lastTroubledEvent,
            Boolean needsAttention, AuditEvent lastNeedsAttentionEvent, String curationNote,
            AuditEvent lastCurationNoteEvent ) {
        this.lastUpdated = lastUpdated;
        this.troubled = troubled;
        this.lastTroubledEvent = lastTroubledEvent;
        this.needsAttention = needsAttention;
        this.lastNeedsAttentionEvent = lastNeedsAttentionEvent;
        this.curationNote = curationNote;
        this.lastCurationNoteEvent = lastCurationNoteEvent;
    }

    public Date getLastUpdated() {
        return lastUpdated;
    }

    public void setLastUpdated( Date lastUpdated ) {
        this.lastUpdated = lastUpdated;
    }

    public Boolean getTroubled() {
        return troubled;
    }

    public void setTroubled( Boolean troubled ) {
        this.troubled = troubled;
    }

    public AuditEvent getLastTroubledEvent() {
        return lastTroubledEvent;
    }

    public void setLastTroubledEvent( AuditEvent lastTroubledEvent ) {
        this.lastTroubledEvent = lastTroubledEvent;
    }

    public Boolean getNeedsAttention() {
        return needsAttention;
    }

    public void setNeedsAttention( Boolean needsAttention ) {
        this.needsAttention = needsAttention;
    }

    public AuditEvent getLastNeedsAttentionEvent() {
        return lastNeedsAttentionEvent;
    }

    public void setLastNeedsAttentionEvent( AuditEvent lastNeedsAttentionEvent ) {
        this.lastNeedsAttentionEvent = lastNeedsAttentionEvent;
    }

    public String getCurationNote() {
        return curationNote;
    }

    public void setCurationNote( String curationNote ) {
        this.curationNote = curationNote;
    }

    public AuditEvent getLastCurationNoteEvent() {
        return lastCurationNoteEvent;
    }

    public void setLastCurationNoteEvent( AuditEvent lastCurationNoteEvent ) {
        this.lastCurationNoteEvent = lastCurationNoteEvent;
    }
}

@@ -53,16 +53,67 @@
 ation;%0A%0A
+import org.apache.commons.lang3.StringEscapeUtils;%0A
 import u
@@ -164,16 +164,16 @@
 tEvent;%0A
-
 %0Aimport 
@@ -232,11 +232,8 @@
 17.%0A
- *%0A
  * A
@@ -371,16 +371,16 @@
 ts.%0A */%0A
-
 public a
@@ -425,16 +425,90 @@
 ject %7B%0A%0A
+    protected static final String TROUBLE_DETAILS_NONE = %22Not troubled%22;%0A%0A
     prot
@@ -2844,11 +2844,555 @@
 t;%0A    %7D
+%0A%0A    /**%0A     * @return a string describing the current trouble status of this object.%0A     *%0A     * The EEDetailsVO actually goes through the ADs and composes complete trouble details.%0A     */%0A    public String getTroubleDetails() %7B%0A        return this.getTroubleDetails( true );%0A    %7D%0A%0A    public String getTroubleDetails( boolean htmlEscape ) %7B%0A        String details = this.getTroubled() ? this.getLastTroubledEvent().toString() : TROUBLE_DETAILS_NONE;%0A%0A        return htmlEscape ? StringEscapeUtils.escapeHtml4( details ) : details;%0A    %7D
 %0A%7D%0A

Work on git Issue #1 - Model - added getCurationDetails method