Ejemplo n.º 1
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;
  }
 private void updateAddRemoveDataGetterStatements(
     OntModel displayModel,
     Model removeStatements,
     Model addStatements,
     Resource oldType,
     Resource newType) {
   log.debug("Old type: " + oldType.getURI() + " - newType: " + newType.getURI());
   removeStatements.add(displayModel.listStatements(null, RDF.type, oldType));
   StmtIterator oldStatements = displayModel.listStatements(null, RDF.type, oldType);
   while (oldStatements.hasNext()) {
     Statement stmt = oldStatements.nextStatement();
     addStatements.add(stmt.getSubject(), RDF.type, newType);
   }
   // Print out remove and add statements here
   StringWriter sw = new StringWriter();
   try {
     log.debug(
         "Adding statements with old data getter types to remove statements, remove statements is now");
     removeStatements.write(sw, "N3");
     log.debug(sw.toString());
     sw.close();
     sw = new StringWriter();
     log.debug(
         "Adding statements with new data getter types to add statements, add statements is now");
     addStatements.write(sw, "N3");
     log.debug(sw.toString());
     sw.close();
   } catch (Exception ex) {
     log.error("Error occurred in writing out remove and statements for data getter types", ex);
   }
 }
Ejemplo n.º 3
0
  private List<OntClass> listNamedClasses() {
    List<OntClass> result = new ArrayList<OntClass>();

    StmtIterator classes = model.listStatements(null, RDF.type, OWL.Class);
    while (classes.hasNext()) {
      Resource type = classes.next().getSubject();
      String uri = type.getURI();
      if (uri == null || manager.getDatatypeByUri(uri) != null) continue;
      if (!isStandard(uri)) {
        result.add(type.as(OntClass.class));
      }
    }
    classes = model.listStatements(null, RDF.type, RDFS.Class);
    while (classes.hasNext()) {
      Resource type = classes.next().getSubject();
      String uri = type.getURI();
      if (uri == null || manager.getDatatypeByUri(uri) != null) continue;
      if (!isStandard(uri)) {
        result.add(type.as(OntClass.class));
      }
    }

    List<Resource> rdfsClassList = model.listResourcesWithProperty(RDF.type, RDFS.Class).toList();
    for (Resource r : rdfsClassList) {
      if (r.canAs(OntClass.class)
          && r.getURI() != null
          && !isStandard(r.getURI())
          && manager.getDatatypeByUri(r.getURI()) == null) {
        result.add(r.as(OntClass.class));
      }
    }
    return result;
  }
Ejemplo n.º 4
0
  private Model execute(Model inputModel, String endpoint) {
    Model cube = createModel();
    Resource dataset;
    Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
    dataset =
        cube.createResource(
            GK.uri + "Properties_per_Class" + calendar.getTimeInMillis(), QB.Dataset);
    dataset.addLiteral(RDFS.comment, "Properties per class");
    dataset.addLiteral(DCTerms.date, cube.createTypedLiteral(calendar));
    dataset.addLiteral(DCTerms.publisher, "R & D, Unister GmbH, Geoknow");
    dataset.addProperty(QB.structure, cube.createResource(STRUCTURE));

    QueryExecution qExec;
    if (inputModel != null) {
      qExec = QueryExecutionFactory.create(INSTANCES, inputModel);
    } else {
      qExec =
          QueryExecutionFactory.sparqlService(endpoint, INSTANCES, defaultGraphs, defaultGraphs);
    }
    ResultSet result = qExec.execSelect();
    int i = 0;
    while (result.hasNext()) {
      Resource owlClass = result.next().getResource("class");
      NUMBER_OF_PROPERTIES.setIri("class", owlClass.getURI());
      QueryExecution propertiesQexec;
      if (inputModel != null) {
        propertiesQexec = QueryExecutionFactory.create(NUMBER_OF_PROPERTIES.asQuery(), inputModel);
      } else {
        propertiesQexec =
            QueryExecutionFactory.sparqlService(
                endpoint, NUMBER_OF_PROPERTIES.asQuery(), defaultGraphs, defaultGraphs);
        System.out.println(NUMBER_OF_PROPERTIES.asQuery());
      }
      try {
        ResultSet propertiesResult = propertiesQexec.execSelect();
        if (propertiesResult.hasNext()) {
          System.out.println(i);
          Resource obs =
              cube.createResource(
                  "http://www.geoknow.eu/data-cube/metric2/observation" + i, QB.Observation);
          obs.addProperty(QB.dataset, dataset);
          obs.addProperty(GK.DIM.Class, owlClass);
          obs.addLiteral(GK.MEASURE.PropertyCount, propertiesResult.next().getLiteral("count"));

          i++;
        }
      } catch (Exception e) {
        System.out.println(i);
        Resource obs =
            cube.createResource(
                "http://www.geoknow.eu/data-cube/metric2/observation" + i, QB.Observation);
        obs.addProperty(QB.dataset, dataset);
        obs.addProperty(GK.DIM.Class, owlClass);
        obs.addLiteral(GK.MEASURE.PropertyCount, -1);
        obs.addLiteral(RDFS.comment, e.getMessage());
        i++;
      }
    }
    return cube;
  }
Ejemplo n.º 5
0
  /** @todo Add Documentation. */
  @Override
  public boolean isFedoraGraphSubject(Resource subject) {
    checkArgument(subject != null, "null cannot be a Fedora object!");
    assert (subject != null);

    return subject.isURIResource() && subject.getURI().startsWith("info:fedora/");
  }
Ejemplo n.º 6
0
 public void testCreateAnonResourceWithNull() {
   final Resource r = model.createResource((String) null);
   Assert.assertTrue(r.isAnon());
   Assert.assertNull(r.getURI());
   Assert.assertNull(r.getNameSpace());
   Assert.assertNull(r.getLocalName());
 }
Ejemplo n.º 7
0
 public Resource getIdentity(Resource resource) {
   if (!_model.contains(resource, Vertere.identity)) {
     throw new RuntimeException(
         "Resource " + resource.getURI() + " does not contain an identity so cannot be created.");
   }
   return _model.getProperty(resource, Vertere.identity).getResource();
 }
Ejemplo n.º 8
0
  public List<ReMSerialisation> getReMSerialisations() throws OREException {
    try {
      List<ReMSerialisation> serialisations = new ArrayList<ReMSerialisation>();
      StmtIterator itr = res.listProperties(ORE.isDescribedBy);
      while (itr.hasNext()) {
        Statement statement = itr.nextStatement();
        Resource resource = (Resource) statement.getObject();
        StmtIterator itr2 = resource.listProperties(DC.format);
        StmtIterator itr3 = resource.listProperties(OREX.isAuthoritativeFor);
        String mime = "application/octet-stream";
        if (itr2.hasNext()) {
          Statement stmt = itr2.nextStatement();
          mime = ((Literal) stmt.getObject()).getLexicalForm();
        }
        boolean authoritative = false;
        if (itr3.hasNext()) {
          authoritative = true;
        }
        ReMSerialisation serialisation = new ReMSerialisation(mime, new URI(resource.getURI()));
        serialisation.setAuthoritative(authoritative);

        serialisations.add(serialisation);
      }
      return serialisations;
    } catch (URISyntaxException e) {
      throw new OREException(e);
    }
  }
Ejemplo n.º 9
0
  private static Set<Property> getPermissions(String userPrefix, String username, String uri) {
    Set<Property> permissions = new HashSet<Property>();
    Resource resource = configModel.createResource(uri);
    Resource user;
    if (username == null) user = PERM.Public;
    else user = configModel.createResource(userPrefix + username);

    StmtIterator stmts = configModel.listStatements(user, null, resource);
    while (stmts.hasNext()) permissions.add(stmts.next().getPredicate());

    String queryString = "";
    queryString += "PREFIX perm: <http://vocab.ox.ac.uk/perm#>\n";
    queryString += "SELECT ?perm ?regex WHERE {\n";
    queryString += "  <" + user.getURI() + "> ?perm ?rm .";
    queryString += "  ?rm a perm:ResourceMatch ;";
    queryString += "      perm:matchExpression ?regex }";

    com.hp.hpl.jena.query.Query query = QueryFactory.create(queryString);
    QueryExecution qexec = QueryExecutionFactory.create(query, configModel);
    ResultSet results = qexec.execSelect();
    while (results.hasNext()) {
      QuerySolution sol = results.next();
      if (uri.matches(((Literal) sol.get("regex")).getLexicalForm()))
        permissions.add(configModel.createProperty(((Resource) sol.get("perm")).getURI()));
    }

    if (username != null) permissions.addAll(getPermissions(userPrefix, null, uri));
    return permissions;
  }
Ejemplo n.º 10
0
 /**
  * Adds the LSRN SIO identifier structure to an LSRN-typed Resource. Attempts to use the URL of
  * the Resource to determine the ID.
  *
  * @param lsrnNode
  */
 public static void addIdentifier(Resource lsrnNode) {
   if (lsrnNode.isURIResource()) {
     Matcher idMatcher = ID_PATTERN.matcher(lsrnNode.getURI());
     if (idMatcher.find()) {
       String id = idMatcher.group(1);
       for (Resource type : RdfUtils.getTypes(lsrnNode).toList()) {
         if (!type.isURIResource()) continue;
         Matcher typeMatcher = TYPE_PATTERN.matcher(type.getURI());
         if (typeMatcher.find()) {
           String idTypeURI = OUTPUT_ID_TYPE_PATTERN.replace("$NS", typeMatcher.group(1));
           SIOUtils.createAttribute(
               lsrnNode, SIO.has_identifier, ResourceFactory.createResource(idTypeURI), id);
         }
       }
     }
   }
 }
Ejemplo n.º 11
0
 public Property getRelationshipProperty(Resource relationship) {
   if (_model.contains(relationship, Vertere.property)) {
     Resource resource = _model.getProperty(relationship, Vertere.property).getResource();
     return ResourceFactory.createProperty(resource.getURI());
   } else {
     return null;
   }
 }
Ejemplo n.º 12
0
 /** Adds a random Observable to any Activities that are missing Observables */
 public void fillInObservables() {
   for (Resource r : process.getActivities()) {
     if (process.getObservables(r).size() < 1) {
       String obsUri = String.format("%1$s_OBSERVABLE", r.getURI());
       addObservable(r, createObservable(obsUri));
     }
   }
 }
 private String printAsClass(VClassDao vcDao, Resource res) {
   String UNKNOWN = "???";
   try {
     VClass vClass = vcDao.getVClassByURI(res.getURI());
     return (vClass.getName() != null) ? vClass.getName() : UNKNOWN;
   } catch (Exception e) {
     return UNKNOWN;
   }
 }
Ejemplo n.º 14
0
 /**
  * Returns the main rdf:type of the given Thing.
  *
  * @param t is thing object
  * @return URI reference of value for rdf:type property
  */
 public static String getClosestRDFType(Thing t) {
   try {
     Class clazz = t.getClass();
     Resource r = (Resource) clazz.getField("TYPE").get(t);
     return r.getURI();
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 15
0
 public RDFDatatype getDatatype(Resource attribute) {
   if (_model.contains(attribute, Vertere.datatype)) {
     Resource resource = _model.getProperty(attribute, Vertere.datatype).getResource();
     RDFDatatype datatype = new BaseDatatype(resource.getURI());
     return datatype;
   } else {
     return null;
   }
 }
Ejemplo n.º 16
0
 protected void initPatternList(Resource lsrnIdentifierType) {
   List<Pattern> uriPatterns = new ArrayList<Pattern>();
   // add default LSRN URI pattern
   String lsrnNamespace = getNamespaceFromLSRNIdentifierTypeURI(lsrnIdentifierType.getURI());
   uriPatterns.add(Pattern.compile(String.format("http://lsrn\\.org/%s:(.+)", lsrnNamespace)));
   // add failsafe URI pattern (must always be last in list)
   uriPatterns.add(DEFAULT_FAILSAFE_URI_PATTERN);
   lsrnIdTypeToUriPattern.put(lsrnIdentifierType, uriPatterns);
 }
Ejemplo n.º 17
0
 private boolean isAbstract(OntProperty p) {
   List<RDFNode> list = p.listPropertyValues(RDF.type).toList();
   for (RDFNode node : list) {
     if (node.canAs(Resource.class)) {
       Resource r = node.asResource();
       if (BindVocabulary.AbstractProperty.getURI().equals(r.getURI())) return true;
     }
   }
   return false;
 }
  // add page list sparql query
  private void addPageListDisplayModel(
      OntModel displayModel, Model addStatements, Model removeStatements, UpdateSettings settings) {
    OntModel newDisplayModel = settings.getNewDisplayModelFromFile();
    // Get all statements about pageListPage and pageListData
    Resource pageList = newDisplayModel.getResource(DisplayVocabulary.DISPLAY_NS + "pageListPage");
    Resource pageListData =
        newDisplayModel.getResource(DisplayVocabulary.DISPLAY_NS + "pageListData");

    addStatements.add(newDisplayModel.listStatements(pageList, null, (RDFNode) null));
    addStatements.add(newDisplayModel.listStatements(pageListData, null, (RDFNode) null));
    StringWriter sw = new StringWriter();
    try {
      if (pageList != null) {
        log.debug("Page list uri is " + pageList.getURI());
      } else {
        log.debug("Page list uri is null for some reason");
      }
      log.debug("New Display model from file is ");
      newDisplayModel.write(sw, "N3");
      log.debug(sw.toString());
      sw.close();
      sw = new StringWriter();
      log.debug("Added statements now include ");
      addStatements.write(sw, "N3");
      log.debug(sw.toString());
      sw.close();
    } catch (Exception ex) {
      log.error("Exception occurred in writing out new display model", ex);
    }

    log.debug("Checking: AFTER adding pageList resource, what do we have for pageList page");
    Resource testResource =
        ResourceFactory.createResource(DisplayVocabulary.DISPLAY_NS + "pageListPage");
    StmtIterator testIt = addStatements.listStatements(testResource, null, (RDFNode) null);
    if (!testIt.hasNext()) {
      log.debug(
          "Add statements does not have the page list page resource " + testResource.getURI());
    }

    while (testIt.hasNext()) {
      log.debug("Statement for page list resource: " + testIt.nextStatement().toString());
    }
  }
Ejemplo n.º 19
0
      ProcessProfile(Resource device) {
        myARPReader.setProperty("WARN_RESOLVING_URI_AGAINST_EMPTY_BASE", "EM_IGNORE");
        myARPReader.setErrorHandler(
            new RDFErrorHandler() {
              // ARP parser error handling routines
              public void warning(Exception e) {
                outputMsg("RDF parser warning:" + e.getMessage());
              }

              public void error(Exception e) {
                outputMsg("RDF parser error:" + e.getMessage());
                profileValidFlag = false;
              }

              public void fatalError(Exception e) {
                e.printStackTrace();
                error(e);
              }
            });
        this.deviceURI = device.getURI();
        try {
          profile = UrlUtils.getURL(deviceURI).trim();
          if (profile.contains("<html") || profile.contains("<head>")) {
            // this is HTML not a UAProf profile
            device.removeProperties();
          } else if (!profile.contains("rdf") && !profile.contains("RDF")) {
            device.removeProperties();
          } else if (!profile.contains("uaprof") && !profile.contains("UAPROF")) {
            device.removeProperties();
          } else if (!profile.contains("openmobilealliance") && !profile.contains("wapforum")) {
            device.removeProperties();
          } else {
            validate(device);
            profiles.fixMetadata(device, profile);
          }
        } catch (IOException io) {
          outputMsg("Could not retrieve " + device.getURI());
          device.removeProperties();
          unreachableProfiles++;
        }
        System.out.println(messages.toString());
      }
  /**
   * Implementación del servicio
   *
   * @param __inbean Parámetro de entrada al servicio:
   * @param __outbean Parámetro de salida del servicio:
   * @param context Objeto context necesario en el servicio
   * @throws Exception Excepción producida en la ejecución del servicio en la clase hija
   */
  public void execute(
      CreateResource_req __inbean, CreateResource_resp __outbean, ServletContext context)
      throws Exception {
    // Get the Feed API
    QualiPSoFeedAPI model = AdvancedDocModel.getFeedAPI(context);

    // Invoke core API
    Resource newResource = model.createResource(__inbean.getResourceUri());

    // Output
    __outbean.setResourceUri(newResource.getURI());
  }
 public static String algorithmResourceToString(Resource algorithmResource)
     throws InvalidSPDXAnalysisException {
   String uri = algorithmResource.getURI();
   if (!algorithmResource.isURIResource()) {
     throw (new InvalidSPDXAnalysisException("Algorithm resource must be a URI"));
   }
   String retval = URI_TO_ALGORITHM.get(uri);
   if (retval == null) {
     throw (new InvalidSPDXAnalysisException("Invalid algorithm resource."));
   }
   return retval;
 }
Ejemplo n.º 22
0
 /**
  * Returns a Resource in the specified model that is an instance of the specified type with the
  * specified ID. The Resource will be created with an appropriate URI (@link {@link
  * #OUTPUT_URI_PATTERN}).
  *
  * @param model the model in which to create the new Resource
  * @param type the type (class) of the new instance
  * @param id the id of the new instance
  * @return a Resource view of the new instance
  */
 public static Resource createInstance(Model model, Resource type, String id) {
   Matcher matcher = TYPE_PATTERN.matcher(type.getURI());
   if (matcher.find()) {
     String namespace = matcher.group(1);
     String uri = getURI(namespace, id);
     Resource lsrnNode = model.createResource(uri, type);
     SIOUtils.createAttribute(lsrnNode, SIO.has_identifier, getIdentifierClass(namespace), id);
     return lsrnNode;
   } else {
     throw new IllegalArgumentException(
         "at present this method only works with LSRN database record classes");
   }
 }
Ejemplo n.º 23
0
 public List<URI> getRights() throws OREException {
   try {
     List<URI> rights = new ArrayList<URI>();
     StmtIterator itr = res.listProperties(DC.rights);
     while (itr.hasNext()) {
       Statement statement = itr.nextStatement();
       Resource right = (Resource) statement.getObject();
       rights.add(new URI(right.getURI()));
     }
     return rights;
   } catch (URISyntaxException e) {
     throw new OREException(e);
   }
 }
Ejemplo n.º 24
0
 public List<URI> getSimilarTo() throws OREException {
   try {
     List<URI> similars = new ArrayList<URI>();
     StmtIterator itr = res.listProperties(ORE.similarTo);
     while (itr.hasNext()) {
       Statement statement = itr.nextStatement();
       Resource node = (Resource) statement.getObject();
       similars.add(new URI(node.getURI()));
     }
     return similars;
   } catch (URISyntaxException e) {
     throw new OREException(e);
   }
 }
Ejemplo n.º 25
0
  private void handlePropertySubclassOf(OntProperty p) {

    List<RDFNode> list = p.listPropertyValues(RDFS.subClassOf).toList();
    for (RDFNode node : list) {
      if (!node.canAs(Resource.class)) continue;
      Resource resource = node.asResource();
      Resource onPropertyValue = resource.getPropertyResourceValue(OWL.onProperty);
      if (!RDFS.domain.equals(onPropertyValue)) continue;
      Resource someValuesFrom = resource.getPropertyResourceValue(OWL.someValuesFrom);
      if (someValuesFrom == null) continue;
      String uri = someValuesFrom.getURI();
      if (uri != null) {
        OntResource type = someValuesFrom.as(OntResource.class);
        addField(type, p, null);
      } else {
        Resource unionList = someValuesFrom.getPropertyResourceValue(OWL.unionOf);
        while (unionList != null) {
          Resource first = unionList.getPropertyResourceValue(RDF.first);
          if (first != null) {
            String typeURI = first.getURI();
            if (typeURI == null) {
              logger.warn(
                  "Cannot handle union that contains an anonymous class in the domain of "
                      + p.getURI());
            } else {
              OntResource type = first.as(OntResource.class);
              addField(type, p, null);
            }
          }
          unionList = unionList.getPropertyResourceValue(RDF.rest);
          if (RDF.nil.equals(unionList)) {
            break;
          }
        }
      }
    }
  }
 private String getURIStr(Resource res) {
   String URIStr;
   if (res == null) {
     URIStr =
         OWL.Thing
             .getURI(); // TODO: rdf:Resource if using RDF model; or option to turn off entirely
   } else {
     if (res.isAnon()) {
       URIStr = PSEUDO_BNODE_NS + res.getId().toString();
     } else {
       URIStr = res.getURI();
     }
   }
   return URIStr;
 }
 protected synchronized Map<Pattern, String> buildUrlPatternToURI() {
   OntModel displayModel = (OntModel) getServletContext().getAttribute("displayOntModel");
   Map<Pattern, String> map = new HashMap<Pattern, String>();
   StmtIterator stmts =
       displayModel.listStatements(null, DisplayVocabulary.URL_MAPPING, (Literal) null);
   while (stmts.hasNext()) {
     Statement stmt = stmts.nextStatement();
     if (stmt.getSubject().isURIResource() && stmt.getObject().isLiteral()) {
       Resource r = (Resource) stmt.getSubject().as(Resource.class);
       Pattern regex = Pattern.compile(stmt.getLiteral().getLexicalForm());
       map.put(regex, r.getURI());
     }
   }
   return map;
 }
 /* (non-Javadoc)
  * @see org.sadiframework.client.Registry#findServicesByConnectedClass(com.hp.hpl.jena.rdf.model.Resource)
  */
 @Override
 public Collection<? extends Service> findServicesByConnectedClass(Resource clazz)
     throws SADIException {
   Set<String> classURIs = new HashSet<String>();
   if (clazz.isURIResource()) classURIs.add(clazz.getURI());
   if (clazz.canAs(OntClass.class)) {
     for (Iterator<? extends OntClass> i = clazz.as(OntClass.class).listSubClasses();
         i.hasNext(); ) {
       OntClass c = i.next();
       if (c.isURIResource()) classURIs.add(c.getURI());
     }
   }
   return findServicesByConnectedClass(classURIs);
   // TODO
   //		return findServices(RegistrySearchCriteria.findService().addConnectedClass(clazz));
 }
 public Individual fillExistingDataPropertyStatementsForIndividual(
     Individual entity /*, boolean allowAnyNameSpace*/) {
   if (entity.getURI() == null) {
     return entity;
   } else {
     OntModel ontModel = getOntModelSelector().getABoxModel();
     ontModel.enterCriticalSection(Lock.READ);
     try {
       Resource ind = ontModel.getResource(entity.getURI());
       List<DataPropertyStatement> edList = new ArrayList<DataPropertyStatement>();
       StmtIterator stmtIt = ind.listProperties();
       while (stmtIt.hasNext()) {
         Statement st = (Statement) stmtIt.next();
         boolean addToList = /*allowAnyNameSpace ? st.getObject().canAs(Literal.class) :*/
             st.getObject().isLiteral()
                 && ((RDF.value.equals(st.getPredicate())
                         || VitroVocabulary.value.equals(st.getPredicate().getURI()))
                     || !(NONUSER_NAMESPACES.contains(st.getPredicate().getNameSpace())));
         if (addToList) {
             /* now want to expose Cornellemailnetid and potentially other properties so can at least control whether visible
             boolean isExternalId = false;
             ClosableIterator externalIdStmtIt = getOntModel().listStatements(st.getPredicate(), DATAPROPERTY_ISEXTERNALID, (Literal)null);
             try {
                 if (externalIdStmtIt.hasNext()) {
                     isExternalId = true;
                 }
             } finally {
                 externalIdStmtIt.close();
             }
             if (!isExternalId) { */
           DataPropertyStatement ed = new DataPropertyStatementImpl();
           Literal lit = (Literal) st.getObject();
           fillDataPropertyStatementWithJenaLiteral(ed, lit);
           ed.setDatapropURI(st.getPredicate().getURI());
           ed.setIndividualURI(ind.getURI());
           ed.setIndividual(entity);
           edList.add(ed);
           /* } */
         }
       }
       entity.setDataPropertyStatements(edList);
       return entity;
     } finally {
       ontModel.leaveCriticalSection();
     }
   }
 }
  public static void main(String[] args) throws IOException {
    Model model = ModelFactory.createDefaultModel();
    try (InputStream is =
        new BZip2CompressorInputStream(new URL(DBPEDIA_SCHEMA_DOWNLOAD_URL).openStream())) {
      //			model = FileManager.get().loadModel("input/dbpedia_3.9.owl");
      model.read(is, null, "RDF/XML");
    }

    System.out.println(model.size() + " triples loaded.");

    Set<Resource> classes = subjects(model, RDF.type, OWL.Class);
    Set<Resource> objectProperties = subjects(model, RDF.type, OWL.ObjectProperty);
    Set<Resource> dataProperties = subjects(model, RDF.type, OWL.DatatypeProperty);

    Map<Set<Resource>, String> setToName = new HashMap<>();
    setToName.put(classes, "classes");
    setToName.put(objectProperties, "objectproperties");
    setToName.put(dataProperties, "dataproperties");

    FieldType stringType = new FieldType(StringField.TYPE_STORED);
    stringType.setStoreTermVectors(false);
    FieldType textType = new FieldType(TextField.TYPE_STORED);
    textType.setStoreTermVectors(false);

    for (Set<Resource> set : setToName.keySet()) {
      IndexWriter writer = createWriter(setToName.get(set));
      Set<Document> documents = new HashSet<>();

      for (Resource resource : set) {
        for (RDFNode object : model.listObjectsOfProperty(resource, RDFS.label).toSet()) {
          String label = object.asLiteral().getLexicalForm();

          Document luceneDocument = new Document();
          luceneDocument.add(new Field("uri", resource.getURI(), stringType));
          //					luceneDocument.add(new Field("dbpediaUri", indexDocument.getCanonicalDBpediaUri(),
          // stringType));
          luceneDocument.add(new Field("label", label, textType));
          //					documents.add(luceneDocument);
          writer.addDocument(luceneDocument);
        }
      }
      writer.addDocuments(documents);
      writer.commit();
      writer.close();
    }
  }