@Override public Literal cast(RDFNode node) { return node.asLiteral(); } @Override
@Override protected Literal getLiteralVal(Ident fieldID, boolean throwOnFailure) { Literal resultLit = null; RDFNode resultNode = getSinglePropertyVal(fieldID, throwOnFailure); if (resultNode != null) { resultLit = resultNode.asLiteral(); } return resultLit; }
@Override public RDFNode getNewTargetNode(Statement originalStatement, JComponent component) { JSpinner spinner = (JSpinner) component; Date d = (Date) spinner.getValue(); if ((originalStatement == null) || !originalStatement.getObject().asLiteral().getValue() .equals(d)) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(d); return createTypedLiteral(cal); } return null; }
@Override public RDFNode getNewTargetNode(Statement originalStatement, JComponent component) { JSpinner spinner = (JSpinner) component; Date d = (Date) spinner.getValue(); if ((originalStatement == null) || !originalStatement.getObject().asLiteral().getValue() .equals(d)) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(d); return createTypedLiteral(cal); } return null; }
/** * Extracts property hasDbXref from an {@link RDFNode} and adds it to the {@link SolrInputDocument}. * * @param doc the Solr input document for an {@link OntClass} of interest * @param object the {@link RDFNode} object contained within the {@link OntClass} of interest */ private void extractDbxRef(@Nonnull final SolrInputDocument doc, @Nonnull final RDFNode object) { // If the node is not a literal, will throw a {@link LiteralRequiredException}. For Orphanet, this is always // a literal. if (object.isLiteral()) { final String externalRef = object.asLiteral().getLexicalForm(); final String ontology = StringUtils.substringBefore(externalRef, SEPARATOR); final String externalId = StringUtils.substringAfter(externalRef, SEPARATOR); addMultivaluedField(doc, ontology.toLowerCase() + "_id", externalId); } }
/** * Extracts property hasDbXref from an {@link RDFNode} and adds it to the {@link SolrInputDocument}. * * @param doc the Solr input document for an {@link OntClass} of interest * @param object the {@link RDFNode} object contained within the {@link OntClass} of interest */ private void extractDbxRef(@Nonnull final SolrInputDocument doc, @Nonnull final RDFNode object) { // If the node is not a literal, will throw a {@link LiteralRequiredException}. For ORDO, this is always a // literal. if (object.isLiteral()) { final String externalRef = object.asLiteral().getLexicalForm(); final String ontology = StringUtils.substringBefore(externalRef, SEPARATOR); final String externalId = StringUtils.substringAfter(externalRef, SEPARATOR); addMultivaluedField(doc, ontology.toLowerCase() + "_id", externalId); } }
/** * Extracts the fieldName property from the provided {@link RDFNode}, and adds this data to the * {@link SolrInputDocument}. * * @param doc the Solr input document * @param fieldName the name of the field to be stored * @param object the {@link RDFNode} object */ private void extractField(@Nonnull final SolrInputDocument doc, @Nonnull final String fieldName, @Nonnull final RDFNode object) { // If the node is not a literal, will throw a {@link LiteralRequiredException}, so need to check. Non literals // will be properties like Class or subClassOf. This kind of data is already added via parents. if (object.isLiteral()) { final String fieldValue = object.asLiteral().getLexicalForm(); addMultivaluedField(doc, fieldName, fieldValue); } }
/** * Extracts the fieldName property from the provided {@link RDFNode}, and adds this data to the * {@link SolrInputDocument}. * * @param doc the Solr input document * @param fieldName the name of the field to be stored * @param object the {@link RDFNode} object */ private void extractField(@Nonnull final SolrInputDocument doc, @Nonnull final String fieldName, @Nonnull final RDFNode object) { // If the node is not a literal, will throw a {@link LiteralRequiredException}, so need to check. Non literals // will be properties like Class or subClassOf. This kind of data is already added via parents. if (object.isLiteral()) { final String fieldValue = object.asLiteral().getLexicalForm(); addMultivaluedField(doc, fieldName, fieldValue); } }
@Override public Integer call() throws Exception { int size = qe.execSelect().next().get("count").asLiteral().getInt(); System.out.println(size); return size; } });
private Object getAxiom(Individual axiomIndiv) { RDFNode value = axiomIndiv.getPropertyValue(RDF.value); if (value != null && value.isLiteral()) { return value.asLiteral().getValue(); } return null; }
/** * Answer the string value of the parameter if set, or null otherwise. Note command line * has precedence. * * @return String */ protected String getStringValue( List<String> cmdLineArgs, Resource confRoot ) { RDFNode n = getValue( cmdLineArgs, confRoot ); return (n == null) ? null : (n.isLiteral() ? n.asLiteral().getLexicalForm() : n.toString() ); }
@Override public Integer call() throws Exception{ String query = "SELECT DISTINCT (count(?s) AS ?count) { { ?s ?p ?o . } UNION { GRAPH ?g { ?s ?p ?o .} } }"; QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(sparqlEndPoint,query); int size = qe.execSelect().next().get("count").asLiteral().getInt(); return size; } });
private String asBody( RDFNode n ) { if (n.isLiteral()) return n.asLiteral().getLexicalForm(); if (n.isResource()) return n.asResource().getURI(); return n.toString(); }
public final Literal literal(String binding) { if(!this.solution.contains(binding)) { return null; } RDFNode node = this.solution.get(binding); if(!node.canAs(Literal.class)) { throw new IllegalStateException("Binding '"+binding+"' is not a literal"); } return node.asLiteral(); }
private void add(Collection<Attribute> attributes, String attr_type, String prefix, String name, RDFNode node) throws StatefulIngestServiceException { String value = null; if (attr_type.equals(AttributeValueType.DATETIME)) { // Eventually could deal with the typed DateTime literal } if (node.isLiteral()) { value = node.asLiteral().getString(); } else if (node.isURIResource()) { value = node.asResource().getURI(); } else { throw new StatefulIngestServiceException("Expected resource to be literal or uri: " + node); } add(attributes, attr_type, prefix, name, value); }
private SourceTypes getSourceType(Resource mappingResource) { Property sourceNameProp = model.getProperty(Uris.KM_SOURCE_TYPE_URI); Statement s = model.getProperty(mappingResource, sourceNameProp); String sourceType; if(s != null) { RDFNode node = s.getObject(); if(node != null && node.isLiteral()) { sourceType = node.asLiteral().getString(); return SourceTypes.valueOf(sourceType); } } return SourceTypes.CSV; }
private Object getValue(RDFNode n, Object outer) throws Exception { if (n.isLiteral()) return n.asLiteral().getValue(); if (n.isResource()) { Statement st = n.asResource().getProperty(pValue); if (st != null) { n = st.getObject(); if (n.isLiteral()) return n.asLiteral().getValue(); return parseAnything(object(), st.getObject(), outer, null); } } throw new ParseException(this, "Unknown value type for node ''{0}''", n); }
private static Term createTerm(RDFNode node) { Term term = null; if (node.isLiteral()) { Literal l = node.asLiteral(); term = DefaultTermFactory.instance().createLiteral(URIUtils.createURI(l.getDatatypeURI()), l.getValue()); } else { term = DefaultTermFactory.instance().createConstant(URIzer.instance().output(node.toString())); } return term; }
private Value createValue(RDFNode object) { if(object.isLiteral()) { Literal literal = object.asLiteral(); return ProtocolFactory. newLiteral(). withLexicalForm(literal.getLexicalForm()). withDatatype(literal.getDatatypeURI()). withLanguage(literal.getLanguage()). build(); } else { return resolveResource(object.asResource(),true); } }
private void populateBindingValue(BindingBuilder builder, RDFNode node) { LOGGER.trace("- Value {}",node); if(node.isLiteral()) { Literal literal=node.asLiteral(); builder. withValue( ProtocolFactory. newLiteral(). withLexicalForm(literal.getLexicalForm()). withDatatype(literal.getDatatypeURI()). withLanguage(literal.getLanguage())); } else if(node.isURIResource()) { builder.withValue(ProtocolFactory.newResource(node.asResource().getURI())); } else { builder.withValue(ProtocolFactory.newVariable(node.asResource().getId().getLabelString())); } }