Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vlkb-siav2
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
ViaLactea
vlkb-siav2
Commits
ed302e3a
Commit
ed302e3a
authored
1 year ago
by
Robert Butora
Browse files
Options
Downloads
Patches
Plain Diff
response: implements preliminary VOTable response.xml
parent
d95b1dcb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
data-discovery/src/main/java/vlkb/output/XmlSerializer.java
+82
-11
82 additions, 11 deletions
data-discovery/src/main/java/vlkb/output/XmlSerializer.java
with
82 additions
and
11 deletions
data-discovery/src/main/java/vlkb/output/XmlSerializer.java
+
82
−
11
View file @
ed302e3a
...
...
@@ -2,6 +2,14 @@
//import java.util.logging.Logger;
import
java.io.PrintWriter
;
// VOTable
import
uk.ac.starlink.table.*
;
// StarTable needed
import
uk.ac.starlink.votable.*
;
// Writer needed
import
java.io.IOException
;
import
java.io.OutputStreamWriter
;
import
java.io.BufferedWriter
;
public
final
class
XmlSerializer
...
...
@@ -13,21 +21,84 @@ public final class XmlSerializer
public
static
void
serializeToVoTable
(
PrintWriter
writer
,
String
charEncoding
,
SearchOutputData
searchOutputData
,
boolean
showDuration
,
long
startTime_msec
)
{
writer
.
println
(
"<?xml version=\"1.0\" encoding=\""
+
charEncoding
+
"\" standalone=\"yes\"?>"
);
writer
.
println
(
"<results>"
);
writer
.
println
(
"<description> TBD: VOTable "
+
searchOutputData
.
description
+
" </description>"
);
serialize
(
writer
,
searchOutputData
.
inputs
);
writer
.
println
(
"<msg> "
+
searchOutputData
.
versionString
+
" </msg>"
);
writer
.
println
(
"<DatacubeCount> "
+
searchOutputData
.
datacubeCount
+
" </DatacubeCount>"
);
for
(
Subsurvey
subsurvey
:
searchOutputData
.
subsurveyArr
)
// writer.println("<msg> " + searchOutputData.versionString + " </msg>");
// writer.println("<DatacubeCount> " + searchOutputData.datacubeCount + " </DatacubeCount>");
StarTable
dstable
=
makeSearchResultsTable
(
searchOutputData
.
subsurveyArr
);
StarTable
[]
tables
=
{
dstable
};
try
{
serialize
(
writer
,
subsurvey
);
writeTables
(
writer
,
tables
);
}
if
(
showDuration
)
writer
.
println
(
"<duration unit=\"msec\">"
+
(
System
.
currentTimeMillis
()
-
startTime_msec
)
+
"</duration>"
);
writer
.
println
(
"</results>"
);
catch
(
IOException
ex
)
{
;
// FIXME System.out.println( ex.getMessage() );
}
}
private
static
void
writeTables
(
PrintWriter
writer
,
StarTable
[]
tables
)
throws
IOException
{
BufferedWriter
out
=
new
BufferedWriter
(
writer
/*new OutputStreamWriter( System.out )*/
);
out
.
write
(
"<VOTABLE version='1.1'>\n"
);
out
.
write
(
"<RESOURCE>\n"
);
out
.
write
(
"<DESCRIPTION>Some tables</DESCRIPTION>\n"
);
for
(
int
i
=
0
;
i
<
tables
.
length
;
i
++
)
{
VOSerializer
.
makeSerializer
(
DataFormat
.
TABLEDATA
,
tables
[
i
]
)
.
writeInlineTableElement
(
out
);
}
out
.
write
(
"</RESOURCE>\n"
);
out
.
write
(
"</VOTABLE>\n"
);
out
.
flush
();
}
private
static
StarTable
makeSearchResultsTable
(
Subsurvey
[]
ssurv
)
{
ColumnInfo
[]
colInfos
=
new
ColumnInfo
[
5
+
2
*
4
];
colInfos
[
0
]
=
new
ColumnInfo
(
"overlap"
,
Integer
.
class
,
"Overlap Code"
);
colInfos
[
1
]
=
new
ColumnInfo
(
"overlapSky"
,
Integer
.
class
,
"Overlap Code for Sky axes"
);
colInfos
[
2
]
=
new
ColumnInfo
(
"overlapSpec"
,
Integer
.
class
,
"Overlap Code for Spectral axis"
);
colInfos
[
3
]
=
new
ColumnInfo
(
"dataType"
,
String
.
class
,
"Data Type (image|cube)"
);
colInfos
[
4
]
=
new
ColumnInfo
(
"pubdid"
,
String
.
class
,
"PublisherDid"
);
colInfos
[
5
]
=
new
ColumnInfo
(
"P1lon"
,
Double
.
class
,
"longitude"
);
colInfos
[
6
]
=
new
ColumnInfo
(
"P1lat"
,
Double
.
class
,
"latitude"
);
colInfos
[
7
]
=
new
ColumnInfo
(
"P2lon"
,
Double
.
class
,
"longitude"
);
colInfos
[
8
]
=
new
ColumnInfo
(
"P2lat"
,
Double
.
class
,
"latitude"
);
colInfos
[
9
]
=
new
ColumnInfo
(
"P3lon"
,
Double
.
class
,
"longitude"
);
colInfos
[
10
]
=
new
ColumnInfo
(
"P3lat"
,
Double
.
class
,
"latitude"
);
colInfos
[
11
]
=
new
ColumnInfo
(
"P4lon"
,
Double
.
class
,
"longitude"
);
colInfos
[
12
]
=
new
ColumnInfo
(
"P4lat"
,
Double
.
class
,
"latitude"
);
RowListStarTable
astro
=
new
RowListStarTable
(
colInfos
);
for
(
Subsurvey
subsurvey
:
ssurv
)
{
for
(
Dataset
dataset
:
subsurvey
.
datasetArr
)
{
astro
.
addRow
(
new
Object
[]
{
new
Integer
(
dataset
.
overlapCode
),
new
Integer
(
dataset
.
overlapCodeSky
),
new
Integer
(
dataset
.
overlapCodeVel
),
dataset
.
dataType
,
dataset
.
publisherDid
,
new
Double
(
dataset
.
vertices_deg
.
lon
[
0
]),
new
Double
(
dataset
.
vertices_deg
.
lat
[
0
]),
new
Double
(
dataset
.
vertices_deg
.
lon
[
1
]),
new
Double
(
dataset
.
vertices_deg
.
lat
[
1
]),
new
Double
(
dataset
.
vertices_deg
.
lon
[
2
]),
new
Double
(
dataset
.
vertices_deg
.
lat
[
2
]),
new
Double
(
dataset
.
vertices_deg
.
lon
[
3
]),
new
Double
(
dataset
.
vertices_deg
.
lat
[
3
]),
});
}
}
return
astro
;
}
// legacy
public
static
void
serializeToLegacyResults
(
PrintWriter
writer
,
String
charEncoding
,
SearchOutputData
searchOutputData
,
boolean
showDuration
,
long
startTime_msec
)
...
...
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