private static void extractList(List<String> output, Resource head) {
    if (head.hasProperty(RDF.first))
      output.add(head.getProperty(RDF.first).getObject().asLiteral().getString());

    if (head.hasProperty(RDF.rest))
      extractList(output, head.getProperty(RDF.rest).getObject().asResource());
  }
Ejemplo n.º 2
0
  public static Offering convertOffering(Resource resource, Float price) {
    Offering offering = new Offering();

    offering.setId(resource.getLocalName());
    if (resource.hasProperty(label)) {
      offering.setName(resource.getProperty(label).getString());
    } else {
      offering.setName(resource.getLocalName());
    }

    if (resource.hasProperty(comment)) {
      offering.setDescription(resource.getProperty(comment).getString());
    }

    // get included services
    StmtIterator iter = resource.listProperties(includes);
    // System.out.println(iter.toList().size());
    while (iter.hasNext()) {
      Resource service = iter.next().getResource();
      offering = addFeatures(service, offering);
    }

    // get offering price
    offering = getOfferingPrice(price, offering);

    return offering;
  }
Ejemplo n.º 3
0
  private static QualitativeFeature convertQualitativeFeature(Resource r, String attributeType) {
    QualitativeFeature qf = new QualitativeFeature();
    qf.setType(QUAL_FEATURE.get(attributeType));
    if (r.hasProperty(comment)) qf.setDescription(r.getProperty(comment).getString());
    if (r.hasProperty(name)) qf.setName(r.getProperty(name).getString());

    return qf;
  }
Ejemplo n.º 4
0
 public static String getVocabularyTitle(Model vocabulary, String uri) {
   Resource nsResource = vocabulary.createResource(uri);
   if (nsResource.hasProperty(DCTerms.title)) {
     return nsResource.getProperty(DCTerms.title).getString();
   } else if (nsResource.hasProperty(DC.title)) {
     return nsResource.getProperty(DC.title).getString();
   } else if (nsResource.hasProperty(RDFS.label))
     return nsResource.getProperty(RDFS.label).getString();
   return null;
 }
Ejemplo n.º 5
0
  private static QuantitativeFeature convertQuantitativeFeature(Resource r, String attributeType) {
    QuantitativeFeature qf = new QuantitativeFeature();
    qf.setName(r.getLocalName());
    qf.setType(QUANT_FEATURE.get(attributeType));
    if (r.hasProperty(comment)) qf.setDescription(r.getProperty(comment).getString());
    if (r.hasProperty(hasValue)) qf.setValueFloat(r.getProperty(hasValue).getFloat());
    if (r.hasProperty(hasUnitOfMeasurement))
      qf.setUnitOfMeasurement(
          UNIT_OF_MEASUREMENT.get(r.getProperty(hasUnitOfMeasurement).getString()));

    return qf;
  }
 public static URI objectUriOfPropertyOfResource(Property property, Resource resource) {
   try {
     return new URI(resource.getProperty(property).getObject().asResource().getURI());
   } catch (URISyntaxException e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 7
0
 DeviceData(Resource device) {
   this.device = device;
   if (device.hasProperty(DeliSchema.manufacturedBy)) {
     if (device.getProperty(DeliSchema.manufacturedBy).getResource().hasProperty(RDFS.label)) {
       this.manufacturerName =
           device
               .getProperty(DeliSchema.manufacturedBy)
               .getResource()
               .getProperty(RDFS.label)
               .getString();
     }
   }
   if (device.hasProperty(DeliSchema.deviceName)) {
     this.deviceName = device.getProperty(DeliSchema.deviceName).getString();
   }
 }
Ejemplo n.º 8
0
  /**
   * Returns the identifier of an LSRN-typed Resource
   *
   * @param lsrnNode
   * @return the identifier
   */
  public static String getID(Resource lsrnNode) {
    Set<String> namespaces = new HashSet<String>();
    for (Iterator<Resource> types = RdfUtils.getTypes(lsrnNode); types.hasNext(); ) {
      Resource type = types.next();
      if (type.isURIResource()) {
        String ns = getNamespaceFromLSRNTypeURI(type.getURI());
        if (ns != null) namespaces.add(ns);
      }
    }

    Iterator<Resource> ids =
        RdfUtils.getPropertyValues(lsrnNode, SIO.has_identifier, null)
            .andThen(RdfUtils.getPropertyValues(lsrnNode, SIO.has_attribute, null));
    while (ids.hasNext()) {
      Resource identifier = ids.next();
      for (Iterator<Resource> types = RdfUtils.getTypes(identifier); types.hasNext(); ) {
        Resource type = types.next();
        if (type.isURIResource()) {
          String ns = getNamespaceFromLSRNIdentifierTypeURI(type.getURI());
          if (ns != null && namespaces.contains(ns)) {
            Statement s = identifier.getProperty(SIO.has_value);
            if (s != null) {
              return s.getString();
            }
          }
        }
      }
    }

    return null;
  }
Ejemplo n.º 9
0
 public MappedResource getIndexResource() {
   if (!config.hasProperty(CONF.indexResource)) {
     return null;
   }
   return getMappedResourceFromDatasetURI(
       config.getProperty(CONF.indexResource).getResource().getURI());
 }
  @Override
  public void processInput(Resource input, Resource output) {
    Printing.print(input.getModel());

    // Extract the link to the JSON specification
    Literal jsonSpecificationURL =
        input.getProperty(Vocabulary.hasJSONExperimentSpecificationURL).getLiteral();
    JSONSpecification jsonSpec = new JSONSpecification(getURL(jsonSpecificationURL));
    String jsonSpecID = jsonSpec.getSpecID();

    // Create output model
    Model outputModel = ModelFactory.createDefaultModel();

    // Create the UnpostedScenario
    ResourceURI resourceURI = new ResourceURI();
    Resource unpostedScenario =
        outputModel.createResource(
            resourceURI.getURI("unpublishedScenario", jsonSpecID).toASCIIString(),
            Vocabulary.UnpostedScenario);
    unpostedScenario.addProperty(Vocabulary.hasScenarioLayer, input);
    unpostedScenario.addLiteral(Vocabulary.hasJSONExperimentSpecificationURL, jsonSpecificationURL);

    // Merge our temporary output model
    output.getModel().add(outputModel);

    // Set output scenario layer to reference parent scenario
    output.addProperty(Vocabulary.isScenarioLayerOf, unpostedScenario);

    Printing.print(output.getModel());
  }
 /** @see com.hp.hpl.jena.rdf.model.Resource#getProperty(com.hp.hpl.jena.rdf.model.Property) */
 public Statement getProperty(Property p) {
   synchronized (model) {
     Statement wrappedResult = wrapped.getProperty(p);
     if (wrappedResult == null) {
       return null;
     }
     return new ThreadSafeStatement(model, wrappedResult);
   }
 }
 protected Set<ValueFactory> getValueFactory(RDFNode valueNode, OntModel displayOntModel) {
   // maybe use jenabean or owl2java for this?
   if (valueNode.isResource()) {
     Resource res = (Resource) valueNode.as(Resource.class);
     Statement stmt = res.getProperty(DisplayVocabulary.JAVA_CLASS_NAME);
     if (stmt == null || !stmt.getObject().isLiteral()) {
       log.debug("Cannot build value factory: java class was " + stmt.getObject());
       return Collections.emptySet();
     }
     String javaClassName = ((Literal) stmt.getObject().as(Literal.class)).getLexicalForm();
     if (javaClassName == null || javaClassName.length() == 0) {
       log.debug("Cannot build value factory: no java class was set.");
       return Collections.emptySet();
     }
     Class<?> clazz;
     Object newObj;
     try {
       clazz = Class.forName(javaClassName);
     } catch (ClassNotFoundException e) {
       log.debug("Cannot build value factory: no class found for " + javaClassName);
       return Collections.emptySet();
     }
     try {
       newObj = clazz.newInstance();
     } catch (Exception e) {
       log.debug(
           "Cannot build value factory: exception while creating object of java class "
               + javaClassName
               + " "
               + e.getMessage());
       return Collections.emptySet();
     }
     if (newObj instanceof ValueFactory) {
       ValueFactory valueFactory = (ValueFactory) newObj;
       return Collections.singleton(valueFactory);
     } else {
       log.debug(
           "Cannot build value factory: "
               + javaClassName
               + " does not implement "
               + ValueFactory.class.getName());
       return Collections.emptySet();
     }
   } else {
     log.debug("Cannot build value factory for " + valueNode);
     return Collections.emptySet();
   }
 }
  public static void main(String[] args) {
    Model adapterModel =
        OntologyModelUtil.loadModel("ontologies/docker.ttl", IMessageBus.SERIALIZATION_TURTLE);

    Property propCommand =
        adapterModel.getProperty(adapterModel.getNsPrefixURI("docker"), "command");

    Model m = OntologyModelUtil.loadModel("test.ttl", IMessageBus.SERIALIZATION_TURTLE);

    ResIterator rs = m.listResourcesWithProperty(propCommand);
    while (rs.hasNext()) {
      Resource r = rs.next();
      Statement c = r.getProperty(propCommand);

      Resource listHead = c.getObject().asResource();
      LinkedList<String> output = new LinkedList<String>();
      extractList(output, listHead);

      for (String elem : output) {
        System.out.println("elem: " + elem);
      }
    }
  }
Ejemplo n.º 14
0
 /**
  * @see org.caboto.jena.db.Database#updateProperty(java.lang.String, java.lang.String,
  *     com.hp.hpl.jena.rdf.model.Property, com.hp.hpl.jena.rdf.model.RDFNode)
  */
 public boolean updateProperty(String uri, String resourceUri, Property property, RDFNode value) {
   try {
     log.info("Updting property in model: " + uri + " " + reasoner);
     Data data = getData();
     Model m = data.getModel(uri);
     if (!m.containsResource(ResourceFactory.createResource(resourceUri))) {
       m.close();
       data.close();
       return false;
     }
     Resource resource = m.getResource(resourceUri);
     if (resource.hasProperty(property)) {
       resource.getProperty(property).changeObject(value);
     } else {
       resource.addProperty(property, value);
     }
     m.close();
     data.close();
     return true;
   } catch (DataException e) {
     e.printStackTrace();
     return false;
   }
 }
  public Organization getOrganization(String organizationUri) {
    long startTime = System.currentTimeMillis();
    Organization org = new Organization();
    // ResIterator iter =
    // ontModel.listSubjectsWithProperty(ontModel.getProperty(ORGID),organizationId);

    Resource r = ontModel.getResource(organizationUri);
    if (r != null) {
      // Resource r = iter.nextResource();

      org.setUri(organizationUri);

      StmtIterator typeStmtIter = r.listProperties(ontModel.getProperty(TYPE));
      Resource organizationalCollaboration = ontModel.getResource(ORGANIZATIONALCOLLABORATION);
      while (typeStmtIter.hasNext()) {
        Statement typeStmt = typeStmtIter.next();
        if (typeStmt != null) {
          String organizationClass = typeStmt.getResource().getURI();
          if (organizationClass.equalsIgnoreCase(organizationalCollaboration.getURI()))
            org.setOrganizationalCollaboration(true);
        }
      }

      Statement id = r.getProperty(ontModel.getProperty(ORGID));
      if (id != null) org.setId(id.getString());

      Statement title = r.getProperty(ontModel.getProperty(TITLE));
      if (title != null) org.setTitle(title.getString());

      Statement preflabel = r.getProperty(ontModel.getProperty(PREFLABEL));
      if (preflabel != null) org.setPrefLabel(preflabel.getString());

      Statement purpose = r.getProperty(ontModel.getProperty(PURPOSE));
      if (purpose != null) org.setPurpose(purpose.getString());

      Statement description = r.getProperty(ontModel.getProperty(DESCRIPTION));
      if (description != null) org.setDescription(description.getString());

      Statement classification = r.getProperty(ontModel.getProperty(CLASSIFICATION));
      if (classification != null) {
        Resource classificationObj = classification.getObject().asResource();
        Statement preflabelClassification =
            classificationObj.getProperty(ontModel.getProperty(PREFLABEL));
        org.setClassification(preflabelClassification.getString());
      }

      // depiction
      Statement depiction = r.getProperty(ontModel.getProperty(DEPICTION));
      if (depiction != null) {
        Statement depicts = depiction.getProperty(ontModel.getProperty(DEPICTS));
        if (depicts != null) {
          Resource imgRes = depicts.getResource();
          if (imgRes != null) org.setDepicts(depicts.getResource().getURI());
        }
      }

      // memberOrganizations
      StmtIterator memberOrgIter = r.listProperties(ontModel.getProperty(HASMEMBERORGANIZATION));
      ArrayList<String> hasMemberOrganization = new ArrayList<String>();
      while (memberOrgIter.hasNext()) {
        Statement stmtMembOrg = memberOrgIter.next();
        Resource memberOrgRes = stmtMembOrg.getResource();
        if (memberOrgRes != null) {
          //			    	Statement memberOrgStmt = memberOrgRes.getProperty(ontModel.getProperty(ORGID));
          //			    	if (memberOrgStmt!=null)
          //			    	    hasMemberOrganization.add(memberOrgStmt.getString());
          hasMemberOrganization.add(memberOrgRes.getURI());
        }
      }
      org.setHasMemberOrganization(hasMemberOrganization);

      // hasProject
      StmtIterator projectOrgIter = r.listProperties(ontModel.getProperty(HASPROJECT));
      ArrayList<String> hasProject = new ArrayList<String>();
      while (projectOrgIter.hasNext()) {
        Statement stmtProjOrg = projectOrgIter.next();
        Resource projRes = stmtProjOrg.getResource();
        if (projRes != null) {
          hasProject.add(projRes.getURI());
        }
      }
      org.setHasProject(hasProject);

      // hasProduct
      StmtIterator productOrgIter = r.listProperties(ontModel.getProperty(HASPRODUCT));
      ArrayList<String> hasProduct = new ArrayList<String>();
      while (productOrgIter.hasNext()) {
        Statement stmtProdOrg = productOrgIter.next();
        Resource prodRes = stmtProdOrg.getResource();
        if (prodRes != null) {
          hasProduct.add(prodRes.getURI());
        }
      }
      org.setHasProduct(hasProduct);

      // hasMember
      StmtIterator hasMemberIter = r.listProperties(ontModel.getProperty(HASMEMBER));
      ArrayList<String> hasMember = new ArrayList<String>();
      while (hasMemberIter.hasNext()) {
        Statement stmtHasMember = hasMemberIter.next();
        Resource personRes = stmtHasMember.getResource();
        if (personRes != null) {
          //			    	Statement personIdStmt = personRes.getProperty(ontModel.getProperty(PERSONID));
          //			    	if (personIdStmt!=null)
          //			    	    hasMember.add(personIdStmt.getString());
          hasMember.add(personRes.getURI());
        }
      }
      org.setHasMember(hasMember);

      // organizationPosition
      StmtIterator orgPositionIter = r.listProperties(ontModel.getProperty(ORGPOSITION));
      ArrayList<String> position = new ArrayList<String>();
      while (orgPositionIter.hasNext()) {
        Statement stmtOrgPosition = orgPositionIter.next();
        Resource positionRes = stmtOrgPosition.getResource();
        if (positionRes != null) {
          position.add(positionRes.getURI());
        }
      }
      org.setPosition(position);

      // organizationRole
      StmtIterator orgRoleIter = r.listProperties(ontModel.getProperty(ORGROLE));
      ArrayList<String> role = new ArrayList<String>();
      while (orgRoleIter.hasNext()) {
        Statement stmtOrgRole = orgRoleIter.next();
        Resource roleRes = stmtOrgRole.getResource();
        if (roleRes != null) {
          role.add(roleRes.getURI());
        }
      }
      org.setRole(role);

      // membership
      StmtIterator membershipIter = r.listProperties(ontModel.getProperty(MEMBERSHIP));
      ArrayList<String> membership = new ArrayList<String>();
      while (membershipIter.hasNext()) {
        Statement stmtMembership = membershipIter.next();
        Resource membershipRes = stmtMembership.getResource();
        if (membershipRes != null) {
          membership.add(membershipRes.getURI());
        }
      }
      org.setMembership(membership);

      long stopTime = System.currentTimeMillis();
      long elapsedTime = stopTime - startTime;
      LOGGER.debug("- Load the organization, elapsed time (ms)..: {}", elapsedTime);
    }
    return org;
  }
Ejemplo n.º 16
0
 public String getWebApplicationBaseURI() {
   return config.getProperty(CONF.webBase).getResource().getURI();
 }
Ejemplo n.º 17
0
 public String getProjectName() {
   return config.getProperty(CONF.projectName).getString();
 }
Ejemplo n.º 18
0
 public String getProjectLink() {
   return config.getProperty(CONF.projectHomepage).getResource().getURI();
 }
  @Test
  public void testConversion() throws Exception {
    status.put(DepositField.sourcePath.name(), "src/test/resources/paths/valid-bag");
    status.put(DepositField.fileName.name(), "Test File");
    status.put(
        DepositField.extras.name(), "{\"accessionNumber\" : \"123456\", \"mediaId\" : \"789\"}");

    when(stages.getStagedURI(any(URI.class)))
        .thenAnswer(
            new Answer<URI>() {
              public URI answer(InvocationOnMock invocation) throws URISyntaxException {
                Object[] args = invocation.getArguments();
                URI uri = (URI) args[0];
                String path = uri.toString();
                int index = path.lastIndexOf("/paths");
                path = path.substring(index + 6);

                return new URI("tag:" + path);
              }
            });

    job.run();

    Model model = job.getReadOnlyModel();
    Bag depositBag = model.getBag(job.getDepositPID().getURI());

    assertEquals(depositBag.size(), 1);

    Bag bagFolder = model.getBag((Resource) depositBag.iterator().next());
    assertEquals(
        "Bag folder label was not set",
        "Test File",
        bagFolder.getProperty(dprop(model, label)).getString());
    assertEquals(
        "Content model was not set",
        CONTAINER.toString(),
        bagFolder.getPropertyResourceValue(fprop(model, hasModel)).getURI());

    Resource folder = (Resource) bagFolder.iterator().next();

    assertEquals(
        "Folder label was not set", folder.getProperty(dprop(model, label)).getString(), "test");
    assertEquals(
        "Content model was not set",
        CONTAINER.toString(),
        folder.getPropertyResourceValue(fprop(model, hasModel)).getURI());

    Bag childrenBag = model.getBag(folder.getURI());

    assertEquals(childrenBag.size(), 2);

    // Put children into a map since we can't guarantee order from jena
    Map<String, Resource> children = new HashMap<>(2);
    NodeIterator childIt = childrenBag.iterator();
    while (childIt.hasNext()) {
      Resource file = (Resource) childIt.next();
      children.put(file.getProperty(dprop(model, label)).getString(), file);
    }

    ArgumentCaptor<String> filePathCaptor = ArgumentCaptor.forClass(String.class);
    verify(depositStatusFactory, times(2)).addManifest(anyString(), filePathCaptor.capture());
    List<String> capturedFilePaths =
        Arrays.asList("tag:/valid-bag/bagit.txt", "tag:/valid-bag/manifest-md5.txt");
    assertEquals(capturedFilePaths, filePathCaptor.getAllValues());

    Resource file = children.get("lorem.txt");
    assertEquals(
        "Content model was not set",
        SIMPLE.toString(),
        file.getPropertyResourceValue(fprop(model, hasModel)).getURI());
    assertEquals(
        "Checksum was not set",
        "fa5c89f3c88b81bfd5e821b0316569af",
        file.getProperty(dprop(model, md5sum)).getString());
    assertEquals(
        "File location not set",
        "tag:/valid-bag/data/test/lorem.txt",
        file.getProperty(dprop(model, stagingLocation)).getString());

    Resource file2 = children.get("ipsum.txt");
    assertEquals(
        "Content model was not set",
        SIMPLE.toString(),
        file2.getPropertyResourceValue(fprop(model, hasModel)).getURI());
    assertEquals(
        "Checksum was not set",
        "e78f5438b48b39bcbdea61b73679449d",
        file2.getProperty(dprop(model, md5sum)).getString());
    assertEquals(
        "File location not set",
        "tag:/valid-bag/data/test/ipsum.txt",
        file2.getProperty(dprop(model, stagingLocation)).getString());

    File modsFile =
        new File(job.getDescriptionDir(), new PID(bagFolder.getURI()).getUUID() + ".xml");
    assertTrue(modsFile.exists());

    Set<String> cleanupSet = new HashSet<>();
    StmtIterator it = depositBag.listProperties(dprop(model, cleanupLocation));
    while (it.hasNext()) {
      Statement stmt = it.nextStatement();
      cleanupSet.add(stmt.getString());
    }

    assertEquals("Incorrect number of objects identified for cleanup", 3, cleanupSet.size());
    assertTrue("Cleanup of bag not set", cleanupSet.contains("tag:/valid-bag/"));
    assertTrue("Cleanup of manifest not set", cleanupSet.contains("tag:/valid-bag/bagit.txt"));
    assertTrue(
        "Cleanup of manifest not set", cleanupSet.contains("tag:/valid-bag/manifest-md5.txt"));
  }
Ejemplo n.º 20
0
 public String getDefaultLanguage() {
   if (!config.hasProperty(CONF.defaultLanguage)) {
     return null;
   }
   return config.getProperty(CONF.defaultLanguage).getString();
 }
Ejemplo n.º 21
0
 String getRelease() {
   return device.getProperty(DeliSchema.release).getString();
 }
Ejemplo n.º 22
0
 String getProvider() {
   return device.getProperty(DeliSchema.provider).getResource().getURI();
 }
Ejemplo n.º 23
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;
  }
Ejemplo n.º 24
0
 private void addLabel(Resource blankNode, Resource queryNode, Model outputModel) {
   final Statement labelStatement = queryNode.getProperty(RDFS.label);
   if (labelStatement != null) {
     outputModel.add(blankNode, RDFS.label, labelStatement.getObject());
   }
 }