hs.hsadmin/hsarback/src/de/hsadmin/remote/QueueTaskRemote.java

50 lines
1.3 KiB
Java
Raw Normal View History

2010-10-01 21:52:51 +02:00
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.Entity;
import de.hsadmin.core.qserv.QueueTask;
public class QueueTaskRemote extends AbstractRemote {
private static final DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.SHORT);
@Override
protected Class<? extends Entity> getEntityClass() {
return QueueTask.class;
}
@Override
protected void entity2map(Entity entity, Map<String, String> 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<String, String> setParams, Entity entity) {
// never used
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "user", "user.name");
}
}