use of com.torodb.mongodb.repl.ReplicationFilters.IndexPattern in project torodb by torodb.
the class ReplicationFiltersFactory method convertFilterList.
@SuppressWarnings("checkstyle:LineLength")
private static ImmutableMap<Pattern, ImmutableMap<Pattern, ImmutableList<IndexPattern>>> convertFilterList(FilterList filterList) {
ImmutableMap.Builder<Pattern, ImmutableMap<Pattern, ImmutableList<IndexPattern>>> filterBuilder = ImmutableMap.builder();
if (filterList != null) {
for (Map.Entry<String, Map<String, List<IndexFilter>>> databaseEntry : filterList.entrySet()) {
ImmutableMap.Builder<Pattern, ImmutableList<IndexPattern>> collectionsBuilder = ImmutableMap.builder();
for (Map.Entry<String, List<IndexFilter>> collection : databaseEntry.getValue().entrySet()) {
ImmutableList.Builder<IndexPattern> indexesBuilder = ImmutableList.builder();
for (IndexFilter indexFilter : collection.getValue()) {
Pattern indexNamePattern = ANY;
if (indexFilter.getName() != null) {
indexNamePattern = SimpleRegExpDecoder.decode(indexFilter.getName());
}
IndexPattern.Builder indexPatternBuilder = new IndexPattern.Builder(indexNamePattern, indexFilter.getUnique());
for (Map.Entry<String, String> indexFieldFilter : indexFilter.getKeys().entrySet()) {
ImmutableList.Builder<Pattern> fieldReferencePatternBuilder = ImmutableList.builder();
for (String indexFieldKeyFilter : KEYS_SPLITTER.split(indexFieldFilter.getKey())) {
fieldReferencePatternBuilder.add(SimpleRegExpDecoder.decode(indexFieldKeyFilter));
}
indexPatternBuilder.addFieldPattern(fieldReferencePatternBuilder.build(), SimpleRegExpDecoder.decode(FilterList.getIndexType(indexFieldFilter.getValue()).getName()));
}
indexesBuilder.add(indexPatternBuilder.build());
}
collectionsBuilder.put(SimpleRegExpDecoder.decode(collection.getKey()), indexesBuilder.build());
}
filterBuilder.put(SimpleRegExpDecoder.decode(databaseEntry.getKey()), collectionsBuilder.build());
}
}
return filterBuilder.build();
}
Aggregations