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

51 lines
1.6 KiB
Java

package de.hsadmin.remote;
import java.util.Date;
import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.core.qserv.QueueTask.QueueTaskStatus;
import de.hsadmin.core.util.TextUtil;
import de.hsadmin.mods.user.UnixUser;
public class QueueTaskRemote extends AbstractRemote {
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return QueueTask.class;
}
@Override
protected void entity2map(AbstractEntity entity, Map<String, Object> resultMap) {
QueueTask task = (QueueTask) entity;
resultMap.put("id", Long.toString(task.getId()));
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());
Date started = task.getStarted();
if (assertNotNull(started)) {
resultMap.put("started", TextUtil.format(started));
}
Date finished = task.getFinished();
if (assertNotNull(finished)) {
resultMap.put("finished", TextUtil.format(finished));
}
}
@Override
protected void map2entity(Map<String, Object> setParams, AbstractEntity entity) {
// never used
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "user", "user.name");
}
}