use of org.ambraproject.wombat.config.site.RequestMappingContext in project wombat by PLOS.
the class AppRootPage method buildMappingTable.
private ImmutableList<MappingTableRow> buildMappingTable() {
Table<RequestMappingContext, Site, String> table = HashBasedTable.create();
Set<RequestMappingContext> sitelessMappings = new HashSet<>();
ImmutableList<Site> allSites = siteSet.getSites().asList();
for (RequestMappingContextDictionary.MappingEntry entry : requestMappingContextDictionary.getAll()) {
RequestMappingContext mapping = entry.getMapping();
Optional<Site> site = entry.getSite();
String handlerName = entry.getHandlerName();
if (site.isPresent()) {
table.put(mapping, site.get(), handlerName);
} else {
sitelessMappings.add(mapping);
for (Site s : allSites) {
table.put(mapping, s, handlerName);
}
}
}
Set<RequestMappingContext> mappings = table.rowKeySet();
List<MappingTableRow> rows = new ArrayList<>(mappings.size());
for (final RequestMappingContext mapping : mappings) {
final List<String> row = new ArrayList<>(allSites.size());
for (Site site : allSites) {
String cell = table.get(mapping, site);
row.add(Strings.nullToEmpty(cell));
}
final String mappingRepresentation = represent(mapping);
final boolean isGlobal = sitelessMappings.contains(mapping);
rows.add(new MappingTableRow() {
@Override
public String getPattern() {
return mappingRepresentation;
}
@Override
public List<String> getRow() {
return row;
}
@Override
public boolean isGlobal() {
return isGlobal;
}
});
}
return ROW_ORDERING.immutableSortedCopy(rows);
}
Aggregations