/** * Sets a property filter. If given, all data will be preprocessed to * contain only statements for the given (main) properties. * * @see DocumentDataFilter#setPropertyFilter(Set) * @param propertyFilter * set of properties that should be retained (can be empty) */ public void setPropertyFilter(Set<PropertyIdValue> propertyFilter) { this.filter.setPropertyFilter(propertyFilter); }
/** * @deprecated Use {@link DatamodelFilter} * * Sets the (possibly empty) set of {@link PropertyIdValue} objects that are * used to filter statements while copying data. Setting this to null * disables this filter (this is the default). If not equal to null, only * statements using the given properties will be copied. * <p> * The property filter is not applied to qualifiers and references in * statements. Only the main property of statements is filtered. * * @param propertyFilter * set of properties to use for filtering */ @Deprecated public void setOptionPropertyFilter(Set<PropertyIdValue> propertyFilter) { filter.setPropertyFilter(propertyFilter); }
/** * @deprecated Use {@link DatamodelFilter} * * Sets the (possibly empty) set of {@link PropertyIdValue} objects that are * used to filter statements while copying data. Setting this to null * disables this filter (this is the default). If not equal to null, only * statements using the given properties will be copied. * <p> * The property filter is not applied to qualifiers and references in * statements. Only the main property of statements is filtered. * * @param propertyFilter * set of properties to use for filtering */ @Deprecated public void setOptionPropertyFilter(Set<PropertyIdValue> propertyFilter) { filter.setPropertyFilter(propertyFilter); }
propertyFilter.add(Datamodel.makeWikidataPropertyIdValue("P106")); // occupation propertyFilter.add(Datamodel.makeWikidataPropertyIdValue("P569")); // birthdate documentDataFilter.setPropertyFilter(propertyFilter);
wbdf.getFilter().setPropertyFilter( Collections.<PropertyIdValue> emptySet()); EntityDocument q8 = wbdf.getEntityDocument("Q8");
/** * Constructor. Initializes various helper objects we use for the JSON * serialization, and opens the file that we want to write to. * * @throws IOException * if there is a problem opening the output file */ public JsonSerializationProcessor() throws IOException { // The filter is used to copy selected parts of the data. We use this // to remove some parts from the documents we serialize. DocumentDataFilter filter = new DocumentDataFilter(); // Only copy English labels, descriptions, and aliases: filter.setLanguageFilter(Collections.singleton("en")); // Only copy statements of some properties: Set<PropertyIdValue> propertyFilter = new HashSet<>(); propertyFilter.add(Datamodel.makeWikidataPropertyIdValue("P18")); // image propertyFilter.add(Datamodel.makeWikidataPropertyIdValue("P106")); // occupation propertyFilter.add(Datamodel.makeWikidataPropertyIdValue("P569")); // birthdate filter.setPropertyFilter(propertyFilter); // Do not copy any sitelinks: filter.setSiteLinkFilter(Collections.<String>emptySet()); this.datamodelFilter = new DatamodelFilter(new DataObjectFactoryImpl(), new DocumentDataFilter()); // The (compressed) file we write to. OutputStream outputStream = new GzipCompressorOutputStream( new BufferedOutputStream( ExampleHelpers .openExampleFileOuputStream(OUTPUT_FILE_NAME))); this.jsonSerializer = new JsonSerializer(outputStream); this.jsonSerializer.open(); }
wbdf.getFilter().setPropertyFilter( Collections.<PropertyIdValue> emptySet()); EntityDocument q8 = wbdf.getEntityDocument("Q8");