What is this all about.
If you landed here through social media link or from nowhere, You might wonder what is an Enterprise Store and even what is WSO2. So let me explain about the topic first.And also since this is my first post regarding WSO2 product I will briefly explain what is WSO2 and what they do.And finally, will go to the main part of the topic
Defining sort attributes.If you already know the story about WSO2 and ES(Enterprise Store), You may directly jump into the main #topic.
About WSO2 Enterprise Store
In simple words, WSO2 is a 100% OpenSource company who provides a full stack enterprise platform to connecting businesses.As a part of that, The Enterprise Store provide facility to manage all types of enterprise assets and make it easy for users to efficiently locate and manage assets through WSO2 ES.In fact, it is the application that connects all aspects of a business.Mainly it has two component which is Publisher app and Store applications.In Publisher, Authorized users(Users are created through carbon management console) can Create , Update or Delete (Obviously, they can Read as well) enterprise assets.And also they can manage the versions of an asset by creating new versions of existing assets.WSO2 Enterprise Store comprises with lifestyle feature , where users can attach lifecycle (Kind of state diagram) to an asset and update the lifecycle of the assets during its existence in the store.With all the above features,Users can make the assets visible to public through public store front.
The store on the other side, where users can view, comment , rate, and interact with the assets.The store is allowed to anonymous users and assets which are available to anonymous users will be visible in the store.These are just a fraction of the features available with WSO2 Enterprise Store. You may follow the ES Documentation for more details.
Before going to configure the sort attributes let’s see How It Works
How It Works (Sorting)
Whether you sort , list or search assets in the ES, Ultimately it is a search(AdvanceSearch, StrictSearch or Search) query which does the work.More specifically a solar query. So let’s go into the code level to see what is happening inside When you select a sort attribute from the sort drop-down menu.
When you click on an item in the sort drop-down menu, it sends an AJAX GET request to <hostname>:<port>/store/assets/<asset_type>/list endpoint with the selected sorting attribute name and conditions.Following is the sample request URL with URL encoded parameters.
This request is handled by the <ES-HOME>/repository/deployment/server/jaggery apps/store/extensions/assets/default/pages/list.jag . There it unloads the URL encoded parameters and goes through series of filters(ie: Previous sample query goes through !tag !q else !popular else !isGroupingEnabled) to route the request to proper handler.From the list.jag script, It hands over the data coming through the request parameter to am.search() method to do the further processing.Inside the AssetManager.prototype.search it further processes the query and paging parameters and handover those into am.search which is a search method resides in ArtifactManager. In the ArtifactManager.prototype.search method, it finally passes the query parameters to the Java API findGenericArtifacts after making the parameters usable in the solr query.
Ultimate search action is done using solr engine.Following is an extract from solr result JSON which relates to the sorting query sample mentioned above.
The findGenericArtifacts method returns an array of assets which returns from the solr engine, and
Configuring sort attributes
So finally come to the main topic.Configuring the sort attributes.We have written all the above (How It Works) mind-boggling codes to make sure that working with ES is easy and intuitive to its users and developers, So configuration is simple.
Locate the <ES-HOME>/repository/deployment/server/jaggeryapps/store/extensions/assets/default/asset.js file in your distribution.Append a new associative array named sorting to asset.configure object as shown below.
Add the desired sort attribute name(As defined in the asset RXT file) and map a meaningful label to that attribute name. The given label name will appear in the sort drop-down menu.
 : http://wso2.com/library/articles/2014/01/why-deploy-an-enterprise-app-store-and-how-wso2-enterprise-app-store-can-work-for-you/