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

47 lines
1.1 KiB
Java

package de.hsadmin.remote;
import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.mods.email.EMailAlias;
public class EMailAliasRemote extends AbstractRemote {
@Override
protected void entity2map(AbstractEntity entity, Map<String, String> map) {
EMailAlias alias = (EMailAlias) entity;
String id = Long.toString(alias.getId());
String name = alias.getName();
String pac = alias.getPac().getName();
String target = alias.getTarget();
map.put("id", id);
map.put("name", name);
map.put("pac", pac);
map.put("target", target);
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return EMailAlias.class;
}
@Override
protected void map2entity(Map<String, String> map, AbstractEntity entity) {
EMailAlias alias = (EMailAlias) entity;
String name = map.get("name");
String target = map.get("target");
if (assertNotNull(name)) {
alias.setName(name);
}
if (assertNotNull(target)) {
alias.setTarget(target);
}
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "pac", "pac.name");
}
}