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

54 lines
1.7 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;
2010-12-16 18:24:21 +01:00
import de.hsadmin.core.qserv.QueueTask.QueueTaskStatus;
import de.hsadmin.mods.user.UnixUser;
2010-10-01 21:52:51 +02:00
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
2011-10-28 16:08:18 +02:00
protected void entity2map(AbstractEntity entity, Map<String, Object> resultMap) {
2010-10-01 21:52:51 +02:00
QueueTask task = (QueueTask) entity;
resultMap.put("id", Long.toString(task.getId()));
2010-12-16 18:24:21 +01:00
QueueTaskStatus status = task.getStatus();
if (status != null) resultMap.put("status", status.toString());
if (assertNotNull(task.getTitle())) resultMap.put("title", task.getTitle());
if (assertNotNull(task.getDetails())) resultMap.put("details", task.getDetails());
if (assertNotNull(task.getException())) resultMap.put("exception", task.getException());
UnixUser user = task.getUser();
if (user != null) resultMap.put("user", user.getName());
2010-10-01 21:52:51 +02:00
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
2011-10-28 16:08:18 +02:00
protected void map2entity(Map<String, Object> 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");
}
}