Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Raphael
histream
Commits
918aa9fd
Commit
918aa9fd
authored
Nov 16, 2016
by
R.W.Majeed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
table export will return summary
parent
87a10fe3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
3 deletions
+56
-3
histream-export/src/main/java/de/sekmi/histream/export/ExportSummary.java
...src/main/java/de/sekmi/histream/export/ExportSummary.java
+19
-0
histream-export/src/main/java/de/sekmi/histream/export/FragmentExporter.java
.../main/java/de/sekmi/histream/export/FragmentExporter.java
+15
-2
histream-export/src/main/java/de/sekmi/histream/export/TableExport.java
...t/src/main/java/de/sekmi/histream/export/TableExport.java
+11
-1
histream-export/src/main/java/de/sekmi/histream/export/TableParser.java
...t/src/main/java/de/sekmi/histream/export/TableParser.java
+11
-0
No files found.
histream-export/src/main/java/de/sekmi/histream/export/ExportSummary.java
0 → 100644
View file @
918aa9fd
package
de.sekmi.histream.export
;
public
class
ExportSummary
{
private
int
patientCount
;
private
int
visitCount
;
// TODO maybe add information for additional tables (e.g. table ids and maybe counts)
ExportSummary
(
int
patientCount
,
int
visitCount
){
this
.
patientCount
=
patientCount
;
this
.
visitCount
=
visitCount
;
}
public
int
getPatientCount
(){
return
patientCount
;
}
public
int
getVisitCount
(){
return
visitCount
;
}
}
histream-export/src/main/java/de/sekmi/histream/export/FragmentExporter.java
View file @
918aa9fd
...
...
@@ -113,8 +113,6 @@ class FragmentExporter extends VisitFragmentParser {
// remove visit from patient
currentPatient
.
removeChild
(
visit
);
}
// TODO check for repeating concepts and write to separate parsers
// iterate through facts and
}
@Override
...
...
@@ -150,4 +148,19 @@ class FragmentExporter extends VisitFragmentParser {
}
}
}
/**
* Retrieve number of processed patients
* @return patient count
*/
public
int
getPatientCount
(){
return
patientParser
.
getRowCount
();
}
/**
* Retrieve number of processed visits
* @return visit count
*/
public
int
getVisitCount
(){
return
visitParser
.
getRowCount
();
}
}
histream-export/src/main/java/de/sekmi/histream/export/TableExport.java
View file @
918aa9fd
...
...
@@ -33,6 +33,8 @@ public class TableExport {
private
XPathFactory
factory
;
private
NamespaceContext
ns
;
private
ExportErrorHandler
errorHandler
;
private
int
patientCount
;
private
int
visitCount
;
public
TableExport
(
ExportDescriptor
desc
){
this
.
desc
=
desc
;
...
...
@@ -119,11 +121,12 @@ public class TableExport {
* @throws ExportException export exception
* @throws IOException IO exception
*/
public
void
export
(
ObservationSupplier
supplier
,
ExportWriter
writer
)
throws
ExportException
,
IOException
{
public
ExportSummary
export
(
ObservationSupplier
supplier
,
ExportWriter
writer
)
throws
ExportException
,
IOException
{
requireDisjointConcepts
();
try
(
FragmentExporter
e
=
new
FragmentExporter
(
createXPath
(),
desc
,
writer
)
){
e
.
setErrorHandler
(
new
ExportErrorHandler
());
Streams
.
transfer
(
supplier
,
e
);
return
new
ExportSummary
(
e
.
getPatientCount
(),
e
.
getVisitCount
());
}
catch
(
XMLStreamException
|
ParserConfigurationException
e
)
{
throw
new
ExportException
(
"Unable to create exporter"
,
e
);
}
catch
(
UncheckedExportException
e
){
...
...
@@ -134,4 +137,11 @@ public class TableExport {
throw
e
.
getCause
();
}
}
public
int
getPatientCount
(){
return
patientCount
;
}
public
int
getVisitCount
(){
return
visitCount
;
}
}
histream-export/src/main/java/de/sekmi/histream/export/TableParser.java
View file @
918aa9fd
...
...
@@ -24,11 +24,14 @@ public class TableParser implements AutoCloseable{
private
XPath
xpath
;
private
XPathExpression
[]
xpaths
;
private
TableWriter
writer
;
/** Count data rows (excluding header) */
private
int
rowCount
;
public
TableParser
(
AbstractTable
table
,
TableWriter
writer
,
XPath
xpath
)
throws
ExportException
,
IOException
{
this
.
table
=
table
;
this
.
writer
=
writer
;
this
.
xpath
=
xpath
;
this
.
rowCount
=
0
;
Objects
.
requireNonNull
(
table
);
Objects
.
requireNonNull
(
writer
);
compileXPaths
();
...
...
@@ -58,6 +61,7 @@ public class TableParser implements AutoCloseable{
public
void
processNode
(
Node
node
)
throws
ExportException
,
IOException
{
writer
.
row
(
valuesForFragment
(
node
));
rowCount
++;
}
private
String
[]
valuesForFragment
(
Node
node
)
throws
ExportException
{
...
...
@@ -77,4 +81,11 @@ public class TableParser implements AutoCloseable{
public
void
close
()
throws
IOException
{
writer
.
close
();
}
/**
* Get the number of processed data rows (excluding header rows if applicable).
* @return row count
*/
public
int
getRowCount
(){
return
rowCount
;
}
}
Write
Preview
Markdown
is supported
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