e.printStackTrace();
}
}
//get the reference project for update
final ReferenceScienceProject refProject = refProjDao.getReferenceScienceProject();
/*Get the existing project forms,
* iterate and remove the AttachmentType being added if it exists
* to avoid duplicate documents of the same AttachmentType.
*/
final Set<Attachment> forms = refProject.getForms();
for(Iterator <Attachment> it = forms.iterator(); it.hasNext();)
{
if(key.equalsIgnoreCase(it.next().getType().getKey()))
{
it.remove();
}
}
forms.add(att);
refProject.setForms(forms);
//update the Science Project with the new/updated Attachment
refProjDao.updateReferenceScienceProject(refProject);
}