Juan Hernandez has submitted this change and it was merged.
Change subject: restapi: Auto-Generate Enums in the API.
......................................................................
restapi: Auto-Generate Enums in the API.
This patch adds infrastructure for auto-generating API enums.
'Skeleton' enums, containing only the enum entries, are placed
in 'types' package in 'model' project (alongside the API's
other business entities). A skeleton enum looks like this:
package types;
import org.ovirt.api.metamodel.annotations.Type;
@Type
public enum DiskFormat {
COW, RAW;
}
Full Enum classes with value() and fromValue() methods are generated
from the skeleton enums and placed in:
...definition/target/generated-sources/model/org/ovirt/engine/api/model
directory.
The enums are *not* added to the schema file (api.xsd). The exception
to this rule are three existing enums: ValueType, StatisticType,
StatisticKind, which do exist in the schema for historic reasons.
In the schema file, enums are still represented as strings, for example:
<xs:complexType name="Disk">
<xs:element maxOccurs="1" minOccurs="0" name="format"
type="xs:string"/>
</xs:complexType>
But in the model files, the enums themselves are used (instead of
strings, which is the case today), for example:
@Type
public interface Disk extends Device {
DiskFormat format();
}
Future patches will delete all existing enums, place skeletons for them
in model project, and replace string references with enum references
where appropriate in model interfaces.
Change-Id: If4643497a5cc0fce8e78d820da8a90c612a3ca21
Signed-off-by: Ori Liel <oliel(a)redhat.com>
Signed-off-by: Juan Hernandez <juan.hernandez(a)redhat.com>
---
D
backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/DiskFormat.java
M
backend/manager/modules/restapi/metamodel/analyzer/src/main/java/org/ovirt/api/metamodel/analyzer/ModelAnalyzer.java
A
backend/manager/modules/restapi/metamodel/tool/src/main/java/org/ovirt/api/metamodel/tool/EnumGenerator.java
M
backend/manager/modules/restapi/metamodel/tool/src/main/java/org/ovirt/api/metamodel/tool/JavaClassBuffer.java
M
backend/manager/modules/restapi/metamodel/tool/src/main/java/org/ovirt/api/metamodel/tool/SchemaGenerator.java
M
backend/manager/modules/restapi/metamodel/tool/src/main/java/org/ovirt/api/metamodel/tool/SchemaNames.java
M
backend/manager/modules/restapi/metamodel/tool/src/main/java/org/ovirt/api/metamodel/tool/Tool.java
M backend/manager/modules/restapi/model/src/main/java/types/Disk.java
A backend/manager/modules/restapi/model/src/main/java/types/DiskFormat.java
9 files changed, 201 insertions(+), 48 deletions(-)
Approvals:
Juan Hernandez: Verified; Looks good to me, approved
Jenkins CI: Passed CI tests
--
To view, visit
https://gerrit.ovirt.org/49560
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If4643497a5cc0fce8e78d820da8a90c612a3ca21
Gerrit-PatchSet: 7
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Ori Liel <oliel(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Juan Hernandez <juan.hernandez(a)redhat.com>
Gerrit-Reviewer: Marcin Mirecki <mmirecki(a)redhat.com>
Gerrit-Reviewer: Ori Liel <oliel(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>