Juan Hernandez has uploaded a new change for review.

Change subject: restapi: Calculate singulars correctly
......................................................................

restapi: Calculate singulars correctly

The RSDL generator doesn't calculate singulars correctly. For example,
for the plural form "schedulingpolicies" it calculats the singular as
"schedulingpolicie". This is incorrect and doesn't match with the
singular form specified in the RSDL metadata. As a result the parameter
metadata for some entities and collections, in particular for scheduling
policy related entities and collections, isn't generated. As a result of
that the Python SDK doesn't contain the metadata, and thus the CLI
auto-completion doesn't work. This patch fixes the RSDL generator so
that singulars will be calculated correctly.

Change-Id: Ifbd00642de18637e2620433395b3065a062a4ee9
Bug-Url: https://bugzilla.redhat.com/1189095
Signed-off-by: Juan Hernandez <[email protected]>
---
M 
backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java
1 file changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/17/37517/1

diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java
 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java
index df96597..2cb08f3 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java
@@ -593,8 +593,14 @@
     //but for "{api}/hosts/{host:id}/storage" return "storage" (don't truncate 
last character)
     private String getSingleForm(String prefix) {
         int startIndex = prefix.lastIndexOf('/')+1;
-        int endPos = prefix.endsWith("s") ?  prefix.length() -1 : 
prefix.length();
-        return prefix.substring(startIndex, endPos);
+        prefix = prefix.substring(startIndex);
+        if (prefix.endsWith("ies")) {
+            return prefix.replaceAll("ies$", "y");
+        }
+        if (prefix.endsWith("s")) {
+            return prefix.replaceAll("s$", "");
+        }
+        return prefix;
     }
 
     /**


-- 
To view, visit http://gerrit.ovirt.org/37517
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifbd00642de18637e2620433395b3065a062a4ee9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to