Juan Hernandez has submitted this change and it was merged.
Change subject: codegen: Avoid calculation of singulars and plurals
......................................................................
codegen: Avoid calculation of singulars and plurals
Currently the code generator assumes that there is a semantic
relationship between the names of XML schema complex type that represent
collections and entities: the name of the entity is the plural of the
name of the collection. To handle this it uses rules to calculate the
plurals from singulars, and the other way around. But for some
collections and entities simple calculation of plural and singular
(adding or removing a trailing "s") doesn't work. For example:
SchedulingPolicies -> SchedulingPolicy
Another example is the following, which has been introduced in the
server side:
KatelloErrata -> KatelloErratum
The code generator also assumes that the names of the XML schema complex
types match the URL segments. This doesn't always work. For example,
with the recent addition of external providers to the server side there
are URL segments like this one:
/externalhostproviders/{externalhostprovider:id}/hosts
The XML complex type corresponding to this "hosts" collection is
"ExternalHost", and not "Host" as the existing rules expect.
We have been handling these situations adding exceptions in the code of
the generator, and implementing more robust rules for calculations of
plurals and singulars, but this doesn't scale well, and it is prone to
unexcpected failures. To avoid these issues in a more systematic way
this patch modifies the generator so that it will extract the required
information from the XML schema and the RSDL instead of making
calculations.
The core of this change is the introduction of a tree data structure
that stores the links extracted from the RSDL, so that it is easy to
find from one node its children and parents. This data structure is used
to decide if a location corresponds to a collection, entity or action,
and combined with querying the XML schema to extract the type names.
Change-Id: I55bbcf7a0a6b5cefb0b39956e9312bfc4c5830de
Signed-off-by: Juan Hernandez <juan.hernandez(a)redhat.com>
---
M generator/src/main/java/org/ovirt/engine/sdk/codegen/Main.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/common/IDocCodegen.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/documentation/DocsGen.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/holders/AbstractCollectionHolder.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/holders/AbstractResourceHolder.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/holders/CollectionHolder.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/holders/IHolder.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/holders/ResourceHolder.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/rsdl/ApiCodegen.java
A generator/src/main/java/org/ovirt/engine/sdk/codegen/rsdl/BrokerRules.java
A generator/src/main/java/org/ovirt/engine/sdk/codegen/rsdl/Location.java
A generator/src/main/java/org/ovirt/engine/sdk/codegen/rsdl/LocationRules.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/rsdl/RsdlCodegen.java
A generator/src/main/java/org/ovirt/engine/sdk/codegen/rsdl/SchemaRules.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/AbstractOverloadableTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/AbstractTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/ApiTemplate
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/ApiTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/CollectionActionMethodTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/CollectionAddMethodTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/CollectionGetterTemplate
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/CollectionGetterTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/CollectionListMethodTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/CollectionTemplate
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/CollectionTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/CopyrightTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/DeleteMethodTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/DeleteMethodWithBodyTemplate.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/ExtraMethodParameterTemplate
D generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/ExtraMethodParameterTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/HeaderBuilderParameterTemplate.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/ITemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/ListMethodTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/MethodParameterTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/ResourceActionMethodTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/ResourceTemplate
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/ResourceTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/RootResourceDynamicTemplate
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/RootResourceDynamicTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/RootResourceStaticTemplate
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/RootResourceStaticTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/SubCollectionAddMethodTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/SubCollectionGetterTemplate
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/SubCollectionGetterTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/SubCollectionListMethodTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/SubCollectionTemplate
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/SubCollectionTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/SubResourceTemplate
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/SubResourceTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/UpdateMethodTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/UrlBuilderParameterTemplate.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/templates/VariableTemplate.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/utils/ArrayUtils.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/utils/ClassUtils.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/utils/LinkUtils.java
D generator/src/main/java/org/ovirt/engine/sdk/codegen/utils/StringTemplateWrapper.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/utils/StringUtils.java
A generator/src/main/java/org/ovirt/engine/sdk/codegen/utils/Tree.java
M generator/src/main/java/org/ovirt/engine/sdk/codegen/xsd/XsdCodegen.java
A generator/src/main/java/org/ovirt/engine/sdk/codegen/xsd/XsdData.java
60 files changed, 1,870 insertions(+), 3,038 deletions(-)
Approvals:
Martin Peřina: Looks good to me, but someone else must approve
Juan Hernandez: Verified; Looks good to me, approved
--
To view, visit https://gerrit.ovirt.org/38194
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I55bbcf7a0a6b5cefb0b39956e9312bfc4c5830de
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-sdk-java
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernandez(a)redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernandez(a)redhat.com>
Gerrit-Reviewer: Martin Peřina <mperina(a)redhat.com>
Gerrit-Reviewer: Moti Asayag <masayag(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org

Juan Hernandez has submitted this change and it was merged.
Change subject: sdk: Manually fix type of disk snapshots
......................................................................
sdk: Manually fix type of disk snapshots
Currently the RSDL generator of the engine doesn't report correctly the
type of disk snapshots collection, it reports "BaseResource" instead of
"DiskSnapshot". The current version of the generator doesn't have a
problem with this, because it doesn't use this information (it
calculates it from the collection type, using plural to singular rules).
But the new version of the generator will stick to the reported
information, and will generate wrong code. To avoid this issue this
patch fixes the type manually. The issue will be fixed in the engine by
the following change:
http://gerrit.ovirt.org/37755
Signed-off-by: Juan Hernandez <juan.hernandez(a)redhat.com>
Change-Id: I54a5a99f325f3fd31b834b88d25353bb40242f43
---
M generator/src/main/resources/rsdl.xml
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Juan Hernandez: Verified; Looks good to me, approved
--
To view, visit https://gerrit.ovirt.org/38193
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I54a5a99f325f3fd31b834b88d25353bb40242f43
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-sdk-java
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernandez(a)redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernandez(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org