use of com.serotonin.m2m2.web.dojo.DojoMemoryStoreListItem in project ma-core-public by infiniteautomation.
the class DataPointDwr method getUnitsList.
@DwrPermission(user = true)
public ProcessResult getUnitsList() {
ProcessResult result = new ProcessResult();
List<DojoMemoryStoreListItem> pairs = new ArrayList<>();
// Get SI Units
int id = 0;
for (Unit<?> unit : SI.getInstance().getUnits()) {
pairs.add(new DojoMemoryStoreListItem(unit.toString(), id++));
}
// Get US Units
for (Unit<?> unit : NonSI.getInstance().getUnits()) {
pairs.add(new DojoMemoryStoreListItem(unit.toString(), id++));
}
List<String> addedUnits = UnitUtil.getAddedUnitLabels();
for (String unit : addedUnits) {
pairs.add(new DojoMemoryStoreListItem(unit, id++));
}
Collections.sort(pairs, new Comparator<DojoMemoryStoreListItem>() {
@Override
public int compare(DojoMemoryStoreListItem arg0, DojoMemoryStoreListItem arg1) {
return arg0.getName().compareToIgnoreCase(arg1.getName());
}
});
result.addData("units", pairs);
return result;
}
Aggregations