jvermillard / leshan

OMA Lightweight M2M java implementation - LWM2M
40 stars 25 forks source link

Display objects on the details page ordered by objectId #31

Closed andrau closed 10 years ago

andrau commented 10 years ago

Currently it seems like objects are displayed in the order they are announced in the registration message. It would be a nice enhancement to always display them ordered by objectId. When using ascending order, the predefined OMA objects would be displayed first (that seems natural). When using descending order, custom objects would be displayed first (that might be more useful when using leshan to test actual devices). I fixed this in an ugly way inside the eventServlet, but core would probably a better place to do it.

@Override
public void registered(Client client) {
  Arrays.sort( client.getObjectLinks(), new Comparator<LinkObject>() {
    public int compare( LinkObject o1, LinkObject o2) {
      return o2.getObjectId().compareTo( o1.getObjectId());
    }
  });
  String jClient = EventServlet.this.gson.toJson(client);
  // ...<snip>...
jvermillard commented 10 years ago

+1

jvermillard commented 10 years ago

I sorted by string URL wich is not really a good idea :)