@SuppressWarnings("all") public boolean canAs(Class view) { return blankNode.canAs(view); }
public static boolean isList(RDFNode node) { return node.isAnon() && node.canAs(RDFList.class); }
public static <T extends RDFNode> boolean canAsProperty(Statement stmt, Class<T> clazz) { boolean result = stmt.getObject().canAs(clazz); return result; }
public static boolean isList(RDFNode node) { return node.isAnon() && node.canAs(RDFList.class); }
private Individual getWorkflowStep(RDFNode stepNode) { if (stepNode == null) { return null; } if ( (stepNode != null) && (stepNode.canAs(Individual.class)) ) { Individual nextStepInd = (Individual) stepNode.as(Individual.class); if (instanceOf(nextStepInd,WorkflowOntology.WorkflowStep)) { return nextStepInd; } } return null; }
private Individual getAction(Individual stepInd) { log.debug("Workflow step: "+stepInd.getURI()); RDFNode actionNode = stepInd.getPropertyValue(WorkflowOntology.action); if (actionNode != null && actionNode.canAs(Individual.class)) { return (Individual) actionNode.as(Individual.class); } return null; }
private Set<Individual> listObjectProperties(OntResource ontResource, ObjectProperty prop) { LinkedHashSet<Individual> results = new LinkedHashSet<>(); try (ClosableIterable<RDFNode> props = iterate(ontResource .listPropertyValues(prop))) { for (RDFNode node : props) { if (!node.isResource() || !node.canAs(Individual.class)) continue; results.add(node.as(Individual.class)); } } return results; }
@Override public <T extends RDFNode> boolean canAs(final Class<T> view) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); // see if the base Item can as if (holder.getBaseItem().canAs(view)) { return getConstructor(view) != null; } return false; }
/** If _n_ is a ReifiedStatement, create a local copy of it, which will force the underlying reifier to take note of the mapping. */ private void noteIfReified( RDFNode n ) { if (n.canAs( ReifiedStatement.class )) { ReifiedStatement rs = n.as( ReifiedStatement.class ); createReifiedStatement( rs.getURI(), rs.getStatement() ); } }
/** If _n_ is a ReifiedStatement, create a local copy of it, which will force the underlying reifier to take note of the mapping. */ private void noteIfReified( RDFNode n ) { if (n.canAs( ReifiedStatement.class )) { ReifiedStatement rs = n.as( ReifiedStatement.class ); createReifiedStatement( rs.getURI(), rs.getStatement() ); } }
public static RDFList getListProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().canAs(RDFList.class)) { return s.getResource().as(RDFList.class); } else { return null; } }
public static RDFList getListProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().canAs(RDFList.class)) { return s.getResource().as(RDFList.class); } else { return null; } }
private List<OntClass> relatedClasses(OntClass ontClass, org.apache.jena.rdf.model.Property property) { List<OntClass> classes = new ArrayList<OntClass>(); StmtIterator closeIt = ontClass.listProperties(property); try { while (closeIt.hasNext()) { Statement stmt = closeIt.nextStatement(); if (stmt.getObject().canAs(OntClass.class)) { classes.add(stmt.getObject().as(OntClass.class)); } } } finally { closeIt.close(); } return classes; }
private static List<Statement> getDependentResourceDeleteList ( Statement stmt, Model model, Set<String> visitedUris, boolean perviousWasDependentResource ){ if( stmt == null ) return Collections.emptyList(); List<Statement> toDelete = new LinkedList<Statement>(); toDelete.add(stmt); RDFNode obj = stmt.getObject(); if( ( obj.canAs(Resource.class) && isPredicateDependencyRelation(stmt.getPredicate(), model) ) || ( obj.isAnon() && perviousWasDependentResource ) ){ Resource res = obj.as(Resource.class); String id = res.isAnon()?res.getId().toString():res.getURI(); if( !visitedUris.contains(id) ){ visitedUris.add(id); for( Statement stubStmt : getAllStatements(res, model)){ toDelete.addAll( getDependentResourceDeleteList(stubStmt, model,visitedUris,true)); } } } return toDelete; }
/** * <p>Answer the RDF value that all values of the restricted property must be equal to.</p> * @return An RDFNode that is the value of the restricted property * @exception ProfileException If the {@link Profile#HAS_VALUE()} property is not supported in the current language profile. */ @Override public RDFNode getHasValue() { checkProfile( getProfile().HAS_VALUE(), "HAS_VALUE" ); RDFNode n = getPropertyValue( getProfile().HAS_VALUE() ); // map to an individual in the case of a resource value if (!(n instanceof Literal) && n.canAs( Individual.class )) { n = n.as( Individual.class ); } return n; }
/** * <p>Answer the RDF value that all values of the restricted property must be equal to.</p> * @return An RDFNode that is the value of the restricted property * @exception ProfileException If the {@link Profile#HAS_VALUE()} property is not supported in the current language profile. */ @Override public RDFNode getHasValue() { checkProfile( getProfile().HAS_VALUE(), "HAS_VALUE" ); RDFNode n = getPropertyValue( getProfile().HAS_VALUE() ); // map to an individual in the case of a resource value if (!(n instanceof Literal) && n.canAs( Individual.class )) { n = n.as( Individual.class ); } return n; }
private void processChange( Statement s, ChangeType add){ //is it a change to an exclude class property? if( s != null && s.getPredicate() != null && s.getPredicate().getURI() != null && s.getPredicate().getURI().equals(DisplayVocabulary.EXCLUDE_CLASS.getURI())){ //is it about this ProhibitedFromSearch? if( s.getSubject() != null ){ String subURI = s.getSubject().getURI() ; if( subURI != null && subURI.equals( ProhibitedFromSearchURI )){ if( s.getObject() != null && s.getObject().canAs(Resource.class)){ String classURI = s.getObject().as(Resource.class).getURI(); if( add == ChangeType.ADD ) pfs.addProhibitedClass(classURI); else pfs.removeProhibitedClass(classURI); } } } } }
@Override public Individual getRelatedIndividual(String propertyURI) { if (propertyURI == null) { return null; } ind.getOntModel().enterCriticalSection(Lock.READ); try { RDFNode value = ind.getPropertyValue(ind.getModel().getProperty(propertyURI)); if (value != null && value.canAs(OntResource.class)) { return new IndividualJena(value.as(OntResource.class), webappDaoFactory); } else { return null; } } finally { ind.getOntModel().leaveCriticalSection(); } }
@Override protected void ontTest( OntModel m ) { OntClass A = m.createClass( NS + "A" ); Resource r = m.createResource( NS + "r" ); Resource s = m.createResource( NS + "s" ); m.add( r, RDF.type, A ); assertTrue( r.canAs( Individual.class ) ); assertTrue( s.canAs( Individual.class ) ); // does not have to have an rdf:type to be an Individual Property p = m.createDatatypeProperty(NS + "p"); m.add( r, p, m.createTypedLiteral( 42 )); assertFalse( r.getProperty( p ).getObject().canAs(Individual.class)); } },
@Override protected void ontTest( OntModel m ) { OntClass A = m.createClass( NS + "A" ); Resource r = m.createResource( NS + "r" ); Resource s = m.createResource( NS + "s" ); m.add( r, RDF.type, A ); assertTrue( r.canAs( Individual.class ) ); assertTrue( s.canAs( Individual.class ) ); // does not have to have an rdf:type to be an Individual Property p = m.createDatatypeProperty(NS + "p"); m.add( r, p, m.createTypedLiteral( 42 )); assertFalse( r.getProperty( p ).getObject().canAs(Individual.class)); } },