Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

How to Fill Sorted Data with model Driven Development

Avatar

Former Community Member

Hello

I am using model driven development. I am using getAll in the Fill method. But the results are not returned sorted by some field that I am interested in. How do I tell the Fill to sort it by some field. Is there some annotation that I can provided in the model...

thanks

RK

1 Accepted Solution

Avatar

Correct answer by
Level 3

You should be able to achieve what you want with an explicit criteria filter on your entity.

In the Modeler Design view, select your entity and add a filter. You'll see that there is a an "Order By" field in the Properties view.

Enter the value you want there and then save and redeploy your model. When you don't enter anything in the "Criteria" field, you create a getAll fill.

Here's an example of an entity created with this type of filter; it is sorted by price in ascending order:

<entity name="Product" persistent="true">

  <annotation name="ServerProperties" ServerType="LCDS"/>

  <annotation name="DMS" Table="PRODUCT"/>

  <annotation name="RDS" introspectedColumns="PRODUCTID,DESCRIPTION,PRICE,PRODUCTNAME"/>

  <annotation name="VisualModeler" width="115" height="110" x="364" y="203"/>

  <id name="productid" type="integer">

  <annotation name="DMS" ColumnName="PRODUCTID"/>

  </id>

  <property name="description" type="string" length="255">

  <annotation name="DMS" ColumnName="DESCRIPTION"/>

  </property>

  <property name="price" type="float">

  <annotation name="DMS" ColumnName="PRICE"/>

  </property>

  <property name="productname" type="string" length="255">

  <annotation name="DMS" ColumnName="PRODUCTNAME"/>

  </property>

  <filter name="MyFill" order="price ASC"/>

  </entity>

View solution in original post

5 Replies

Avatar

Correct answer by
Level 3

You should be able to achieve what you want with an explicit criteria filter on your entity.

In the Modeler Design view, select your entity and add a filter. You'll see that there is a an "Order By" field in the Properties view.

Enter the value you want there and then save and redeploy your model. When you don't enter anything in the "Criteria" field, you create a getAll fill.

Here's an example of an entity created with this type of filter; it is sorted by price in ascending order:

<entity name="Product" persistent="true">

  <annotation name="ServerProperties" ServerType="LCDS"/>

  <annotation name="DMS" Table="PRODUCT"/>

  <annotation name="RDS" introspectedColumns="PRODUCTID,DESCRIPTION,PRICE,PRODUCTNAME"/>

  <annotation name="VisualModeler" width="115" height="110" x="364" y="203"/>

  <id name="productid" type="integer">

  <annotation name="DMS" ColumnName="PRODUCTID"/>

  </id>

  <property name="description" type="string" length="255">

  <annotation name="DMS" ColumnName="DESCRIPTION"/>

  </property>

  <property name="price" type="float">

  <annotation name="DMS" ColumnName="PRICE"/>

  </property>

  <property name="productname" type="string" length="255">

  <annotation name="DMS" ColumnName="PRODUCTNAME"/>

  </property>

  <filter name="MyFill" order="price ASC"/>

  </entity>

Avatar

Former Community Member

It did not help yet.. Here is the FML.. After making the change in model file, If I click on Generate Code..do I expect to see any changes in the auto-gen java code.. I don’t see any change though (like in the assembler file)..

</filter

Avatar

Former Community Member

My mistake… I was still calling ordersService.getAll() in the client instead of ordersService.FillSortedByTWSTimestamp()..it should be okay now..

The changes are made in the auto-gen AS file instead of java file..

Avatar

Former Community Member

while it is working, I noticed that my additions to the database using DataServiceTransaction.createItem() have stopped displaying on the client GUI but are making it to the database. If I switch back to ordersService.getAll() from the new method ordersService.getSortedByTWSTimestamp(), then the client GUI is happily updated.. any ideas...

Avatar

Former Community Member

looks like auto-refresh was set to false for this filter...