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