Java Code Examples for org.eclipse.rdf4j.model.vocabulary.XMLSchema#ANYURI
The following examples show how to use
org.eclipse.rdf4j.model.vocabulary.XMLSchema#ANYURI .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValueTypeSupportRegistryImpl.java From inception with Apache License 2.0 | 6 votes |
private String getDataType(KBStatement aStatement, KBProperty aProperty) { String datatype = null; if (aStatement.getValue() != null) { Class<?> clazz = aStatement.getValue().getClass(); IRI type = DefaultDatatypeMapper.getDatatypeURI(clazz); // Mapping fails for NaiveIRI class, so check manually // if the value is an instance of IRI if (type == null && aStatement.getValue() instanceof IRI) { type = XMLSchema.ANYURI; } datatype = type != null ? type.stringValue() : null; } if (datatype == null && aProperty != null && aProperty.getRange() != null) { return aProperty.getRange(); } if (datatype == null) { datatype = XMLSchema.STRING.stringValue(); } return datatype; }
Example 2
Source File: SmartUriAdapter.java From rya with Apache License 2.0 | 6 votes |
private static IRI determineType(final String data) { if (Ints.tryParse(data) != null) { return XMLSchema.INTEGER; } else if (Doubles.tryParse(data) != null) { return XMLSchema.DOUBLE; } else if (Floats.tryParse(data) != null) { return XMLSchema.FLOAT; } else if (isShort(data)) { return XMLSchema.SHORT; } else if (Longs.tryParse(data) != null) { return XMLSchema.LONG; } if (Boolean.parseBoolean(data)) { return XMLSchema.BOOLEAN; } else if (isByte(data)) { return XMLSchema.BYTE; } else if (isDate(data)) { return XMLSchema.DATETIME; } else if (isUri(data)) { return XMLSchema.ANYURI; } return XMLSchema.STRING; }
Example 3
Source File: MongoEntityIndexerIT.java From rya with Apache License 2.0 | 6 votes |
@Test public void addStatement_setsType() throws Exception { try(MongoEntityIndexer indexer = new MongoEntityIndexer()) { indexer.setConf(conf); indexer.init(); // Load a type into the TypeStorage. final TypeStorage types = new MongoTypeStorage(getMongoClient(), conf.getRyaInstanceName()); types.create(PERSON_TYPE); // Index a RyaStatement that will create an Entity with an explicit type. final RyaStatement statement = new RyaStatement(new RyaIRI("urn:SSN/111-11-1111"), new RyaIRI( RDF.TYPE.toString() ), new RyaType(XMLSchema.ANYURI, "urn:person")); indexer.storeStatement(statement); // Fetch the Entity from storage and ensure it looks correct. final EntityStorage entities = new MongoEntityStorage(getMongoClient(), conf.getRyaInstanceName()); final Entity entity = entities.get(new RyaIRI("urn:SSN/111-11-1111")).get(); final Entity expected = Entity.builder() .setSubject(new RyaIRI("urn:SSN/111-11-1111")) .setExplicitType(new RyaIRI("urn:person")) .build(); assertEquals(expected, entity); } }
Example 4
Source File: SmartUriAdapter.java From rya with Apache License 2.0 | 5 votes |
/** * Serializes an {@link Entity} into a Smart {@link IRI}. * @param entity the {@link Entity} to serialize into a Smart URI. * @return the Smart {@link IRI}. * @throws SmartUriException */ public static IRI serializeUriEntity(final Entity entity) throws SmartUriException { final Map<IRI, Value> objectMap = new LinkedHashMap<>(); // Adds the entity's types to the Smart URI final List<RyaIRI> typeIds = entity.getExplicitTypeIds(); final Map<RyaIRI, String> ryaTypeMap = createTypeMap(typeIds); final IRI ryaTypeMapUri = createTypeMapUri(typeIds); final RyaType valueRyaType = new RyaType(XMLSchema.ANYURI, ryaTypeMapUri.stringValue()); final Value typeValue = RyaToRdfConversions.convertValue(valueRyaType); objectMap.put(RYA_TYPES_URI, typeValue); final RyaIRI subject = entity.getSubject(); final Map<RyaIRI, ImmutableMap<RyaIRI, Property>> typeMap = entity.getProperties(); for (final Entry<RyaIRI, ImmutableMap<RyaIRI, Property>> typeEntry : typeMap.entrySet()) { final RyaIRI type = typeEntry.getKey(); String typeShortName = ryaTypeMap.get(type); typeShortName = typeShortName != null ? typeShortName + "." : ""; final ImmutableMap<RyaIRI, Property> typeProperties = typeEntry.getValue(); for (final Entry<RyaIRI, Property> properties : typeProperties.entrySet()) { final RyaIRI key = properties.getKey(); final Property property = properties.getValue(); final String valueString = property.getValue().getData(); final RyaType ryaType = property.getValue(); //final RyaType ryaType = new RyaType(VF.createIRI(key.getData()), valueString); final Value value = RyaToRdfConversions.convertValue(ryaType); String formattedKey = key.getData(); if (StringUtils.isNotBlank(typeShortName)) { formattedKey = addTypePrefixToUri(formattedKey, typeShortName); } final IRI iri = VF.createIRI(formattedKey); objectMap.put(iri, value); } } return serializeUri(subject, objectMap); }
Example 5
Source File: RyaIRIResolver.java From rya with Apache License 2.0 | 4 votes |
public RyaIRIResolver() { super((byte) URI_MARKER, XMLSchema.ANYURI); }
Example 6
Source File: RyaIRI.java From rya with Apache License 2.0 | 4 votes |
public RyaIRI(String data) { super(XMLSchema.ANYURI, data); }
Example 7
Source File: RyaIRI.java From rya with Apache License 2.0 | 4 votes |
public RyaIRI(String namespace, String data) { super(XMLSchema.ANYURI, namespace + data); }
Example 8
Source File: DuplicateDataDetector.java From rya with Apache License 2.0 | 4 votes |
@Override public IRI getXmlSchemaUri() { return XMLSchema.ANYURI; }
Example 9
Source File: RyaTypeUtils.java From rya with Apache License 2.0 | 2 votes |
/** * * Creates a IRI {@link RyaType} object. * @param value the {@link IRI} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#ANYURI} and the data set to the specified {@code value}. */ public static RyaType iriRyaType(final IRI value) { return new RyaType(XMLSchema.ANYURI, value.stringValue()); }