/** * * BPS Bildungsportal Sachsen GmbH
* Bahnhofstrasse 6
* 09111 Chemnitz
* Germany
* * Copyright (c) 2005-2009 by BPS Bildungsportal Sachsen GmbH
* http://www.bps-system.de
* * All rights reserved. */ package de.bps.olat.modules.cl; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; import org.olat.core.commons.persistence.PersistentObject; import org.olat.core.id.ModifiedInfo; /** * Description:
* Checklist object, stored in "o_checklist" via Hibernate * *

* Initial Date: 23.07.2009
* @author bja */ public class Checklist extends PersistentObject implements ModifiedInfo, Serializable { private String title; private String description; private Date lastMofified; private List checkpoints = new ArrayList(); public Checklist() { this.title = ""; this.description = ""; } public Checklist(String title, String description, List checkpoints) { this.title = title; this.description = description; this.checkpoints = checkpoints; this.lastMofified = new Date(); } /** * @return Returns the title. */ public String getTitle() { return title; } /** * @return Returns the description. */ public String getDescription() { return description; } /** * @return Returns the checkpoints. */ public List getCheckpoints() { return checkpoints; } /** * @return Returns the checkpoints sorted. */ public List getCheckpointsSorted(Comparator comparator) { Collections.sort(checkpoints, comparator); return checkpoints; } /** * @param title The title to set. */ public void setTitle(String title) { this.title = title; } /** * @param description The description to set. */ public void setDescription(String description) { this.description = description; } /** * @param checkpoints The checkpoints to set. */ public void setCheckpoints(List checkpoints) { this.checkpoints = checkpoints; } /** * @see org.olat.core.id.ModifiedInfo#getLastModified() */ public Date getLastModified() { return this.lastMofified; } /** * @see org.olat.core.id.ModifiedInfo#setLastModified(java.util.Date) */ public void setLastModified(Date date) { this.lastMofified = date; } /** * Add checkpoint to this checklist * @param index * @param checkpoint */ public void addCheckpoint(int index, Checkpoint checkpoint) { this.checkpoints.add(index, checkpoint); } /** * Remove checkpoint from this checklist * @param checkpoint */ public void removeCheckpoint(Checkpoint checkpoint) { this.checkpoints.remove(checkpoint); } /** * @return true or false */ public boolean hasCheckpoints() { return (this.checkpoints != null) && (this.checkpoints.size() > 0); } /** * Filter out unvisible checkpoints. * @return List with all visible checkpoints */ public List getVisibleCheckpoints() { List visibleCheckpoints = new ArrayList(); for(Checkpoint checkpoint : getCheckpoints()) { if(!checkpoint.getMode().equals(CheckpointMode.MODE_HIDDEN)) visibleCheckpoints.add(checkpoint); } return visibleCheckpoints; } }