diff --git a/docs/db/Schema_data_migration.txt b/docs/db/Schema_data_migration.txt index fcb011f04165d544e33069d36f10636e5dd259f9..740478f471f4d9d3c7f590f057a82c101070744c 100644 --- a/docs/db/Schema_data_migration.txt +++ b/docs/db/Schema_data_migration.txt @@ -718,6 +718,35 @@ BEGIN END; $$; +CREATE OR REPLACE FUNCTION public.get_instance_index(convention_name text) + RETURNS text + LANGUAGE plpgsql +AS +$$ +DECLARE + len int; + pos int; + mnemonic_path text; + nbr_delimiters int; +BEGIN + pos = strpos(convention_name, ':'); + IF pos > 0 THEN + mnemonic_path = substr(convention_name, pos+1); + nbr_delimiters = array_length(string_to_array(mnemonic_path, '-'), 1) - 1; + IF nbr_delimiters = 2 then + mnemonic_path = reverse(mnemonic_path); + len = length(mnemonic_path); + pos = strpos(mnemonic_path, '-'); + mnemonic_path = reverse(mnemonic_path); + RETURN substr(mnemonic_path, len - pos + 2); + ELSE + RETURN null; + END IF; + END IF; + RETURN null; +END; +$$; + CREATE OR REPLACE FUNCTION get_mnemonic_path_system(system_uuid text) RETURNS text LANGUAGE plpgsql diff --git a/src/main/java/org/openepics/names/repository/NameRepository.java b/src/main/java/org/openepics/names/repository/NameRepository.java index 02434fdfb6cb2aea4d8a4b5ece1d097be6b6d519..84b1ca15e3413a1d868cda8213d122ffb13416ff 100644 --- a/src/main/java/org/openepics/names/repository/NameRepository.java +++ b/src/main/java/org/openepics/names/repository/NameRepository.java @@ -57,13 +57,14 @@ public class NameRepository { * @param nameequivalence name equivalence * @param systemstructure system structure mnemonic * @param devicestructure device structure mnemonic + * @param index index * @param description description * @return count of names */ public Long countNames(Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description) { + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description) { return countNames(deleted, - uuid, name, nameequivalence, systemstructure, devicestructure, description, + uuid, name, nameequivalence, systemstructure, devicestructure, index, description, Boolean.FALSE); } @@ -76,12 +77,13 @@ public class NameRepository { * @param nameequivalence name equivalence * @param systemstructure system structure mnemonic * @param devicestructure device structure mnemonic + * @param index index * @param description description * @param includeHistory include history * @return count of names */ public Long countNames(Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description, + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description, Boolean includeHistory) { // note @@ -95,7 +97,7 @@ public class NameRepository { Root<Name> from = cq.from(Name.class); cq.where(cb.and(preparePredicatesNames(cb, from, deleted, - uuid, name, nameequivalence, systemstructure, devicestructure, description, + uuid, name, nameequivalence, systemstructure, devicestructure, index, description, includeHistory).toArray(new Predicate[0]))); cq.select(cb.count(from)); @@ -111,14 +113,15 @@ public class NameRepository { * @param nameequivalence name equivalence * @param systemstructure system structure mnemonic * @param devicestructure device structure mnemonic + * @param index index * @param description description * @return list of names */ public List<Name> readNames(Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description) { + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description) { return readNames(deleted, - uuid, name, nameequivalence, systemstructure, devicestructure, description, + uuid, name, nameequivalence, systemstructure, devicestructure, index, description, Boolean.FALSE, null, null, null, null); } @@ -131,6 +134,7 @@ public class NameRepository { * @param nameequivalence name equivalence * @param systemstructure system structure mnemonic * @param devicestructure device structure mnemonic + * @param index index * @param description description * @param orderBy order by * @param isAsc is ascending @@ -139,10 +143,10 @@ public class NameRepository { * @return list of names */ public List<Name> readNames(Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description, + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description, FieldName orderBy, Boolean isAsc, Integer offset, Integer limit) { return readNames(deleted, - uuid, name, nameequivalence, systemstructure, devicestructure, description, + uuid, name, nameequivalence, systemstructure, devicestructure, index, description, Boolean.FALSE, orderBy, isAsc, offset, limit); } @@ -155,6 +159,7 @@ public class NameRepository { * @param nameequivalence name equivalence * @param systemstructure system structure mnemonic * @param devicestructure device structure mnemonic + * @param index index * @param description description * @param includeHistory include history * @param orderBy order by @@ -164,7 +169,7 @@ public class NameRepository { * @return list of names */ public List<Name> readNames(Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description, + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description, Boolean includeHistory, FieldName orderBy, Boolean isAsc, Integer offset, Integer limit) { // note @@ -182,7 +187,7 @@ public class NameRepository { Root<Name> from = cq.from(Name.class); cq.where(cb.and(preparePredicatesNames(cb, from, deleted, - uuid, name, nameequivalence, systemstructure, devicestructure, description, + uuid, name, nameequivalence, systemstructure, devicestructure, index, description, includeHistory).toArray(new Predicate[0]))); cq.select(from); @@ -196,6 +201,8 @@ public class NameRepository { cq.orderBy(cb.asc(cb.function(NameStructure.FUNCTION_GET_MNEMONIC_PATH_SYSTEM_STRUCTURE, String.class, from.get(Name.FIELD_CONVENTION_NAME)))); } else if (FieldName.DEVICESTRUCTURE.equals(orderBy)) { cq.orderBy(cb.asc(cb.function(NameStructure.FUNCTION_GET_MNEMONIC_PATH_DEVICE_STRUCTURE, String.class, from.get(Name.FIELD_CONVENTION_NAME)))); + } else if (FieldName.INDEX.equals(orderBy)) { + cq.orderBy(cb.asc(cb.function(NameStructure.FUNCTION_GET_INSTANCE_INDEX, String.class, from.get(Name.FIELD_CONVENTION_NAME)))); } else if (FieldName.DESCRIPTION.equals(orderBy)) { cq.orderBy(cb.asc(from.get(NameStructure.FIELD_DESCRIPTION))); } else if (FieldName.WHEN.equals(orderBy)) { @@ -212,6 +219,8 @@ public class NameRepository { cq.orderBy(cb.desc(cb.function(NameStructure.FUNCTION_GET_MNEMONIC_PATH_SYSTEM_STRUCTURE, String.class, from.get(Name.FIELD_CONVENTION_NAME)))); } else if (FieldName.DEVICESTRUCTURE.equals(orderBy)) { cq.orderBy(cb.desc(cb.function(NameStructure.FUNCTION_GET_MNEMONIC_PATH_DEVICE_STRUCTURE, String.class, from.get(Name.FIELD_CONVENTION_NAME)))); + } else if (FieldName.INDEX.equals(orderBy)) { + cq.orderBy(cb.desc(cb.function(NameStructure.FUNCTION_GET_INSTANCE_INDEX, String.class, from.get(Name.FIELD_CONVENTION_NAME)))); } else if (FieldName.DESCRIPTION.equals(orderBy)) { cq.orderBy(cb.desc(from.get(NameStructure.FIELD_DESCRIPTION))); } else if (FieldName.WHEN.equals(orderBy)) { @@ -242,12 +251,13 @@ public class NameRepository { * @param nameequivalence name equivalence * @param systemstructure system structure mnemonic * @param devicestructure device structure mnemonic + * @param index index * @param description description * @param includeHistory include history * @return list of predicates */ private List<Predicate> preparePredicatesNames(CriteriaBuilder cb, Root<Name> from, Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description, + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description, Boolean includeHistory) { List<Predicate> predicates = new ArrayList<>(); @@ -290,6 +300,9 @@ public class NameRepository { if (!StringUtils.isEmpty(devicestructure)) { predicates.add(cb.and(cb.like(cb.function(NameStructure.FUNCTION_GET_MNEMONIC_PATH_DEVICE_STRUCTURE, String.class, from.get(Name.FIELD_CONVENTION_NAME)), RepositoryUtil.preparePattern(devicestructure)))); } + if (!StringUtils.isEmpty(index)) { + predicates.add(cb.and(cb.like(cb.function(NameStructure.FUNCTION_GET_INSTANCE_INDEX, String.class, from.get(Name.FIELD_CONVENTION_NAME)), RepositoryUtil.preparePattern(index)))); + } if (!StringUtils.isEmpty(description)) { predicates.add(cb.and(cb.like(from.get(NameStructure.FIELD_DESCRIPTION), RepositoryUtil.preparePattern(description)))); } diff --git a/src/main/java/org/openepics/names/repository/model/NameStructure.java b/src/main/java/org/openepics/names/repository/model/NameStructure.java index 5ef3a2b585bf9a49fce48463bfdf48591182ed29..a282ff4c24dd1672f933b82ae302be8b6018c34d 100644 --- a/src/main/java/org/openepics/names/repository/model/NameStructure.java +++ b/src/main/java/org/openepics/names/repository/model/NameStructure.java @@ -57,6 +57,7 @@ public class NameStructure extends Persistable implements Serializable { public static final String FUNCTION_GET_MNEMONIC_PATH_DEVICE_STRUCTURE = "get_mnemonic_path_device_structure"; public static final String FUNCTION_GET_MNEMONIC_PATH_SYSTEM_STRUCTURE = "get_mnemonic_path_system_structure"; + public static final String FUNCTION_GET_INSTANCE_INDEX = "get_instance_index"; private String uuid; private String description; diff --git a/src/main/java/org/openepics/names/rest/api/v1/INames.java b/src/main/java/org/openepics/names/rest/api/v1/INames.java index f3a46b41e4c9e672a7e115dac5adfa681c137fdb..9fae34417541458d3c0c381a436024e05a12a992 100644 --- a/src/main/java/org/openepics/names/rest/api/v1/INames.java +++ b/src/main/java/org/openepics/names/rest/api/v1/INames.java @@ -265,6 +265,7 @@ public interface INames { * @param nameequivalence name equivalence * @param systemstructure system structure mnemonic path * @param devicestructure device structure mnemonic path + * @param index index * @param description description * @param orderBy order by field * @param isAsc sort order, ascending or descending @@ -314,6 +315,7 @@ public interface INames { @Parameter(in = ParameterIn.QUERY, description = "search by name equivalence") @RequestParam(required = false) String nameequivalence, @Parameter(in = ParameterIn.QUERY, description = "search by system structure mnemonic path") @RequestParam(required = false) String systemstructure, @Parameter(in = ParameterIn.QUERY, description = "search by device structure mnemonic path") @RequestParam(required = false) String devicestructure, + @Parameter(in = ParameterIn.QUERY, description = "search by index") @RequestParam(required = false) String index, @Parameter(in = ParameterIn.QUERY, description = "search by description") @RequestParam(required = false) String description, @Parameter(in = ParameterIn.QUERY, description = "order by field") @RequestParam(required = false) FieldName orderBy, @Parameter(in = ParameterIn.QUERY, description = "sort order, ascending or descending") @RequestParam(required = false) Boolean isAsc, @@ -331,6 +333,7 @@ public interface INames { * @param nameequivalence name equivalence * @param systemstructure system structure mnemonic path * @param devicestructure device structure mnemonic path + * @param index index * @param description description * @param orderBy order by field * @param isAsc sort order, ascending or descending @@ -379,6 +382,7 @@ public interface INames { @Parameter(in = ParameterIn.QUERY, description = "search by name equivalence") @RequestParam(required = false) String nameequivalence, @Parameter(in = ParameterIn.QUERY, description = "search by system structure mnemonic path") @RequestParam(required = false) String systemstructure, @Parameter(in = ParameterIn.QUERY, description = "search by device structure mnemonic path") @RequestParam(required = false) String devicestructure, + @Parameter(in = ParameterIn.QUERY, description = "search by index") @RequestParam(required = false) String index, @Parameter(in = ParameterIn.QUERY, description = "search by description") @RequestParam(required = false) String description, @Parameter(in = ParameterIn.QUERY, description = "order by field") @RequestParam(required = false) FieldName orderBy, @Parameter(in = ParameterIn.QUERY, description = "sort order, ascending or descending") @RequestParam(required = false) Boolean isAsc, diff --git a/src/main/java/org/openepics/names/rest/beans/FieldName.java b/src/main/java/org/openepics/names/rest/beans/FieldName.java index 3fcb8ffe47ec0c1e3267a146c7ce30a816888018..3853174a5fdaeb59942063ec4bc49d5d602926a9 100644 --- a/src/main/java/org/openepics/names/rest/beans/FieldName.java +++ b/src/main/java/org/openepics/names/rest/beans/FieldName.java @@ -39,6 +39,8 @@ public enum FieldName { SYSTEMSTRUCTURE, @Schema(description = "Mnemonic path for for the device structure.") DEVICESTRUCTURE, + @Schema(description = "Index of the name.") + INDEX, @Schema(description = "Description of the name.") DESCRIPTION, @Schema(description = "Date and time when the name was created.") diff --git a/src/main/java/org/openepics/names/rest/controller/NamesController.java b/src/main/java/org/openepics/names/rest/controller/NamesController.java index 13a8731261d13f3fcf2b5e0156f959a84169f7fc..b6b997d05d3860535cb42def6300f2bc5aabd36d 100644 --- a/src/main/java/org/openepics/names/rest/controller/NamesController.java +++ b/src/main/java/org/openepics/names/rest/controller/NamesController.java @@ -133,11 +133,11 @@ public class NamesController implements INames { @Override public ResponsePageNameElements readNames(Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description, + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description, FieldName orderBy, Boolean isAsc, Integer page, Integer pageSize) { try { return namesService.readNames(deleted, - uuid, name, nameequivalence, systemstructure, devicestructure, description, + uuid, name, nameequivalence, systemstructure, devicestructure, index, description, orderBy, isAsc, page, pageSize); } catch (ServiceException e) { logService.logServiceException(LOGGER, Level.WARNING, e); @@ -151,10 +151,10 @@ public class NamesController implements INames { @Override public ResponseEntity<Resource> readNamesDownload(Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description, + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description, FieldName orderBy, Boolean isAsc, Integer page, Integer pageSize) { ResponsePageNameElements nameElements = readNames(deleted, - uuid, name, nameequivalence, systemstructure, devicestructure, description, + uuid, name, nameequivalence, systemstructure, devicestructure, index, description, orderBy, isAsc, page, pageSize); InputStreamResource isr = new InputStreamResource(ExcelUtil.nameElementsToExcel(nameElements)); return ResponseEntity.ok() diff --git a/src/main/java/org/openepics/names/rest/controller/ReportController.java b/src/main/java/org/openepics/names/rest/controller/ReportController.java index b4c7437aaa8c6f5fd0a9c96ca418f22cbb1fe182..b9030406e8a4aba4e466acd931646c21405550bf 100644 --- a/src/main/java/org/openepics/names/rest/controller/ReportController.java +++ b/src/main/java/org/openepics/names/rest/controller/ReportController.java @@ -132,9 +132,9 @@ public class ReportController { // metrics can be read with service layer or repository layer // prepare metrics - ResponsePageNameElements nameElementsEssNames = namesService.readNames(null, null, null, null, null, null, null, Boolean.FALSE, null, null, null, null); - ResponsePageNameElements nameElementsEssNamesDeleted = namesService.readNames(Boolean.TRUE, null, null, null, null, null, null, Boolean.FALSE, null, null, null, null); - ResponsePageNameElements nameElementsEssNamesNotDeleted = namesService.readNames(Boolean.FALSE, null, null, null, null, null, null, Boolean.FALSE, null, null, null, null); + ResponsePageNameElements nameElementsEssNames = namesService.readNames(null, null, null, null, null, null, null, null, Boolean.FALSE, null, null, null, null); + ResponsePageNameElements nameElementsEssNamesDeleted = namesService.readNames(Boolean.TRUE, null, null, null, null, null, null, null, Boolean.FALSE, null, null, null, null); + ResponsePageNameElements nameElementsEssNamesNotDeleted = namesService.readNames(Boolean.FALSE, null, null, null, null, null, null, null, Boolean.FALSE, null, null, null, null); long nbrEssNameSystemstructure = 0; long nbrEssNameSystemstructureDevicestructure = 0; diff --git a/src/main/java/org/openepics/names/service/NamesService.java b/src/main/java/org/openepics/names/service/NamesService.java index fa15e74b8a249d8e191da797d1fb693ea3849d6b..f8fcec326f7ddd0af8bf5e6ebc1c126737baf5bd 100644 --- a/src/main/java/org/openepics/names/service/NamesService.java +++ b/src/main/java/org/openepics/names/service/NamesService.java @@ -207,15 +207,15 @@ public class NamesService { // ---------------------------------------------------------------------------------------------------- public ResponsePageNameElements readNames(Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description, + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description, FieldName orderBy, Boolean isAsc, Integer offset, Integer limit) { return readNames(deleted, - uuid, name, nameequivalence, systemstructure, devicestructure, description, + uuid, name, nameequivalence, systemstructure, devicestructure, index, description, Boolean.FALSE, orderBy, isAsc, offset, limit); } public ResponsePageNameElements readNames(Boolean deleted, - String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String description, + String uuid, String name, String nameequivalence, String systemstructure, String devicestructure, String index, String description, Boolean includeHistory, FieldName orderBy, Boolean isAsc, Integer offset, Integer limit) { LOGGER.log(Level.FINE, "readNames, deleted: {0}", deleted); @@ -224,6 +224,7 @@ public class NamesService { LOGGER.log(Level.FINE, "readNames, nameequivalence: {0}", nameequivalence); LOGGER.log(Level.FINE, "readNames, systemstructure: {0}", systemstructure); LOGGER.log(Level.FINE, "readNames, devicestructure: {0}", devicestructure); + LOGGER.log(Level.FINE, "readNames, index: {0}", index); LOGGER.log(Level.FINE, "readNames, description: {0}", description); LOGGER.log(Level.FINE, "readNames, includeHistory: {0}", includeHistory); LOGGER.log(Level.FINE, "readNames, orderBy: {0}", orderBy); @@ -248,8 +249,8 @@ public class NamesService { offset, limit); // do - List<Name> names = nameRepository.readNames(deleted, uuid, name, nameequivalence, systemstructure, devicestructure, description, includeHistory, orderBy, isAsc, offset, limit); - Long totalCount = nameRepository.countNames(deleted, uuid, name, nameequivalence, systemstructure, devicestructure, description, includeHistory); + List<Name> names = nameRepository.readNames(deleted, uuid, name, nameequivalence, systemstructure, devicestructure, index, description, includeHistory, orderBy, isAsc, offset, limit); + Long totalCount = nameRepository.countNames(deleted, uuid, name, nameequivalence, systemstructure, devicestructure, index, description, includeHistory); final List<NameElement> nameElements = Lists.newArrayList(); for (Name namee : names) { @@ -288,7 +289,7 @@ public class NamesService { } } catch (IllegalArgumentException e) { return readNames(false, - null, name, null, null, null, null, + null, name, null, null, null, null, null, orderBy, isAsc, offset, limit); } @@ -312,7 +313,7 @@ public class NamesService { // do return readNames(false, - null, null, null, mnemonicpath, null, null, + null, null, null, mnemonicpath, null, null, null, orderBy, isAsc, offset, limit); } @@ -333,7 +334,7 @@ public class NamesService { // do return readNames(false, - null, null, null, null,mnemonicpath, null, + null, null, null, null,mnemonicpath, null, null, orderBy, isAsc, offset, limit); } @@ -355,7 +356,7 @@ public class NamesService { // do ResponsePageNameElements response = readNames(null, - uuid, null, null, null, null, null, + uuid, null, null, null, null, null, null, Boolean.TRUE, orderBy, isAsc, offset, limit); Collections.sort(response.getList(), new Comparator<NameElement>() { @Override @@ -395,7 +396,7 @@ public class NamesService { // do List<Name> names = nameRepository.readNames(false, - null, name, null, null, null, null); + null, name, null, null, null, null, null); return !names.isEmpty(); } @@ -411,7 +412,7 @@ public class NamesService { // do List<Name> names = nameRepository.readNames(false, - null, name, null, null, null, null); + null, name, null, null, null, null, null); ExceptionUtil.validateConditionDataNotFoundException(names != null && names.size() == 1, "name not found", name, null); Name toBeChecked = names.get(0); diff --git a/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java b/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java index 4409d1ac30bd2b84962e9ef753ce0df002e53370..b19b554b06401d456057ce89eea3de826c1c2a99 100644 --- a/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java +++ b/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java @@ -247,7 +247,7 @@ public class ValidateNameElementUtil { // update, delete - uuid available, not deleted // retrieve for uuid and check if (NameChoice.UPDATE.equals(nameChoice) || NameChoice.DELETE.equals(nameChoice)) { - List<Name> names = nameRepository.readNames(false, nameElement.getUuid().toString(), null, null, null, null, null); + List<Name> names = nameRepository.readNames(false, nameElement.getUuid().toString(), null, null, null, null, null, null); ExceptionUtil.validateConditionDataNotCorrectException(names != null && names.size() == 1, TextUtil.VALUE_IS_NOT_CORRECT, details, TextUtil.UUID); } @@ -323,7 +323,7 @@ public class ValidateNameElementUtil { // name // ok with same name, name equivalence if same uuid - List<Name> names = nameRepository.readNames(false, null, derivedName, null, null, null, null); + List<Name> names = nameRepository.readNames(false, null, derivedName, null, null, null, null, null); if (NameChoice.CREATE.equals(nameChoice)) { condition = names == null || names.isEmpty(); } else { @@ -332,7 +332,7 @@ public class ValidateNameElementUtil { } ExceptionUtil.validateConditionDataExistException(condition, TextUtil.CONVENTION_NAME_EXISTS, details, TextUtil.PARENTSYSTEMSTRUCTURE); - names = nameRepository.readNames(false, null, null, namingConvention.equivalenceClassRepresentative(derivedName), null, null, null); + names = nameRepository.readNames(false, null, null, namingConvention.equivalenceClassRepresentative(derivedName), null, null, null, null); if (NameChoice.CREATE.equals(nameChoice)) { condition = names == null || names.isEmpty(); } else { @@ -461,10 +461,10 @@ public class ValidateNameElementUtil { // convention name equivalence not exists ExceptionUtil.validateConditionDataNotCorrectException(StringUtils.equals(name, derivedName), TextUtil.CONVENTION_NAME_IS_NOT_CORRECT, details, field); - List<Name> names = holderRepositories.getNameRepository().readNames(false, null, name, null, null, null, null); + List<Name> names = holderRepositories.getNameRepository().readNames(false, null, name, null, null, null, null, null); ExceptionUtil.validateConditionDataExistException(names.isEmpty(), TextUtil.CONVENTION_NAME_EXISTS, details, field); - names = holderRepositories.getNameRepository().readNames(false, null, null, namingConvention.equivalenceClassRepresentative(name), null, null, null); + names = holderRepositories.getNameRepository().readNames(false, null, null, namingConvention.equivalenceClassRepresentative(name), null, null, null, null); ExceptionUtil.validateConditionDataExistException(names.isEmpty(), TextUtil.CONVENTION_NAME_EQUIVALENCE_EXISTS, details, field); } diff --git a/src/test/java/org/openepics/names/docker/NamesIT.java b/src/test/java/org/openepics/names/docker/NamesIT.java index b0abccfe7b27203d1df6a0bc39e87d6622bc0c30..799def8298db5a86bb1682ef1f63312333d88e41 100644 --- a/src/test/java/org/openepics/names/docker/NamesIT.java +++ b/src/test/java/org/openepics/names/docker/NamesIT.java @@ -797,6 +797,7 @@ class NamesIT { ITUtilNameElement.assertRead("?uuid=" + uuid.toString(), 1); ITUtilNameElement.assertRead("?nameequivalence=RFQ-10%25", 8, -1); ITUtilNameElement.assertRead("?nameequivalence=RFQ-10%25&devicestructure=EMR-FS", 6, -1); + ITUtilNameElement.assertRead("?index=003", 1); ITUtilNameElement.assertRead("?deleted=false", 6, -1); ITUtilNameElement.assertRead("?deleted=true", 2, -1); diff --git a/src/test/resources/db/schema_migration/V4__Schema_data_migration.sql b/src/test/resources/db/schema_migration/V4__Schema_data_migration.sql index fcb011f04165d544e33069d36f10636e5dd259f9..740478f471f4d9d3c7f590f057a82c101070744c 100644 --- a/src/test/resources/db/schema_migration/V4__Schema_data_migration.sql +++ b/src/test/resources/db/schema_migration/V4__Schema_data_migration.sql @@ -718,6 +718,35 @@ BEGIN END; $$; +CREATE OR REPLACE FUNCTION public.get_instance_index(convention_name text) + RETURNS text + LANGUAGE plpgsql +AS +$$ +DECLARE + len int; + pos int; + mnemonic_path text; + nbr_delimiters int; +BEGIN + pos = strpos(convention_name, ':'); + IF pos > 0 THEN + mnemonic_path = substr(convention_name, pos+1); + nbr_delimiters = array_length(string_to_array(mnemonic_path, '-'), 1) - 1; + IF nbr_delimiters = 2 then + mnemonic_path = reverse(mnemonic_path); + len = length(mnemonic_path); + pos = strpos(mnemonic_path, '-'); + mnemonic_path = reverse(mnemonic_path); + RETURN substr(mnemonic_path, len - pos + 2); + ELSE + RETURN null; + END IF; + END IF; + RETURN null; +END; +$$; + CREATE OR REPLACE FUNCTION get_mnemonic_path_system(system_uuid text) RETURNS text LANGUAGE plpgsql