Skip to content

Commit d02d7ec

Browse files
OUW-3517
1 parent 4861006 commit d02d7ec

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

features/features/filter/filter_dataset_fields.feature

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Feature: Searching datasets fields
3434
And the "type" "HISTORY"
3535
And the "columns" with...
3636
| param |
37-
| [{"path": "provision.device.identifier._current.value", "name": "Prov identifier", "filter": "YES", "sort": true }, { "path": "device.model._current.value.manufacturer", "name": "Manufacturer", "filter": "ALWAYS", "sort": false }, { "path": "device.model._current.at", "name": "Manufacturer Date", "filter": "YES", "sort": false }, { "path": "device.communicationModules[0].subscriber.mobile.icc._current.value", "name": "ICC", "filter": "NO", "sort": false }] |
37+
| [{"path": "provision.device.identifier._current.value", "name": "Prov identifier", "filter": "YES", "sort": true }, { "path": "device.model._current.value.manufacturer", "name": "Manufacturer", "filter": "ALWAYS", "sort": false }, { "path": "device.model._current.at", "name": "Manufacturer Date", "filter": "YES", "sort": false }, { "path": "device.communicationModules[0].subscriber.mobile.icc._current.value", "name": "ICC", "filter": "NO", "sort": false }, { "path": "entity.location._current.value.position.coordinates[0]", "name": "Latitud", "filter": "NO", "sort": false }] |
3838
Then I create it
3939
And response code should be: 201
4040

@@ -52,6 +52,15 @@ Feature: Searching datasets fields
5252
| field | content |
5353
| findFieldPath | Manufacturer |
5454
Then response data should has elements
55+
When I get filter fields...
56+
| field | content |
57+
| findFieldPath | ICC |
58+
Then response data should has elements
59+
When I get filter fields...
60+
| field | content |
61+
| findFieldPath | Latitud |
62+
Then response data should has elements
63+
5564

5665
And an ogapi "datasets builder" util
5766
And I want to delete a "dataset"

features/step_definitions/when_step_definitions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ When(/^I "([^"]*)" it with bulk and response with format csv$/, function (action
654654
});
655655

656656

657-
When(/^I delete it$/, function () {
657+
When(/^I delete it$/, {timeout: 60 * 1000}, function () {
658658

659659
var _this = this;
660660
_this.error = undefined;

scripts/execute_tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ var gulp = require('gulp'),
88
cucumberOptionsCatalog = {
99
string: 'tags',
1010
default: {
11-
'tags': 'not @ignore and @wip'
11+
'tags': 'not @ignore'
1212
}
1313
};
1414
argv.push("--tags");
15-
argv.push("not @ignore and @wip");
15+
argv.push("not @ignore");
1616

1717
var cucumberOptions = minimist(argv, cucumberOptionsCatalog);
1818

src/util/searchingFields/FieldFinder.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ for (var field in IOT_FIELDS) {
1818
}
1919
}
2020

21+
const REGEX_PATH_CURRENT = new RegExp("^(.+)._current\\.?(.+)?$")
22+
const REGEX_PATH_ARRAY = new RegExp("\\[[0-9]+\\]")
23+
const REGEX_DATASTREAM_VALUE = new RegExp('value\\.?')
24+
25+
2126
const match_url = {
2227
'/jobs': 'JOB',
2328
'/tasks': 'TASKS',
@@ -150,7 +155,6 @@ const _getDatamodelFields = function(parent, objSearcher){
150155
}
151156
});
152157
}
153-
154158
if (rtFilter.and.length > 0) {
155159
datamodelSearchBuilder.filter(rtFilter);
156160
}
@@ -355,24 +359,24 @@ const FIELD_SEARCHER = {
355359
//search de la definición de schemas de opengate
356360
_this._ogapi.basicTypesSearchBuilder().withPath('$').build().execute().then(function (basicTypes) {
357361
const definitions = basicTypes.data.definitions
358-
let query = {selectAll: true}
362+
objSearcher.selectAll = true
359363
if (selectedField) {
360364
columns = columns.filter(function (column) { return selectedField === column.name })
361365
const column = columns[0]
362-
const datastreamMatch = column.path.match(new RegExp("^(.+)._current\.?(.+)?$"));
363-
const datastream = datastreamMatch[1].replace(new RegExp("\[[0-9]+\]"), "[]")
364-
query = {selectedField: datastream}
366+
const datastreamMatch = column.path.match(REGEX_PATH_CURRENT);
367+
const datastream = datastreamMatch[1].replace(REGEX_PATH_ARRAY, "[]")
368+
objSearcher.selectedField = datastream
365369
}
366-
query.organization = organization
367370
//recuperamos la defnición de todas las columnas y todos los datastreams
368-
_getDatamodelFields(_this, query).then(function (datamodelFields) {
371+
_getDatamodelFields(_this, objSearcher).then(function (datamodelFields) {
369372
columns.forEach(function (column) {
370373
//Expresión regular para recuperar el path del datastream (1) y, si se tratase de un datastream complejo, también el path hasta el dato simple (2).
371374
//Datastream simple: provision.device.identifier._current.value, device.communicationModules[0].subscriber.mobile.icc._current.at
372375
//Datastream complejo: device.model._current.value.manufacturer, device.location._current.value.position.type
373-
const datastreamMatch = column.path.match(new RegExp("^(.+)._current\.?(.+)?$"));
374-
const datastream = datastreamMatch[1].replace(new RegExp("\[[0-9]+\]"), "[]")
375-
const subdatastream = datastreamMatch[2].replace(new RegExp('value\.?'), '');
376+
const datastreamMatch = column.path.match(REGEX_PATH_CURRENT);
377+
//Eliminamos el indice para los modulos de comunicaciones y los arrays para el resto de datastreams
378+
const datastream = datastreamMatch[1].replace(REGEX_PATH_ARRAY, "[]")
379+
const subdatastream = datastreamMatch[2].replace(REGEX_DATASTREAM_VALUE, '').replace(REGEX_PATH_ARRAY, '');
376380
//Buscamos la definición del datastream en el datamodel
377381
const datamodelField = Array.isArray(datamodelFields) ? datamodelFields.find(function (df) {
378382
return datastream === df.identifier

0 commit comments

Comments
 (0)