private static String readStringAnnotation(SubmissionStatus status, String key) { Annotations annotations = status.getAnnotations(); if (annotations == null) return null; List<StringAnnotation> sas = annotations.getStringAnnos(); if (sas == null) return null; for (StringAnnotation sa : sas) { if (sa.getKey().equals(key)) return sa.getValue(); } return null; }
// the 'isPrivate' flag should be set to 'true' for information // used by the scoring application but not to be revealed to participants // to see 'public' annotations requires READ access in the Evaluation's // access control list, as the participant has (see setUp(), above). To // see 'private' annotatations requires READ_PRIVATE_SUBMISSION access, // which the Evaluation admin has by default private static void addAnnotation( SubmissionStatus status, String key, String value, boolean isPrivate) { if (value.length() > 499) value = value.substring(0, 499); Annotations annotations = status.getAnnotations(); if (annotations == null) { annotations = new Annotations(); status.setAnnotations(annotations); } List<StringAnnotation> sas = annotations.getStringAnnos(); if (sas == null) { sas = new ArrayList<StringAnnotation>(); annotations.setStringAnnos(sas); } StringAnnotation matchingSa = null; for (StringAnnotation existingSa : sas) { if (existingSa.getKey().equals(key)) { matchingSa = existingSa; break; } } if (matchingSa == null) { StringAnnotation sa = new StringAnnotation(); sa.setIsPrivate(isPrivate); sa.setKey(key); sa.setValue(value); sas.add(sa); } else { matchingSa.setIsPrivate(isPrivate); matchingSa.setValue(value); } }
private static void removeAnnotation(SubmissionStatus status, String key) { Annotations annotations = status.getAnnotations(); if (annotations == null) return; List<StringAnnotation> sas = annotations.getStringAnnos(); if (sas == null) return; for (StringAnnotation existingSa : sas) { if (existingSa.getKey().equals(key)) { sas.remove(existingSa); } } }