2011-04-01 18:53:37 +02:00
|
|
|
package de.hsadmin.remote;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import de.hsadmin.core.model.AbstractEntity;
|
|
|
|
import de.hsadmin.mods.db.PgSqlUser;
|
|
|
|
|
|
|
|
public class PgsqlUserRemote extends AbstractRemote {
|
|
|
|
|
|
|
|
@Override
|
2011-10-28 16:08:18 +02:00
|
|
|
protected void entity2map(AbstractEntity entity, Map<String, Object> map) {
|
2011-04-01 18:53:37 +02:00
|
|
|
PgSqlUser user = (PgSqlUser) 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<? extends AbstractEntity> getEntityClass() {
|
|
|
|
return PgSqlUser.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-28 16:08:18 +02:00
|
|
|
protected void map2entity(Map<String, Object> map, AbstractEntity entity) {
|
2011-04-01 18:53:37 +02:00
|
|
|
PgSqlUser user = (PgSqlUser) entity;
|
|
|
|
user.setInstance("pgsql");
|
2011-10-28 16:08:18 +02:00
|
|
|
String name = (String) map.get("name");
|
|
|
|
String password = (String) map.get("password");
|
2011-04-01 18:53:37 +02:00
|
|
|
if (assertNotNull(name)) {
|
|
|
|
user.setName(name);
|
|
|
|
}
|
|
|
|
if (assertNotNull(password)) {
|
|
|
|
user.setPassword(password);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void regularizeKeys(Map<String, String> whereParams) {
|
|
|
|
replaceKey(whereParams, "pac", "pac.name");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|