use of org.wikidata.query.rdf.blazegraph.constraints.WikibaseNowBOp in project wikidata-query-rdf by wikimedia.
the class WikibaseContextListener method initializeServices.
/**
* Initializes BG service setup to allow whitelisted services.
* Also add additional custom services and functions.
*/
@VisibleForTesting
public void initializeServices() {
MetricRegistry metricRegistry = createMetricRegistry();
// Enable service whitelisting
final ServiceRegistry reg = ServiceRegistry.getInstance();
reg.setWhitelistEnabled(ENABLE_WHITELIST);
LabelService.register();
GeoService.register();
MWApiServiceFactory.register(metricRegistry.timer(name(MWApiServiceCall.class, MW_API_REQUEST)));
CategoriesStoredQuery.register();
// Whitelist services we like by default
reg.addWhitelistURL(GASService.Options.SERVICE_KEY.toString());
reg.addWhitelistURL(ValuesServiceFactory.SERVICE_KEY.toString());
reg.addWhitelistURL(BDS.SEARCH_IN_SEARCH.toString());
reg.addWhitelistURL(SliceServiceFactory.SERVICE_KEY.toString());
reg.addWhitelistURL(SampleServiceFactory.SERVICE_KEY.toString());
loadWhitelist(reg);
// Initialize remote services
reg.setDefaultServiceFactory(getDefaultServiceFactory(metricRegistry.timer(name(RemoteServiceFactoryImpl.class, REMOTE_REQUEST))));
// Override date functions so that we can handle them
// via WikibaseDate
FunctionRegistry.remove(FunctionRegistry.YEAR);
FunctionRegistry.add(FunctionRegistry.YEAR, getWikibaseDateBOpFactory(DateOp.YEAR));
FunctionRegistry.remove(FunctionRegistry.MONTH);
FunctionRegistry.add(FunctionRegistry.MONTH, getWikibaseDateBOpFactory(DateOp.MONTH));
FunctionRegistry.remove(FunctionRegistry.DAY);
FunctionRegistry.add(FunctionRegistry.DAY, getWikibaseDateBOpFactory(DateOp.DAY));
FunctionRegistry.remove(FunctionRegistry.HOURS);
FunctionRegistry.add(FunctionRegistry.HOURS, getWikibaseDateBOpFactory(DateOp.HOURS));
FunctionRegistry.remove(FunctionRegistry.MINUTES);
FunctionRegistry.add(FunctionRegistry.MINUTES, getWikibaseDateBOpFactory(DateOp.MINUTES));
FunctionRegistry.remove(FunctionRegistry.SECONDS);
FunctionRegistry.add(FunctionRegistry.SECONDS, getWikibaseDateBOpFactory(DateOp.SECONDS));
FunctionRegistry.remove(FunctionRegistry.NOW);
FunctionRegistry.add(FunctionRegistry.NOW, (context, globals, scalarValues, args) -> {
if (args != null && args.length > 0)
throw new IllegalArgumentException("no args for NOW()");
return new WikibaseNowBOp(globals);
});
// Geospatial distance function
FunctionRegistry.add(new URIImpl(GeoSparql.FUNCTION_NAMESPACE + "distance"), getDistanceBOPFactory());
// Geospatial functions
FunctionRegistry.add(new URIImpl(GeoSparql.NORTH_EAST_FUNCTION), getCornersBOPFactory(WikibaseCornerBOp.Corners.NE));
FunctionRegistry.add(new URIImpl(GeoSparql.SOUTH_WEST_FUNCTION), getCornersBOPFactory(WikibaseCornerBOp.Corners.SW));
FunctionRegistry.add(new URIImpl(GeoSparql.GLOBE_FUNCTION), getCoordinatePartBOpFactory(CoordinatePartBOp.Parts.GLOBE));
FunctionRegistry.add(new URIImpl(GeoSparql.LON_FUNCTION), getCoordinatePartBOpFactory(CoordinatePartBOp.Parts.LON));
FunctionRegistry.add(new URIImpl(GeoSparql.LAT_FUNCTION), getCoordinatePartBOpFactory(CoordinatePartBOp.Parts.LAT));
// wikibase:decodeUri
FunctionRegistry.add(new URIImpl(Ontology.NAMESPACE + "decodeUri"), getDecodeUriBOpFactory());
IsSomeValueFunctionFactory.SomeValueMode mode = IsSomeValueFunctionFactory.SomeValueMode.lookup(System.getProperty("wikibaseSomeValueMode", "blank"));
UrisScheme uris = UrisSchemeFactory.getURISystem();
registerIsSomeValueFunction(FunctionRegistry::add, mode, uris.wellKnownBNodeIRIPrefix());
addPrefixes(uris);
log.info("Wikibase services initialized.");
}
Aggregations