ImageAnnotation annotation;
    public static List fillImagesInUserDatasets(List datasets,                         ImageSummary iProto, List annotations, List datasetIDs)    {        Map ids = AnnotationMapper.reverseListImageAnnotations(annotations);        List images = new ArrayList();        HashMap map = new HashMap();        Iterator d = datasets.iterator();        Iterator i;        Image image;        ImageSummary is;        Integer imageID;        ImageAnnotation annotation;        Dataset dDTO;        while (d.hasNext()) {            dDTO = (Dataset) d.next();            if (datasetIDs.contains(new Integer(dDTO.getID()))) {                i = dDTO.getImages().iterator();                while (i.hasNext()) {                    image = (Image) i.next();                    imageID = new Integer(image.getID());                    annotation = (ImageAnnotation) ids.get(imageID);                    if (annotation != null) {                        is = (ImageSummary) map.get(imageID);                        if (is == null) {                            //Make a new DataObject and fill it up.                            is = (ImageSummary) iProto.makeNew();                            fillImageSummary(image, is);                            is.setAnnotation(                                AnnotationMapper.fillImageAnnotation(annotation));                            //Add the image summary object to the list.                            images.add(is);                            map.put(imageID, is);                        }                    }                }            }        }        return images;    }