Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xnat-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dhcp
xnat-web
Commits
33ee7c64
Commit
33ee7c64
authored
8 years ago
by
Rick Herrick
Browse files
Options
Downloads
Patches
Plain Diff
Added handling of DICOM project rules from the config service, with
fallback to the dicom-project.rules file.
parent
075983fd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/nrg/dcm/id/Xnat15DicomProjectIdentifier.java
+29
-29
29 additions, 29 deletions
...ain/java/org/nrg/dcm/id/Xnat15DicomProjectIdentifier.java
with
29 additions
and
29 deletions
src/main/java/org/nrg/dcm/id/Xnat15DicomProjectIdentifier.java
+
29
−
29
View file @
33ee7c64
...
@@ -11,15 +11,15 @@
...
@@ -11,15 +11,15 @@
package
org.nrg.dcm.id
;
package
org.nrg.dcm.id
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.lang3.StringUtils
;
import
org.dcm4che2.data.Tag
;
import
org.dcm4che2.data.Tag
;
import
org.nrg.config.entities.Configuration
;
import
org.nrg.xdat.XDAT
;
import
org.nrg.xft.XFT
;
import
org.nrg.xft.XFT
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.io.BufferedReader
;
import
java.io.*
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
...
@@ -31,11 +31,11 @@ class Xnat15DicomProjectIdentifier extends DbBackedProjectIdentifier {
...
@@ -31,11 +31,11 @@ class Xnat15DicomProjectIdentifier extends DbBackedProjectIdentifier {
Xnat15DicomProjectIdentifier
()
{
Xnat15DicomProjectIdentifier
()
{
super
(
getIdentifiers
());
super
(
getIdentifiers
());
}
}
private
static
Logger
slog
()
{
private
static
Logger
slog
()
{
return
LoggerFactory
.
getLogger
(
Xnat15DicomProjectIdentifier
.
class
);
return
LoggerFactory
.
getLogger
(
Xnat15DicomProjectIdentifier
.
class
);
}
}
private
static
List
<
DicomDerivedString
>
getIdentifiers
()
{
private
static
List
<
DicomDerivedString
>
getIdentifiers
()
{
final
List
<
DicomDerivedString
>
identifiers
=
Lists
.
newArrayList
();
final
List
<
DicomDerivedString
>
identifiers
=
Lists
.
newArrayList
();
identifiers
.
add
(
new
ContainedAssignmentDicomIdentifier
(
Tag
.
PatientComments
,
"Project"
,
Pattern
.
CASE_INSENSITIVE
));
identifiers
.
add
(
new
ContainedAssignmentDicomIdentifier
(
Tag
.
PatientComments
,
"Project"
,
Pattern
.
CASE_INSENSITIVE
));
...
@@ -45,14 +45,22 @@ class Xnat15DicomProjectIdentifier extends DbBackedProjectIdentifier {
...
@@ -45,14 +45,22 @@ class Xnat15DicomProjectIdentifier extends DbBackedProjectIdentifier {
loadFrom15Config
(
identifiers
);
loadFrom15Config
(
identifiers
);
return
identifiers
;
return
identifiers
;
}
}
private
static
void
loadFrom15Config
(
final
Collection
<
DicomDerivedString
>
identifiers
)
{
private
static
void
loadFrom15Config
(
final
Collection
<
DicomDerivedString
>
identifiers
)
{
final
File
config
=
new
File
(
XFT
.
GetConfDir
(),
DICOM_PROJECT_RULES
);
try
{
IOException
ioexception
=
null
;
final
Reader
source
;
if
(
config
.
isFile
())
{
final
Configuration
configuration
=
XDAT
.
getConfigService
().
getConfig
(
"dicom"
,
"projectRules"
);
try
{
final
File
config
=
new
File
(
XFT
.
GetConfDir
(),
DICOM_PROJECT_RULES
);
final
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
config
));
if
(
configuration
!=
null
&&
configuration
.
isEnabled
()
&&
StringUtils
.
isNotBlank
(
configuration
.
getContents
()))
{
try
{
source
=
new
StringReader
(
configuration
.
getContents
());
}
else
if
(
config
.
exists
()
&&
config
.
isFile
())
{
source
=
new
FileReader
(
config
);
}
else
{
source
=
null
;
}
if
(
source
!=
null
)
{
try
(
final
BufferedReader
reader
=
new
BufferedReader
(
source
))
{
String
line
;
String
line
;
while
(
null
!=
(
line
=
reader
.
readLine
()))
{
while
(
null
!=
(
line
=
reader
.
readLine
()))
{
final
DicomDerivedString
extractor
=
parseRule
(
line
);
final
DicomDerivedString
extractor
=
parseRule
(
line
);
...
@@ -60,23 +68,15 @@ class Xnat15DicomProjectIdentifier extends DbBackedProjectIdentifier {
...
@@ -60,23 +68,15 @@ class Xnat15DicomProjectIdentifier extends DbBackedProjectIdentifier {
identifiers
.
add
(
extractor
);
identifiers
.
add
(
extractor
);
}
}
}
}
}
catch
(
IOException
e
)
{
throw
ioexception
=
e
;
}
finally
{
try
{
reader
.
close
();
}
catch
(
IOException
e
)
{
throw
ioexception
=
null
==
ioexception
?
e
:
ioexception
;
}
}
}
}
catch
(
Throwable
t
)
{
slog
().
error
(
"Unable to load project identification rules from "
+
DICOM_PROJECT_RULES
,
t
);
}
}
}
else
{
}
catch
(
FileNotFoundException
ignored
)
{
slog
().
debug
(
"custom project rules spec {} not found"
,
DICOM_PROJECT_RULES
);
//
}
catch
(
IOException
e
)
{
slog
().
error
(
"An error occurred trying to open the DICOM project rules configuration"
,
e
);
}
}
}
}
private
static
final
Pattern
CUSTOM_RULE_PATTERN
=
Pattern
.
compile
(
"\\((\\p{XDigit}{4})\\,(\\p{XDigit}{4})\\):(.+?)(?::(\\d+))?"
);
private
static
final
Pattern
CUSTOM_RULE_PATTERN
=
Pattern
.
compile
(
"\\((\\p{XDigit}{4})\\,(\\p{XDigit}{4})\\):(.+?)(?::(\\d+))?"
);
...
@@ -85,10 +85,10 @@ class Xnat15DicomProjectIdentifier extends DbBackedProjectIdentifier {
...
@@ -85,10 +85,10 @@ class Xnat15DicomProjectIdentifier extends DbBackedProjectIdentifier {
if
(
matcher
.
matches
())
{
if
(
matcher
.
matches
())
{
final
StringBuilder
tagsb
=
new
StringBuilder
(
"0x"
);
final
StringBuilder
tagsb
=
new
StringBuilder
(
"0x"
);
tagsb
.
append
(
matcher
.
group
(
1
)).
append
(
matcher
.
group
(
2
));
tagsb
.
append
(
matcher
.
group
(
1
)).
append
(
matcher
.
group
(
2
));
final
int
tag
=
Integer
.
decode
(
tagsb
.
toString
());
final
int
tag
=
Integer
.
decode
(
tagsb
.
toString
());
final
String
regexp
=
matcher
.
group
(
3
);
final
String
regexp
=
matcher
.
group
(
3
);
final
String
groupIdx
=
matcher
.
group
(
4
);
final
String
groupIdx
=
matcher
.
group
(
4
);
final
int
group
=
null
==
groupIdx
?
1
:
Integer
.
parseInt
(
groupIdx
);
final
int
group
=
null
==
groupIdx
?
1
:
Integer
.
parseInt
(
groupIdx
);
return
new
PatternDicomIdentifier
(
tag
,
Pattern
.
compile
(
regexp
),
group
);
return
new
PatternDicomIdentifier
(
tag
,
Pattern
.
compile
(
regexp
),
group
);
}
else
{
}
else
{
return
null
;
return
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment