moduleprops now generally working for referredProps, too. Annotations for testing added to Customer. Added qualified field type.
This commit is contained in:
parent
c1f04434a0
commit
9b3192c230
@ -81,13 +81,14 @@ public class Customer extends AbstractEntity implements Serializable {
|
||||
private Set<Contact> 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")
|
||||
|
@ -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<String, Object> 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<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("property", fieldName);
|
||||
return result;
|
||||
private Map<String, Object> createReferredPropertyInfo(String propertyName, Field sourceField,
|
||||
String annotated) throws SecurityException {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
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<String, Object> propertyInfo, Field sourceField) {
|
||||
propertyInfo.put("type", sourceField.getType().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user