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

75 lines
2.3 KiB
Java
Raw Normal View History

2010-10-05 21:42:07 +02:00
package de.hsadmin.remote;
import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.email.EMailAddress;
public class EMailAddressRemote extends AbstractRemote {
@Override
protected void entity2map(AbstractEntity entity, Map<String, String> map) {
EMailAddress adr = (EMailAddress) entity;
long id = adr.getId();
String domain = adr.getDomain().getName();
String admin = adr.getDomain().getUser().getName();
String pac = adr.getDomain().getUser().getPac().getName();
String target = adr.getTarget();
String localpart = adr.getLocalPart();
String subdomain = adr.getSubdomain();
String emailaddress = adr.getEMailAddress();
String fulldomain = adr.getFullDomain();
map.put("id", Long.toString(id));
2010-12-16 18:24:21 +01:00
if (assertNotNull(domain)) map.put("domain", domain);
if (assertNotNull(admin)) map.put("admin", admin);
if (assertNotNull(pac)) map.put("pac", pac);
if (assertNotNull(target)) map.put("target", target);
if (assertNotNull(localpart)) map.put("localpart", localpart);
if (assertNotNull(subdomain)) map.put("subdomain", subdomain);
if (assertNotNull(emailaddress)) map.put("emailaddress", emailaddress);
if (assertNotNull(fulldomain)) map.put("fulldomain", fulldomain);
2010-10-05 21:42:07 +02:00
}
@Override
protected void map2entity(Map<String, String> map, AbstractEntity entity) {
EMailAddress adr = (EMailAddress) entity;
String localPart = map.get("localpart");
if (assertNotNull(localPart)) {
adr.setLocalPart(localPart);
}
String subdomain = map.get("subdomain");
if (assertNotNull(subdomain)) {
adr.setSubdomain(subdomain);
}
String target = map.get("target");
if (assertNotNull(target)) {
adr.setTarget(target);
}
String domain = map.get("domain");
if (assertNotNull(domain)) {
Domain dom = new Domain();
dom.setName(domain);
adr.setDomain(dom);
}
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return EMailAddress.class;
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "domain", "domain.name");
replaceKey(whereParams, "pac", "domain.user.pac.name");
replaceKey(whereParams, "admin", "domain.user.name");
}
@Override
public String getOrderBy() {
return "ORDER BY obj.domain.name ASC, obj.subdomain ASC, obj.localpart ASC";
}
}