package de.hsadmin.remote; import java.util.Map; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.mods.db.MySqlUser; public class MysqlUserRemote extends AbstractRemote { @Override protected void entity2map(AbstractEntity entity, Map map) { MySqlUser user = (MySqlUser) entity; String id = Long.toString(user.getId()); String name = user.getName(); String instance = user.getInstance(); String pac = user.getPac().getName(); String hive = user.getHiveName(); map.put("id", id); map.put("name", name); map.put("pac", pac); map.put("hive", hive); map.put("instance", instance); } @Override protected Class getEntityClass() { return MySqlUser.class; } @Override protected void map2entity(Map map, AbstractEntity entity) { MySqlUser user = (MySqlUser) entity; user.setInstance("mysql"); String name = map.get("name"); String password = map.get("password"); if (assertNotNull(name)) { user.setName(name); } if (assertNotNull(password)) { user.setPassword(password); } } @Override protected void regularizeKeys(Map whereParams) { replaceKey(whereParams, "pac", "pac.name"); } }