*/
private void delete(boolean immediate, OpCallbacks call, boolean deref) {
if (objval == null)
return;
FieldMetaData fmd = _sm.getMetaData().getField(field);
if (fmd.getCascadeDelete() != ValueMetaData.CASCADE_NONE) {
// immediate cascade works on field value; dependent deref
// works on external value
if ((immediate || fmd.isEmbeddedPC())
&& fmd.getCascadeDelete() == ValueMetaData.CASCADE_IMMEDIATE) {
if (fmd.isEmbeddedPC() && deref) {
StateManagerImpl sm = _broker.getStateManagerImpl(objval, false);
if (sm != null)
dereferenceEmbedDependent(sm);
}
delete(fmd, objval, call);
}
else if (fmd.getCascadeDelete() == ValueMetaData.CASCADE_AUTO)
dereferenceDependent(fmd.getExternalValue(objval, _broker));
return;
}
Object external = null;
ValueMetaData vmd = fmd.getKey();
if ((immediate || vmd.isEmbeddedPC())
&& vmd.getCascadeDelete() == ValueMetaData.CASCADE_IMMEDIATE)
delete(vmd, ((Map) objval).keySet(), call);
else if (vmd.getCascadeDelete() == ValueMetaData.CASCADE_AUTO) {
external = fmd.getExternalValue(objval, _broker);
if (external == null)
return;
dereferenceDependent(((Map) external).keySet());
}
vmd = fmd.getElement();
if ((immediate || vmd.isEmbeddedPC())
&& vmd.getCascadeDelete() == ValueMetaData.CASCADE_IMMEDIATE) {
switch (fmd.getDeclaredTypeCode()) {
case JavaTypes.COLLECTION:
delete(vmd, (Collection) objval, call);
break;
case JavaTypes.ARRAY:
delete(vmd, (Object[]) objval, call);
break;
case JavaTypes.MAP:
delete(vmd, ((Map) objval).values(), call);
break;
}
} else if (vmd.getCascadeDelete() == ValueMetaData.CASCADE_AUTO) {
if (external == null) {
external = fmd.getExternalValue(objval, _broker);
if (external == null)
return;
}
switch (fmd.getTypeCode()) {
case JavaTypes.COLLECTION:
dereferenceDependent((Collection) external);
break;
case JavaTypes.ARRAY:
dereferenceDependent((Object[]) external);