Skip to content

fix: [ODatav4] Support for property name properties #886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ public class Receipt extends VdmEntity<Receipt> implements VdmEntitySet
Receipt.class,
"ProductCounts",
ProductCount.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<ProductCount> 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<Receipt, ProductCount> PROPERTIES =
new com.sap.cloud.sdk.datamodel.odatav4.core.ComplexProperty.Collection<Receipt, ProductCount>(
Receipt.class,
"properties",
ProductCount.class);
/**
* Navigation property <b>Customer</b> for <b>Receipt</b> to single <b>Customer</b>.
*
Expand Down Expand Up @@ -203,6 +223,21 @@ public void setProductCounts( @Nullable final java.util.Collection<ProductCount>
this.productCounts = productCounts;
}

/**
* 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<ProductCount> properties )
{
rememberChangedField("properties", this.properties);
this.properties = properties;
}

@Override
protected String getEntityCollection()
{
Expand All @@ -227,6 +262,7 @@ protected Map<String, Object> toMapOfFields()
cloudSdkValues.put("CustomerId", getCustomerId());
cloudSdkValues.put("TotalAmount", getTotalAmount());
cloudSdkValues.put("ProductCounts", getProductCounts());
cloudSdkValues.put("properties", getProperties());
return cloudSdkValues;
}

Expand Down Expand Up @@ -261,8 +297,8 @@ protected void fromMap( final Map<String, Object> inputValues )
final Object value = cloudSdkValues.remove("ProductCounts");
if( value instanceof Iterable ) {
final LinkedList<ProductCount> productCounts = new LinkedList<ProductCount>();
for( Object properties : ((Iterable<?>) value) ) {
if( properties instanceof Map ) {
for( Object cloudSdkProperties : ((Iterable<?>) value) ) {
if( cloudSdkProperties instanceof Map ) {
final ProductCount item = new ProductCount();
@SuppressWarnings( "unchecked" )
final Map<String, Object> inputMap = ((Map<String, Object>) value);
Expand All @@ -276,6 +312,25 @@ protected void fromMap( final Map<String, Object> inputValues )
setProductCounts(null);
}
}
if( cloudSdkValues.containsKey("properties") ) {
final Object value = cloudSdkValues.remove("properties");
if( value instanceof Iterable ) {
final LinkedList<ProductCount> properties = new LinkedList<ProductCount>();
for( Object cloudSdkProperties : ((Iterable<?>) value) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here was the collision before the fix

if( cloudSdkProperties instanceof Map ) {
final ProductCount item = new ProductCount();
@SuppressWarnings( "unchecked" )
final Map<String, Object> inputMap = ((Map<String, Object>) value);
item.fromMap(inputMap);
properties.add(item);
}
}
setProperties(properties);
}
if( (value == null) && (getProperties() != null) ) {
setProperties(null);
}
}
}
// navigation properties
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<Property Name="CustomerId" Type="Edm.Int32" Nullable="false"/>
<Property Name="TotalAmount" Type="Edm.Decimal" Nullable="false"/>
<Property Name="ProductCounts" Type="Collection(GroceryStore.ProductCount)" Nullable="false"/>
<Property Name="properties" Type="Collection(GroceryStore.ProductCount)"/>
<NavigationProperty Name="Customer" Type="GroceryStore.Customer" Partner="Receipts"/>
</EntityType>
<EntityType Name="Address">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ else if( isPrimitive ) {
final JBlock ifValueIsList = ifFoundBody._if(value._instanceof(typeIterable))._then();
final JVar listInst = ifValueIsList.decl(JMod.FINAL, listType, javaFieldName, JExpr._new(listType));
final JExpression iter = JExpr.cast(typeIterable.narrow(codeModel.wildcard()), value);
final JForEach forEach = ifValueIsList.forEach(typeObject, "properties", iter);
final JForEach forEach = ifValueIsList.forEach(typeObject, "cloudSdkProperties", iter);
final JBlock isMap = forEach.body()._if(forEach.var()._instanceof(codeModel.ref(Map.class)))._then();
final JVar item = isMap.decl(JMod.FINAL, javaType, "item", JExpr._new(javaType));
isMap.directStatement("@SuppressWarnings(\"unchecked\")");
Expand Down
2 changes: 1 addition & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

### 🐛 Fixed Issues

-
- [ODatav4] Fixed an issue when generating a client with property name `properties`.
Loading