Opened 9 years ago

Closed 9 years ago

#1098 closed defect (fixed)

SECORE - Delete a definition will delete all definitions which contains same pattern

Reported by: Bang Pham Huu Owned by: Bang Pham Huu
Priority: major Milestone: 9.2
Component: secore Version: development
Keywords: secore delete Cc: Dimitar Misev
Complexity: Medium

Description

This problem is in class SecoreUtil, method "deleteDef" using XQUERY contains then when delete group definitions like this

crs/0/abcdefeg

it will also delete all group definitions in group crs which starts with "0" like
crs/01111/abcdefef
crs/0000111/abcdefefg

Solution: use XQUERY matches instead of contains

I will submit patch for this ticket after you have reviewed the code review (submited by arc diff) in ticket 1093.

// if "/" does exist behind todel then it should be a string next to it (i.g:/crs/0/Template)
    // if "/" does not exist behind todel then only match string end with todel (i.g: /crs/0 not /crs/000 or /crs/001111)
    
    String match= id + todel + "((?=(\\/))\\S*|$)";
    String query
        = "declare namespace gml = \"" + NAMESPACE_GML + "\";" + NEW_LINE
        + "for $x in collection('" + COLLECTION_NAME + "')//gml:identifier[text() = '" + id + todel + "']/.. "
        + "union doc('" + COLLECTION_NAME + "')//gml:identifier[matches(.,'" + match + "')]/.." + NEW_LINE
        + "return delete node $x";

Change History (1)

comment:1 by Bang Pham Huu, 9 years ago

Resolution: fixed
Status: newclosed

close as patch has been accepted.

Note: See TracTickets for help on using tickets.