package ca.corefacility.bioinformatics.irida.ria.web.models.datatables;

import java.util.Date;

import ca.corefacility.bioinformatics.irida.model.announcements.Announcement;
import ca.corefacility.bioinformatics.irida.model.user.User;
import ca.corefacility.bioinformatics.irida.ria.web.components.datatables.models.DataTablesResponseModel;

/**
 * User interface model for DataTables for administration of {@link Announcement}
 */
public class DTAnnouncementAdmin implements DataTablesResponseModel {
	private Long id;
	private String message;
	private Date createdDate;
	private User user;

	public DTAnnouncementAdmin(Announcement announcement) {
		this.id = announcement.getId();
		// Only display the first line of the message.
		this.message = announcement.getMessage().split("\\r?\\n")[0];
		this.createdDate = announcement.getCreatedDate();
		this.user = announcement.getUser();
	}

	@Override
	public Long getId() {
		return id;
	}

	public String getMessage() {
		return message;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public User getUser() {
		return user;
	}
}

@@ -791,16 +791,183 @@
 n%22)%5B0%5D;%0A
+%09%09if(this.message.length() %3E 80)%7B%0A%09%09%09// If the message is still really long just take a substring of it.%0A%09%09%09this.message = this.message.substring(0, 79) + %22 ...%22;%0A%09%09%7D%0A
 %09%09this.c

Truncate really long message previews