Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8852

Re: Problem with buildin sort function while mapping

$
0
0

After struggling for couple more days I have finally implemented my own EJB Function ListSorter. For the case that someone faces the same issue and does not get any response as I didn't here is my solution.

 

Since my first question about the default sorter was not answered I wont mark this as the "right answer".

 

public class ListSorter implements ListSorterLocal {

 

          @SuppressWarnings("unchecked")

          public DataObject invokeSdo(DataObject inputDO,

                              InvocationContext invocationContext) {

                    List<DataObject> list = inputDO.getList(0);

                    List<DataObject> sortedList = new ArrayList<DataObject>();

                    sortedList.addAll(0, list);

                    Collections.sort(sortedList, new CustomComparator());

                    DataObject outputDO = invocationContext.createOutputDataObject();

                    outputDO.setList(0, sortedList);

                    return outputDO;

          }

 

          public class CustomComparator implements Comparator<DataObject> {

              @Override

              public int compare(DataObject o1, DataObject o2) {

                  return o1.getString("appointmentID").compareTo(o2.getString("appointmentID"));

              }

          }

}


Viewing all articles
Browse latest Browse all 8852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>