Skip to content

Exact matches in a list of exclusion patterns do not work #337

Description

@anton-abushkevich

"resultExclusions" are passing to ArachneExecutionEngine through DTO https://github.com/OHDSI/ArachneCommons/blob/develop/execution-engine-commons/src/main/java/com/odysseusinc/arachne/execution_engine_common/api/v1/dto/AnalysisSyncRequestDTO.java#L22

Before result send back to client, it's content is filtered according to exclusion patterns, and files that matches these patterns are deleted from results. But if list of exclusion patterns contains exact match, it will be skipped. See filterFiles() method in https://github.com/OHDSI/ArachneCommons/blob/develop/execution-engine-commons/src/main/java/com/odysseusinc/arachne/execution_engine_common/util/CommonFileUtils.java#L119

filterFiles() uses noneMatch() to filter files:

private static boolean noneMatch(List<String> patterns, String fileName) {

        return patterns.stream()
                .filter(matcher::isPattern)
                .noneMatch(e -> matcher.match(e.trim(), fileName));
}

matcher::isPattern returns false for exact matches, so only actual patterns are applied.

To fix this, we should change noneMatch() to something like this:

private static boolean noneMatch(List<String> patterns, String fileName) {

        return patterns.stream()
                .noneMatch(pattern -> matcher.isPattern(pattern)
                        ? matcher.match(pattern.trim(), fileName)
                        : pattern.equals(fileName));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions