@Override
  protected Protocol convert(File directory) {
    Protocol protocol = new Protocol();
    protocol.setIdentifier(directory.getName());
    if (key != null) {}

    return protocol;
  }
示例#2
0
  @Override
  public Protocol fromJena(Model source, Resource res) throws IllegalArgumentException {
    Protocol protocol = new Protocol();
    try {
      protocol.setResourceURL(new URL(res.getURI()));
    } catch (MalformedURLException e) {
      throw new IllegalArgumentException(String.format(msg_InvalidURI, "protocol", res.getURI()));
    }
    try {
      protocol.setSearchable(res.getProperty(TOXBANK.ISSUMMARYSEARCHABLE).getBoolean());
    } catch (Exception x) {
      protocol.setSearchable(false);
    }
    try {
      protocol.setVersion(res.getProperty(TOXBANK.HASVERSIONINFO).getInt());
    } catch (Exception x) {
      protocol.setVersion(0);
    }
    try {
      protocol.setPublished(res.getProperty(TOXBANK.ISPUBLISHED).getBoolean());
    } catch (Exception x) {
      protocol.setPublished(null);
    }
    try {
      protocol.setTimeModified(res.getProperty(DCTerms.modified).getLong());
    } catch (Exception x) {
      protocol.setTimeModified(null);
    }
    try {
      protocol.setSubmissionDate(res.getProperty(DCTerms.dateSubmitted).getLong());
    } catch (Exception x) {
      protocol.setSubmissionDate(null);
    }
    if (res.getProperty(DCTerms.title) != null)
      protocol.setTitle(res.getProperty(DCTerms.title).getString());
    if (res.getProperty(TOXBANK.HASSTATUS) != null)
      try {
        protocol.setStatus(Protocol.STATUS.valueOf(res.getProperty(TOXBANK.HASSTATUS).getString()));
      } catch (Exception x) {
        protocol.setStatus(STATUS.RESEARCH);
      }
    if (res.getProperty(DCTerms.identifier) != null)
      protocol.setIdentifier(res.getProperty(DCTerms.identifier).getString());
    if (res.getProperty(TOXBANK.HASABSTRACT) != null)
      protocol.setAbstract(res.getProperty(TOXBANK.HASABSTRACT).getString());
    StmtIterator keywords = res.listProperties(TOXBANK.HASKEYWORD);
    while (keywords.hasNext()) {
      protocol.addKeyword(keywords.next().getString());
    }

    String uri = null;
    StmtIterator authors = res.listProperties(TOXBANK.HASAUTHOR);
    while (authors.hasNext()) {
      Resource authorRes = authors.next().getResource();
      User author = userIO.fromJena(source, authorRes);
      protocol.addAuthor(author);
    }
    authors.close();

    StmtIterator projects = res.listProperties(TOXBANK.HASPROJECT);
    while (projects.hasNext()) {
      Resource projectRes = projects.next().getResource();
      Project project = projectIO.fromJena(source, projectRes);
      protocol.addProject(project);
    }
    projects.close();

    if (res.getProperty(TOXBANK.HASORGANISATION) != null) {
      Organisation org =
          organisationIO.fromJena(source, res.getProperty(TOXBANK.HASORGANISATION).getResource());
      protocol.setOrganisation(org);
    }

    if (res.getProperty(TOXBANK.HASOWNER) != null)
      try {
        uri = res.getProperty(TOXBANK.HASOWNER).getResource().getURI();
        User author = new User();

        author.setResourceURL(new URL(uri));
        protocol.setOwner(author);
      } catch (MalformedURLException e) {
        throw new IllegalArgumentException(String.format(msg_InvalidURI, "a protocol owner", uri));
      }

    if (res.getProperty(TOXBANK.HASDOCUMENT) != null)
      try {
        uri = res.getProperty(TOXBANK.HASDOCUMENT).getResource().getURI();
        Document document = new Document(new URL(uri));

        protocol.setDocument(document);
      } catch (MalformedURLException e) {
        throw new IllegalArgumentException(String.format(msg_InvalidURI, "a document", uri));
      }

    if (res.getProperty(TOXBANK.HASTEMPLATE) != null)
      try {
        uri = res.getProperty(TOXBANK.HASTEMPLATE).getResource().getURI();
        Template dataTemplate = new Template(new URL(uri));

        protocol.setDataTemplate(dataTemplate);
      } catch (MalformedURLException e) {
        throw new IllegalArgumentException(String.format(msg_InvalidURI, "data template", uri));
      }
    if (res.getProperty(DCTerms.license) != null)
      try {
        protocol.setLicense(new URL(res.getProperty(DCTerms.license).getObject().toString()));
      } catch (MalformedURLException e) {
        throw new IllegalArgumentException(
            String.format(
                msg_InvalidURI, "a license", res.getProperty(DCTerms.license).getObject()));
      }
    return protocol;
  }