null values, hive ip is pac default now
This commit is contained in:
parent
a744393240
commit
a6ee788d67
@ -2,6 +2,9 @@ importClass(java.util.ArrayList);
|
||||
importClass(java.util.HashMap);
|
||||
|
||||
function hsaParseParam(val) {
|
||||
if (val === null) {
|
||||
return val;
|
||||
}
|
||||
if (val instanceof java.util.List) {
|
||||
return val;
|
||||
}
|
||||
@ -36,12 +39,14 @@ function hsaParseParamObject(o) {
|
||||
var hsh = new HashMap();
|
||||
for (var key in o) {
|
||||
var val = o[key];
|
||||
if (!val === null) {
|
||||
if (typeof val === 'object' && val.constructor === Array) {
|
||||
val = hsaParseParamArray(val);
|
||||
}
|
||||
else if (typeof val === 'object') {
|
||||
val = hsaParseParamObject(val);
|
||||
};
|
||||
}
|
||||
hsh.put(key, val);
|
||||
};
|
||||
return hsh;
|
||||
|
@ -22,6 +22,7 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
||||
|
||||
private PersistentObjectMapper<T> persistentObjectMapper;
|
||||
private ParameterMapMapper<T> parameterMapMapper;
|
||||
private boolean undefinedValue;
|
||||
|
||||
public AbstractProperty(
|
||||
final ValueObject owner,
|
||||
@ -34,6 +35,7 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
||||
this.policy = readWritePolicy;
|
||||
this.search = searchPolicy;
|
||||
this.required = required;
|
||||
this.undefinedValue = true;
|
||||
}
|
||||
|
||||
protected PersistentObjectMapper<T> getPersistentObjectMapper() {
|
||||
@ -50,7 +52,7 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setParameterMapMapper(ParameterMapMapper<?> mapper) {
|
||||
protected void setParameterMapMapper(final ParameterMapMapper<?> mapper) {
|
||||
parameterMapMapper = (ParameterMapMapper<T>) mapper;
|
||||
}
|
||||
|
||||
@ -74,6 +76,11 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
||||
return required;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUndefined() {
|
||||
return undefinedValue;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Class<? extends Property<T>> getPropertyType() {
|
||||
return (Class<? extends Property<T>>) getClass();
|
||||
@ -82,11 +89,15 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T getValue() throws TechnicalException {
|
||||
if (undefinedValue) {
|
||||
throw new TechnicalException("undefined value");
|
||||
}
|
||||
return (T) ReflectionUtil.invokeGetter(owningVO, getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value) throws TechnicalException {
|
||||
undefinedValue = false;
|
||||
ReflectionUtil.invokeSetter(owningVO, getName(), value);
|
||||
}
|
||||
|
||||
@ -115,9 +126,8 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
||||
|
||||
@Override
|
||||
public void copyValueToPersistentObject(Object persistentObject) throws TechnicalException, UserException {
|
||||
T newValue = getValue();
|
||||
if (newValue != null) {
|
||||
getPersistentObjectMapper().writeValueToPersistentObject(persistentObject, getName(), newValue);
|
||||
if (!undefinedValue) {
|
||||
getPersistentObjectMapper().writeValueToPersistentObject(persistentObject, getName(), getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@ public interface Property<T> {
|
||||
|
||||
public boolean valueIsNullOrEmpty();
|
||||
|
||||
public boolean isUndefined();
|
||||
|
||||
public void copyValueFromPersistentObject(final Object persistentObject) throws TechnicalException, UserException;
|
||||
|
||||
public void copyValueToPersistentObject(final Object persistentObject) throws TechnicalException, UserException;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractProperty;
|
||||
@ -67,18 +66,4 @@ public class StringSetProperty extends AbstractProperty<StringSet> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyValueFromPersistentObject(Object persistentObject)
|
||||
throws TechnicalException, UserException {
|
||||
// TODO Auto-generated method stub
|
||||
super.copyValueFromPersistentObject(persistentObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyValueToPersistentObject(Object persistentObject)
|
||||
throws TechnicalException, UserException {
|
||||
// TODO Auto-generated method stub
|
||||
super.copyValueToPersistentObject(persistentObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,12 +44,16 @@ public class PacService extends AbstractModule<PacVO> implements PacServiceLocal
|
||||
throws UserException, TechnicalException {
|
||||
final PacVO vo = super.create(requestContext, prototype);
|
||||
final Pac bo = new Pac();
|
||||
final String inetAddressProperty = prototype.getInetAddress();
|
||||
assert inetAddressProperty != null;
|
||||
bo.setCurINetAddr(findInetAddress(inetAddressProperty));
|
||||
final String hiveProperty = prototype.getHive();
|
||||
assert hiveProperty != null;
|
||||
bo.setHive(findHiveByName(hiveProperty));
|
||||
final Hive hive = findHiveByName(hiveProperty);
|
||||
bo.setHive(hive);
|
||||
final String inetAddressProperty = prototype.getInetAddress();
|
||||
if (inetAddressProperty != null) {
|
||||
bo.setCurINetAddr(findInetAddress(inetAddressProperty));
|
||||
} else {
|
||||
bo.setCurINetAddr(hive.getInetAddr());
|
||||
}
|
||||
final String basePacProperty = prototype.getBasePac();
|
||||
assert basePacProperty != null;
|
||||
bo.setBasePac(findBasePacByName(basePacProperty));
|
||||
|
@ -164,8 +164,12 @@ public class PacVO extends AbstractVO implements ValueObject {
|
||||
{
|
||||
assert persistentObject != null;
|
||||
final List<Property<?>> properties = properties();
|
||||
for (Property<?> p : properties) {
|
||||
if ("pacComponents".equals(p.getName())) {
|
||||
for (Property<?> prop : properties) {
|
||||
final String propName = prop.getName();
|
||||
if ("customer".equals(propName) || "basePac".equals(propName) || "hive".equals(propName) || "inetAddress".equals(propName)) {
|
||||
continue;
|
||||
}
|
||||
if ("pacComponents".equals(propName)) {
|
||||
if (persistentObject instanceof Pac) {
|
||||
final Pac persistentPac = (Pac) persistentObject;
|
||||
final List<PacComponentVO> pacComps = getPacComponents();
|
||||
@ -178,7 +182,7 @@ public class PacVO extends AbstractVO implements ValueObject {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.copyValueToPersistentObject(persistentObject);
|
||||
prop.copyValueToPersistentObject(persistentObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user