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

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