public void addedStatement(com.hp.hpl.jena.rdf.model.Statement stmt) { if (stmt.getPredicate().equals(hasContextProperty)) { if (!stmt.getObject().canAs(com.hp.hpl.jena.rdf.model.Resource.class)) return; com.hp.hpl.jena.rdf.model.Resource resource = (com.hp.hpl.jena.rdf.model.Resource) stmt.getObject().as(com.hp.hpl.jena.rdf.model.Resource.class); hasContext = null; if (true) { // don't check resource type if the property range is Resource try { hasContext = ibspan.tss.um.ontology.UserModellingFactory.getUserBehaviourContext(resource, _model); } catch (JastorException e) { // e.printStackTrace(); } } if (listeners != null) { java.util.ArrayList consumers; synchronized (listeners) { consumers = (java.util.ArrayList) listeners.clone(); } for (java.util.Iterator iter = consumers.iterator(); iter.hasNext(); ) { ExtendedUserBehaviourListener listener = (ExtendedUserBehaviourListener) iter.next(); listener.hasContextChanged(ibspan.tss.um.ontology.ExtendedUserBehaviourImpl.this); } } return; } if (stmt.getPredicate().equals(hasUserBehaviourProperty)) { if (!stmt.getObject().canAs(com.hp.hpl.jena.rdf.model.Resource.class)) return; com.hp.hpl.jena.rdf.model.Resource resource = (com.hp.hpl.jena.rdf.model.Resource) stmt.getObject().as(com.hp.hpl.jena.rdf.model.Resource.class); hasUserBehaviour = null; if (true) { // don't check resource type if the property range is Resource try { hasUserBehaviour = ibspan.tss.um.ontology.UserModellingFactory.getUserBehaviour(resource, _model); } catch (JastorException e) { // e.printStackTrace(); } } if (listeners != null) { java.util.ArrayList consumers; synchronized (listeners) { consumers = (java.util.ArrayList) listeners.clone(); } for (java.util.Iterator iter = consumers.iterator(); iter.hasNext(); ) { ExtendedUserBehaviourListener listener = (ExtendedUserBehaviourListener) iter.next(); listener.hasUserBehaviourChanged(ibspan.tss.um.ontology.ExtendedUserBehaviourImpl.this); } } return; } }
public ibspan.tss.um.ontology.UserBehaviourContext setHasContext() throws JastorException { if (_model.contains(_resource, hasContextProperty)) { _model.removeAll(_resource, hasContextProperty, null); } ibspan.tss.um.ontology.UserBehaviourContext hasContext = ibspan.tss.um.ontology.UserModellingFactory.createUserBehaviourContext( _model.createResource(), _model); this.hasContext = hasContext; _model.add(_model.createStatement(_resource, hasContextProperty, hasContext.resource())); return hasContext; }
public ibspan.tss.um.ontology.UserBehaviour setHasUserBehaviour( com.hp.hpl.jena.rdf.model.Resource resource) throws JastorException { if (!_model.contains(resource, RDF.type, ibspan.tss.um.ontology.UserBehaviour.TYPE)) throw new JastorException( "Resource " + resource + " not of type " + ibspan.tss.um.ontology.UserBehaviour.TYPE); if (_model.contains(_resource, hasUserBehaviourProperty)) { _model.removeAll(_resource, hasUserBehaviourProperty, null); } ibspan.tss.um.ontology.UserBehaviour hasUserBehaviour = ibspan.tss.um.ontology.UserModellingFactory.getUserBehaviour(resource, _model); this.hasUserBehaviour = hasUserBehaviour; _model.add( _model.createStatement(_resource, hasUserBehaviourProperty, hasUserBehaviour.resource())); return hasUserBehaviour; }
public ibspan.tss.um.ontology.UserBehaviourContext getHasContext() throws JastorException { if (hasContext != null) return hasContext; com.hp.hpl.jena.rdf.model.Statement stmt = _model.getProperty(_resource, hasContextProperty); if (stmt == null) return null; if (!stmt.getObject().canAs(com.hp.hpl.jena.rdf.model.Resource.class)) throw new JastorInvalidRDFNodeException( uri() + ": hasContext getProperty() in ibspan.tss.um.ontology.ExtendedUserBehaviour model not Resource", stmt.getObject()); com.hp.hpl.jena.rdf.model.Resource resource = (com.hp.hpl.jena.rdf.model.Resource) stmt.getObject().as(com.hp.hpl.jena.rdf.model.Resource.class); hasContext = ibspan.tss.um.ontology.UserModellingFactory.getUserBehaviourContext(resource, _model); return hasContext; }
private void setupModelListener() { listeners = new java.util.ArrayList(); ibspan.tss.um.ontology.UserModellingFactory.registerThing(this); }