/*
 * Copyright (c) 2008-2019 Haulmont.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.haulmont.cuba.core.app;

import com.haulmont.chile.core.model.MetaPropertyPath;

/**
 * Spring bean that generates sort expression for datatype and LOB properties.
 * It's possible to override bean and use custom sort logic, e.g. use functions.
 */
public interface JpqlSortExpressionProvider {

    String NAME = "cuba_JpqlSortExpressionProvider";

    /**
     * Returns JPQL order expression for specified property,
     * e.g. <code>{E}.property</code>, where <code>{E}</code> is a selected entity alias.
     * It's possible to:
     * <ul>
     *     <li>Apply JPQL functions for property, e.g <code>upper({E}.property)</code></li>
     *     <li>Use <code>asc/desc</code> or <code>nulls last/nulls first</code>,
     *     e.g. <code>{E}.property asc nulls first</code></li>
     * </ul>
     */
    String getDatatypeSortExpression(MetaPropertyPath metaPropertyPath, boolean sortDirectionAsc);

    /**
     * Returns JPQL order expression for specified lob property.
     */
    String getLobSortExpression(MetaPropertyPath metaPropertyPath, boolean sortDirectionAsc);
}
@@ -695,16 +695,49 @@
 %0A%0A/**%0A *
+ Interface to be implemented by a
  Spring 
@@ -756,16 +756,21 @@
 nerates 
+JPQL 
 sort exp
@@ -802,49 +802,39 @@
 LOB 
-properties.%0A * It's possible to o
+attributes.%0A * %3Cp%3E%0A * O
 verride 
 bean
@@ -833,19 +833,26 @@
 ide 
+the 
 bean 
-and us
+to provid
 e cu
@@ -873,19 +873,27 @@
 c, e.g. 
-use
+to use JPQL
  functio
@@ -1021,37 +1021,42 @@
  * Returns JPQL 
+%22
 order
+ by%22
  expression for 
@@ -1047,32 +1047,36 @@
  expression for 
+the 
 specified proper
@@ -1069,24 +1069,25 @@
 ecified 
-property
+attribute
 ,%0A     *
@@ -1151,16 +1151,23 @@
 s a 
-selected
+placeholder for
  ent
@@ -1268,16 +1268,20 @@
 ty, e.g 
+%3Cbr%3E
 %3Ccode%3Eup
@@ -1403,24 +1403,28 @@
  *     e.g. 
+%3Cbr%3E
 %3Ccode%3E%7BE%7D.pr
@@ -1607,21 +1607,26 @@
 ns JPQL 
+%22
 order
+ by%22
  express
@@ -1633,16 +1633,20 @@
 ion for 
+the 
 specifie
@@ -1651,21 +1651,95 @@
 ied 
-lob property.
+LOB attribute.%0A     *%0A     * @see #getDatatypeSortExpression(MetaPropertyPath, boolean)
 %0A   

Fix Javadocs #1838