WIP on JSON refactor

This commit is contained in:
Rob Bygrave committed 2014-06-28 03:09:10 +12:00
1 parent 7966d74eb3
commit 0ceda6406e
52 files changed
+1583 -174

No files matched your search

@@ -6,6 +6,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.json.stream.JsonParser;
import javax.persistence.PersistenceException;
import org.slf4j.Logger;
@@ -40,6 +41,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
private static final Logger logger = LoggerFactory.getLogger(BeanPropertyAssocMany.class);
private final BeanPropertyAssocManyJsonHelp jsonHelp;
/**
* Join for manyToMany intersection table.
*/
@@ -91,7 +94,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
/**
* Property on the 'child' bean that links back to the 'master'.
*/
private BeanPropertyAssocOne<?> childMasterProperty;
protected BeanPropertyAssocOne<?> childMasterProperty;
private boolean embeddedExportedProperties;
@@ -116,6 +119,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
this.intersectionJoin = deploy.createIntersectionTableJoin();
this.inverseJoin = deploy.createInverseTableJoin();
this.modifyListenMode = deploy.getModifyListenMode();
this.jsonHelp = new BeanPropertyAssocManyJsonHelp(this);
}
public void initialise() {
@@ -900,37 +904,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
}
}
public void jsonRead(ReadJsonContext ctx, EntityBean bean){
if(!this.jsonDeserialize){
return;
}
if (!ctx.readArrayBegin()) {
// the array is null
return;
}
Object collection = help.createEmpty(false);
BeanCollectionAdd add = getBeanCollectionAdd(collection, null);
do {
ReadBeanState detailBeanState = targetDescriptor.jsonRead(ctx, name);
if (detailBeanState == null){
// probably empty array
break;
}
EntityBean detailBean = (EntityBean)detailBeanState.getBean();
add.addBean(detailBean);
if (bean != null && childMasterProperty != null){
// bind detail bean back to master via mappedBy property
childMasterProperty.setValue(detailBean, bean);
detailBeanState.setLoaded(childMasterProperty.getName());
}
if (!ctx.readArrayNext()){
break;
}
} while(true);
setValue(bean, collection);
public void jsonRead(JsonParser parser, EntityBean parentBean) {
jsonHelp.jsonRead(parser, parentBean);
}
}