use of org.openrdf.model.impl.IntegerLiteralImpl in project wikidata-query-rdf by wikimedia.
the class RdfRepositoryIntegrationTest method syncJustVersion.
private void syncJustVersion(String entityId, int version) {
Statement statement = statement(entityId, SchemaDotOrg.VERSION, new IntegerLiteralImpl(new BigInteger(Integer.toString(version))));
rdfRepository.sync(entityId, ImmutableList.of(statement));
}
use of org.openrdf.model.impl.IntegerLiteralImpl in project incubator-rya by apache.
the class CountFunction method update.
@Override
public void update(final AggregationElement aggregation, final AggregationState state, final VisibilityBindingSet childBindingSet) {
checkArgument(aggregation.getAggregationType() == AggregationType.COUNT, "The CountFunction only accepts COUNT AggregationElements.");
requireNonNull(state);
requireNonNull(childBindingSet);
// Only add one to the count if the child contains the binding that we are counting.
final String aggregatedName = aggregation.getAggregatedBindingName();
if (childBindingSet.hasBinding(aggregatedName)) {
final MapBindingSet result = state.getBindingSet();
final String resultName = aggregation.getResultBindingName();
final boolean newBinding = !result.hasBinding(resultName);
if (newBinding) {
// Initialize the binding.
result.addBinding(resultName, new IntegerLiteralImpl(BigInteger.ONE));
} else {
// Update the existing binding.
final Literal count = (Literal) result.getValue(resultName);
final BigInteger updatedCount = count.integerValue().add(BigInteger.ONE);
result.addBinding(resultName, new IntegerLiteralImpl(updatedCount));
}
}
}
use of org.openrdf.model.impl.IntegerLiteralImpl in project incubator-rya by apache.
the class BindingSetStringConverterTest method toString_Integer.
@Test
public void toString_Integer() throws BindingSetConversionException {
// Setup the binding set that will be converted.
final MapBindingSet originalBindingSet = new MapBindingSet();
originalBindingSet.addBinding("x", new IntegerLiteralImpl(BigInteger.valueOf(5)));
// Convert it to a String.
final VariableOrder varOrder = new VariableOrder("x");
final BindingSetConverter<String> converter = new BindingSetStringConverter();
final String bindingSetString = converter.convert(originalBindingSet, varOrder);
// Ensure it converted to the expected result.
final String expected = "5<<~>>http://www.w3.org/2001/XMLSchema#integer";
assertEquals(expected, bindingSetString);
}
use of org.openrdf.model.impl.IntegerLiteralImpl in project incubator-rya by apache.
the class BindingSetStringConverterTest method fromString_Integer.
@Test
public void fromString_Integer() throws BindingSetConversionException {
// Setup the String that will be converted.
final String bindingSetString = "5<<~>>http://www.w3.org/2001/XMLSchema#integer";
// Convert it to a BindingSet
final BindingSetConverter<String> converter = new BindingSetStringConverter();
final BindingSet bindingSet = converter.convert(bindingSetString, new VariableOrder("x"));
// Ensure it converted to the expected result.
final MapBindingSet expected = new MapBindingSet();
expected.addBinding("x", new IntegerLiteralImpl(BigInteger.valueOf(5)));
assertEquals(expected, bindingSet);
}
Aggregations