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
public void writeValueToPersistentObject(Object persistentObject, String propertyName, List<VO> value) throws TechnicalException, UserException {
final List<VO> valueFromPersistentObject = readValueFromPersistentObject(persistentObject, propertyName);
valueFromPersistentObject.clear();
// for (final VO elem : value) {
// valueFromPersistentObject.add(elem);
// elem.
// }
// ReflectionUtil.invokeSetter(persistentObject, propertyName, ???;
public void writeValueToPersistentObject(final Object persistentObject, final String propertyName, final List<VO> value)
throws TechnicalException, UserException {
throw new TechnicalException("writeValueToPersistentObject not implemented");
}
@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);
if (object instanceof Collection<?>) {
final List<VO> valueList = new ArrayList<>();

View File

@ -3,10 +3,13 @@ package de.hsadmin.service.pac;
import java.util.Date;
import java.util.List;
import de.hsadmin.bo.pac.Pac;
import de.hsadmin.common.error.TechnicalException;
import de.hsadmin.common.error.UserException;
import de.hsadmin.module.ValueObject;
import de.hsadmin.module.impl.AbstractVO;
import de.hsadmin.module.property.ElementsType;
import de.hsadmin.module.property.Property;
import de.hsadmin.module.property.ReadWrite;
import de.hsadmin.module.property.ReadWritePolicy;
import de.hsadmin.module.property.Required;
@ -146,4 +149,25 @@ public class PacVO extends AbstractVO implements ValueObject {
public void setPacComponents(List<PacComponentVO> 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);
}
}
}
}