protected DataPropertyStatement fillDataPropertyStatementWithJenaLiteral(
     DataPropertyStatement dataPropertyStatement, Literal l) {
   dataPropertyStatement.setData(l.getLexicalForm());
   dataPropertyStatement.setDatatypeURI(l.getDatatypeURI());
   dataPropertyStatement.setLanguage(l.getLanguage());
   return dataPropertyStatement;
 }
 public void deleteDataPropertyStatement(DataPropertyStatement dataPropertyStatement) {
   OntModel ontModel = getOntModelSelector().getABoxModel();
   try {
     ontModel.enterCriticalSection(Lock.WRITE);
     getOntModel()
         .getBaseModel()
         .notifyEvent(
             new IndividualUpdateEvent(
                 getWebappDaoFactory().getUserURI(),
                 true,
                 dataPropertyStatement.getIndividualURI()));
     com.hp.hpl.jena.ontology.Individual ind =
         ontModel.getIndividual(dataPropertyStatement.getIndividualURI());
     OntModel tboxModel = getOntModelSelector().getTBoxModel();
     tboxModel.enterCriticalSection(Lock.READ);
     try {
       Property prop = tboxModel.getProperty(dataPropertyStatement.getDatapropURI());
       Literal l = jenaLiteralFromDataPropertyStatement(dataPropertyStatement, ontModel);
       if (ind != null && prop != null && l != null) {
         ontModel.getBaseModel().remove(ind, prop, l);
       }
     } finally {
       tboxModel.leaveCriticalSection();
     }
   } finally {
     getOntModel()
         .getBaseModel()
         .notifyEvent(
             new IndividualUpdateEvent(
                 getWebappDaoFactory().getUserURI(),
                 false,
                 dataPropertyStatement.getIndividualURI()));
     ontModel.leaveCriticalSection();
   }
 }
 public List<DataPropertyStatement> getDataPropertyStatements(
     DataProperty dp, int startIndex, int endIndex) {
   getOntModel().enterCriticalSection(Lock.READ);
   List<DataPropertyStatement> dpss = new ArrayList<DataPropertyStatement>();
   try {
     Property prop = ResourceFactory.createProperty(dp.getURI());
     ClosableIterator dpsIt = getOntModel().listStatements(null, prop, (Literal) null);
     try {
       int count = 0;
       while ((dpsIt.hasNext()) && ((endIndex < 0) || (count < endIndex))) {
         ++count;
         Statement stmt = (Statement) dpsIt.next();
         if (startIndex < 0 || startIndex <= count) {
           Literal lit = (Literal) stmt.getObject();
           DataPropertyStatement dps = new DataPropertyStatementImpl();
           dps.setDatapropURI(dp.getURI());
           dps.setIndividualURI(stmt.getSubject().getURI());
           fillDataPropertyStatementWithJenaLiteral(dps, lit);
           dpss.add(dps);
         }
       }
     } finally {
       dpsIt.close();
     }
   } finally {
     getOntModel().leaveCriticalSection();
   }
   return dpss;
 }
 @Override
 public String toString() {
   return "DisplayDataPropertyStatement["
       + dataPropertyStatement.getIndividualURI()
       + "==>"
       + dataPropertyStatement.getDatapropURI()
       + "==>"
       + dataPropertyStatement.getData()
       + "]";
 }
 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 Collection<DataPropertyStatement> getDataPropertyStatementsForIndividualByDataPropertyURI(
     Individual entity, String datapropURI) {
   Collection<DataPropertyStatement> edList = new ArrayList<DataPropertyStatement>();
   if (entity.getURI() == null) {
     return edList;
   }
   try {
     getOntModel().enterCriticalSection(Lock.READ);
     OntResource ontRes =
         (VitroVocabulary.PSEUDO_BNODE_NS.equals(entity.getNamespace()))
             ? (OntResource)
                 getOntModel()
                     .createResource(new AnonId(entity.getLocalName()))
                     .as(OntResource.class)
             : getOntModel().getOntResource(entity.getURI());
     if (ontRes == null) {
       return edList;
     }
     ClosableIterator stmtIt;
     stmtIt =
         (datapropURI != null)
             ? ontRes.listProperties(getOntModel().getProperty(datapropURI))
             : ontRes.listProperties();
     try {
       while (stmtIt.hasNext()) {
         Statement st = (Statement) stmtIt.next();
         if (st.getObject().isLiteral()) {
           DataPropertyStatement ed = new DataPropertyStatementImpl();
           Literal lit = (Literal) st.getObject();
           fillDataPropertyStatementWithJenaLiteral(ed, lit);
           ed.setIndividualURI(entity.getURI());
           ed.setIndividual(entity);
           ed.setDatapropURI(st.getPredicate().getURI());
           edList.add(ed);
         }
       }
     } finally {
       stmtIt.close();
     }
   } finally {
     getOntModel().leaveCriticalSection();
   }
   return edList;
 }
 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 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);
  }
 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;
 }