Improved sorting.

This commit is contained in:
Christian P. MOMON 2020-10-01 16:04:34 +02:00
parent e0184400c5
commit cf0fa8600c
13 changed files with 107 additions and 19 deletions

View file

@ -16,6 +16,7 @@ public class OrganizationComparator implements Comparator<Organization>
{ {
NAME, NAME,
SERVICE_COUNT, SERVICE_COUNT,
REVERSE_SERVICE_COUNT,
USER_COUNT USER_COUNT
} }
@ -77,11 +78,23 @@ public class OrganizationComparator implements Comparator<Organization>
{ {
default: default:
case NAME: case NAME:
result = CompareUtils.compare(getName(alpha), getName(bravo)); result = CompareUtils.compareIgnoreCase(getName(alpha), getName(bravo));
break; break;
case SERVICE_COUNT: case SERVICE_COUNT:
result = CompareUtils.compare(getServiceCount(alpha), getServiceCount(bravo)); result = CompareUtils.compare(getServiceCount(alpha), getServiceCount(bravo));
if (result == 0)
{
result = CompareUtils.compareIgnoreCase(getName(alpha), getName(bravo));
}
break;
case REVERSE_SERVICE_COUNT:
result = -CompareUtils.compare(getServiceCount(alpha), getServiceCount(bravo));
if (result == 0)
{
result = CompareUtils.compareIgnoreCase(getName(alpha), getName(bravo));
}
break; break;
case USER_COUNT: case USER_COUNT:

View file

@ -87,6 +87,21 @@ public class Organizations extends ArrayList<Organization>
return result; return result;
} }
/**
* Sort by reverse service count.
*
* @return the organizations
*/
public Organizations sortByReverseServiceCount()
{
Organizations result;
result = sort(OrganizationComparator.Sorting.REVERSE_SERVICE_COUNT);
//
return result;
}
/** /**
* Sort by service count. * Sort by service count.
* *
@ -101,5 +116,4 @@ public class Organizations extends ArrayList<Organization>
// //
return result; return result;
} }
} }

View file

@ -15,7 +15,8 @@ public class ServiceComparator implements Comparator<Service>
public enum Sorting public enum Sorting
{ {
NAME, NAME,
USER_COUNT USER_COUNT,
REVERSE_USER_COUNT
} }
private Sorting sorting; private Sorting sorting;
@ -76,11 +77,23 @@ public class ServiceComparator implements Comparator<Service>
{ {
default: default:
case NAME: case NAME:
result = CompareUtils.compare(getName(alpha), getName(bravo)); result = CompareUtils.compareIgnoreCase(getName(alpha), getName(bravo));
break; break;
case USER_COUNT: case USER_COUNT:
result = CompareUtils.compare(getUserCount(alpha), getUserCount(bravo)); result = CompareUtils.compare(getUserCount(alpha), getUserCount(bravo));
if (result == 0)
{
result = CompareUtils.compareIgnoreCase(getName(alpha), getName(bravo));
}
break;
case REVERSE_USER_COUNT:
result = -CompareUtils.compare(getUserCount(alpha), getUserCount(bravo));
if (result == 0)
{
result = CompareUtils.compareIgnoreCase(getName(alpha), getName(bravo));
}
break; break;
} }
} }

View file

@ -62,7 +62,7 @@ public class FederationPage
data.setContent("serviceCount", federation.getServiceCount()); data.setContent("serviceCount", federation.getServiceCount());
int index = 0; int index = 0;
for (Organization organization : federation.getOrganizations().sortByServiceCount().reverse()) for (Organization organization : federation.getOrganizations().sortByReverseServiceCount())
{ {
data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml"); data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml");
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getTechnicalName() + "-logo.png"); data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getTechnicalName() + "-logo.png");

View file

@ -66,7 +66,7 @@ public class PropertiesFilesPage
// //
int index = 0; int index = 0;
for (PropertiesFileStat stat : stats) for (PropertiesFileStat stat : stats.sortByName())
{ {
data.setAttribute("fileListLine", index, "fileListLineNameLink", "href", stat.getLocalName()); data.setAttribute("fileListLine", index, "fileListLineNameLink", "href", stat.getLocalName());
data.setEscapedContent("fileListLine", index, "fileListLineNameLink", stat.getLocalName()); data.setEscapedContent("fileListLine", index, "fileListLineNameLink", stat.getLocalName());

View file

@ -75,7 +75,7 @@ public class PropertyStatsPage
data.setContent("fileCount", stats.getFileCount()); data.setContent("fileCount", stats.getFileCount());
int index = 0; int index = 0;
for (PropertyStat stat : stats.getList().sortByFilledCount().reverse()) for (PropertyStat stat : stats.getList().sortByReverseFilledCount())
{ {
data.setEscapedContent("propertyLine", index, "propertyLinePath", stat.getPath()); data.setEscapedContent("propertyLine", index, "propertyLinePath", stat.getPath());
data.setContent("propertyLine", index, "propertyLineBlankCount", stat.getBlankCount()); data.setContent("propertyLine", index, "propertyLineBlankCount", stat.getBlankCount());
@ -92,7 +92,7 @@ public class PropertyStatsPage
data.setContent("fileCountF", federationStats.getFileCount()); data.setContent("fileCountF", federationStats.getFileCount());
index = 0; index = 0;
for (PropertyStat stat : federationStats.getList().sortByFilledCount().reverse()) for (PropertyStat stat : federationStats.getList().sortByReverseFilledCount())
{ {
data.setEscapedContent("propertyLineF", index, "propertyLinePathF", stat.getPath()); data.setEscapedContent("propertyLineF", index, "propertyLinePathF", stat.getPath());
data.setContent("propertyLineF", index, "propertyLineBlankCountF", stat.getBlankCount()); data.setContent("propertyLineF", index, "propertyLineBlankCountF", stat.getBlankCount());
@ -109,7 +109,7 @@ public class PropertyStatsPage
data.setContent("fileCountO", organizationsStats.getFileCount()); data.setContent("fileCountO", organizationsStats.getFileCount());
index = 0; index = 0;
for (PropertyStat stat : organizationsStats.getList().sortByFilledCount().reverse()) for (PropertyStat stat : organizationsStats.getList().sortByReverseFilledCount())
{ {
data.setEscapedContent("propertyLineO", index, "propertyLinePathO", stat.getPath()); data.setEscapedContent("propertyLineO", index, "propertyLinePathO", stat.getPath());
data.setContent("propertyLineO", index, "propertyLineBlankCountO", stat.getBlankCount()); data.setContent("propertyLineO", index, "propertyLineBlankCountO", stat.getBlankCount());
@ -126,7 +126,7 @@ public class PropertyStatsPage
data.setContent("fileCountS", servicesStats.getFileCount()); data.setContent("fileCountS", servicesStats.getFileCount());
index = 0; index = 0;
for (PropertyStat stat : servicesStats.getList().sortByFilledCount().reverse()) for (PropertyStat stat : servicesStats.getList().sortByReverseFilledCount())
{ {
data.setEscapedContent("propertyLineS", index, "propertyLinePathS", stat.getPath()); data.setEscapedContent("propertyLineS", index, "propertyLinePathS", stat.getPath());
data.setContent("propertyLineS", index, "propertyLineBlankCountS", stat.getBlankCount()); data.setContent("propertyLineS", index, "propertyLineBlankCountS", stat.getBlankCount());

View file

@ -57,7 +57,7 @@ public class ServicesPage
data.setContent("serviceCount", services.size()); data.setContent("serviceCount", services.size());
int index = 0; int index = 0;
for (Service service : services) for (Service service : services.sortByName())
{ {
data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png"); data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png");
data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName()); data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName());

View file

@ -57,7 +57,7 @@ public class SoftwaresPage
data.setContent("softwareCount", stats.size()); data.setContent("softwareCount", stats.size());
int index = 0; int index = 0;
for (SoftwareStat stat : stats) for (SoftwareStat stat : stats.sortByName())
{ {
data.setEscapedContent("softwareListLine", index, "softwareListLineNameLink", stat.getName()); data.setEscapedContent("softwareListLine", index, "softwareListLineNameLink", stat.getName());
data.setAttribute("softwareListLine", index, "softwareListLineNameLink", "href", "software-" + stat.getTechnicalName() + ".xhtml"); data.setAttribute("softwareListLine", index, "softwareListLineNameLink", "href", "software-" + stat.getTechnicalName() + ".xhtml");

View file

@ -20,11 +20,11 @@
<table class="table_classic center_table sortable"> <table class="table_classic center_table sortable">
<thead> <thead>
<tr> <tr>
<th style="width: 150px;">Path</th> <th style="width: 150px;">Chemin</th>
<th style="width: 10px;">Filled Count</th> <th style="width: 10px;">Remplis</th>
<th style="width: 10px;">File&#160;%</th> <th style="width: 10px;">%</th>
<th style="width: 10px;">Blank Count</th> <th style="width: 10px;">Vides</th>
<th style="width: 10px;">File&#160;%</th> <th style="width: 10px;">%</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View file

@ -16,7 +16,8 @@ public class PropertyStatComparator implements Comparator<PropertyStat>
{ {
PATH, PATH,
BLANK_COUNT, BLANK_COUNT,
FILLED_COUNT FILLED_COUNT,
REVERSE_FILLED_COUNT
} }
private Sorting sorting; private Sorting sorting;
@ -88,6 +89,14 @@ public class PropertyStatComparator implements Comparator<PropertyStat>
case FILLED_COUNT: case FILLED_COUNT:
result = CompareUtils.compare(getFilledCount(alpha), getFilledCount(bravo)); result = CompareUtils.compare(getFilledCount(alpha), getFilledCount(bravo));
break; break;
case REVERSE_FILLED_COUNT:
result = -CompareUtils.compare(getFilledCount(alpha), getFilledCount(bravo));
if (result == 0)
{
result = CompareUtils.compare(getPath(alpha), getPath(bravo));
}
break;
} }
} }

View file

@ -87,6 +87,11 @@ public class PropertyStatList extends ArrayList<PropertyStat>
return result; return result;
} }
/**
* Sort by filled count.
*
* @return the property stat list
*/
public PropertyStatList sortByFilledCount() public PropertyStatList sortByFilledCount()
{ {
PropertyStatList result; PropertyStatList result;
@ -111,4 +116,19 @@ public class PropertyStatList extends ArrayList<PropertyStat>
// //
return result; return result;
} }
/**
* Sort by reverse filled count.
*
* @return the property stat list
*/
public PropertyStatList sortByReverseFilledCount()
{
PropertyStatList result;
result = sort(PropertyStatComparator.Sorting.REVERSE_FILLED_COUNT);
//
return result;
}
} }

View file

@ -117,7 +117,7 @@ public class SoftwareStatComparator implements Comparator<SoftwareStat>
} }
else else
{ {
result = source.getCategory().getName(); result = source.getName();
} }
// //

View file

@ -216,6 +216,25 @@ public class CompareUtils
return result; return result;
} }
/**
* Compare ignore case.
*
* @param alpha
* the alpha
* @param bravo
* the bravo
* @return the int
*/
public static int compareIgnoreCase(final String alpha, final String bravo)
{
int result;
result = StringUtils.compareIgnoreCase(alpha, bravo);
//
return result;
}
/** /**
* Compare reverse. * Compare reverse.
* *