2011-04-01 18:53:37 +02:00
|
|
|
package de.hsadmin.remote;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import de.hsadmin.core.model.AbstractEntity;
|
2013-04-29 20:01:09 +02:00
|
|
|
import de.hsadmin.core.model.Transaction;
|
2011-04-01 18:53:37 +02:00
|
|
|
import de.hsadmin.mods.db.PgSqlDatabase;
|
|
|
|
|
|
|
|
public class PgsqlDbRemote extends AbstractRemote {
|
|
|
|
|
|
|
|
@Override
|
2013-04-29 20:01:09 +02:00
|
|
|
protected void entity2map(Transaction tx, AbstractEntity entity, Map<String, Object> map) {
|
2011-04-01 18:53:37 +02:00
|
|
|
PgSqlDatabase db = (PgSqlDatabase) entity;
|
|
|
|
String id = Long.toString(db.getId());
|
|
|
|
String name = db.getName();
|
|
|
|
String instance = db.getInstance();
|
|
|
|
String owner = db.getOwner();
|
|
|
|
String encoding = db.getEncoding();
|
|
|
|
String pac = db.getPac().getName();
|
|
|
|
String hive = db.getHiveName();
|
|
|
|
map.put("id", id);
|
|
|
|
map.put("name", name);
|
|
|
|
map.put("instance", instance);
|
|
|
|
map.put("pac", pac);
|
|
|
|
map.put("hive", hive);
|
|
|
|
map.put("owner", owner);
|
|
|
|
map.put("encoding", encoding);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Class<? extends AbstractEntity> getEntityClass() {
|
|
|
|
return PgSqlDatabase.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-04-29 20:01:09 +02:00
|
|
|
protected void map2entity(Transaction tx, Map<String, Object> map, AbstractEntity entity) {
|
2011-04-01 18:53:37 +02:00
|
|
|
PgSqlDatabase db = (PgSqlDatabase) entity;
|
|
|
|
db.setInstance("pgsql");
|
2011-10-28 16:08:18 +02:00
|
|
|
String name = (String) map.get("name");
|
|
|
|
String owner = (String) map.get("owner");
|
|
|
|
String encoding = (String) map.get("encoding");
|
2011-04-01 18:53:37 +02:00
|
|
|
if (assertNotNull(name)) {
|
|
|
|
db.setName(name);
|
|
|
|
}
|
|
|
|
if (assertNotNull(owner)) {
|
|
|
|
db.setOwner(owner);
|
|
|
|
}
|
|
|
|
if (assertNotNull(encoding)) {
|
|
|
|
db.setEncoding(encoding);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void regularizeKeys(Map<String, String> whereParams) {
|
|
|
|
replaceKey(whereParams, "pac", "pac.name");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|