dominikriemer commented on code in PR #2905:
URL: https://github.com/apache/streampipes/pull/2905#discussion_r1618669392


##########
streampipes-connect-management/src/main/java/org/apache/streampipes/connect/management/management/UnitMasterManagement.java:
##########
@@ -68,4 +68,22 @@ public String getFittingUnits(UnitDescription 
unitDescription) throws AdapterExc
     return gson.toJson(unitDescriptionList);
   }
 
+  public String getAllUnits(){
+    List<UnitDescription> unitDescriptionList = new LinkedList<>();
+
+    List<Unit> units = UnitProvider.INSTANCE.getAvailableUnits();
+
+    for (Unit unit : units) {
+      try {
+        UnitDescription unitDescriptionTmp =
+            new UnitDescription(unit.getResource().toString(), 
unit.getLabel());
+        unitDescriptionList.add(unitDescriptionTmp);
+      } catch (NullPointerException e) {
+        logger.error("Unit has no resource and/or Label");
+      }
+    }
+
+    return gson.toJson(unitDescriptionList);

Review Comment:
   Do you know if there is a reason why we return a serialized string instead 
of a `List<UnitDescription>`?
   Then the REST API could serialize the result value automatically.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to