-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Range Matching by Attributes.matches(Attributes keys,..) #125
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -790,7 +790,7 @@ public String[] getStrings(String privateCreator, int tag, VR vr) { | |
|
||
private static String[] toStrings(Object val) { | ||
return (val instanceof String) | ||
? new String[] { (String) val } | ||
? new String[] { (String) val } | ||
: (String[]) val; | ||
} | ||
|
||
|
@@ -2943,9 +2943,19 @@ private boolean matches(String privateCreator, int tag, VR vr, | |
|
||
boolean ignoreCase = ignorePNCase && vr == VR.PN; | ||
for (String keyVal : keyVals) { | ||
DateRange dateRange = null; | ||
if (vr == VR.PN) | ||
keyVal = new PersonName(keyVals[0]).toString(); | ||
|
||
switch (vr) { | ||
case PN: | ||
keyVal = new PersonName(keyVals[0]).toString(); | ||
break; | ||
case DA: | ||
case DT: | ||
case TM: | ||
dateRange = toDateRange(keyVal, vr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also add a break here for safety reasons (should someone in the future add additional cases the break could be forgotten), and maybe even (Personally I would have just used an if / else if construct in this case, and not a switch at all.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added the break and removed the duplicated lines... |
||
} | ||
|
||
if (StringUtils.containsWildCard(keyVal)) { | ||
Pattern pattern = StringUtils.compilePattern(keyVal, ignoreCase); | ||
for (String val : vals) { | ||
|
@@ -2966,6 +2976,12 @@ private boolean matches(String privateCreator, int tag, VR vr, | |
return true; | ||
else | ||
continue; | ||
if (dateRange != null) | ||
if (dateRange.contains( | ||
vr.toDate(val, getTimeZone(), 0, false, null, new DatePrecision()))) | ||
return true; | ||
else | ||
continue; | ||
if (vr == VR.PN) | ||
val = new PersonName(val).toString(); | ||
if (ignoreCase ? keyVal.equalsIgnoreCase(val) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this if is now handled in the switch below, so the if can be removed.