You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by "Naser, Moneer" <mo...@sap.com> on 2017/01/23 10:40:54 UTC

Olingo support for csv content type

Hi,
I'm required to expose OData service results in csv as well.
Is there any out-of-box support for this content type, or any interface for implementing such requirement?

Thanks,
Moneer


Re: Olingo support for csv content type

Posted by Ramesh Reddy <ra...@redhat.com>.
You have to extend ODataImpl for now (few others too), see an example in "odata-server-core-ext" project. AFAIK, CSV is never going to be odata specification complaint feature, so I am not sure how much you would be able to pursue Olingo folks to offer this as more pluggable feature than this already is. 

----- Original Message -----

> I understand the concept. Yet, in ODataImpl. createSerializer(), code doesn’t
> let plugging in a different serializer!

> public ODataSerializer createSerializer(ContentType contentType) throws
> SerializerException {

> Object serializer = null;

> if(contentType.isCompatible(ContentType.APPLICATION_JSON)) {

> String metadata = contentType.getParameter("odata.metadata");

> if(metadata == null || "minimal".equalsIgnoreCase(metadata) ||
> "none".equalsIgnoreCase(metadata) || "full".equalsIgnoreCase(metadata)) {

> serializer = new ODataJsonSerializer(contentType);

> }

> } else if(contentType.isCompatible(ContentType.APPLICATION_XML) ||
> contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {

> serializer = new ODataXmlSerializer();

> }

> if(serializer == null) {

> throw new SerializerException ("Unsupported format: " +
> contentType.toContentTypeString(), MessageKeys.UNSUPPORTED_FORMAT, new
> String[]{contentType.toContentTypeString()});

> } else {

> return (ODataSerializer)serializer;

> }

> }

> From: Ramesh Reddy [mailto:rareddy@redhat.com]
> Sent: Monday, January 23, 2017 4:17 PM
> To: user@olingo.apache.org
> Subject: Re: Olingo support for csv content type

> In the server-core projects, follow how the JSON/XML serilaizers are
> registered based on the contentType, you would need to start with
> similar/same technique. Since this output format is completely defined by/&
> for you, you would need to make lot more choices are to how you represent
> the various other data points in your payload, such that your clients will
> understand the payload. If you are doing CSV for purely for size of payload,
> then I recommend using JSON format (as this can be very compact) and save
> what could be some what decent development time.

> Ramesh..

> http://teiid.org
> ----- Original Message -----

> > Any examples, Ramesh?
> 

> > From: Ramesh Reddy [ mailto:rareddy@redhat.com ]
> 
> > Sent: Monday, January 23, 2017 3:46 PM
> 
> > To: user@olingo.apache.org
> 
> > Subject: Re: Olingo support for csv content type
> 

> > Moneer,
> 

> > In Olingo V4 implementation, there are extension points (serializers,
> > de-serializers) you could use to write the CSV out. However, this would be
> > a
> > custom implementation for your needs, no out of box support.
> 

> > Ramesh..
> 

> > http://teiid.org
> 

> > > Hi,
> > 
> 

> > > I’m required to expose OData service results in csv as well.
> > 
> 

> > > Is there any out-of-box support for this content type, or any interface
> > > for
> > > implementing such requirement?
> > 
> 

> > > Thanks,
> > 
> 

> > > Moneer
> > 
> 

RE: Olingo support for csv content type

Posted by "Naser, Moneer" <mo...@sap.com>.
I understand the concept. Yet, in ODataImpl. createSerializer(), code doesn’t let plugging in a different serializer!

   public ODataSerializer createSerializer(ContentType contentType) throws SerializerException {
        Object serializer = null;
        if(contentType.isCompatible(ContentType.APPLICATION_JSON)) {
            String metadata = contentType.getParameter("odata.metadata");
            if(metadata == null || "minimal".equalsIgnoreCase(metadata) || "none".equalsIgnoreCase(metadata) || "full".equalsIgnoreCase(metadata)) {
                serializer = new ODataJsonSerializer(contentType);
            }
        } else if(contentType.isCompatible(ContentType.APPLICATION_XML) || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
            serializer = new ODataXmlSerializer();
        }

        if(serializer == null) {
            throw new SerializerException("Unsupported format: " + contentType.toContentTypeString(), MessageKeys.UNSUPPORTED_FORMAT, new String[]{contentType.toContentTypeString()});
        } else {
            return (ODataSerializer)serializer;
        }
    }

From: Ramesh Reddy [mailto:rareddy@redhat.com]
Sent: Monday, January 23, 2017 4:17 PM
To: user@olingo.apache.org
Subject: Re: Olingo support for csv content type

In the server-core projects, follow how the JSON/XML serilaizers are registered based on the contentType, you would need to start with similar/same technique. Since this output format is completely defined by/& for you, you would need to make lot more choices are to how you represent the various other data points in your payload, such that your clients will understand the payload. If you are doing CSV for purely for size of payload, then I recommend using JSON format (as this can be very compact) and save what could be some what decent development time.

Ramesh..
http://teiid.org
________________________________
Any examples, Ramesh?

From: Ramesh Reddy [mailto:rareddy@redhat.com]
Sent: Monday, January 23, 2017 3:46 PM
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: Olingo support for csv content type

Moneer,

In Olingo V4 implementation, there are extension points (serializers, de-serializers) you could use to write the CSV out. However, this would be a custom implementation for your needs, no out of box support.

Ramesh..
http://teiid.org
________________________________
Hi,
I’m required to expose OData service results in csv as well.
Is there any out-of-box support for this content type, or any interface for implementing such requirement?

Thanks,
Moneer




Re: Olingo support for csv content type

Posted by Ramesh Reddy <ra...@redhat.com>.
In the server-core projects, follow how the JSON/XML serilaizers are registered based on the contentType, you would need to start with similar/same technique. Since this output format is completely defined by/& for you, you would need to make lot more choices are to how you represent the various other data points in your payload, such that your clients will understand the payload. If you are doing CSV for purely for size of payload, then I recommend using JSON format (as this can be very compact) and save what could be some what decent development time. 

Ramesh.. 
http://teiid.org 
----- Original Message -----

> Any examples, Ramesh?

> From: Ramesh Reddy [mailto:rareddy@redhat.com]
> Sent: Monday, January 23, 2017 3:46 PM
> To: user@olingo.apache.org
> Subject: Re: Olingo support for csv content type

> Moneer,

> In Olingo V4 implementation, there are extension points (serializers,
> de-serializers) you could use to write the CSV out. However, this would be a
> custom implementation for your needs, no out of box support.

> Ramesh..

> http://teiid.org
> ----- Original Message -----

> > Hi,
> 

> > I’m required to expose OData service results in csv as well.
> 

> > Is there any out-of-box support for this content type, or any interface for
> > implementing such requirement?
> 

> > Thanks,
> 

> > Moneer
> 

RE: Olingo support for csv content type

Posted by "Naser, Moneer" <mo...@sap.com>.
Any examples, Ramesh?

From: Ramesh Reddy [mailto:rareddy@redhat.com]
Sent: Monday, January 23, 2017 3:46 PM
To: user@olingo.apache.org
Subject: Re: Olingo support for csv content type

Moneer,

In Olingo V4 implementation, there are extension points (serializers, de-serializers) you could use to write the CSV out. However, this would be a custom implementation for your needs, no out of box support.

Ramesh..
http://teiid.org
________________________________
Hi,
I’m required to expose OData service results in csv as well.
Is there any out-of-box support for this content type, or any interface for implementing such requirement?

Thanks,
Moneer



Re: Olingo support for csv content type

Posted by Ramesh Reddy <ra...@redhat.com>.
Moneer, 

In Olingo V4 implementation, there are extension points (serializers, de-serializers) you could use to write the CSV out. However, this would be a custom implementation for your needs, no out of box support. 

Ramesh.. 
http://teiid.org 
----- Original Message -----

> Hi,

> I’m required to expose OData service results in csv as well.

> Is there any out-of-box support for this content type, or any interface for
> implementing such requirement?

> Thanks,

> Moneer