Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AKTIN
dwh-import
Commits
0c2a7fda
Commit
0c2a7fda
authored
Apr 26, 2018
by
R.W.Majeed
Browse files
verbose assertations for missing files from art-decor resources
parent
01e4514d
Changes
2
Hide whitespace changes
Inline
Side-by-side
cda-validation/src/main/java/org/aktin/cda/SchemaValidator.java
View file @
0c2a7fda
package
org.aktin.cda
;
package
org.aktin.cda
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URL
;
import
javax.xml.XMLConstants
;
import
javax.xml.XMLConstants
;
import
javax.xml.transform.Source
;
import
javax.xml.transform.Source
;
...
@@ -8,6 +9,7 @@ import javax.xml.validation.Schema;
...
@@ -8,6 +9,7 @@ import javax.xml.validation.Schema;
import
javax.xml.validation.SchemaFactory
;
import
javax.xml.validation.SchemaFactory
;
import
javax.xml.validation.Validator
;
import
javax.xml.validation.Validator
;
import
org.junit.Assert
;
import
org.xml.sax.ErrorHandler
;
import
org.xml.sax.ErrorHandler
;
import
org.xml.sax.SAXException
;
import
org.xml.sax.SAXException
;
import
org.xml.sax.SAXParseException
;
import
org.xml.sax.SAXParseException
;
...
@@ -17,7 +19,9 @@ public class SchemaValidator {
...
@@ -17,7 +19,9 @@ public class SchemaValidator {
public
SchemaValidator
()
throws
SAXException
{
public
SchemaValidator
()
throws
SAXException
{
SchemaFactory
sf
=
SchemaFactory
.
newInstance
(
XMLConstants
.
W3C_XML_SCHEMA_NS_URI
);
SchemaFactory
sf
=
SchemaFactory
.
newInstance
(
XMLConstants
.
W3C_XML_SCHEMA_NS_URI
);
this
.
schema
=
sf
.
newSchema
(
getClass
().
getResource
(
"/schemas/CDA.xsd"
));
URL
url
=
getClass
().
getResource
(
"/schemas/CDA.xsd"
);
Assert
.
assertNotNull
(
"CDA XSD resource not found from external release"
,
url
);
this
.
schema
=
sf
.
newSchema
(
url
);
}
}
public
static
class
ErrorForwarder
implements
ErrorHandler
{
public
static
class
ErrorForwarder
implements
ErrorHandler
{
...
...
cda-validation/src/test/java/org/aktin/cda/TestCDAParser.java
View file @
0c2a7fda
...
@@ -2,6 +2,7 @@ package org.aktin.cda;
...
@@ -2,6 +2,7 @@ package org.aktin.cda;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.net.URL
;
import
javax.xml.parsers.ParserConfigurationException
;
import
javax.xml.parsers.ParserConfigurationException
;
import
javax.xml.transform.TransformerException
;
import
javax.xml.transform.TransformerException
;
...
@@ -47,11 +48,18 @@ public class TestCDAParser {
...
@@ -47,11 +48,18 @@ public class TestCDAParser {
}
}
}
}
*/
*/
private
final
InputStream
openExampleDocument
(
String
source
)
throws
IOException
{
URL
url
=
getClass
().
getResource
(
source
);
Assert
.
assertNotNull
(
"CDA example document not found in external release: "
+
url
,
url
);
System
.
out
.
println
(
url
);
return
url
.
openStream
();
}
@Test
@Test
public
void
extractDocumentIDs
()
throws
TransformerException
,
IOException
,
XPathExpressionException
,
ParserConfigurationException
,
SAXException
{
public
void
extractDocumentIDs
()
throws
TransformerException
,
IOException
,
XPathExpressionException
,
ParserConfigurationException
,
SAXException
{
CDAParser
parser
=
new
CDAParser
();
CDAParser
parser
=
new
CDAParser
();
try
(
InputStream
in
=
getClass
().
getResourceAsStream
(
exampleDocuments
[
0
])
){
try
(
InputStream
in
=
openExampleDocument
(
exampleDocuments
[
0
])
){
Assert
.
assertTrue
(
in
.
available
()
>
0
);
Assert
.
assertTrue
(
in
.
available
()
>
0
);
Document
cda
=
parser
.
buildDOM
(
new
StreamSource
(
in
));
Document
cda
=
parser
.
buildDOM
(
new
StreamSource
(
in
));
String
docId
=
parser
.
extractDocumentId
(
cda
);
String
docId
=
parser
.
extractDocumentId
(
cda
);
...
@@ -64,7 +72,7 @@ public class TestCDAParser {
...
@@ -64,7 +72,7 @@ public class TestCDAParser {
@Test
@Test
public
void
extractPatientID
()
throws
TransformerException
,
IOException
,
XPathExpressionException
,
ParserConfigurationException
,
SAXException
{
public
void
extractPatientID
()
throws
TransformerException
,
IOException
,
XPathExpressionException
,
ParserConfigurationException
,
SAXException
{
CDAParser
parser
=
new
CDAParser
();
CDAParser
parser
=
new
CDAParser
();
try
(
InputStream
in
=
getClass
().
getResourceAsStream
(
exampleDocuments
[
0
])
){
try
(
InputStream
in
=
openExampleDocument
(
exampleDocuments
[
0
])
){
Assert
.
assertTrue
(
in
.
available
()
>
0
);
Assert
.
assertTrue
(
in
.
available
()
>
0
);
Document
cda
=
parser
.
buildDOM
(
new
StreamSource
(
in
));
Document
cda
=
parser
.
buildDOM
(
new
StreamSource
(
in
));
String
[]
pat
=
parser
.
extractPatientId
(
cda
);
String
[]
pat
=
parser
.
extractPatientId
(
cda
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment