phax/peppol-practical

Add 'better' natural order for sorting VESID based on ID (and maybe on Display name as well)

Closed this issue · 6 comments

kukel commented

The version 3.10.1 is 'lower' then 3.9 when sorted in ExtValidationKeyRegistry as it currently is, it is even lower than 3.2.0 so they display order is sort of off. Both when sorted by ID and DisplayName.

Using Something like https://github.com/paour/natorder/blob/master/NaturalOrderComparator.java makes it work for ID's. Not sure what to do with the display name that also uses the locale in there

phax commented

Good point - I tried the natural sorting, but it still ends up like this:
grafik

I think this requires more than a String compare - it needs to compare the separate parts with separate comparators....

kukel commented

How did you try it? For the ID's it is simple, for the DisplayName I cannot get anything compiled. Messing with the IComparator and IHasDisplayName even... and still nothing

kukel commented

In IComparator I added this:

@Nonnull
static <T> Comparator <T> getComparatorNaturalOrder (@Nonnull final Function <? super T, String> aMapper)
{
  return Comparator.<T, String> comparing (aMapper,  new NaturalOrderComparator());
}

And in IHasDisplayName I changed this:

@Nonnull
static Comparator <IHasDisplayName> getComparatorNaturalOrder(@Nullable final Locale aSortLocale)
{
  return IComparator.getComparatorNaturalOrder(IHasDisplayName::getDisplayName);
}

And in ExtValidationKeyRegistry#getAllSortedByDisplayName I did this:

return aMap.getSortedByValue (IHasDisplayName.getComparatorNaturalOrder(aDisplayLocale));

I know it is not all in the correct way/location but it does work. Unfortunately (or not) it is not using the locale anymore, but since there are limited locales in this displayName, it might be fine.

Maybe it helps fitting things better in your classes

9For quick testing I copied all classes to the phase4-peppol-client)

kukel commented
1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:despatch-advice:3.12.0, OpenPEPPOL Despatch Advice (3.12.0) (aka BIS 3.0.7), [GroupID=eu.peppol.bis3; ArtifactID=despatch-advice; Version=3.12.0]
1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis2:t10:3.5.0, OpenPEPPOL Invoice (3.5.0) (deprecated!), [GroupID=eu.peppol.bis2; ArtifactID=t10; Version=3.5.0]
1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis2:t10:3.6.0, OpenPEPPOL Invoice (3.6.0) (deprecated!), [GroupID=eu.peppol.bis2; ArtifactID=t10; Version=3.6.0]
1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis2:t10:3.7.0, OpenPEPPOL Invoice (3.7.0) (aka BIS 2) (deprecated!), [GroupID=eu.peppol.bis2; ArtifactID=t10; Version=3.7.0]
1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.8.0, OpenPEPPOL Invoice (3.8.0) (aka BIS Billing 3.0.3) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.8.0]
1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.8.1, OpenPEPPOL Invoice (3.8.1) (aka BIS Billing 3.0.4) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.8.1]
1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.9.0, OpenPEPPOL Invoice (3.9.0) (aka BIS Billing 3.0.5) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.9.0]
1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.9.1, OpenPEPPOL Invoice (3.9.1) (aka BIS Billing 3.0.5 + Hotfix) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.9.1]
1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.10.0, OpenPEPPOL Invoice (3.10.0) (aka BIS Billing 3.0.6) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.10.0]
1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.10.1, OpenPEPPOL Invoice (3.10.1) (aka BIS Billing 3.0.7) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.10.1]
1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.11.0, OpenPEPPOL Invoice (3.11.0) (aka BIS Billing 3.0.8) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.11.0]
1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.11.1, OpenPEPPOL Invoice (3.11.1) (aka BIS Billing 3.0.9), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.11.1]
1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.12.0, OpenPEPPOL Invoice (3.12.0) (aka BIS Billing 3.0.10), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.12.0]
1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis2:t10:6:at, OpenPEPPOL Invoice (Austria), [GroupID=eu.peppol.bis2; ArtifactID=t10; Version=6; Classifier=at]
kukel commented

it DOES use the comparator that I linked too... That does exactly that, split/use numbers as numbers

phax commented

Finally made it work - thanks!