diff --git a/hsarback/src/de/hsadmin/mods/cust/Customer.java b/hsarback/src/de/hsadmin/mods/cust/Customer.java index c8d1eaa..a3151a4 100644 --- a/hsarback/src/de/hsadmin/mods/cust/Customer.java +++ b/hsarback/src/de/hsadmin/mods/cust/Customer.java @@ -81,13 +81,14 @@ public class Customer extends AbstractEntity implements Serializable { private Set contacts; @OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer") - //@AnnFieldIO(referredProps = "customer") - //@AnnFieldIO(referredProps = "customer.CustomersTariffl") - //@AnnFieldIO(referredProps = "customer.CustomersTariff.domainDiscountUntil") + //@AnnFieldIO(referredProps = "customer")//gut + //@AnnFieldIO(referredProps = "customer.CustomersTariff.domainDiscountUntil")//Das ist Kappes! + //@AnnFieldIO(referredProps = "customer.billData.domainDiscountUntil.year")//falsch! + @AnnFieldIO(referredProps = "customer.billData.domainDiscountUntil.cdate")//gut private BankAccount bankAccount; @OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer") - //@AnnFieldIO(referredProps = "domainDiscountUntil") + @AnnFieldIO(referredProps = "domainDiscountUntil") private CustomersTariff billData; @OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "customer") diff --git a/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java b/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java index af40d37..e2313be 100644 --- a/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java +++ b/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java @@ -51,11 +51,13 @@ public class ModulePropertiesRemote implements IRemote { propertyProperties.put("rw", rw.name()); String[] referredProps = fieldIO.referredProps(); propertyProperties.put("referredProps", referredProps); - Class declaringClass = f.getDeclaringClass(); + // Class declaringClass = f.getDeclaringClass(); + // declaringClass = f.getDeclaringClass(); for(String s : referredProps){ String fullPropertyName = fieldName+"."+s; - propertiesList.add(createReferredPropertyInfo(fullPropertyName, declaringClass, fullPropertyName)); + propertiesList.add(createReferredPropertyInfo(fullPropertyName, f, s)); } + AddCommonPropertyInfo(propertyProperties, f); propertiesList.add(propertyProperties); } } @@ -73,18 +75,42 @@ public class ModulePropertiesRemote implements IRemote { } } - private Map createReferredPropertyInfo(String fieldName, Class declaringClass, - String propertyName) throws SecurityException, NoSuchFieldException { - int indexOfDot = propertyName.indexOf('.'); - if (indexOfDot>=0) { - String prefix = propertyName.substring(0, indexOfDot); - String remainingPart = propertyName.substring(indexOfDot + 1); - return createReferredPropertyInfo(fieldName, declaringClass.getDeclaredField(prefix).getDeclaringClass(), remainingPart); - } else { - Map result = new HashMap(); - result.put("property", fieldName); - return result; + private Map createReferredPropertyInfo(String propertyName, Field sourceField, + String annotated) throws SecurityException { + Map result = new HashMap(); + result.put("property", propertyName); +// String trace = "" ; + Field field = sourceField; + String remainingPart = annotated; + int indexOfDot = 0; + while (indexOfDot>=0) { + indexOfDot = remainingPart.indexOf('.'); + Class fieldType = field.getType(); + String prefix = (indexOfDot>=0 ? remainingPart.substring(0, indexOfDot) : remainingPart); + try { + field = fieldType.getDeclaredField(prefix); + } catch (Exception NoSuchFieldException) { + Field[] flds = fieldType.getDeclaredFields(); + String trace = indexOfDot + + " SF=" + field.getName() + +" T=" + fieldType.getName() + + " (" + flds.length +" fields):"; + for (Field f : flds ){ + trace = trace + " " + f.getName(); + } + trace = trace + " [" + prefix + " missing]" ; + result.put("BOOM", trace); + return result; + } +// trace = trace + " TF=" + field.getName(); + remainingPart = remainingPart.substring(indexOfDot + 1); } + AddCommonPropertyInfo(result, field); + return result; + } + + private void AddCommonPropertyInfo(Map propertyInfo, Field sourceField) { + propertyInfo.put("type", sourceField.getType().getName()); } @Override