[
https://issues.apache.org/jira/browse/OLINGO-118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13871854#comment-13871854
]
M Carissimi commented on OLINGO-118:
------------------------------------
Hell Michael,
thanks for your comment.
I use the SimpleProperty class in my custom EdmProvider when I create
EntityTypes, for example:
{code}
if (myAttrType.equals(AttributeTypeCatalogue.INTEGER_TYPE))
{
// set integer type
myEntryProperties.add(new
SimpleProperty().setName(myAttrName).setType(EdmSimpleTypeKind.Int32).setFacets(new
Facets().setNullable(!(myAttrSpec.getRequired() ||
myAttrSpec.getPrimaryKeyField()))));
}
{code}
As a consequence, my $metadata document shows the correct types for my
attributes:
{code}
<EntityType Name="ES_APPLICATION">
<Key>
<PropertyRef Name="NAME"/>
</Key>
<Property Name="GUID" Type="Edm.String" Nullable="false"/>
<Property Name="NAME" Type="Edm.String" Nullable="false"/>
<Property Name="FROM_DATE" Type="Edm.DateTime" Nullable="false"/>
<Property Name="TO_DATE" Type="Edm.DateTime" Nullable="true"/>
<Property Name="DESCRIPTION" Type="Edm.String" Nullable="true"/>
<Property Name="IS_ACTIVE" Type="Edm.Boolean" Nullable="false"/>
<Property Name="ORGANISATION" Type="Edm.String" Nullable="false"/>
<Property Name="ORDER_NUMBER" Type="Edm.Int32" Nullable="true"/>
</EntityType>
{code}
In my ODataSingleProcessor class, method readEntitySet() loads the data from
the database and then creates entries using the EntityProvider.writeFeed()
method by passing the appropriate EdmEntitySet and a List of Maps where data
has been set with String keys and plain Object types (i.e. Date, Integer,
Double, Boolean, etc).
{code}
EntityProvider.writeFeed(contentType, myEntitySet, myEntries,
EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
{code}
This results odata entries that have no types associated with the single
properties, as you can see in file "olingo output.xml". Am I missing something?
As for my question about caching the metadata document (or the Schema
generated in the getSchema() method), I want to be able to avoid running db
queries to recreate the schema every time an entry or feed is requested.
Caching the entire XML document would be fine too, as long as I can re-create
the schema/xml document when required.
Thanks again for your help
Miki
> Typing of odata entry properties
> --------------------------------
>
> Key: OLINGO-118
> URL: https://issues.apache.org/jira/browse/OLINGO-118
> Project: Olingo
> Issue Type: Question
> Affects Versions: V2 1.1.0
> Reporter: M Carissimi
> Attachments: odata4j output.xml, olingo output.xml
>
>
> Hello,
> I am migrating an odata service from odata4j to olingo. During creation of
> single odata entries or odata feeds, odata4j allows you to specify the type
> of each property element. How can this be achieved in olingo? See attached
> xml feeds for an entry generated in odata4j and one generated in olingo.
> We generate the metadata at runtime using custom database queries and in
> odata4j we can cache the metadata document to avoid having to rebuild it
> every time a request is received. How can metadata be cached between requests
> in olingo? Following the simple read example on the olingo website, we use an
> ODataServiceFactory to create a service using method
> createODataSingleProcessorService(), but these methods are invoked during
> each request.
> Cheers
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)