possible to update pacOptions now

This commit is contained in:
Peter Hormanns 2016-08-15 19:14:19 +02:00
parent ee11acdaab
commit 2cd335c7d4
2 changed files with 28 additions and 9 deletions

View File

@ -18,18 +18,13 @@ public class DefaultListPersistentObjectMapper<VO extends ValueObject> implement
} }
@Override @Override
public void writeValueToPersistentObject(Object persistentObject, String propertyName, List<VO> value) throws TechnicalException, UserException { public void writeValueToPersistentObject(final Object persistentObject, final String propertyName, final List<VO> value)
final List<VO> valueFromPersistentObject = readValueFromPersistentObject(persistentObject, propertyName); throws TechnicalException, UserException {
valueFromPersistentObject.clear(); throw new TechnicalException("writeValueToPersistentObject not implemented");
// for (final VO elem : value) {
// valueFromPersistentObject.add(elem);
// elem.
// }
// ReflectionUtil.invokeSetter(persistentObject, propertyName, ???;
} }
@Override @Override
public List<VO> readValueFromPersistentObject(Object persistentObject, String propertyName) throws TechnicalException, UserException { public List<VO> readValueFromPersistentObject(final Object persistentObject, final String propertyName) throws TechnicalException, UserException {
final Object object = ReflectionUtil.invokeGetter(persistentObject, propertyName); final Object object = ReflectionUtil.invokeGetter(persistentObject, propertyName);
if (object instanceof Collection<?>) { if (object instanceof Collection<?>) {
final List<VO> valueList = new ArrayList<>(); final List<VO> valueList = new ArrayList<>();

View File

@ -3,10 +3,13 @@ package de.hsadmin.service.pac;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import de.hsadmin.bo.pac.Pac;
import de.hsadmin.common.error.TechnicalException; import de.hsadmin.common.error.TechnicalException;
import de.hsadmin.common.error.UserException;
import de.hsadmin.module.ValueObject; import de.hsadmin.module.ValueObject;
import de.hsadmin.module.impl.AbstractVO; import de.hsadmin.module.impl.AbstractVO;
import de.hsadmin.module.property.ElementsType; import de.hsadmin.module.property.ElementsType;
import de.hsadmin.module.property.Property;
import de.hsadmin.module.property.ReadWrite; import de.hsadmin.module.property.ReadWrite;
import de.hsadmin.module.property.ReadWritePolicy; import de.hsadmin.module.property.ReadWritePolicy;
import de.hsadmin.module.property.Required; import de.hsadmin.module.property.Required;
@ -146,4 +149,25 @@ public class PacVO extends AbstractVO implements ValueObject {
public void setPacComponents(List<PacComponentVO> pacComponents) { public void setPacComponents(List<PacComponentVO> pacComponents) {
this.pacComponents = pacComponents; this.pacComponents = pacComponents;
} }
@Override
public void copyPropertiesToPersistentObject(final Object persistentObject) throws UserException, TechnicalException
{
assert persistentObject != null;
final List<Property<?>> properties = properties();
for (Property<?> p : properties) {
if ("pacComponents".equals(p.getName())) {
if (persistentObject instanceof Pac) {
final Pac persistentPac = (Pac) persistentObject;
for (final PacComponentVO componentVO : getPacComponents()) {
final String feature = componentVO.getFeature();
final Integer quantity = componentVO.getQuantity();
persistentPac.getPacComponent(feature).setQuantity(quantity);
}
}
} else {
p.copyValueToPersistentObject(persistentObject);
}
}
}
} }