use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.
the class SmartUriAdapter method createTypePropertiesUri.
private static URI createTypePropertiesUri(final ImmutableMap<RyaURI, ImmutableMap<RyaURI, Property>> typeProperties) throws SmartUriException {
final List<NameValuePair> nameValuePairs = new ArrayList<>();
for (final Entry<RyaURI, ImmutableMap<RyaURI, Property>> typeProperty : typeProperties.entrySet()) {
final RyaURI type = typeProperty.getKey();
final Map<RyaURI, Property> propertyMap = typeProperty.getValue();
final URI typeUri = createIndividualTypeWithPropertiesUri(type, propertyMap);
final String keyString = type.getDataType().getLocalName();
final String valueString = typeUri.getLocalName();
nameValuePairs.add(new BasicNameValuePair(keyString, valueString));
}
final URIBuilder uriBuilder = new URIBuilder();
uriBuilder.addParameters(nameValuePairs);
String uriString;
try {
final java.net.URI uri = uriBuilder.build();
final String queryString = uri.getRawSchemeSpecificPart();
uriString = "urn:test" + queryString;
} catch (final URISyntaxException e) {
throw new SmartUriException("Unable to create type properties for the Smart URI", e);
}
return new URIImpl(uriString);
}
use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.
the class SmartUriAdapter method removeTypePrefixFromUri.
private static String removeTypePrefixFromUri(final String uriString, final String typePrefix) {
final String localName = new URIImpl(uriString).getLocalName();
final String beginning = StringUtils.removeEnd(uriString, localName);
final String replacement = localName.replaceFirst(typePrefix + ".", "");
final String formattedUriString = beginning + replacement;
return formattedUriString;
}
use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.
the class SmartUriAdapter method createIndividualTypeWithPropertiesUri.
private static URI createIndividualTypeWithPropertiesUri(final RyaURI type, final Map<RyaURI, Property> map) throws SmartUriException {
final List<NameValuePair> nameValuePairs = new ArrayList<>();
for (final Entry<RyaURI, Property> entry : map.entrySet()) {
final RyaURI key = entry.getKey();
final Property property = entry.getValue();
final RyaType ryaType = property.getValue();
final String keyString = (new URIImpl(key.getData())).getLocalName();
final Value value = RyaToRdfConversions.convertValue(ryaType);
final String valueString = value.stringValue();
nameValuePairs.add(new BasicNameValuePair(keyString, valueString));
}
final URIBuilder uriBuilder = new URIBuilder();
uriBuilder.addParameters(nameValuePairs);
String uriString;
try {
final java.net.URI uri = uriBuilder.build();
final String queryString = uri.getRawSchemeSpecificPart();
uriString = type.getData() + /*new URIImpl(type.getData()).getLocalName()*/
queryString;
} catch (final URISyntaxException e) {
throw new SmartUriException("Unable to create type URI with all its properties for the Smart URI", e);
}
return new URIImpl(uriString);
}
use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.
the class AccumuloPcjSerializerTest method basicShortMixLiteralBsTest.
@Test
public void basicShortMixLiteralBsTest() throws BindingSetConversionException {
final QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("X", new LiteralImpl("literal1"));
bs.addBinding("Y", new LiteralImpl("5", new URIImpl("http://www.w3.org/2001/XMLSchema#integer")));
final VariableOrder varOrder = new VariableOrder("X", "Y");
BindingSetConverter<byte[]> converter = new AccumuloPcjSerializer();
final byte[] byteVal = converter.convert(bs, varOrder);
final BindingSet newBs = converter.convert(byteVal, varOrder);
assertEquals(bs, newBs);
}
use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.
the class AccumuloPcjSerializerTest method basicShortUriBsTest.
@Test
public void basicShortUriBsTest() throws BindingSetConversionException {
final QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("X", new URIImpl("http://uri1"));
bs.addBinding("Y", new URIImpl("http://uri2"));
final VariableOrder varOrder = new VariableOrder("X", "Y");
BindingSetConverter<byte[]> converter = new AccumuloPcjSerializer();
final byte[] byteVal = converter.convert(bs, varOrder);
final BindingSet newBs = converter.convert(byteVal, varOrder);
assertEquals(bs, newBs);
}
Aggregations