@Override public Alt getAlt() { return object.as( Alt.class ); }
@Override public List<Item> getLinkedOrderedList(Ident linkName) { List<Item> results = new ArrayList<Item>(); RDFNode resultNode = getSinglePropertyVal(linkName, false); if (resultNode != null) { RDFList rdfList = resultNode.as(RDFList.class); //System.out.println("Found rdfList[" + linkName + "] = " + rdfList); if (rdfList != null) { List<RDFNode> javaNodeList = rdfList.asJavaList(); // System.out.println("JavaNodeList = " + javaNodeList); for (RDFNode elementNode : javaNodeList) { Resource res = elementNode.asResource(); JenaResourceItem jri = makeItemOfMyJClazz(res); // new JenaResourceItem(res); results.add(jri); } } } return results; } public Resource getJenaResource() {
@Override public Seq getSeq() { return object.as( Seq.class ); }
@Override public T map1( RDFNode x ) { return x.as( m_as ); } }
@Override public Bag getBag() { return object.as( Bag.class ); }
/** Answer the given node presenting the OntResource facet if it can */ private static RDFNode asOntResource( RDFNode n ) { return n.isResource() ? n.as( OntResource.class ) : n; }
@Override public T map1( Statement x ) { return x.getObject().as( m_as ); } }
private void enableDefaultMetadata(Resource root) { List<Statement> ss = root.listProperties(ELDA_API.enable_default_metadata).toList(); for (Statement s: ss) { List< RDFNode> l = s.getObject().as(RDFList.class).asJavaList(); for (RDFNode n: l) { Property p = n.as(Property.class); enabled.add(p); } } }
@Override public boolean accept(T node) { if (node.canAs(Individual.class)) { Individual individual = node.as(Individual.class); for (Resource rdfType : rdfTypes) { if (!individual.hasRDFType(rdfType)) return false; } } return true; } }
@Override public boolean accept(T node) { if (node.canAs(Individual.class)) { Individual individual = node.as(Individual.class); for (Resource rdfType : rdfTypes) { if (individual.hasRDFType(rdfType)) return true; } } return false; } }
private List<Property> getPropertyList(Resource config, Property property) { List<Property> result = new ArrayList<Property>(); Statement s = config.getProperty( property ); if (s != null) { for (RDFNode p: RDFUtil.asJavaList( s.getResource() )) { result.add( p.as( Property.class ) ); } } return result; }
/** * Convert the given Jena node as a Sesame Value * @param theNode the Jena node to convert * @return the jena node as a Sesame Value */ public static Value asSesameValue(RDFNode theNode) { if (theNode == null) { return null; } else if (theNode.canAs(Literal.class)) { return asSesameLiteral(theNode.as(Literal.class)); } else { return asSesameResource(theNode.as(Resource.class)); } }
@Override public boolean accept(T node) { if (node.canAs(Individual.class)) { Individual individual = node.as(Individual.class); if (individual.hasRDFType(rdfType)) { return true; } } return false; } }
/** Answer the object of a statement with the given property, .as() the given class */ protected <T extends RDFNode> T objectAs( Property p, String name, Class<T> asClass ) { checkProfile( p, name ); try { return getRequiredProperty( p ).getObject().as( asClass ); } catch (PropertyNotFoundException e) { return null; } }
/** 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() ); } }
/** Answer this view after modifying it to contain all the property chains defined by <code>spec</code>. */ public View addViewFromRDFList(Resource spec, ShortnameService sns) { cannotUpdateALL(); if (spec.canAs(RDFList.class)) { List<ViewProperty> properties = new ArrayList<>(); Iterator<RDFNode> list = spec.as(RDFList.class).iterator(); while(list.hasNext()) { properties.add(new ViewProperty.Base(list.next().as(Property.class))); } chains.add( new PropertyChain( properties ) ); } else { String uri = spec.asResource().getURI(); Property prop = ResourceFactory.createProperty(uri); ViewProperty vp = new ViewProperty.Base(prop); chains.add(new PropertyChain(vp)); } if (chains.size() > 0) type = Type.T_CHAINS; return this; }
private MessagePart obtainMessagePart(RDFNode inputNode) throws URISyntaxException { MessagePart result = null; if (inputNode == null || !inputNode.canAs(Individual.class)) { return result; } Individual individual = inputNode.as(Individual.class); result = new MessagePart(new URI(individual.getURI())); setAnnotableResourceProperties(individual, result); // Process mandatory parts List<MessagePart> mps; mps = obtainParts(individual, MSM.hasMandatoryPart); result.setMandatoryParts(mps); // Process optional parts mps = obtainParts(individual, MSM.hasOptionalPart); result.setOptionalParts(mps); return result; }
/** * <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 OntProfileException 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 MessageContent obtainMessageContent(RDFNode inputNode) throws URISyntaxException { MessageContent result = null; if (inputNode == null || !inputNode.canAs(Individual.class)) { return result; } Individual individual = inputNode.as(Individual.class); result = new MessageContent(new URI(individual.getURI())); setAnnotableResourceProperties(individual, result); // Process mandatory parts List<MessagePart> mps; mps = obtainParts(individual, MSM.hasMandatoryPart); result.setMandatoryParts(mps); // Process optional parts mps = obtainParts(individual, MSM.hasOptionalPart); result.setOptionalParts(mps); // Process Lifting and Lowerings List<URI> mappings; mappings = obtainMappings(individual, SAWSDL.liftingSchemaMapping); result.setLiftingSchemaMappings(mappings); mappings = obtainMappings(individual, SAWSDL.loweringSchemaMapping); result.setLoweringSchemaMappings(mappings); return result; }
/** Add the given value to a list which is the value of the given property */ protected void addListPropertyValue( Property p, String name, RDFNode value ) { checkProfile( p, name ); // get the list value if (hasProperty( p )) { RDFNode cur = getRequiredProperty( p ).getObject(); if (!cur.canAs( RDFList.class )) { throw new OntologyException( "Tried to add a value to a list-valued property " + p + " but the current value is not a list: " + cur ); } RDFList values = cur.as( RDFList.class ); // now add our value to the list if (!values.contains( value )){ RDFList newValues = values.with( value ); // if the previous values was nil, the return value will be a new list if (newValues != values) { removeAll( p ); addProperty( p, newValues ); } } } else { // create a new list to hold the only value we know so far addProperty( p, ((OntModel) getModel()).createList( new RDFNode[] {value} ) ); } }