Uploaded image for project: 'Olingo'
  1. Olingo
  2. OLINGO-1513

How can I add Annotations from core vocabularies in my Metadata.xml file using olingo Java?

    XMLWordPrintableJSON

Details

    • Question
    • Status: Open
    • Major
    • Resolution: Unresolved
    • (Java) V4 4.8.0
    • None
    • odata4-server
    • None

    Description

      I am trying to add an annotation to mark an Entity Set as NonFilterable to my Metadata.

      I cannot find any example on the internet to do this. Is there a sample which shows how to write Olingo 4 code to generate a metadata file with FilterRestrictions annotation or any other core vocabulary annotations?

      I have tried this method after creating my entity set in my Entity Data Model Provider class.

      //In my EntityDataModelProvider.java I call this method after i create an EntitySet
      
      private void setNonFilterableTypeId(CsdlEntitySet csdlEntitySet{
              List<CsdlAnnotation> annotationList = csdlEntitySet.getAnnotations();
              CsdlPropertyPath path = new CsdlPropertyPath();
              path.setValue("token");
              CsdlCollection collection = new CsdlCollection();
              collection.setItems(Arrays.asList(path));
              CsdlPropertyValue propertyValue1 = new CsdlPropertyValue();
              propertyValue1.setProperty("NonFilterableProperties");
              propertyValue1.setValue(collection);
              CsdlRecord record = new CsdlRecord();
              record.setPropertyValues(Arrays.asList(propertyValue1));
              CsdlAnnotation annotation = new CsdlAnnotation();
              annotation.setTerm("Org.OData.Capabilities.V1.FilterRestrictions");
              annotation.setExpression(record);
              annotationList.add(annotation);
          }
      
      
      

      The output Metadata XML that is created is missing the value of the term attribute. It shows
      <Annotation> instead of <Annotation Term="Org.OData.Capabilities.V1.FilterRestrictions">

      <EntitySet Name="Persons" EntityType="mynamespace.Person">
         <Annotation>
          <Record>
           <PropertyValue Property="NonFilterableProperties">
             <Collection>
               <PropertyPath>token</PropertyPath>
             </Collection>
           </PropertyValue>
          </Record>
         </Annotation>
      </EntitySet>
      

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            stalwalk Saurabh Talwalkar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: