package de.hsadmin.remote; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.qserv.QueueTask; public class QueueTaskRemote extends AbstractRemote { private static final DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.SHORT); @Override protected Class getEntityClass() { return QueueTask.class; } @Override protected void entity2map(AbstractEntity entity, Map resultMap) { QueueTask task = (QueueTask) entity; resultMap.put("id", Long.toString(task.getId())); resultMap.put("status", task.getStatus().toString()); resultMap.put("title", task.getTitle()); resultMap.put("details", task.getDetails()); resultMap.put("exception", task.getException()); resultMap.put("user", task.getUser().getName()); Date started = task.getStarted(); if (assertNotNull(started)) { resultMap.put("started", df.format(started)); } Date finished = task.getFinished(); if (assertNotNull(finished)) { resultMap.put("finished", df.format(finished)); } } @Override protected void map2entity(Map setParams, AbstractEntity entity) { // never used } @Override protected void regularizeKeys(Map whereParams) { replaceKey(whereParams, "user", "user.name"); } }