ContextManager.getStudyService().save(theStudy);
Submission theSubmission = theStudy.getSubmission();
ContextManager.getSubmissionService().save(theSubmission);
Citation theCitation = theStudy.getCitation();
if (theCitation == null) {
theCitation = ContextManager.getCitationService().createCitation("TB1");
theCitation.setStudy(theStudy);
theStudy.setCitation(theCitation);
ContextManager.getStudyService().save(theStudy);
}
{ // Truncate extremely long abstracts
String theAbstract = aux.getString(null, "abstract");
if (theAbstract.length() > citationMaxLength - 4) {
theAbstract = theAbstract.substring(0, citationMaxLength - 4) + "...";
}
theCitation.setAbstract(theAbstract);
}
// this next isn't quite right, because TB1 "citation" contains title, author, publisher, etc.
// nothing to be done here, I think. 20080229 MJD
// We can postprocess the citation data with Perl or something
// to break it up into its component parts. 20080605 MJD
// Piel says that Rod Page already did this. 20080702 MJD
// Rutger has a program in util.CitationDataImporter that should do it 20090220 MJD
{
String citation = aux.getString(null, "citation");
if (citation.length() > 250) {
// It won't all fit into the "title" field of the database
citation = citation.substring(0, 250); // XXX
}
theCitation.setTitle(citation); // XXX
}
ContextManager.getCitationService().save(theCitation);
// Create or link authors
for (ValueSection a : aux.getSections("AUTHOR")) {
Person theAuthor = new Person();
theAuthor.setFirstName(a.getsval("first_name"));
theAuthor.setLastName(a.getsval("last_name"));
theAuthor.setMiddleName("");
// ContextManager.getPersonService().save(theAuthor);
// TB1 "author_id" ??
Person oldAuthor = ContextManager.getPersonService().findByExactMatch(theAuthor);
if (oldAuthor != null) {
theAuthor = oldAuthor;
} else {
ContextManager.getPersonService().createPerson(theAuthor);
theAuthor = ContextManager.getPersonService().findByExactMatch(theAuthor);
}
String oldEmail = theAuthor.getEmailAddressString();
if (oldEmail == null || oldEmail.equals("")) {
theAuthor.setEmailAddressString(a.getsval("email"));
}
ContextManager.getPersonService().save(theAuthor);
theCitation.addAuthor(theAuthor);
}
ContextManager.getCitationHome().flush();
ContextManager.getCitationService().save(theCitation);
// TODO: submission.setSubmitter