public static HumanAnnotation newHumanAnnotation(String collectionPid, String coderId) { HumanAnnotation humanAnnotation = null; if (null == getHumanAnnotationPid(collectionPid, coderId)) { String pid = newObject(new Collection(collectionPid).getTitle() + " Annotation"); if (null != pid) { humanAnnotation = new HumanAnnotation(pid); DublinCore dc = humanAnnotation.getDc(); dc.addType(FedoraObjectType.HUMAN_ANNOTATION.toString()); dc.saveOrUpdate(); List<Integer> instances = new Collection(collectionPid).getInstanceIds(); humanAnnotation.setInstances(instances, collectionPid, coderId); } } return humanAnnotation; }
public static String getHumanAnnotationPid(String collectionPid, String coderId) { String query = "select $obj from <#ri> " + "where $obj <dc:type> '" + FedoraObjectType.HUMAN_ANNOTATION.toString() + "' " + "and $obj <dc:creator> '" + coderId + "' " + "and $obj <" + Predicate.IS_ANNOTATION_OF.toString() + "> <info:fedora/" + collectionPid + "> "; FedoraSearch search = new FedoraSearch(); RiSearchResponse response = search.riSearch(query); String pid = search.getValue(response); response.close(); return pid; }