Juan Hernandez has uploaded a new change for review.

Change subject: codegen: Fix naming conflict
......................................................................

codegen: Fix naming conflict

Currently the code generator generates conflicting classes when the
calculated name of a entity is the same of a collection. For example,
for the following collection:

  /hosts/{host:id}/storage

Note that the name of the collection doesn't end in "s". As a result the
code generator produces a HostStorage class for the collection and a
HostStorage (same name) class for the entity. Due to the order they are
generated the collection class overwrites the entity class.

To avoid this issue this patch changes the code generator so that it
will automaticall add the "s" to the collection class name when there is
a conflict like this.

Change-Id: Ia408b8e16234595b4454c2d252f5fec16414ca49
Bug-Url: https://bugzilla.redhat.com/1120502
Signed-off-by: Juan Hernandez <[email protected]>
---
M src/codegen/rsdl/rsdlcodegen.py
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-sdk refs/changes/10/30210/1

diff --git a/src/codegen/rsdl/rsdlcodegen.py b/src/codegen/rsdl/rsdlcodegen.py
index a613e0e..2748fb5 100644
--- a/src/codegen/rsdl/rsdlcodegen.py
+++ b/src/codegen/rsdl/rsdlcodegen.py
@@ -471,6 +471,13 @@
         sub_coll_type = root_res + sub_coll
         sub_res_type = StringUtils.toSingular(sub_coll_type, 
RsdlCodegen.COLLECTION_TO_ENTITY_EXCEPTIONS)
 
+        # Avoid situations where the name of the resource type is the same than
+        # the name of the sub collection. Currently this only happens with the
+        # collection /hosts/{host:id}/storage, which is using a singular name
+        # instead of a plural name.
+        if sub_coll_type == sub_res_type:
+            sub_coll_type += "s"
+
         if (not collectionsHolder.has_key(sub_coll_type)):
             sub_coll_body = SubCollection.collection(sub_coll_type, root_res)
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia408b8e16234595b4454c2d252f5fec16414ca49
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-sdk
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