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(); } }
@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; }