revert (GenericAbstractRemote is buggy)

This commit is contained in:
Peter Hormanns 2012-08-16 12:32:39 +02:00
parent d2dc9e575c
commit cf132cf569

View File

@ -13,66 +13,66 @@ import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.dom.DomainOption;
import de.hsadmin.mods.user.UnixUser;
public class DomainRemote extends GenericAbstractRemote {
public class DomainRemote extends AbstractRemote {
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return Domain.class;
}
// @Override
// protected void entity2map(AbstractEntity entity, Map<String, Object> resultMap) {
// Domain dom = (Domain) entity;
// String id = Long.toString(dom.getId());
// resultMap.put("id", id);
// String name = dom.getName();
// resultMap.put("name", name);
// String user = dom.getUser().getName();
// resultMap.put("user", user);
// String hive = dom.getHiveName();
// resultMap.put("hive", hive);
// String pac = dom.getUser().getPac().getName();
// resultMap.put("pac", pac);
// Date sDate = dom.getSince();
// if (assertNotNull(sDate)) {
// String since = TextUtil.format(sDate);
// resultMap.put("since", since);
// }
// List<String> domainOptionsList = new ArrayList<String>();
// resultMap.put("domainoptions", domainOptionsList);
// Set<DomainOption> domainOptions = dom.getDomainOptions();
// if (domainOptions != null) {
// for (DomainOption opt : domainOptions) {
// domainOptionsList.add(opt.getName());
// }
// }
// }
@Override
protected void entity2map(AbstractEntity entity, Map<String, Object> resultMap) {
Domain dom = (Domain) entity;
String id = Long.toString(dom.getId());
resultMap.put("id", id);
String name = dom.getName();
resultMap.put("name", name);
String user = dom.getUser().getName();
resultMap.put("user", user);
String hive = dom.getHiveName();
resultMap.put("hive", hive);
String pac = dom.getUser().getPac().getName();
resultMap.put("pac", pac);
Date sDate = dom.getSince();
if (assertNotNull(sDate)) {
String since = TextUtil.format(sDate);
resultMap.put("since", since);
}
List<String> domainOptionsList = new ArrayList<String>();
resultMap.put("domainoptions", domainOptionsList);
Set<DomainOption> domainOptions = dom.getDomainoptions();
if (domainOptions != null) {
for (DomainOption opt : domainOptions) {
domainOptionsList.add(opt.getName());
}
}
}
// @Override
// protected void map2entity(Map<String, Object> setParams, AbstractEntity entity) {
// Domain dom = (Domain) entity;
// String name = (String) setParams.get("name");
// String user = (String) setParams.get("user");
// if (assertNotNull(name)) {
// dom.setName(name);
// }
// if (assertNotNull(user)) {
// UnixUser u = new UnixUser();
// u.setName(user);
// dom.setUser(u);
// }
// Object domOptsObj = setParams.get("domainoptions");
// if (domOptsObj != null && domOptsObj instanceof Object[]) {
// Set<DomainOption> domainOptionsSet = new HashSet<DomainOption>();
// Object[] domOptions = (Object[]) domOptsObj;
// for (int i=0; i<domOptions.length; i++) {
// DomainOption domainOption = new DomainOption();
// domainOption.setName((String)domOptions[i]);
// domainOptionsSet.add(domainOption);
// }
// dom.setDomainOptions(domainOptionsSet);
// }
// }
@Override
protected void map2entity(Map<String, Object> setParams, AbstractEntity entity) {
Domain dom = (Domain) entity;
String name = (String) setParams.get("name");
String user = (String) setParams.get("user");
if (assertNotNull(name)) {
dom.setName(name);
}
if (assertNotNull(user)) {
UnixUser u = new UnixUser();
u.setName(user);
dom.setUser(u);
}
Object domOptsObj = setParams.get("domainoptions");
if (domOptsObj != null && domOptsObj instanceof Object[]) {
Set<DomainOption> domainOptionsSet = new HashSet<DomainOption>();
Object[] domOptions = (Object[]) domOptsObj;
for (int i=0; i<domOptions.length; i++) {
DomainOption domainOption = new DomainOption();
domainOption.setName((String)domOptions[i]);
domainOptionsSet.add(domainOption);
}
dom.setDomainoptions(domainOptionsSet);
}
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {