child = (DataObject) i.next(); if (child instanceof ImageData) { img = child.asImage(); link = ModelMapper.unlinkChildFromParent(img, p); if (links == null) links = new ArrayList(); if (link != null) links.add(link); if (!(toUpdate.contains(p))) toUpdate.add(p); } else { toUpdate.add(ModelMapper.removeIObject(child.asIObject(), p)); }
ioChild = ((DataObject) i.next()).asIObject(); link = ModelMapper.unlinkChildFromParent(ioChild, p); if (links == null) links = new ArrayList(); if (link != null) links.add(link); if (!(toUpdate.contains(p))) toUpdate.add(p);
    public Set removeDataObjects(Set children, DataObject parent)            throws DSOutOfServiceException, DSAccessException    {        if (children == null)             throw new IllegalArgumentException("The children cannot be null.");        if (children.size() == 0)             throw new IllegalArgumentException("The children cannot be null.");        Iterator i = children.iterator();        if (parent == null) {            int index = 0;            IObject[] ioObjects  = new IObject[children.size()];            while (i.hasNext()) {                ioObjects[index] = ((DataObject) i.next()).asIObject();                index++;            }            gateway.deleteObjects(ioObjects);        } else {            DataObject child;            IObject p = parent.asIObject();            Image img;            IObject link;            List links = null;            List toUpdate = new ArrayList();            while (i.hasNext()) {                child = (DataObject) i.next();                if (child instanceof ImageData) {                    img = child.asImage();                    link = ModelMapper.unlinkChildFromParent(img, p);                    if (links == null) links = new ArrayList();                    if (link != null) links.add(link);                    if (!(toUpdate.contains(p))) toUpdate.add(p);                } else {                    toUpdate.add(ModelMapper.removeIObject(child.asIObject(),                                                         p));                }            }            if (links != null) {                gateway.deleteObjects((IObject[])                         links.toArray(new IObject[links.size()]));            }            IObject[] results = gateway.updateObjects(                                (IObject[]) toUpdate.toArray(                                        new IObject[toUpdate.size()]),                                    (new PojoOptions()).map());            for (int j = 0; j < results.length; j++)                PojoMapper.asDataObject(results[j]);        }        return children;    }