this.session = session;
this.out = out;
}
public Value perform(Value v) {
AuxData aux = new AuxData((ValueStudy) v);
Study s;
{
String studyId = aux.getStudyID();
Collection<Study> studies = ContextManager.getStudyService().findByTBStudyID(studyId);
if (studies.size() == 0) {
out.println("Couldn't locate study " + studyId + "; skipping");
return new ValueNone();
} else if (studies.size() > 1) {
out.println("Multiple studies with ID " + studyId + "; skipping");
return new ValueNone();
}
Study[] tmp = { null };
studies.toArray(tmp);
s = tmp[0];
out.println("Processing study " + studyId);
}
Transaction t = session.beginTransaction();
Citation cit = s.getCitation();
cit.setAuthors(new ArrayList<Person>());
ContextManager.getCitationHome().flush();
for (ValueSection authorSection : aux.getSections("AUTHOR")) {
Person theAuthor = new Person();
theAuthor.setFirstName(authorSection.getsval("first_name"));
theAuthor.setLastName(authorSection.getsval("last_name"));
Person oldAuthor = ContextManager.getPersonService().findByExactMatch(theAuthor);
if (oldAuthor == null) {