if (cloudSdkValues.containsKey("properties")) {
final Object value = cloudSdkValues.remove("properties");
if (value instanceof Iterable) {
final LinkedList<entityMetadataField> properties = new LinkedList<entityMetadataField>();
for (Object properties: ((Iterable<?> ) value)) { // <----- Redefines final properties variable
if (properties instanceof Map) {
final entityMetadataField item = new entityMetadataField();
@SuppressWarnings("unchecked")
final Map<java.lang.String, Object> inputMap = ((Map<java.lang.String, Object> ) value);
item.fromMap(inputMap);
properties.add(item);
}
}
setProperties(properties);
}
if ((value == null)&&(getProperties()!= null)) {
setProperties(null);
}
}
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema Namespace="Microsoft.NAV" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EntityType Name="entityMetadata">
<Key>
<PropertyRef Name="entityName" />
</Key>
<Property Name="entityName" Type="Edm.String" Nullable="false" />
<Property Name="entitySetName" Type="Edm.String" />
<Property Name="entityCaptions" Type="Collection(Microsoft.NAV.entityMetadataLabel)" />
<Property Name="entitySetCaptions" Type="Collection(Microsoft.NAV.entityMetadataLabel)" />
<Property Name="properties" Type="Collection(Microsoft.NAV.entityMetadataField)" />
<Property Name="actions" Type="Collection(Microsoft.NAV.entityMetadataAction)" />
<Property Name="enumMembers" Type="Collection(Microsoft.NAV.entityMetadataEnumMember)" />
</EntityType>
tasks.register<DefaultTask>("generateODataClient") {
val inputDirectory = file("${layout.projectDirectory}/src/main/resources/")
val outputDirectory = file("${layout.projectDirectory}/src/main/java/")
DataModelGenerator()
.withInputDirectory(inputDirectory)
.withOutputDirectory(outputDirectory)
.pojosOnly(false)
.withNameSource(NameSource.NAME)
.withPackageName("com.example.dynamics365.client")
.withDefaultBasePath("/my/path")
.serviceMethodsPerEntitySet()
.execute()
}
/*
* Generated by OData VDM code generator of SAP Cloud SDK in version 5.21.0
*/
package com.company.dynamics365.client.namespaces.dynamics365;
import java.util.LinkedList;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.collect.Maps;
import com.google.gson.annotations.JsonAdapter;
import com.sap.cloud.sdk.datamodel.odata.client.request.ODataEntityKey;
import com.sap.cloud.sdk.datamodel.odatav4.core.SimpleProperty;
import com.sap.cloud.sdk.datamodel.odatav4.core.VdmEntity;
import com.sap.cloud.sdk.datamodel.odatav4.core.VdmEntitySet;
import com.sap.cloud.sdk.result.ElementName;
import com.company.dynamics365.client.services.Dynamics365Service;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* <p>Original entity name from the Odata EDM: <b>entityMetadata</b></p>
*
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(doNotUseGetters = true, callSuper = true)
@EqualsAndHashCode(doNotUseGetters = true, callSuper = true)
@JsonAdapter(com.sap.cloud.sdk.datamodel.odatav4.adapter.GsonVdmAdapterFactory.class)
@JsonSerialize(using = com.sap.cloud.sdk.datamodel.odatav4.adapter.JacksonVdmObjectSerializer.class)
@JsonDeserialize(using = com.sap.cloud.sdk.datamodel.odatav4.adapter.JacksonVdmObjectDeserializer.class)
public class EntityMetadata
extends VdmEntity<EntityMetadata>
implements VdmEntitySet
{
@Getter
private final java.lang.String odataType = "Microsoft.NAV.entityMetadata";
/**
* Selector for all available fields of EntityMetadata.
*
*/
public final static SimpleProperty<EntityMetadata> ALL_FIELDS = all();
/**
* (Key Field) Constraints: Not nullable<p>Original property name from the Odata EDM: <b>entityName</b></p>
*
* @return
* The entityName contained in this {@link VdmEntity}.
*/
@Nullable
@ElementName("entityName")
private java.lang.String entityName;
public final static SimpleProperty.String<EntityMetadata> ENTITY_NAME = new SimpleProperty.String<EntityMetadata>(EntityMetadata.class, "entityName");
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>entitySetName</b></p>
*
* @return
* The entitySetName contained in this {@link VdmEntity}.
*/
@Nullable
@ElementName("entitySetName")
private java.lang.String entitySetName;
public final static SimpleProperty.String<EntityMetadata> ENTITY_SET_NAME = new SimpleProperty.String<EntityMetadata>(EntityMetadata.class, "entitySetName");
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>entityCaptions</b></p>
*
* @return
* The entityCaptions contained in this {@link VdmEntity}.
*/
@Nullable
@ElementName("entityCaptions")
private java.util.Collection<entityMetadataLabel> entityCaptions;
/**
* Use with available request builders to apply the <b>entityCaptions</b> complex property to query operations.
*
*/
public final static com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataLabel> ENTITY_CAPTIONS = new com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataLabel>(EntityMetadata.class, "entityCaptions", entityMetadataLabel.class);
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>entitySetCaptions</b></p>
*
* @return
* The entitySetCaptions contained in this {@link VdmEntity}.
*/
@Nullable
@ElementName("entitySetCaptions")
private java.util.Collection<entityMetadataLabel> entitySetCaptions;
/**
* Use with available request builders to apply the <b>entitySetCaptions</b> complex property to query operations.
*
*/
public final static com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataLabel> ENTITY_SET_CAPTIONS = new com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataLabel>(EntityMetadata.class, "entitySetCaptions", entityMetadataLabel.class);
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>properties</b></p>
*
* @return
* The properties contained in this {@link VdmEntity}.
*/
@Nullable
@ElementName("properties")
private java.util.Collection<entityMetadataField> properties;
/**
* Use with available request builders to apply the <b>properties</b> complex property to query operations.
*
*/
public final static com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataField> PROPERTIES = new com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataField>(EntityMetadata.class, "properties", entityMetadataField.class);
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>actions</b></p>
*
* @return
* The actions contained in this {@link VdmEntity}.
*/
@Nullable
@ElementName("actions")
private java.util.Collection<entityMetadataAction> actions;
/**
* Use with available request builders to apply the <b>actions</b> complex property to query operations.
*
*/
public final static com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataAction> ACTIONS = new com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataAction>(EntityMetadata.class, "actions", entityMetadataAction.class);
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>enumMembers</b></p>
*
* @return
* The enumMembers contained in this {@link VdmEntity}.
*/
@Nullable
@ElementName("enumMembers")
private java.util.Collection<entityMetadataEnumMember> enumMembers;
/**
* Use with available request builders to apply the <b>enumMembers</b> complex property to query operations.
*
*/
public final static com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataEnumMember> ENUM_MEMBERS = new com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<EntityMetadata, entityMetadataEnumMember>(EntityMetadata.class, "enumMembers", entityMetadataEnumMember.class);
@Nonnull
@Override
public Class<EntityMetadata> getType() {
return EntityMetadata.class;
}
/**
* (Key Field) Constraints: Not nullable<p>Original property name from the Odata EDM: <b>entityName</b></p>
*
* @param entityName
* The entityName to set.
*/
public void setEntityName(
@Nullable
final java.lang.String entityName) {
rememberChangedField("entityName", this.entityName);
this.entityName = entityName;
}
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>entitySetName</b></p>
*
* @param entitySetName
* The entitySetName to set.
*/
public void setEntitySetName(
@Nullable
final java.lang.String entitySetName) {
rememberChangedField("entitySetName", this.entitySetName);
this.entitySetName = entitySetName;
}
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>entityCaptions</b></p>
*
* @param entityCaptions
* The entityCaptions to set.
*/
public void setEntityCaptions(
@Nullable
final java.util.Collection<entityMetadataLabel> entityCaptions) {
rememberChangedField("entityCaptions", this.entityCaptions);
this.entityCaptions = entityCaptions;
}
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>entitySetCaptions</b></p>
*
* @param entitySetCaptions
* The entitySetCaptions to set.
*/
public void setEntitySetCaptions(
@Nullable
final java.util.Collection<entityMetadataLabel> entitySetCaptions) {
rememberChangedField("entitySetCaptions", this.entitySetCaptions);
this.entitySetCaptions = entitySetCaptions;
}
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>properties</b></p>
*
* @param properties
* The properties to set.
*/
public void setProperties(
@Nullable
final java.util.Collection<entityMetadataField> properties) {
rememberChangedField("properties", this.properties);
this.properties = properties;
}
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>actions</b></p>
*
* @param actions
* The actions to set.
*/
public void setActions(
@Nullable
final java.util.Collection<entityMetadataAction> actions) {
rememberChangedField("actions", this.actions);
this.actions = actions;
}
/**
* Constraints: Nullable<p>Original property name from the Odata EDM: <b>enumMembers</b></p>
*
* @param enumMembers
* The enumMembers to set.
*/
public void setEnumMembers(
@Nullable
final java.util.Collection<entityMetadataEnumMember> enumMembers) {
rememberChangedField("enumMembers", this.enumMembers);
this.enumMembers = enumMembers;
}
@Override
protected java.lang.String getEntityCollection() {
return "entityDefinitions";
}
@Nonnull
@Override
protected ODataEntityKey getKey() {
final ODataEntityKey entityKey = super.getKey();
entityKey.addKeyProperty("entityName", getEntityName());
return entityKey;
}
@Nonnull
@Override
protected Map<java.lang.String, Object> toMapOfFields() {
final Map<java.lang.String, Object> cloudSdkValues = super.toMapOfFields();
cloudSdkValues.put("entityName", getEntityName());
cloudSdkValues.put("entitySetName", getEntitySetName());
cloudSdkValues.put("entityCaptions", getEntityCaptions());
cloudSdkValues.put("entitySetCaptions", getEntitySetCaptions());
cloudSdkValues.put("properties", getProperties());
cloudSdkValues.put("actions", getActions());
cloudSdkValues.put("enumMembers", getEnumMembers());
return cloudSdkValues;
}
@Override
protected void fromMap(final Map<java.lang.String, Object> inputValues) {
final Map<java.lang.String, Object> cloudSdkValues = Maps.newLinkedHashMap(inputValues);
// simple properties
{
if (cloudSdkValues.containsKey("entityName")) {
final Object value = cloudSdkValues.remove("entityName");
if ((value == null)||(!value.equals(getEntityName()))) {
setEntityName(((java.lang.String) value));
}
}
if (cloudSdkValues.containsKey("entitySetName")) {
final Object value = cloudSdkValues.remove("entitySetName");
if ((value == null)||(!value.equals(getEntitySetName()))) {
setEntitySetName(((java.lang.String) value));
}
}
}
// structured properties
{
if (cloudSdkValues.containsKey("entityCaptions")) {
final Object value = cloudSdkValues.remove("entityCaptions");
if (value instanceof Iterable) {
final LinkedList<entityMetadataLabel> entityCaptions = new LinkedList<entityMetadataLabel>();
for (Object properties: ((Iterable<?> ) value)) {
if (properties instanceof Map) {
final entityMetadataLabel item = new entityMetadataLabel();
@SuppressWarnings("unchecked")
final Map<java.lang.String, Object> inputMap = ((Map<java.lang.String, Object> ) value);
item.fromMap(inputMap);
entityCaptions.add(item);
}
}
setEntityCaptions(entityCaptions);
}
if ((value == null)&&(getEntityCaptions()!= null)) {
setEntityCaptions(null);
}
}
if (cloudSdkValues.containsKey("entitySetCaptions")) {
final Object value = cloudSdkValues.remove("entitySetCaptions");
if (value instanceof Iterable) {
final LinkedList<entityMetadataLabel> entitySetCaptions = new LinkedList<entityMetadataLabel>();
for (Object properties: ((Iterable<?> ) value)) {
if (properties instanceof Map) {
final entityMetadataLabel item = new entityMetadataLabel();
@SuppressWarnings("unchecked")
final Map<java.lang.String, Object> inputMap = ((Map<java.lang.String, Object> ) value);
item.fromMap(inputMap);
entitySetCaptions.add(item);
}
}
setEntitySetCaptions(entitySetCaptions);
}
if ((value == null)&&(getEntitySetCaptions()!= null)) {
setEntitySetCaptions(null);
}
}
if (cloudSdkValues.containsKey("properties")) {
final Object value = cloudSdkValues.remove("properties");
if (value instanceof Iterable) {
final LinkedList<entityMetadataField> properties = new LinkedList<entityMetadataField>();
for (Object properties: ((Iterable<?> ) value)) {
if (properties instanceof Map) {
final entityMetadataField item = new entityMetadataField();
@SuppressWarnings("unchecked")
final Map<java.lang.String, Object> inputMap = ((Map<java.lang.String, Object> ) value);
item.fromMap(inputMap);
properties.add(item);
}
}
setProperties(properties);
}
if ((value == null)&&(getProperties()!= null)) {
setProperties(null);
}
}
if (cloudSdkValues.containsKey("actions")) {
final Object value = cloudSdkValues.remove("actions");
if (value instanceof Iterable) {
final LinkedList<entityMetadataAction> actions = new LinkedList<entityMetadataAction>();
for (Object properties: ((Iterable<?> ) value)) {
if (properties instanceof Map) {
final entityMetadataAction item = new entityMetadataAction();
@SuppressWarnings("unchecked")
final Map<java.lang.String, Object> inputMap = ((Map<java.lang.String, Object> ) value);
item.fromMap(inputMap);
actions.add(item);
}
}
setActions(actions);
}
if ((value == null)&&(getActions()!= null)) {
setActions(null);
}
}
if (cloudSdkValues.containsKey("enumMembers")) {
final Object value = cloudSdkValues.remove("enumMembers");
if (value instanceof Iterable) {
final LinkedList<entityMetadataEnumMember> enumMembers = new LinkedList<entityMetadataEnumMember>();
for (Object properties: ((Iterable<?> ) value)) {
if (properties instanceof Map) {
final entityMetadataEnumMember item = new entityMetadataEnumMember();
@SuppressWarnings("unchecked")
final Map<java.lang.String, Object> inputMap = ((Map<java.lang.String, Object> ) value);
item.fromMap(inputMap);
enumMembers.add(item);
}
}
setEnumMembers(enumMembers);
}
if ((value == null)&&(getEnumMembers()!= null)) {
setEnumMembers(null);
}
}
}
// navigation properties
{
}
super.fromMap(cloudSdkValues);
}
@Override
protected java.lang.String getDefaultServicePath() {
return Dynamics365Service.DEFAULT_SERVICE_PATH;
}
}
Describe the Bug
I'm generating odata-v4 for Microsoft Dynamics 365 using
com.sap.cloud.sdk.datamodel:odata-v4-generator:5.21.0. The EntityMetadata.java file that it generates does not compile because it redefines a variable:Steps to Reproduce
Expected Behavior
EntityMetadata.java should compile
Screenshots
Used Versions
mvn --version: openjdk 21.0.4 2024-07-16 LTScom.sap.cloud.sdk:sdk-bom:5.21.0Dependency tree via
mvn dependency:treeCode Examples
// Your code hereStack Trace
No response
Log File
Log file
...Affected Development Phase
Getting Started
Impact
Blocked
Timeline
No response