Hello 'jena-users',

My question is related to the situation when I want to validate the (OntModel) 
model after an update operation using the SPARQUL query. 
If there are not conflicts, the model can go ahead a commit. But, what happen 
when there are some conflicts?

See below my two methods: one for model consistency and another to update the 
model using SPARUL API. However, in the latter,  the abort() call does not work 
obviously as the model does not support transaction. 

Therefore, the question is what I could do in order to guarantee a consistent 
model after model updates.

 Lib being used: TDB-0.8.10 and Jena-2.7.0

Regards,
Emilio
 

private static boolean modelConsistencyCheck() throws ConsistencyException {
            boolean check;
            ValidityReport validity = model.validate();

            if (validity.isValid()) {
                logger.info("Consistency Checking: OK");
                check=true;
            } else {
                logger.warn("Consistency Checking: Conflicts");
                for (Iterator i = validity.getReports(); i.hasNext();) {
                    logger.warn(" - " + i.next());
                }
                check=true;
                throw new ConsistencyException("Model is INCONSISTENT > check 
logs to see conflicts");
            }
        return check;
    }

public String updateModel(String inputQuery)  throws ConsistencyException, 
QueryParseException, QueryExecException, IOException, 
ConcurrentModificationException, Exception {
        
 // Construct a SPARUL query
        String queryResults = null;
        model.enterCriticalSection(Lock.WRITE);
        try {
            UpdateRequest updateRequest = UpdateFactory.create(queryPrefix + 
inputQuery);
            UpdateAction.execute(updateRequest, model);

                logger.debug("Consistency checking of UPDATED Model");
                if (modelConsistencyCheck()) {
                    model.commit();
                } else {
                    model.abort();
                }
        } finally {
            TDB.sync(model);
            queryResults = "Model Updated";
            model.leaveCriticalSection();
        }

        return queryResults;
  }

Reply via email to