package li.l1t.tingo.model;

import org.hibernate.validator.constraints.Length;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.Valid;

/**
 * Represents a field in a Tingo bingo field, representing something a teacher might do in a lesson.
 *
 * @author <a href="http://xxyy.github.io/">xxyy</a>
 * @since 2016-02-14
 */
@Entity
@Table(name = "tingo_field")
public class TingoField extends BaseEntity {
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "teacher_id", updatable = false, nullable = false)
    private Teacher teacher;

    @Column(nullable = false, columnDefinition = "TEXT")
    @Valid
    @Length(max = 256)
    private String text;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "creator_name", updatable = false)
    private RegisteredUser creator;

    protected TingoField() { }

    public TingoField(Teacher teacher, String text) {
        this(0, teacher, text);
    }

    public TingoField(int id, Teacher teacher, String text) {
        super(id);
        this.teacher = teacher;
        this.text = text;
    }

    public Teacher getTeacher() {
        return teacher;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public RegisteredUser getCreator() {
        return creator;
    }

    public void setCreator(RegisteredUser creator) {
        this.creator = creator;
    }

    @Override
    public String toString() {
        return "TingoField{" +
                "teacher=" + teacher +
                ", text='" + text + '\'' +
                '}';
    }
}

@@ -1371,19 +1371,74 @@
     
-return text
+// Legacy newline support%0A        return text.replace(%22%5C%5Cn%22, %22%5Cn%22)
 ;%0A  

Translate legacy/messed-up newlines