Loading data-discovery/src/main/java/vlkb/output/XmlSerializer.java +140 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,8 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.List; import java.util.ArrayList; final class XmlSerializer Loading Loading @@ -135,6 +137,144 @@ final class XmlSerializer } public static void serializeToVoTableBySurveys( PrintWriter writer, String charEncoding, SearchOutputData searchOutputData, boolean showDuration, long startTime_msec) throws IOException { BufferedWriter out = new BufferedWriter( writer ); out.write( "<VOTABLE version='1.1'>" ); out.write( "<DESCRIPTION> " + searchOutputData.versionString + " SUBSURVCOUNT: " + searchOutputData.subsurveyArr.length + " </DESCRIPTION>" ); if((searchOutputData.subsurveyArr != null) && (searchOutputData.subsurveyArr.length > 0)) { // assumes ORDERED subsurveyArray: by surveyname List<StarTable> tableList = new ArrayList(); String prevSurveyname = searchOutputData.subsurveyArr[0].surveyname.trim(); for(Subsurvey subsurvey : searchOutputData.subsurveyArr) { if(prevSurveyname.equals(subsurvey.surveyname.trim())) { StarTable table = makeSubsurveyTable( subsurvey ); tableList.add(table); } else { out.write( "<RESOURCE>" ); out.write( "<DESCRIPTION> " + prevSurveyname + " </DESCRIPTION>" ); /* PLACEHOLDER FOR RESOURCE PARAM table.setParameter(new DescribedValue( new DefaultValueInfo("subsurveyCount",Integer.class, "Count of subsurveys with found datacube(s)" ), subsurveyArr.length ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "survey", String.class, "Survey name" ), subsurvey.surveyname ) ); */ StarTable[] tables = tableList.toArray(new StarTable[0]); for ( int i = 0; i < tables.length; i++ ) { VOSerializer.makeSerializer( DataFormat.TABLEDATA, tables[i] ).writeInlineTableElement( out ); } tableList.clear(); out.write( "</RESOURCE>" ); prevSurveyname = subsurvey.surveyname.trim(); StarTable table = makeSubsurveyTable( subsurvey ); tableList.add(table); } } if(!tableList.isEmpty()) { out.write( "<RESOURCE>" ); out.write( "<DESCRIPTION> " + prevSurveyname + " </DESCRIPTION>" ); /* PLACEHOLDER FOR RESOURCE PARAM table.setParameter(new DescribedValue( new DefaultValueInfo("subsurveyCount",Integer.class, "Count of subsurveys with found datacube(s)" ), subsurveyArr.length ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "survey", String.class, "Survey name" ), subsurvey.surveyname ) ); */ StarTable[] tables = tableList.toArray(new StarTable[0]); for ( int i = 0; i < tables.length; i++ ) { VOSerializer.makeSerializer( DataFormat.TABLEDATA, tables[i] ).writeInlineTableElement( out ); } tableList.clear(); out.write( "</RESOURCE>" ); } } out.write( "</VOTABLE>" ); out.flush(); } private static StarTable makeSubsurveyTable(Subsurvey subsurvey) { RowListStarTable table = new RowListStarTable( ObscoreExt.OBSCORE_VLKB_COLINFO ); table.setParameter(new DescribedValue( new DefaultValueInfo("datacubeCount", Integer.class, "Count of all datacubes from VLKB-search" ), subsurvey.datasetArr.length ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "velocity_unit", String.class, "Unit of velocity in FITS header" ), subsurvey.vel_unit ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "survey", String.class, "Survey name" ), subsurvey.surveyname ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "species", String.class, "Species" ), subsurvey.species ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "transition", String.class, "Transition" ), subsurvey.transition ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "description", String.class, "Reference description" ), subsurvey.description ) ); for(Dataset dataset : subsurvey.datasetArr) { if(dataset.obsCore == null) continue; // FIXME skip mergeable datasets table.addRow( ObscoreExt.obscoreVlkbRow(dataset) ); } return table; } // legacy public static void serializeToLegacyResults( Loading data-discovery/src/main/java/vlkb/webapi/FormatResponseFilter.java +8 −2 Original line number Diff line number Diff line Loading @@ -156,9 +156,15 @@ public class FormatResponseFilter implements Filter boolean showDuration = false; if(respFormat.contains("mode=bysubsurveys")) XmlSerializer.serializeToVoTableBySubsurveys(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); XmlSerializer.serializeToVoTableBySubsurveys(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); else if(respFormat.contains("mode=bysurveys")) XmlSerializer.serializeToVoTableBySurveys(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); else XmlSerializer.serializeToVoTable(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); XmlSerializer.serializeToVoTable(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); } else { Loading Loading
data-discovery/src/main/java/vlkb/output/XmlSerializer.java +140 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,8 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.List; import java.util.ArrayList; final class XmlSerializer Loading Loading @@ -135,6 +137,144 @@ final class XmlSerializer } public static void serializeToVoTableBySurveys( PrintWriter writer, String charEncoding, SearchOutputData searchOutputData, boolean showDuration, long startTime_msec) throws IOException { BufferedWriter out = new BufferedWriter( writer ); out.write( "<VOTABLE version='1.1'>" ); out.write( "<DESCRIPTION> " + searchOutputData.versionString + " SUBSURVCOUNT: " + searchOutputData.subsurveyArr.length + " </DESCRIPTION>" ); if((searchOutputData.subsurveyArr != null) && (searchOutputData.subsurveyArr.length > 0)) { // assumes ORDERED subsurveyArray: by surveyname List<StarTable> tableList = new ArrayList(); String prevSurveyname = searchOutputData.subsurveyArr[0].surveyname.trim(); for(Subsurvey subsurvey : searchOutputData.subsurveyArr) { if(prevSurveyname.equals(subsurvey.surveyname.trim())) { StarTable table = makeSubsurveyTable( subsurvey ); tableList.add(table); } else { out.write( "<RESOURCE>" ); out.write( "<DESCRIPTION> " + prevSurveyname + " </DESCRIPTION>" ); /* PLACEHOLDER FOR RESOURCE PARAM table.setParameter(new DescribedValue( new DefaultValueInfo("subsurveyCount",Integer.class, "Count of subsurveys with found datacube(s)" ), subsurveyArr.length ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "survey", String.class, "Survey name" ), subsurvey.surveyname ) ); */ StarTable[] tables = tableList.toArray(new StarTable[0]); for ( int i = 0; i < tables.length; i++ ) { VOSerializer.makeSerializer( DataFormat.TABLEDATA, tables[i] ).writeInlineTableElement( out ); } tableList.clear(); out.write( "</RESOURCE>" ); prevSurveyname = subsurvey.surveyname.trim(); StarTable table = makeSubsurveyTable( subsurvey ); tableList.add(table); } } if(!tableList.isEmpty()) { out.write( "<RESOURCE>" ); out.write( "<DESCRIPTION> " + prevSurveyname + " </DESCRIPTION>" ); /* PLACEHOLDER FOR RESOURCE PARAM table.setParameter(new DescribedValue( new DefaultValueInfo("subsurveyCount",Integer.class, "Count of subsurveys with found datacube(s)" ), subsurveyArr.length ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "survey", String.class, "Survey name" ), subsurvey.surveyname ) ); */ StarTable[] tables = tableList.toArray(new StarTable[0]); for ( int i = 0; i < tables.length; i++ ) { VOSerializer.makeSerializer( DataFormat.TABLEDATA, tables[i] ).writeInlineTableElement( out ); } tableList.clear(); out.write( "</RESOURCE>" ); } } out.write( "</VOTABLE>" ); out.flush(); } private static StarTable makeSubsurveyTable(Subsurvey subsurvey) { RowListStarTable table = new RowListStarTable( ObscoreExt.OBSCORE_VLKB_COLINFO ); table.setParameter(new DescribedValue( new DefaultValueInfo("datacubeCount", Integer.class, "Count of all datacubes from VLKB-search" ), subsurvey.datasetArr.length ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "velocity_unit", String.class, "Unit of velocity in FITS header" ), subsurvey.vel_unit ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "survey", String.class, "Survey name" ), subsurvey.surveyname ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "species", String.class, "Species" ), subsurvey.species ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "transition", String.class, "Transition" ), subsurvey.transition ) ); table.setParameter(new DescribedValue( new DefaultValueInfo( "description", String.class, "Reference description" ), subsurvey.description ) ); for(Dataset dataset : subsurvey.datasetArr) { if(dataset.obsCore == null) continue; // FIXME skip mergeable datasets table.addRow( ObscoreExt.obscoreVlkbRow(dataset) ); } return table; } // legacy public static void serializeToLegacyResults( Loading
data-discovery/src/main/java/vlkb/webapi/FormatResponseFilter.java +8 −2 Original line number Diff line number Diff line Loading @@ -156,9 +156,15 @@ public class FormatResponseFilter implements Filter boolean showDuration = false; if(respFormat.contains("mode=bysubsurveys")) XmlSerializer.serializeToVoTableBySubsurveys(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); XmlSerializer.serializeToVoTableBySubsurveys(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); else if(respFormat.contains("mode=bysurveys")) XmlSerializer.serializeToVoTableBySurveys(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); else XmlSerializer.serializeToVoTable(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); XmlSerializer.serializeToVoTable(responseWriter, RESPONSE_ENCODING, searchOutputData,showDuration,startTime_msec); } else { Loading