teichmann@5835: package org.dive4elements.river.client.shared.model; ingo@3: ingo@3: import java.util.Date; ingo@3: ingo@607: import com.google.gwt.safehtml.shared.SafeHtml; ingo@607: import com.google.gwt.safehtml.shared.SafeHtmlBuilder; ingo@607: ingo@3: import com.smartgwt.client.widgets.grid.ListGridRecord; ingo@3: ingo@3: ingo@3: /** ingo@3: * The CollectionRecord is a wrapper to put Collection objects into a ListGrid. ingo@3: * ingo@3: * @author Ingo Weinzierl ingo@3: */ ingo@3: public class CollectionRecord extends ListGridRecord { ingo@3: ingo@3: /** The artifact collection. */ ingo@3: protected Collection collection; ingo@3: ingo@3: ingo@3: /** ingo@3: * The default constructor. ingo@3: * ingo@3: * @param collection The artifact collection. ingo@3: */ ingo@3: public CollectionRecord(Collection collection) { ingo@3: this.collection = collection; ingo@226: ingo@226: setCreationTime(collection.getCreationTime()); ingo@226: ingo@226: String name = collection.getName(); ingo@226: setName(name != null && name.length() > 0 ingo@226: ? name ingo@226: : collection.identifier()); ingo@587: ingo@587: setTTL(collection.getTTL()); ingo@226: } ingo@226: ingo@226: ingo@226: /** ingo@226: * Sets the creation time. ingo@226: * ingo@226: * @param creationTime The creation time. ingo@226: */ ingo@226: public void setCreationTime(Date creationTime) { ingo@226: setAttribute("creationTime", creationTime); ingo@3: } ingo@3: ingo@3: ingo@3: /** ingo@97: * Returns the date of the creation. ingo@3: * ingo@97: * @return the creation time. ingo@3: */ ingo@97: public Date getCreationTime() { ingo@226: return getAttributeAsDate("creationTime"); ingo@3: } ingo@3: ingo@3: ingo@3: /** ingo@3: * Returns the name of the collection. ingo@3: * ingo@3: * @return the name of the collection. ingo@3: */ ingo@226: public void setName(String name) { ingo@607: SafeHtmlBuilder b = new SafeHtmlBuilder(); ingo@607: b.appendEscaped(name); ingo@607: ingo@607: SafeHtml html = b.toSafeHtml(); ingo@607: ingo@607: setAttribute("name", html.asString()); ingo@3: } ingo@222: ingo@222: ingo@226: /** ingo@226: * Returns the name of the collection or the uuid if no name is specified. ingo@226: * ingo@226: * @return the name of the collection. ingo@226: */ ingo@226: public String getName() { ingo@226: return getAttributeAsString("name"); ingo@226: } ingo@226: ingo@226: ingo@587: public void setTTL(long ttl) { ingo@587: if (ttl == 0) { ingo@587: setAttribute("ttl", "star_gold"); ingo@587: } ingo@587: else { ingo@587: setAttribute("ttl", "star_silver"); ingo@587: } ingo@587: } ingo@587: ingo@587: ingo@587: public String getTTL() { ingo@587: return getAttribute("ttl"); ingo@587: } ingo@587: ingo@587: ingo@226: /** ingo@226: * Returns the collection objects itself. ingo@226: * ingo@226: * @return the collection object. ingo@226: */ ingo@222: public Collection getCollection() { ingo@222: return collection; ingo@222: } ingo@3: } ingo@3: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :