cancel
Showing results for 
Search instead for 
Did you mean: 

sorting the orders/creation date in a descending order

0 Kudos
452

I had to create a new attribute to be displayed in page as creation time for user orders.

The result in page is something like this: order number/ creation date:

For this i had to make a populator.

this is my populator:

public class MyDefaultTicketAssociationPopulator <SOURCE extends AbstractOrderModel, TARGET extends TicketAssociatedData>
extends DefaultTicketAssociationPopulator<SOURCE, TARGET> {

public void populate(final AbstractOrderModel source, final TicketAssociatedData target) {
super.populate(source, target);
target.setCreationtime(source.getCreationtime());} }

Now i need to sort the orders by creation time from the newest to the oldest.

Does anyone have any idea how can i achieve this?

I tried to modifty the actual populator but is not working:

    public void populate(final List<AbstractOrderModel> sourceList, final List<TicketAssociatedData> targetList) {
if(sourceList.size() != targetList.size()) {
throw new IllegalArgumentException("....");
}
sourceList.sort(((o1, o2) -> o2.getCreationtime().compareTo(o1.getCreationtime())));

for (int i = 0; i < sourceList.size(); i++) {
AbstractOrderModel source = sourceList.get(i);
TicketAssociatedData target = targetList.get(i);
super.populate(source, target);
target.setCreationtime(source.getCreationtime());
}
}
}

Accepted Solutions (0)

Answers (0)