@Override public Resource objectToJena(Model toAddTo, Protocol protocol) throws IllegalArgumentException { if (protocol.getResourceURL() == null) { throw new IllegalArgumentException(String.format(msg_ResourceWithoutURI, "protocols")); } Resource res = toAddTo.createResource(protocol.getResourceURL().toString()); toAddTo.add(res, RDF.type, TOXBANK.PROTOCOL); if (protocol.isSearchable() != null) res.addLiteral(TOXBANK.ISSUMMARYSEARCHABLE, protocol.isSearchable()); res.addLiteral(TOXBANK.HASVERSIONINFO, protocol.getVersion()); if (protocol.getTitle() != null) res.addLiteral(DCTerms.title, protocol.getTitle()); if (protocol.getTimeModified() != null) res.addLiteral(DCTerms.modified, protocol.getTimeModified()); if (protocol.getSubmissionDate() != null) res.addLiteral(DCTerms.dateSubmitted, protocol.getSubmissionDate()); if (protocol.isPublished() != null) res.addLiteral(TOXBANK.ISPUBLISHED, protocol.isPublished()); if (protocol.getStatus() != null) res.addLiteral(TOXBANK.HASSTATUS, protocol.getStatus().name()); if (protocol.getIdentifier() != null) res.addLiteral(DCTerms.identifier, protocol.getIdentifier()); if (protocol.getAbstract() != null) res.addLiteral(TOXBANK.HASABSTRACT, cleanLiteral(protocol.getAbstract())); List<String> keywords = protocol.getKeywords(); if (keywords != null) { for (String keyword : keywords) res.addLiteral(TOXBANK.HASKEYWORD, keyword); } if (protocol.getProjects() != null) for (Project aproject : protocol.getProjects()) { if (aproject.getResourceURL() == null) throw new IllegalArgumentException( String.format(msg_InvalidURI, "project", res.getURI())); Resource project = projectIO.objectToJena(toAddTo, aproject); res.addProperty(TOXBANK.HASPROJECT, project); } if (protocol.getOrganisation() != null) { if (protocol.getOrganisation().getResourceURL() == null) throw new IllegalArgumentException( String.format(msg_InvalidURI, "organisation", res.getURI())); Resource org = organisationIO.objectToJena(toAddTo, protocol.getOrganisation()); res.addProperty(TOXBANK.HASORGANISATION, org); } if (protocol.getOwner() != null) { if (protocol.getOwner().getResourceURL() == null) throw new IllegalArgumentException( String.format(msg_InvalidURI, "protocol owner", res.getURI())); Resource ownerRes = toAddTo.createResource(protocol.getOwner().getResourceURL().toString()); res.addProperty(TOXBANK.HASOWNER, ownerRes); } ToxBankResourceSet<User> authors = protocol.getAuthors(); if (authors != null) for (User author : authors) { if (author.getResourceURL() == null) throw new IllegalArgumentException(String.format(msg_InvalidURI, "author", res.getURI())); Resource user = userIO.objectToJena(toAddTo, author); res.addProperty(TOXBANK.HASAUTHOR, user); } if (protocol.getDocument() != null) { if (protocol.getDocument().getResourceURL() == null) throw new IllegalArgumentException(String.format(msg_InvalidURI, "document", res.getURI())); Resource documentRes = toAddTo.createResource(protocol.getDocument().getResourceURL().toString()); res.addProperty(TOXBANK.HASDOCUMENT, documentRes); } if (protocol.getDataTemplate() != null) { if (protocol.getDataTemplate().getResourceURL() == null) throw new IllegalArgumentException( String.format(msg_InvalidURI, "data template", res.getURI())); Resource templateRes = toAddTo.createResource(protocol.getDataTemplate().getResourceURL().toString()); res.addProperty(TOXBANK.HASTEMPLATE, templateRes); } if (protocol.getLicense() != null) { toAddTo.add(res, DCTerms.license, toAddTo.createResource(protocol.getLicense().toString())); } return res; }