Skip to content

How to get Annotation tag with term and String #153

@Boltzmann

Description

@Boltzmann

Why does @EdmAnnotation(term = "Core.Description", constantExpression = @EdmAnnotation.ConstantExpression(type = CsdlConstantExpression.ConstantExpressionType.String, value = "Description Test")) result in the xml output of http://localhost:8080/Cases/V1.0/$metadata only in <Annotation> <String>Description Test</String> </Annotation> - without the string "Term=Core.Description" in the Annotation tag?

I would expect it to behave similar to the qualifier parameter @EdmAnnotation(term = "Core.Description", qualifier = "Qualifier", constantExpression = @EdmAnnotation.ConstantExpression(type = CsdlConstantExpression.ConstantExpressionType.String, value = "Description Test")) that gives <Annotation Qualifier="Qualifier">. At the moment "term" does not matter at all.

Background:
A GET http://localhost:8080/Cases/V1.0/$metadata of a project with Entity

package some.package.example;

import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAnnotation;
import lombok.*;
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression;

import javax.persistence.*;

@Entity
@Table(name = "Example_case")
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ExampleEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @EdmAnnotation(term = "Core.Description", qualifier = "Qualifier",
            constantExpression = @EdmAnnotation.ConstantExpression(type = CsdlConstantExpression.ConstantExpressionType.String,
                    value = "Description Test"))
    @Column(name = "OrderNumber")
    private String order_nr;
}

gives

<?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 xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Cases">
            <EntityType Name="ExampleEntity">
                <Key>
                    <PropertyRef Name="Id"/>
                </Key>
                <Property Name="Order_nr" Type="Edm.String" MaxLength="255">
                    <Annotation Qualifier="Qualifier">
                        <String>Description Test</String>
                    </Annotation>
                </Property>
                <Property Name="Id" Type="Edm.Int64"/>
            </EntityType>
            <EntityContainer Name="Cases">
                <EntitySet Name="ExampleEntities" EntityType="Cases.ExampleEntity"/>
            </EntityContainer>
        </Schema>
    </edmx:DataServices>
</edmx:Edmx>

I seek for a solution with an output off

<Annotation Term="Core.Description" String="Description Test"/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions