Skip to content
Snippets Groups Projects
Commit 0877f02b authored by Fuentes Serna  Juan Mariano (ID SIS)'s avatar Fuentes Serna Juan Mariano (ID SIS)
Browse files

SSDM-6196 : New V3 API Sort option sortBy().fetchedFieldsScore(), js implementation + some tweaks

parent ff26954b
No related branches found
No related tags found
No related merge requests found
define([ "require", "stjs", "as/dto/common/fetchoptions/EntitySortOptions" ], function(require, stjs, EntitySortOptions) {
define([ "require", "stjs", "as/dto/common/fetchoptions/EntitySortOptions", "as/dto/common/fetchoptions/SortParameter" ], function(require, stjs, EntitySortOptions, SortParameter) {
var EntityWithPropertiesSortOptions = function() {
EntitySortOptions.call(this);
};
var fields = {
FETCHED_FIELDS_SCORE : "FETCHED_FIELDS_SCORE",
TYPE : "TYPE",
PROPERTY : "PROPERTY"
};
stjs.extend(EntityWithPropertiesSortOptions, EntitySortOptions, [ EntitySortOptions ], function(constructor, prototype) {
prototype['@type'] = 'as.dto.common.fetchoptions.EntityWithPropertiesSortOptions';
constructor.serialVersionUID = 1;
prototype.fetchedFieldsScore = function() {
var parameters = {
SortParameter.FULL_CODE_BOOST : "1000000",
SortParameter.PARTIAL_CODE_BOOST : "100000",
SortParameter.FULL_PROPERTY_BOOST : "10000",
SortParameter.FULL_TYPE_BOOST : "1000",
SortParameter.PARTIAL_PROPERTY_BOOST : "100"
};
return this.getOrCreateSortingWithParameters(fields.FETCHED_FIELDS_SCORE, parameters);
};
prototype.type = function() {
return this.getOrCreateSorting(fields.TYPE);
};
......
......@@ -6,14 +6,20 @@ define([ "require", "stjs", "as/dto/common/fetchoptions/SortOrder", "as/dto/comm
stjs.extend(SortOptions, null, [], function(constructor, prototype) {
prototype['@type'] = 'as.dto.common.fetchoptions.SortOptions';
constructor.serialVersionUID = 1;
prototype.getOrCreateSorting = function(field) {
return this.getOrCreateSortingWithParameters(field, null);
};
prototype.getOrCreateSortingWithParameters = function(field, parameters) {
var order = this.getSorting(field);
if (order == null) {
order = new SortOrder();
this.sortings.push(new Sorting(field, order));
this.sortings.push(new Sorting(field, order, parameters));
}
return order;
};
prototype.getSorting = function(field) {
var order = null;
this.sortings.forEach(function(sorting) {
......
/**
* @author juanf
*/
define([ "stjs", "as/dto/common/Enum" ], function(stjs, Enum) {
var SortParameter = function() {
Enum.call(this, [ "FULL_CODE_BOOST", "PARTIAL_CODE_BOOST", "FULL_PROPERTY_BOOST", "FULL_TYPE_BOOST", "PARTIAL_PROPERTY_BOOST" ]);
};
stjs.extend(SortParameter, Enum, [ Enum ], function(constructor, prototype) {
}, {});
return new SortParameter();
})
define([ "require", "stjs" ], function(require, stjs) {
var Sorting = function(field, order) {
var Sorting = function(field, order, parameters) {
this.field = field;
this.order = order;
this.parameters = parameters;
};
stjs.extend(Sorting, null, [], function(constructor, prototype) {
......@@ -13,6 +14,9 @@ define([ "require", "stjs" ], function(require, stjs) {
prototype.getOrder = function() {
return this.order;
};
prototype.getParameters = function() {
return this.parameters;
};
}, {});
return Sorting;
})
\ No newline at end of file
......@@ -54,7 +54,7 @@ public class EntityWithPropertiesSortOptions<OBJECT extends ICodeHolder & IPermI
parameters.put(SortParameter.FULL_PROPERTY_BOOST, "10000");
parameters.put(SortParameter.FULL_TYPE_BOOST, "1000");
parameters.put(SortParameter.PARTIAL_PROPERTY_BOOST, "100");
return getOrCreateSorting(FETCHED_FIELDS_SCORE, parameters);
return getOrCreateSortingWithParameters(FETCHED_FIELDS_SCORE, parameters);
}
public SortOrder type()
......
......@@ -39,10 +39,10 @@ public abstract class SortOptions<OBJECT> implements Serializable
protected SortOrder getOrCreateSorting(String field)
{
return getOrCreateSorting(field, null);
return getOrCreateSortingWithParameters(field, null);
}
protected SortOrder getOrCreateSorting(String field, Map<SortParameter, String> parameters)
protected SortOrder getOrCreateSortingWithParameters(String field, Map<SortParameter, String> parameters)
{
SortOrder order = getSorting(field);
if (order == null)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment