protected Literal jenaLiteralFromDataPropertyStatement(
     DataPropertyStatement dataPropertyStatement, OntModel ontModel) {
   Literal l = null;
   if ((dataPropertyStatement.getLanguage()) != null
       && (dataPropertyStatement.getLanguage().length() > 0)) {
     l =
         ontModel.createLiteral(
             dataPropertyStatement.getData(), dataPropertyStatement.getLanguage());
   } else if ((dataPropertyStatement.getDatatypeURI() != null)
       && (dataPropertyStatement.getDatatypeURI().length() > 0)) {
     l =
         ontModel.createTypedLiteral(
             dataPropertyStatement.getData(),
             TypeMapper.getInstance().getSafeTypeByName(dataPropertyStatement.getDatatypeURI()));
   } else {
     l = ontModel.createLiteral(dataPropertyStatement.getData());
   }
   return l;
 }
 @Override
 public String toString() {
   return "DisplayDataPropertyStatement["
       + dataPropertyStatement.getIndividualURI()
       + "==>"
       + dataPropertyStatement.getDatapropURI()
       + "==>"
       + dataPropertyStatement.getData()
       + "]";
 }
 public int insertNewDataPropertyStatement(
     DataPropertyStatement dataPropertyStmt, OntModel ontModel) {
   ontModel.enterCriticalSection(Lock.WRITE);
   getOntModel()
       .getBaseModel()
       .notifyEvent(
           new IndividualUpdateEvent(
               getWebappDaoFactory().getUserURI(), true, dataPropertyStmt.getIndividualURI()));
   DataProperty dp =
       getWebappDaoFactory()
           .getDataPropertyDao()
           .getDataPropertyByURI(dataPropertyStmt.getDatapropURI());
   if ((dataPropertyStmt.getDatatypeURI() == null)
       && (dp != null)
       && (dp.getRangeDatatypeURI() != null)) {
     dataPropertyStmt.setDatatypeURI(dp.getRangeDatatypeURI());
   }
   Property prop = ontModel.getProperty(dataPropertyStmt.getDatapropURI());
   try {
     Resource res = ontModel.getResource(dataPropertyStmt.getIndividualURI());
     Literal literal = jenaLiteralFromDataPropertyStatement(dataPropertyStmt, ontModel);
     if (res != null
         && prop != null
         && literal != null
         && dataPropertyStmt.getData().length() > 0) {
       res.addProperty(prop, literal);
     }
   } finally {
     getOntModel()
         .getBaseModel()
         .notifyEvent(
             new IndividualUpdateEvent(
                 getWebappDaoFactory().getUserURI(), false, dataPropertyStmt.getIndividualURI()));
     ontModel.leaveCriticalSection();
   }
   return 0;
 }
Exemplo n.º 4
0
  @Override
  public void modifyDocument(Individual ind, SolrInputDocument doc, StringBuffer arg2)
      throws SkipIndividualException {

    String t = null;
    StringBuffer allTextValue = new StringBuffer();

    // collecting data property statements
    List<DataPropertyStatement> dataPropertyStatements = ind.getDataPropertyStatements();
    if (dataPropertyStatements != null) {
      Iterator<DataPropertyStatement> dataPropertyStmtIter = dataPropertyStatements.iterator();
      while (dataPropertyStmtIter.hasNext()) {
        DataPropertyStatement dataPropertyStmt = dataPropertyStmtIter.next();

        // we don't want label to be added to alltext
        if (RDFS.label.getURI().equals(dataPropertyStmt.getDatapropURI())) {
          continue;
        }

        allTextValue.append(" ");
        allTextValue.append(((t = dataPropertyStmt.getData()) == null) ? "" : t);
      }
    }

    try {
      String stripped = Jsoup.parse(allTextValue.toString()).text();
      allTextValue.setLength(0);
      allTextValue.append(stripped);
    } catch (Exception e) {
      log.debug("Could not strip HTML during search indexing. ", e);
    }

    String alltext = allTextValue.toString();

    doc.addField(multiSiteTerm.alltext, alltext);
  }