diff --git a/.gitattributes b/.gitattributes index 0fcdea31bbf6501988a87e7953e00e38be4d752a..2bbab33e186cdad4b17a2085e07cc63325f60263 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1202,6 +1202,8 @@ SAS/OTB/MoM-OTDB-adapter/doc/resources/inherit.gif -text SAS/OTB/MoM-OTDB-adapter/examples/mom-otdb-adapter-keystore.jks -text SAS/OTB/MoM-OTDB-adapter/examples/mom-otdb-adapter-trusted-keystore.jks -text SAS/OTB/MoM-OTDB-adapter/examples/mom-otdb-adapter.cer -text +SAS/OTB/MoM-OTDB-adapter/examples/obs-50-active.xml -text +SAS/OTB/MoM-OTDB-adapter/examples/obs-50-specified.xml -text SAS/OTB/MoM-OTDB-adapter/examples/obs.xml -text SAS/OTB/MoM-OTDB-adapter/examples/observation.xml -text SAS/OTB/MoM-OTDB-adapter/lib/astron-http-utils.jar -text diff --git a/SAS/OTB/MoM-OTDB-adapter/examples/obs-50-active.xml b/SAS/OTB/MoM-OTDB-adapter/examples/obs-50-active.xml new file mode 100644 index 0000000000000000000000000000000000000000..4ecfd6e5641494f2d4e79d2e8e3dba171d2b1501 --- /dev/null +++ b/SAS/OTB/MoM-OTDB-adapter/examples/obs-50-active.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lofar:observation mom2Id="50" + xmlns:lofar="http://www.astron.nl/MoM2-Lofar" + xmlns:mom2="http://www.astron.nl/MoM2" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.astron.nl/MoM2-Lofar C:/java/workspace/MoM-OTDB-adapter/schemas/LofarMoM2.xsd http://www.astron.nl/MoM2 C:/java/workspace/MoM-OTDB-adapter/schemas/MoM2.xsd "> + <currentStatus> + <mom2:activeStatus/> + </currentStatus> + <children/> + <observationAttributes> + <observationId>5005</observationId> + <clock/> + <startTime>2009-09-30T13:54:11</startTime> + <stations/> + </observationAttributes> +</lofar:observation> diff --git a/SAS/OTB/MoM-OTDB-adapter/examples/obs-50-specified.xml b/SAS/OTB/MoM-OTDB-adapter/examples/obs-50-specified.xml new file mode 100644 index 0000000000000000000000000000000000000000..c24c52cdcc789d039df2ea4b59c12b4bc797de5d --- /dev/null +++ b/SAS/OTB/MoM-OTDB-adapter/examples/obs-50-specified.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lofar:observation mom2Id="50" + xmlns:lofar="http://www.astron.nl/MoM2-Lofar" + xmlns:mom2="http://www.astron.nl/MoM2" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.astron.nl/MoM2-Lofar C:/java/workspace/MoM-OTDB-adapter/schemas/LofarMoM2.xsd http://www.astron.nl/MoM2 C:/java/workspace/MoM-OTDB-adapter/schemas/MoM2.xsd "> + <currentStatus> + <mom2:preparedStatus/> + </currentStatus> + <children> + <item index="0"> + <lofar:measurement mom2Id="51" xsi:type="lofar:UVMeasurementType"> + <measurementAttributes> + <ra>85.650575</ra> + <dec>49.852009</dec> + <equinox>J2000</equinox> + <duration>PT10M</duration> + <subbands>255,256,257</subbands> + </measurementAttributes> + </lofar:measurement> + </item> + <item index="1"> + <lofar:measurement mom2Id="52" xsi:type="lofar:UVMeasurementType"> + <measurementAttributes> + <ra>85.650575</ra> + <dec>49.852009</dec> + <equinox>J2000</equinox> + <duration>PT40M</duration> + <subbands>224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288</subbands> + </measurementAttributes> + </lofar:measurement> + </item> + <item index="2"> + <lofar:measurement mom2Id="53" xsi:type="lofar:UVMeasurementType"> + <measurementAttributes> + <ra>85.650575</ra> + <dec>49.852009</dec> + <equinox>J2000</equinox> + <duration>PT10M</duration> + <subbands>224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288</subbands> + </measurementAttributes> + </lofar:measurement> + </item> + </children> + <observationAttributes> + <observationId>5004</observationId> + <antenna>HBA Both</antenna> + <clock> + <channelWidth units="Hz">610.3515625</channelWidth> + <samplesPerSecond>155648</samplesPerSecond> + <subbandWidth units="Hz">156.25</subbandWidth> + <systemClock units="Hz">160</systemClock> + </clock> + <integrationInterval>4</integrationInterval> + <channelsPerSubband>256</channelsPerSubband> + <instrumentFilter>10-90 MHz</instrumentFilter> + <stations> + <station> + <name>CS302</name> + </station> + <station> + <name>CS303</name> + </station> + </stations> + </observationAttributes> +</lofar:observation> diff --git a/SAS/OTB/MoM-OTDB-adapter/examples/observation.xml b/SAS/OTB/MoM-OTDB-adapter/examples/observation.xml index b57ac4d73b7f54cf8f6b965a76a536ea069d9671..d7f510bf0b974357c567a9cb85d7647a719509be 100644 --- a/SAS/OTB/MoM-OTDB-adapter/examples/observation.xml +++ b/SAS/OTB/MoM-OTDB-adapter/examples/observation.xml @@ -1,179 +1,179 @@ -<?xml version="1.0" encoding="UTF-8"?> -<lofar:observation mom2Id="27" - xmlns:lofar="http://www.astron.nl/MoM2-Lofar" - xmlns:mom2="http://www.astron.nl/MoM2" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.astron.nl/MoM2-Lofar http://localhost:8080/mom2lofar/schemas/LofarMoM2.xsd http://www.astron.nl/MoM2 http://localhost:8080/mom2lofar/schemas/MoM2.xsd "> - <name>NGC 0628_obs</name> - <description>Tja, tja</description> - <statusHistory> - <item index="0"> - <mom2ObjectStatus> - <name>Verhoef, Ir. Bastiaan</name> - <roles>Craft User, Reviewer, System Maintenance</roles> - <user id="2"/> - <timeStamp>2009-09-22T12:35:34</timeStamp> - <mom2:describedStatus/> - </mom2ObjectStatus> - </item> - <item index="1"> - <mom2ObjectStatus> - <name>Verhoef, Ir. Bastiaan</name> - <roles>Craft User, Reviewer, System Maintenance</roles> - <user id="2"/> - <timeStamp>2009-09-22T12:04:42</timeStamp> - <mom2:openedStatus/> - </mom2ObjectStatus> - </item> - </statusHistory> - <currentStatus> - <mom2:describedStatus/> - </currentStatus> - <children> - <item index="0"> - <lofar:measurement mom2Id="28" xsi:type="lofar:UVMeasurementType"> - <name>Calibrator 1</name> - <description>asdfasd</description> - <statusHistory> - <item index="0"> - <mom2ObjectStatus> - <name>Verhoef, Ir. Bastiaan</name> - <roles>Craft User, Reviewer, System Maintenance</roles> - <user id="2"/> - <timeStamp>2009-09-22T12:35:34</timeStamp> - <mom2:describedStatus/> - </mom2ObjectStatus> - </item> - <item index="1"> - <mom2ObjectStatus> - <name>Verhoef, Ir. Bastiaan</name> - <roles>Craft User, Reviewer, System Maintenance</roles> - <user id="2"/> - <timeStamp>2009-09-22T12:04:42</timeStamp> - <mom2:openedStatus/> - </mom2ObjectStatus> - </item> - </statusHistory> - <currentStatus> - <mom2:describedStatus/> - </currentStatus> - <measurementAttributes> - <measurementType>Calibration</measurementType> - <specification> - <targetName>3C147</targetName> - <ra>85.650575</ra> - <dec>49.852009</dec> - <equinox>J2000</equinox> - <duration>PT10M</duration> - <subbandsSpecification> - <bandWidth>5000000</bandWidth> - <centralFrequency>50000000</centralFrequency> - <contiguous>false</contiguous> - <subbands>304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336</subbands> - </subbandsSpecification> - </specification> - </measurementAttributes> - </lofar:measurement> - </item> - <item index="1"> - <lofar:measurement mom2Id="29" xsi:type="lofar:UVMeasurementType"> - <name>Target 1</name> - <description>asdfasd</description> - <statusHistory> - <item index="0"> - <mom2ObjectStatus> - <name>Verhoef, Ir. Bastiaan</name> - <roles>Craft User, Reviewer, System Maintenance</roles> - <user id="2"/> - <timeStamp>2009-09-22T12:35:34</timeStamp> - <mom2:describedStatus/> - </mom2ObjectStatus> - </item> - <item index="1"> - <mom2ObjectStatus> - <name>Verhoef, Ir. Bastiaan</name> - <roles>Craft User, Reviewer, System Maintenance</roles> - <user id="2"/> - <timeStamp>2009-09-22T12:04:42</timeStamp> - <mom2:openedStatus/> - </mom2ObjectStatus> - </item> - </statusHistory> - <currentStatus> - <mom2:describedStatus/> - </currentStatus> - <measurementAttributes> - <measurementType>Target</measurementType> - <specification> - <targetName>3C147</targetName> - <ra>85.650575</ra> - <dec>49.852009</dec> - <equinox>J2000</equinox> - <duration>PT40M</duration> - <subbandsSpecification> - <bandWidth>5000000</bandWidth> - <centralFrequency>50000000</centralFrequency> - <contiguous>false</contiguous> - <subbands>304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336</subbands> - </subbandsSpecification> - </specification> - </measurementAttributes> - </lofar:measurement> - </item> - <item index="2"> - <lofar:measurement mom2Id="30" xsi:type="lofar:UVMeasurementType"> - <name>Calibrator 2</name> - <description>asdfasd</description> - <statusHistory> - <item index="0"> - <mom2ObjectStatus> - <name>Verhoef, Ir. Bastiaan</name> - <roles>Craft User, Reviewer, System Maintenance</roles> - <user id="2"/> - <timeStamp>2009-09-22T12:35:34</timeStamp> - <mom2:describedStatus/> - </mom2ObjectStatus> - </item> - <item index="1"> - <mom2ObjectStatus> - <name>Verhoef, Ir. Bastiaan</name> - <roles>Craft User, Reviewer, System Maintenance</roles> - <user id="2"/> - <timeStamp>2009-09-22T12:04:42</timeStamp> - <mom2:openedStatus/> - </mom2ObjectStatus> - </item> - </statusHistory> - <currentStatus> - <mom2:describedStatus/> - </currentStatus> - <measurementAttributes> - <measurementType>Calibration</measurementType> - <specification> - <targetName>3C147</targetName> - <ra>85.650575</ra> - <dec>49.852009</dec> - <equinox>J2000</equinox> - <duration>PT10M</duration> - <subbandsSpecification> - <bandWidth>5000000</bandWidth> - <centralFrequency>50000000</centralFrequency> - <contiguous>false</contiguous> - <subbands>304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336</subbands> - </subbandsSpecification> - </specification> - </measurementAttributes> - </lofar:measurement> - </item> - </children> - <observationAttributes> - <specification> - <antenna>HBA Both</antenna> - <clock>160 MHz</clock> - <instrument>Interferometer</instrument> - <instrumentFilter>10-80 MHz</instrumentFilter> - <integrationInterval>4</integrationInterval> - <stationSet>Custom</stationSet> - <stations>CS302,CS303</stations> - </specification> - </observationAttributes> -</lofar:observation> +<?xml version="1.0" encoding="UTF-8"?> +<lofar:observation mom2Id="50" + xmlns:lofar="http://www.astron.nl/MoM2-Lofar" + xmlns:mom2="http://www.astron.nl/MoM2" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <name>NGC 0628_obs</name> + <description>Tja, tja</description> + <statusHistory> + <item index="0"> + <mom2ObjectStatus> + <name>Verhoef, Ir. Bastiaan</name> + <roles>Craft User, manager, Reviewer, System Maintenance</roles> + <user id="2"/> + <timeStamp>2009-09-30T08:00:42</timeStamp> + <mom2:describedStatus/> + </mom2ObjectStatus> + </item> + <item index="1"> + <mom2ObjectStatus> + <name>Verhoef, Ir. Bastiaan</name> + <roles>Craft User, manager, Reviewer, System Maintenance</roles> + <user id="2"/> + <timeStamp>2009-09-30T08:00:10</timeStamp> + <mom2:openedStatus/> + </mom2ObjectStatus> + </item> + </statusHistory> + <currentStatus> + <mom2:describedStatus/> + </currentStatus> + <children> + <item index="0"> + <lofar:measurement mom2Id="51" xsi:type="lofar:UVMeasurementType"> + <name>Calibrator 1</name> + <description>asdfasd</description> + <statusHistory> + <item index="0"> + <mom2ObjectStatus> + <name>Verhoef, Ir. Bastiaan</name> + <roles>Craft User, manager, Reviewer, System Maintenance</roles> + <user id="2"/> + <timeStamp>2009-09-30T08:00:42</timeStamp> + <mom2:describedStatus/> + </mom2ObjectStatus> + </item> + <item index="1"> + <mom2ObjectStatus> + <name>Verhoef, Ir. Bastiaan</name> + <roles>Craft User, manager, Reviewer, System Maintenance</roles> + <user id="2"/> + <timeStamp>2009-09-30T08:00:10</timeStamp> + <mom2:openedStatus/> + </mom2ObjectStatus> + </item> + </statusHistory> + <currentStatus> + <mom2:describedStatus/> + </currentStatus> + <measurementAttributes> + <measurementType>Calibration</measurementType> + <specification> + <targetName>3C147</targetName> + <ra>85.650575</ra> + <dec>49.852009</dec> + <equinox>J2000</equinox> + <duration>PT10M</duration> + <subbandsSpecification> + <bandWidth units="kHz">100</bandWidth> + <centralFrequency units="MHz">40</centralFrequency> + <contiguous>false</contiguous> + <subbands>255,256,257</subbands> + </subbandsSpecification> + </specification> + </measurementAttributes> + </lofar:measurement> + </item> + <item index="1"> + <lofar:measurement mom2Id="52" xsi:type="lofar:UVMeasurementType"> + <name>Target 1</name> + <description>asdfasd</description> + <statusHistory> + <item index="0"> + <mom2ObjectStatus> + <name>Verhoef, Ir. Bastiaan</name> + <roles>Craft User, manager, Reviewer, System Maintenance</roles> + <user id="2"/> + <timeStamp>2009-09-30T08:00:42</timeStamp> + <mom2:describedStatus/> + </mom2ObjectStatus> + </item> + <item index="1"> + <mom2ObjectStatus> + <name>Verhoef, Ir. Bastiaan</name> + <roles>Craft User, manager, Reviewer, System Maintenance</roles> + <user id="2"/> + <timeStamp>2009-09-30T08:00:10</timeStamp> + <mom2:openedStatus/> + </mom2ObjectStatus> + </item> + </statusHistory> + <currentStatus> + <mom2:describedStatus/> + </currentStatus> + <measurementAttributes> + <measurementType>Target</measurementType> + <specification> + <targetName>3C147</targetName> + <ra>85.650575</ra> + <dec>49.852009</dec> + <equinox>J2000</equinox> + <duration>PT40M</duration> + <subbandsSpecification> + <bandWidth units="MHz">10</bandWidth> + <centralFrequency units="MHz">40</centralFrequency> + <contiguous>false</contiguous> + <subbands>224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288</subbands> + </subbandsSpecification> + </specification> + </measurementAttributes> + </lofar:measurement> + </item> + <item index="2"> + <lofar:measurement mom2Id="53" xsi:type="lofar:UVMeasurementType"> + <name>Calibrator 2</name> + <description>asdfasd</description> + <statusHistory> + <item index="0"> + <mom2ObjectStatus> + <name>Verhoef, Ir. Bastiaan</name> + <roles>Craft User, manager, Reviewer, System Maintenance</roles> + <user id="2"/> + <timeStamp>2009-09-30T08:00:42</timeStamp> + <mom2:describedStatus/> + </mom2ObjectStatus> + </item> + <item index="1"> + <mom2ObjectStatus> + <name>Verhoef, Ir. Bastiaan</name> + <roles>Craft User, manager, Reviewer, System Maintenance</roles> + <user id="2"/> + <timeStamp>2009-09-30T08:00:10</timeStamp> + <mom2:openedStatus/> + </mom2ObjectStatus> + </item> + </statusHistory> + <currentStatus> + <mom2:describedStatus/> + </currentStatus> + <measurementAttributes> + <measurementType>Calibration</measurementType> + <specification> + <targetName>3C147</targetName> + <ra>85.650575</ra> + <dec>49.852009</dec> + <equinox>J2000</equinox> + <duration>PT10M</duration> + <subbandsSpecification> + <bandWidth units="MHz">10</bandWidth> + <centralFrequency units="MHz">40</centralFrequency> + <contiguous>false</contiguous> + <subbands>224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288</subbands> + </subbandsSpecification> + </specification> + </measurementAttributes> + </lofar:measurement> + </item> + </children> + <observationAttributes> + <specification> + <antenna>HBA Both</antenna> + <clock units="MHz">160</clock> + <instrument>Interferometer</instrument> + <instrumentFilter>10-90 MHz</instrumentFilter> + <integrationInterval>4</integrationInterval> + <stationSet>Custom</stationSet> + <stations>CS302,CS303</stations> + </specification> + </observationAttributes> +</lofar:observation> diff --git a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/Beam.java b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/Beam.java index 221ea804455a6938238bb6330315fb30a11ed3c6..d35ad8b56803d9844f0e53e623e8b88845e5e48d 100644 --- a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/Beam.java +++ b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/Beam.java @@ -1,6 +1,8 @@ package nl.astron.lofar.odtb.mom2otdbadapter.data; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; public class Beam implements Serializable { @@ -17,12 +19,12 @@ public class Beam implements Serializable { * Angle 1 (mom2 -> otdb) * e.g. [6.123662, 5.233748, 1459568] */ - private Double ra = null; + private List<Double> raList = new ArrayList<Double>(); /** * Angle 2 (mom2 -> otdb) * e.g. [1.026719, 0,711018, 0384089] */ - private Double dec = null; + private List<Double> decList = new ArrayList<Double>(); /** * Direction type (mom2 -> otdb) @@ -33,15 +35,15 @@ public class Beam implements Serializable { /** * duration */ - private Integer duration; + private List<Integer> durations = new ArrayList<Integer>(); - private Integer angleTime; + private List<Integer> angleTimes= new ArrayList<Integer>(); /** * subbands that must be used (mom2 -> otdb) * e.g. [1,3,5,7] */ - private String subbands; + private List<String> subbands = new ArrayList<String>(); public Beam(LofarObservation observation){ this.parentObservation = observation; @@ -55,53 +57,53 @@ public class Beam implements Serializable { this.mom2Id = mom2Id; } - public Double getRa() { - return ra; + + public String getEquinox() { + return equinox; } - public void setRa(Double ra) { - this.ra = ra; + public void setEquinox(String equinox) { + this.equinox = equinox; } - public Double getDec() { - return dec; + + public List<Double> getRaList() { + return raList; } - public void setDec(Double dec) { - this.dec = dec; + public void setRaList(List<Double> raList) { + this.raList = raList; } - public String getEquinox() { - return equinox; + public List<Double> getDecList() { + return decList; } - public void setEquinox(String equinox) { - this.equinox = equinox; + public void setDecList(List<Double> decList) { + this.decList = decList; } - public Integer getDuration() { - return duration; + public List<Integer> getDurations() { + return durations; } - public void setDuration(Integer duration) { - this.duration = duration; + public void setDurations(List<Integer> durations) { + this.durations = durations; } - - - public Integer getAngleTime() { - return angleTime; + public List<Integer> getAngleTimes() { + return angleTimes; } - public void setAngleTime(Integer angleTime) { - this.angleTime = angleTime; + public void setAngleTimes(List<Integer> angleTimes) { + this.angleTimes = angleTimes; } - public String getSubbands() { + public List<String> getSubbands() { return subbands; } - public void setSubbands(String subbands) { + public void setSubbands(List<String> subbands) { this.subbands = subbands; } diff --git a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/LofarObservation.java b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/LofarObservation.java index 94356da5ca0d6b149dc5e1a7cf7ec0555af5371f..929761030e6cf15a79eec9be3da0669229c78b0f 100644 --- a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/LofarObservation.java +++ b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/LofarObservation.java @@ -52,7 +52,7 @@ public class LofarObservation implements Serializable{ * Stations that belongs to the array configuration (mom2 -> otdb) * e.g. [CS001,CS002] */ - private String stations; + private List<String> stations = new ArrayList<String>(); private String antennaArray; @@ -140,11 +140,11 @@ public class LofarObservation implements Serializable{ public void setStationSet(String stationSet) { this.stationSet = stationSet; } - public String getStations() { + public List<String> getStations() { return stations; } - public void setStations(String stations) { + public void setStations(List<String> stations) { this.stations = stations; } diff --git a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/OTDBRepository.java b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/OTDBRepository.java index 69ccfeb2c53ec62e68a1deed4fbe845867a0ac09..a89871d52bf9b1941cf0bd6b762979dd8532a31e 100644 --- a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/OTDBRepository.java +++ b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/OTDBRepository.java @@ -13,6 +13,7 @@ import nl.astron.lofar.odtb.mom2otdbadapter.config.OTDBConfiguration; import nl.astron.lofar.sas.otb.jotdb2.jConverterInterface; import nl.astron.lofar.sas.otb.jotdb2.jOTDBinterface; import nl.astron.lofar.sas.otb.jotdb2.jOTDBnode; +import nl.astron.lofar.sas.otb.jotdb2.jOTDBtree; import nl.astron.lofar.sas.otb.jotdb2.jTreeMaintenanceInterface; import nl.astron.lofar.sas.otb.jotdb2.jTreeState; import nl.astron.util.AstronConverter; @@ -28,6 +29,58 @@ import org.apache.commons.logging.LogFactory; * */ public class OTDBRepository implements Repository { + private static final String STRING_POINT = "."; + + private static final String CHANNELS_PER_SUBBAND = "channelsPerSubband"; + + private static final String FILE_NAME_MASK = "MSNameMask"; + + private static final String INTEGRATION_STEPS = "integrationSteps"; + + private static final String IONPROC = "IONProc"; + + private static final String OLAP = "OLAP"; + + private static final String ONLINE_CONTROL = "OnlineControl"; + + private static final String OBSERVATION_CONTROL = "ObservationControl"; + + private static final String STATION_LIST = "stationList"; + + private static final String VIRTUAL_INSTRUMENT = "VirtualInstrument"; + + private static final String BEAM_MOM_ID = "momID"; + + private static final String SUBBAND_LIST = "subbandList"; + + private static final String DURATIONS = "durations"; + + private static final String ANGLE_TIMES = "angleTimes"; + + private static final String ANGLE2 = "angle2"; + + private static final String ANGLE1 = "angle1"; + + private static final String DIRECTION_TYPES = "directionTypes"; + + private static final String SAMPLE_CLOCK = "systemClock"; + + private static final String SUBBAND_WIDTH = "subbandWidth"; + + private static final String SAMPLES_PER_SECOND = "samplesPerSecond"; + + private static final String CHANNEL_WIDTH = "channelWidth"; + + private static final String BEAM = "Beam"; + + private static final String CLOCK_MODE = "clockMode"; + + private static final String BAND_FILTER = "bandFilter"; + + private static final String ANTENNA_SET = "antennaSet"; + + private static final String ANTENNA_ARRAY = "antennaArray"; + private Log log = LogFactory.getLog(this.getClass()); private jOTDBinterface remoteOTDB = null; @@ -40,6 +93,8 @@ public class OTDBRepository implements Repository { public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; + public static final String OTDB_DATE_TIME_FORMAT = "yyyy-MMM-dd HH:mm:ss"; + private boolean connected = false; private OTDBConfiguration config; @@ -78,33 +133,49 @@ public class OTDBRepository implements Repository { public void store(LofarObservation lofarObservation) throws RepositoryException { try { init(); - int treeId = tm.copyTemplateTree(config.getTemplateId()); + Integer treeId = lofarObservation.getObservationId(); + if (treeId == null) { + treeId = tm.copyTemplateTree(config.getTemplateId()); + } // int treeId = 6; jOTDBnode observationNode = getObservationNode(treeId); List<jOTDBnode> beams = new ArrayList<jOTDBnode>(); Vector<jOTDBnode> childs = getChilds(observationNode); for (jOTDBnode node : childs) { - if ("antennaArray".equals(node.name)) { + if (ANTENNA_ARRAY.equals(node.name)) { fillNode(node, lofarObservation.getAntennaArray()); - } else if ("antennaSet".equals(node.name)) { + } else if (ANTENNA_SET.equals(node.name)) { fillNode(node, lofarObservation.getAntennaSet()); - } else if ("bandFilter".equals(node.name)) { + } else if (BAND_FILTER.equals(node.name)) { fillNode(node, lofarObservation.getBandFilter()); - } else if ("clockMode".equals(node.name)) { + } else if (CLOCK_MODE.equals(node.name)) { fillNode(node, lofarObservation.getClockMode()); - } else if ("Beam".equals(node.name)) { + } else if (BEAM.equals(node.name)) { beams.add(node); - } else if ("VirtualInstrument".equals(node.name)) { + } else if (VIRTUAL_INSTRUMENT.equals(node.name)) { jOTDBnode stationSetNode = getNode(node, "stationSet"); fillNode(stationSetNode, lofarObservation.getStationSet()); - jOTDBnode stationsNode = getNode(node, "stationList"); + jOTDBnode stationsNode = getNode(node, STATION_LIST); fillNode(stationsNode, lofarObservation.getStations()); + } else if (OBSERVATION_CONTROL.equals(node.name)) { + jOTDBnode onlineControlNode = getNode(node, ONLINE_CONTROL); + if (onlineControlNode != null) { + jOTDBnode olapNode = getNode(onlineControlNode, OLAP); + if (olapNode != null) { + jOTDBnode ionProcNode = getNode(olapNode, IONPROC); + if (ionProcNode != null) { + jOTDBnode integrationStepsNode = getNode(olapNode, INTEGRATION_STEPS); + fillNode(integrationStepsNode, lofarObservation.getIntegrationInterval().toString()); + } + } + } + } } if (beams.size() > 0) { for (int i = 1; i < beams.size(); i++) { - tm.deleteNode(beams.get(0)); + tm.deleteNode(beams.get(i)); } jOTDBnode aDefaultNode = beams.get(0); @@ -117,16 +188,20 @@ public class OTDBRepository implements Repository { Vector<jOTDBnode> beamChilds = getChilds(beamNode); // get all the params per child for (jOTDBnode beamChild : beamChilds) { - if ("directionTypes".equals(beamChild.name)) { + if (DIRECTION_TYPES.equals(beamChild.name)) { fillNode(beamChild, beam.getEquinox()); - } else if ("angle1".equals(beamChild.name)) { - fillNode(beamChild, AstronConverter.toString(beam.getRa())); - } else if ("angle2".equals(beamChild.name)) { - fillNode(beamChild, AstronConverter.toString(beam.getDec())); - } else if ("angleTimes".equals(beamChild.name)) { - fillNode(beamChild, AstronConverter.toString(beam.getDuration())); - } else if ("subbandList".equals(beamChild.name)) { + } else if (ANGLE1.equals(beamChild.name)) { + fillNode(beamChild, beam.getRaList()); + } else if (ANGLE2.equals(beamChild.name)) { + fillNode(beamChild, beam.getDecList()); + } else if (ANGLE_TIMES.equals(beamChild.name)) { + fillNode(beamChild, beam.getAngleTimes()); + } else if (DURATIONS.equals(beamChild.name)) { + fillNode(beamChild, beam.getDurations()); + } else if (SUBBAND_LIST.equals(beamChild.name)) { fillNode(beamChild, beam.getSubbands()); + } else if (BEAM_MOM_ID.equals(beamChild.name)) { + fillNode(beamChild, beam.getMom2Id().toString()); } saveNode(beamChild); } @@ -146,6 +221,16 @@ public class OTDBRepository implements Repository { } } + @SuppressWarnings("unchecked") + private jOTDBnode getClockModeNode(int treeId, String clockMode) throws RemoteException { + jOTDBnode node = null; + Vector<jOTDBnode> childs = tm.getItemList(treeId, clockMode.substring(2)); + if (childs.size() > 0) { + node = childs.get(0); + } + return node; + } + @SuppressWarnings("unchecked") private Vector<jOTDBnode> getChilds(jOTDBnode node) throws RemoteException { return tm.getItemList(node.treeID(), node.nodeID(), 1); @@ -155,7 +240,7 @@ public class OTDBRepository implements Repository { @SuppressWarnings("unchecked") private jOTDBnode getObservationNode(int treeId) throws RemoteException { jOTDBnode node = null; - Vector<jOTDBnode> childs = tm.getItemList(treeId, "Observation"); + Vector<jOTDBnode> childs = tm.getItemList(treeId, "%Observation"); if (childs.size() > 0) { node = childs.get(0); } @@ -178,6 +263,61 @@ public class OTDBRepository implements Repository { } } + private void fillNode(jOTDBnode node, List<?> values) throws RemoteException { + + if (values != null && node != null) { + String value = "["; + for (int i = 0; i < values.size(); i++) { + if (i > 0) { + value += ","; + } + value += values.get(i); + } + value += "]"; + node.limits = value; + saveNode(node); + } + } + + private void fillDoubleList(jOTDBnode node, List<Double> values) throws RemoteException { + + if (values != null && node != null) { + String value = node.limits.replaceAll("[\\]\\[ ]", ""); + String[] array = value.split(","); + for (String arrayItem : array) { + Double doubleValue = AstronConverter.toDouble(arrayItem); + if (doubleValue != null) { + values.add(doubleValue); + } + } + } + } + + private void fillStringList(jOTDBnode node, List<String> values) throws RemoteException { + + if (values != null && node != null) { + String value = node.limits.replaceAll("[\\]\\[ ]", ""); + String[] array = value.split(","); + for (String arrayItem : array) { + values.add(arrayItem); + } + } + } + + private void fillIntegerList(jOTDBnode node, List<Integer> values) throws RemoteException { + + if (values != null && node != null) { + String value = node.limits.replaceAll("[\\]\\[ ]", ""); + String[] array = value.split(","); + for (String arrayItem : array) { + Integer intValue = AstronConverter.toInteger(arrayItem); + if (intValue != null) { + values.add(intValue); + } + } + } + } + /** * Stores parameter in the tree by given parent node * @@ -212,13 +352,14 @@ public class OTDBRepository implements Repository { * @return node * @throws RemoteException */ - protected jOTDBnode getNode(jOTDBnode parentNode, String paramName) throws RemoteException { + @SuppressWarnings("unchecked") + private jOTDBnode getNode(jOTDBnode parentNode, String paramName) throws RemoteException { jOTDBnode node = null; /* * if no parent node, do not retrieve something */ if (parentNode != null) { - Vector vector = tm.getItemList(parentNode.treeID(), paramName); + Vector<jOTDBnode> vector = tm.getItemList(parentNode.treeID(), paramName); for (int i = 0; i < vector.size(); i++) { node = (jOTDBnode) vector.get(i); /* @@ -234,6 +375,23 @@ public class OTDBRepository implements Repository { return node; } + private String getValue(jOTDBnode parentNode, String paramName) throws RemoteException { + jOTDBnode node = getNode(parentNode, paramName); + if (node != null) { + return node.limits; + } else { + return null; + } + } + + private String getValue(jOTDBnode node) throws RemoteException { + if (node != null) { + return node.limits; + } else { + return null; + } + } + /** * Retrieve lates changes between start- en endtime * @@ -244,42 +402,44 @@ public class OTDBRepository implements Repository { * @return List of lofarObservation objects * @throws RemoteException */ - public List getLatestChanges(Date startDate, Date endDate) throws RepositoryException { + @SuppressWarnings("unchecked") + public List<LofarObservation> getLatestChanges(Date startDate, Date endDate) throws RepositoryException { try { init(); String startTime = AstronConverter.toDateString(startDate, DATE_TIME_FORMAT); String endTime = AstronConverter.toDateString(endDate, DATE_TIME_FORMAT); log.info("Retrieve latest changes between:" + startTime + " and " + endTime); remoteOTDB.connect(); - List result = new ArrayList(); - Vector stateList = remoteOTDB.getStateList(0, false, startTime, endTime); + List<LofarObservation> result = new ArrayList<LofarObservation>(); + Vector<jTreeState> stateList = remoteOTDB.getStateList(0, false, startTime, endTime); + for (int i = 0; i < stateList.size(); i++) { jTreeState state = (jTreeState) stateList.get(i); - + jOTDBtree treeInfo = remoteOTDB.getTreeInfo(state.treeID, false); String status = converter.getTreeState(state.newState); - log.info("momId: " + state.momID + " status:" + status + " statusId:" + state.newState); + log.info("treeId: " + state.treeID + " momId: " + state.momID + " status:" + status + " statusId:" + + state.newState); if (state.momID > 0 && isStatusThatMustBeExported(status)) { - LofarObservation observation = new LofarObservation(); - observation.setMom2Id(state.momID); - observation.setStatus(status); - // observation.setTimeStamp(state.timestamp); - jOTDBnode observationNode = tm.getTopNode(state.treeID); - jOTDBnode measurementsNode = getNode(observationNode, "measurementMom2Ids"); - // observation.setMeasurementMom2Ids(measurementsNode.limits); - // if (status.equals("finished")){ - // jOTDBnode viNode = getNode(observationNode, "VI1"); - // jOTDBnode angle1 = getNode(viNode, "angle1"); - // jOTDBnode angle2 = getNode(viNode, "angle2"); - // jOTDBnode angleTimes = getNode(viNode, "angleTimes"); - // observation.setAngle1(angle1.limits); - // observation.setAngle2(angle2.limits); - // observation.setAngleTimes(angleTimes.limits); - // jOTDBtree treeInfo = - // remoteOTDB.getTreeInfo(state.treeID,false); - // observation.setStartTime(treeInfo.starttime); - // observation.setEndTime(treeInfo.stoptime); - // } - result.add(observation); + LofarObservation lofarObservation = new LofarObservation(); + lofarObservation.setMom2Id(state.momID); + lofarObservation.setObservationId(state.treeID); + lofarObservation.setStatus(status); + // it must be a template + if (treeInfo.originalTree == config.getTemplateId()) { + jOTDBnode observationNode = getObservationNode(state.treeID); + fillLofarObservation("", observationNode, lofarObservation); + + } else { + + jOTDBnode observationNode = getObservationNode(state.treeID); + String prefix = observationNode.name + STRING_POINT; + fillLofarObservation(prefix, observationNode, lofarObservation); + + lofarObservation + .setStartTime(AstronConverter.toDate(treeInfo.starttime, OTDB_DATE_TIME_FORMAT)); + lofarObservation.setEndTime(AstronConverter.toDate(treeInfo.stoptime, OTDB_DATE_TIME_FORMAT)); + } + result.add(lofarObservation); } } @@ -292,6 +452,92 @@ public class OTDBRepository implements Repository { throw new RepositoryException(e); } } + private void fillLofarObservation(String prefix, jOTDBnode observationNode, LofarObservation lofarObservation) throws RemoteException{ + List<jOTDBnode> beams = new ArrayList<jOTDBnode>(); + Vector<jOTDBnode> childs = getChilds(observationNode); + for (jOTDBnode node : childs) { + if (ANTENNA_ARRAY.equals(node.name)) { + lofarObservation.setAntennaArray(getValue(node)); + } else if (ANTENNA_SET.equals(node.name)) { + lofarObservation.setAntennaSet(getValue(node)); + } else if (BAND_FILTER.equals(node.name)) { + lofarObservation.setBandFilter(getValue(node)); + } else if (CLOCK_MODE.equals(node.name)) { + String clockMode = getValue(node); + jOTDBnode clockNode = getClockModeNode(lofarObservation.getObservationId(), clockMode); + Vector<jOTDBnode> clockNodeChilds = getChilds(clockNode); + for (jOTDBnode clockNodeChild : clockNodeChilds) { + if (CHANNEL_WIDTH.equals(clockNodeChild.name)) { + lofarObservation.setChannelWidth(AstronConverter + .toDouble(getValue(clockNodeChild))); + } else if (SAMPLES_PER_SECOND.equals(clockNodeChild.name)) { + lofarObservation.setSamplesPerSecond(AstronConverter + .toInteger(getValue(clockNodeChild))); + } else if (SUBBAND_WIDTH.equals(clockNodeChild.name)) { + lofarObservation.setSubbandWidth(AstronConverter + .toDouble(getValue(clockNodeChild))); + } else if (SAMPLE_CLOCK.equals(clockNodeChild.name)) { + lofarObservation.setClockFrequency(AstronConverter + .toDouble(getValue(clockNodeChild))); + } + } + } else if (CHANNELS_PER_SUBBAND.equals(node.name)) { + lofarObservation.setChannelsPerSubband(AstronConverter.toInteger(getValue(node))); + } else if (FILE_NAME_MASK.equals(node.name)) { + lofarObservation.setFileNameMask((getValue(node))); + } else if (BEAM.equals(node.name)) { + beams.add(node); + } else if (VIRTUAL_INSTRUMENT.equals(node.name)) { + jOTDBnode stationsNode = getNode(node, STATION_LIST); + fillStringList(stationsNode, lofarObservation.getStations()); + } else if (OBSERVATION_CONTROL.equals(node.name)) { + jOTDBnode onlineControlNode = getNode(node, ONLINE_CONTROL); + if (onlineControlNode != null) { + jOTDBnode olapNode = getNode(onlineControlNode, OLAP); + if (olapNode != null) { + jOTDBnode ionProcNode = getNode(olapNode, IONPROC); + if (ionProcNode != null) { + lofarObservation.setIntegrationInterval(AstronConverter.toDouble(getValue( + olapNode, INTEGRATION_STEPS))); + } + } + } + + } + } + + if (beams.size() > 0) { + // remove default beam + beams.remove(0); + for (jOTDBnode beamNode : beams) { + Beam beam = new Beam(lofarObservation); + Vector<jOTDBnode> beamChilds = getChilds(beamNode); + + // get all the params per child + for (jOTDBnode beamChild : beamChilds) { + + if (DIRECTION_TYPES.equals(beamChild.name)) { + beam.setEquinox(getValue(beamChild)); + } else if (ANGLE1.equals(beamChild.name)) { + fillDoubleList(beamChild, beam.getRaList()); + } else if (ANGLE2.equals(beamChild.name)) { + fillDoubleList(beamChild, beam.getDecList()); + } else if (ANGLE_TIMES.equals(beamChild.name)) { + fillIntegerList(beamChild, beam.getAngleTimes()); + } else if (DURATIONS.equals(beamChild.name)) { + fillIntegerList(beamChild, beam.getDurations()); + } else if (SUBBAND_LIST.equals(beamChild.name)) { + fillStringList(beamChild, beam.getSubbands()); + } else if (BEAM_MOM_ID.equals(beamChild.name)) { + beam.setMom2Id(AstronConverter.toInteger(getValue(beamChild))); + } + + } + lofarObservation.getBeams().add(beam); + } + + } + } /** * Checkes if observation with a status must be exported to MoM diff --git a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/StubRepository.java b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/StubRepository.java index 61e56e32dd2d9b5920e76beab487726230a42f8b..58e637f6780544feab4a5b923964bf764fab5fdf 100644 --- a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/StubRepository.java +++ b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/data/StubRepository.java @@ -27,7 +27,7 @@ public class StubRepository implements Repository { }else if (Mom2OtdbConverter.OTDB_FINISHED_STATUS.equals(observation.getStatus())){ int duration = 0; for (Beam beam : observation.getBeams()) { - duration += beam.getDuration(); + duration += beam.getDurations().get(0); } Date endTime = (Date) observation.getStartTime().clone(); endTime.setSeconds(duration); diff --git a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/XMLParser.java b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/XMLParser.java index e98672842c970dd3870e96d6185ad8bcbd44b3f1..a6f11355daf9c25cb74ebe6fa3a6315a502dd2c8 100644 --- a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/XMLParser.java +++ b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/XMLParser.java @@ -66,8 +66,8 @@ public class XMLParser { } int offSet = 0; for (Beam beam: lofarObservation.getBeams()){ - beam.setAngleTime(offSet); - offSet += beam.getDuration(); + beam.getAngleTimes().add(offSet); + offSet += beam.getDurations().get(0); } return lofarObservation; } @@ -93,6 +93,10 @@ public class XMLParser { if (elements.containsKey(XMLConstants.CLOCK)) { lofarObservation.setClockMode(Mom2OtdbConverter.getOTDBClockMode(getMHzFrequency(elements.get(XMLConstants.CLOCK)))); } + if (elements.containsKey(XMLConstants.INTEGRATION_INTERVAL)) { + lofarObservation.setIntegrationInterval(AstronConverter.toDouble(getValue(elements + .get(XMLConstants.INTEGRATION_INTERVAL)))); + } if (elements.containsKey(XMLConstants.INSTRUMENT_FILTER)) { lofarObservation.setBandFilter(Mom2OtdbConverter.getOTDBBandFilter(getValue(elements .get(XMLConstants.INSTRUMENT_FILTER)), lofarObservation.getAntennaArray())); @@ -101,9 +105,9 @@ public class XMLParser { lofarObservation.setStationSet(getValue(elements.get(XMLConstants.STATION_SET))); } if (elements.containsKey(XMLConstants.STATIONS)) { - lofarObservation.setStations(getValue(elements.get(XMLConstants.STATIONS))); - if (lofarObservation.getStations() != null) { - lofarObservation.setStations("[" + lofarObservation.getStations() + "]"); + String[] stations = getValue(elements.get(XMLConstants.STATIONS)).split(","); + for(String station: stations){ + lofarObservation.getStations().add(station); } } @@ -241,16 +245,16 @@ public class XMLParser { Element specification = (Element) specificationList.item(0); Map<String, Element> elements = getElementMap(specification.getChildNodes()); if (elements.containsKey(XMLConstants.RA)) { - beam.setRa(AstronConverter.toDouble(getValue(elements.get(XMLConstants.RA)))); + beam.getRaList().add(AstronConverter.toDouble(getValue(elements.get(XMLConstants.RA)))); } if (elements.containsKey(XMLConstants.DEC)) { - beam.setDec(AstronConverter.toDouble(getValue(elements.get(XMLConstants.DEC)))); + beam.getDecList().add(AstronConverter.toDouble(getValue(elements.get(XMLConstants.DEC)))); } if (elements.containsKey(XMLConstants.EQUINOX)) { beam.setEquinox(getValue(elements.get(XMLConstants.EQUINOX))); } if (elements.containsKey(XMLConstants.DURATION)) { - beam.setDuration(AstronConverter.convertXMLDurationToSeconds(getValue(elements + beam.getDurations().add(AstronConverter.convertXMLDurationToSeconds(getValue(elements .get(XMLConstants.DURATION)))); } if (elements.containsKey(XMLConstants.SUBBANDS_SPECIFICATION)) { @@ -258,7 +262,11 @@ public class XMLParser { Map<String, Element> subbandsSpecificationsElements = getElementMap(subbandsSpecificationsElement .getChildNodes()); if (subbandsSpecificationsElements.containsKey(XMLConstants.SUBBANDS)) { - beam.setSubbands("[" + getValue(subbandsSpecificationsElements.get(XMLConstants.SUBBANDS)) + "]"); + String[] subbands = getValue(subbandsSpecificationsElements.get(XMLConstants.SUBBANDS)).split(","); + for(String subband: subbands){ + beam.getSubbands().add(subband); + } + } } diff --git a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/otdblistener/XMLGenerator.java b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/otdblistener/XMLGenerator.java index 174150b89f5f55f273723bd61f6fe7a31fd919f6..e4f1b25fefcf4f6c9beebe654a67df201be10386 100644 --- a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/otdblistener/XMLGenerator.java +++ b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/otdblistener/XMLGenerator.java @@ -26,6 +26,8 @@ import org.w3c.dom.Element; */ public class XMLGenerator { + + private static final String STATION_NAME = "name"; private static final String MOM2_LOFAR_PREFIX = "lofar"; @@ -96,8 +98,8 @@ public class XMLGenerator { xmlBuilder.addTextElement(clockElement, "samplesPerSecond", observation.getSamplesPerSecond()); xmlBuilder.addFrequencyElement(clockElement, "subbandWidth", observation.getSubbandWidth()); xmlBuilder.addFrequencyElement(clockElement, "systemClock", observation.getClockFrequency()); - xmlBuilder.addTextElement(observationAttributes, "integrationInterval", observation.getIntegrationInterval()); - xmlBuilder.addTextElement(observationAttributes, "channelsPerSubband", observation.getChannelsPerSubband()); + xmlBuilder.addTextElement(observationAttributes, XMLConstants.INTEGRATION_INTERVAL, observation.getIntegrationInterval()); + xmlBuilder.addTextElement(observationAttributes, "channelsPerSubband", observation.getChannelsPerSubband()); xmlBuilder.addTextElement(observationAttributes, XMLConstants.INSTRUMENT_FILTER, Mom2OtdbConverter .getMom2InstrumentFilter(observation.getBandFilter())); Date startTime = observation.getStartTime(); @@ -107,7 +109,7 @@ public class XMLGenerator { if (observation.getStations() != null) { Element stationsElement = xmlBuilder.addElement(observationAttributes, XMLConstants.STATIONS); - for (String station : Mom2OtdbConverter.getStringArray(observation.getStations())) { + for (String station : observation.getStations()) { Element stationElement = xmlBuilder.addElement(stationsElement, XMLConstants.STATION); xmlBuilder.addTextElement(stationElement, STATION_NAME, station); } @@ -129,40 +131,45 @@ public class XMLGenerator { xmlBuilder.addTypeAttributeToElement(measurementElement, XMLConstants.MOM2_LOFAR_NAMESPACE, XMLConstants.UVMEASUREMENT_TYPE); xmlBuilder.addAttributeToElement(measurementElement, XMLConstants.MOM2_ID, beam.getMom2Id().toString()); - String[] subbands = Mom2OtdbConverter.getStringArray(beam.getSubbands()); + if (Mom2OtdbConverter.OTDB_FINISHED_STATUS.equals(beam.getParentObservation().getStatus())) { String fileMask = beam.getParentObservation().getFileNameMask(); fileMask = fileMask.substring(fileMask.lastIndexOf("/") + 1); fileMask = fileMask.replaceAll("\\$\\{OBSERVATION\\}", beam.getParentObservation().getObservationId() .toString()); fileMask = fileMask.replaceAll("\\$\\{BEAM\\}", index + ""); - if (subbands.length > 0) { + if (beam.getSubbands().size() > 0) { Element resultDataProducts = xmlBuilder.addElement(measurementElement, "resultDataProducts"); - for (int i = 0; i < subbands.length; i++) { + for (int i = 0; i < beam.getSubbands().size(); i++) { Element uvDataProduct = xmlBuilder.addIndexedElement(resultDataProducts, "uvDataProduct"); xmlBuilder.addTextElement(uvDataProduct, "name", fileMask.replaceAll("\\$\\{SUBBAND\\}", i + "")); - xmlBuilder.addTextElement(uvDataProduct, "fileFormat", Mom2OtdbConverter.getMom2DPFileType(fileMask)); + xmlBuilder.addTextElement(uvDataProduct, "fileFormat", Mom2OtdbConverter + .getMom2DPFileType(fileMask)); xmlBuilder.addTextElement(uvDataProduct, "subband", i); - xmlBuilder.addTextElement(uvDataProduct, "stationSubband", subbands[i]); + xmlBuilder.addTextElement(uvDataProduct, "stationSubband", beam.getSubbands().get(i)); } } } Element measurementAttributes = xmlBuilder.addElement(measurementElement, XMLConstants.MEASUREMENT_ATTRIBUTES); - xmlBuilder.addTextElement(measurementAttributes, XMLConstants.RA, beam.getRa()); - xmlBuilder.addTextElement(measurementAttributes, XMLConstants.DEC, beam.getDec()); - xmlBuilder.addTextElement(measurementAttributes, XMLConstants.EQUINOX, beam.getEquinox()); - xmlBuilder.addDurationElement(measurementAttributes, XMLConstants.DURATION, beam.getDuration()); - Date startTime = beam.getParentObservation().getStartTime(); - if (startTime != null) { - Calendar cal = Calendar.getInstance(); - cal.setTime(startTime); - cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) + beam.getAngleTime()); - xmlBuilder.addTextDateTimeElement(measurementAttributes, XMLConstants.START_TIME, cal.getTime()); - if (beam.getParentObservation().getEndTime() != null) { - cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) + beam.getDuration()); - xmlBuilder.addTextDateTimeElement(measurementAttributes, XMLConstants.END_TIME, cal.getTime()); + if (beam.getRaList().size() > 0 && beam.getDecList().size() > 0 && beam.getDurations().size() > 0 + && beam.getAngleTimes().size() > 0) { + xmlBuilder.addTextElement(measurementAttributes, XMLConstants.RA, beam.getRaList().get(0)); + + xmlBuilder.addTextElement(measurementAttributes, XMLConstants.DEC, beam.getDecList().get(0)); + xmlBuilder.addTextElement(measurementAttributes, XMLConstants.EQUINOX, beam.getEquinox()); + xmlBuilder.addDurationElement(measurementAttributes, XMLConstants.DURATION, beam.getDurations().get(0)); + Date startTime = beam.getParentObservation().getStartTime(); + if (startTime != null) { + Calendar cal = Calendar.getInstance(); + cal.setTime(startTime); + cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) + beam.getAngleTimes().get(0)); + xmlBuilder.addTextDateTimeElement(measurementAttributes, XMLConstants.START_TIME, cal.getTime()); + if (beam.getParentObservation().getEndTime() != null) { + cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) + beam.getDurations().get(0)); + xmlBuilder.addTextDateTimeElement(measurementAttributes, XMLConstants.END_TIME, cal.getTime()); + } } } xmlBuilder.addTextElement(measurementAttributes, XMLConstants.SUBBANDS, Mom2OtdbConverter.getMom2Subbands(beam @@ -190,4 +197,5 @@ public class XMLGenerator { } return result + XMLConstants.STATUS_SUFFIX; } + } diff --git a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/util/Mom2OtdbConverter.java b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/util/Mom2OtdbConverter.java index bd3c9ba66c0e4ee8d42fbaa8b5736ecc8b84df8b..6f6da7bd55ad67c2d7668aa6b7fec7d37b1a72db 100644 --- a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/util/Mom2OtdbConverter.java +++ b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/util/Mom2OtdbConverter.java @@ -1,19 +1,18 @@ package nl.astron.lofar.odtb.mom2otdbadapter.util; import java.text.DecimalFormat; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; - - /** * Converts mom2 values to otdb values * * @author Bastiaan Verhoef - * + * */ public class Mom2OtdbConverter { - + private static final String FITS = "FITS"; private static final String HDF5 = "HDF5"; private static final String AIPS_CASA = "AIPS++/CASA"; @@ -23,12 +22,12 @@ public class Mom2OtdbConverter { public static final String OTDB_APPROVED_STATUS = "approved"; public static final String OTDB_BEING_SPECIFIED_STATUS = "being specified"; public static final String MOM2_DESCRIBED_STATUS = "described"; - public static final String MOM2_SPECIFIED_STATUS = "specified"; + public static final String MOM2_SPECIFIED_STATUS = "specified"; public static final String MOM2_ACTIVE_STATUS = "active"; public static final String MOM2_PREPARED_STATUS = "prepared"; public static final String MOM2_FAILED_STATUS = "failed"; public static final String MOM2_ABORTED_STATUS = "aborted"; - public static final String MOM2_SUCCESSFUL_STATUS = "successful"; + public static final String MOM2_SUCCESSFUL_STATUS = "successful"; public static final String OTDB_FAILED_STATUS = "failed"; public static final String OTDB_ABORTED_STATUS = "aborted"; public static final String OTDB_FINISHED_STATUS = "finished"; @@ -37,21 +36,23 @@ public class Mom2OtdbConverter { private static final String MHZ_SUFFIX = " MHz"; private static final String CLOCK_MODE = "<<Clock"; private static final DecimalFormat CLOCK_FORMATTER = new DecimalFormat("000"); - private static final Pattern INSTRUMENT_FILTER_PATTERN = Pattern.compile("(\\d+-\\d+)" + MHZ_SUFFIX); - public static String getOTDBClockMode(Double clock){ - + private static final Pattern INSTRUMENT_FILTER_PATTERN = Pattern.compile("(\\d+-\\d+)" + MHZ_SUFFIX); + + public static String getOTDBClockMode(Double clock) { + return CLOCK_MODE + CLOCK_FORMATTER.format(clock); } - - public static String getOTDBAntennaArray(String antenna){ - return antenna.substring(0,3).toUpperCase(); - } - public static String getOTDBAntennaSet(String antenna){ - return antenna.toUpperCase().replace(' ','_'); + public static String getOTDBAntennaArray(String antenna) { + return antenna.substring(0, 3).toUpperCase(); + } + + public static String getOTDBAntennaSet(String antenna) { + return antenna.toUpperCase().replace(' ', '_'); } - public static String getOTDBBandFilter(String instrumentFilter, String antennaArray){ + + public static String getOTDBBandFilter(String instrumentFilter, String antennaArray) { String result = antennaArray + "_"; Matcher filterMatcher = INSTRUMENT_FILTER_PATTERN.matcher(instrumentFilter); filterMatcher.find(); @@ -61,50 +62,67 @@ public class Mom2OtdbConverter { /** * Convert OTDB status from mom status - * @param status Mom2 status + * + * @param status + * Mom2 status * @return OTDB status */ - public static String getOTDBStatus(String status){ - if (status.equals(MOM2_DESCRIBED_STATUS)){ + public static String getOTDBStatus(String status) { + if (status.equals(MOM2_DESCRIBED_STATUS)) { return OTDB_BEING_SPECIFIED_STATUS; - }else if (status.equals(MOM2_SPECIFIED_STATUS)){ + } else if (status.equals(MOM2_SPECIFIED_STATUS)) { return OTDB_APPROVED_STATUS; } return null; } - - public static String getMom2Antenna(String antennaSet){ - String result = antennaSet.replace('_',' '); - int n = result.indexOf(' '); - n = n + 2; - result = result.substring(0,n) + result.substring(n, result.length()).toLowerCase(); - return result; + + public static String getMom2Antenna(String antennaSet) { + if (antennaSet != null) { + String result = antennaSet.replace('_', ' '); + int n = result.indexOf(' '); + n = n + 2; + result = result.substring(0, n) + result.substring(n, result.length()).toLowerCase(); + return result; + } + return null; } - - public static String getMom2InstrumentFilter(String bandFilter){ - return bandFilter.substring(4).replace('_', '-') + MHZ_SUFFIX; + + public static String getMom2InstrumentFilter(String bandFilter) { + if (bandFilter != null) { + return bandFilter.substring(4).replace('_', '-') + MHZ_SUFFIX; + } + return null; } - public static String[] getStringArray(String string){ - String temp = string.replaceAll("[\\]\\[ ]" , ""); + public static String[] getStringArray(String string) { + String temp = string.replaceAll("[\\]\\[ ]", ""); return temp.split(","); } - public static String getMom2Subbands(String string){ - return string.replaceAll("[\\]\\[]" , ""); + + public static String getMom2Subbands(List<String> subbands) { + String result = ""; + for (int i = 0; i < subbands.size(); i++) { + if (i > 0) { + result += ","; + } + result += subbands.get(i); + } + return result; } - public static String getMom2DPFileType(String fileMask){ - if (fileMask.endsWith(MS_EXTENSION)){ + + public static String getMom2DPFileType(String fileMask) { + if (fileMask.endsWith(MS_EXTENSION)) { return AIPS_CASA; - }else if(fileMask.endsWith(H5_EXTENSION)){ + } else if (fileMask.endsWith(H5_EXTENSION)) { return HDF5; - }else if(fileMask.endsWith(FITS_EXTENSION)){ + } else if (fileMask.endsWith(FITS_EXTENSION)) { return FITS; } return null; } public static String getMom2Status(String code) { - if (code.equals(OTDB_APPROVED_STATUS)){ + if (code.equals(OTDB_APPROVED_STATUS)) { return MOM2_SPECIFIED_STATUS; } if (code.equals(OTDB_SPECIFIED_STATUS)) { diff --git a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/util/XMLConstants.java b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/util/XMLConstants.java index c74e045e42bef50d2140db2c22fb4f959b7b0b5f..434591006c01aacc2ce75ddc8ddbe125d5fda4de 100644 --- a/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/util/XMLConstants.java +++ b/SAS/OTB/MoM-OTDB-adapter/src/nl/astron/lofar/odtb/mom2otdbadapter/util/XMLConstants.java @@ -13,6 +13,8 @@ public final class XMLConstants { public static final String STATION_SET = "stationSet"; + public static final String INTEGRATION_INTERVAL = "integrationInterval"; + public static final String INSTRUMENT_FILTER = "instrumentFilter"; public static final String CLOCK = "clock"; diff --git a/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/data/OTDBRepositoryTest.java b/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/data/OTDBRepositoryTest.java index 69e94785a3f159e59c526094e74567610415a98a..6531c90f116f1587f3659b381ee8364fc955312b 100644 --- a/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/data/OTDBRepositoryTest.java +++ b/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/data/OTDBRepositoryTest.java @@ -15,38 +15,42 @@ public class OTDBRepositoryTest { OTDBConfiguration config =new OTDBConfiguration(); config.setRmiHost("lofar17"); config.setRmiPort(10500); + config.setTemplateId(5001); repository = new OTDBRepository(config); } - @Test - public void testStore() throws RepositoryException{ - LofarObservation lofarObservation = new LofarObservation(); - lofarObservation.setMom2Id(3); - lofarObservation.setStatus("being specified"); - lofarObservation.setAntennaArray("HBA"); - lofarObservation.setAntennaSet("HBA_TWO"); - lofarObservation.setBandFilter("HBA_100_190"); - lofarObservation.setClockMode("<<Clock200"); - lofarObservation.setStationSet("Custom"); - lofarObservation.setStations("[CS302, CS010]"); - Beam beam = new Beam(lofarObservation); - beam.setRa(85.650575); - beam.setDec(49.852009); - beam.setEquinox("J2000"); - beam.setDuration(423); - beam.setSubbands("[123,124]"); - lofarObservation.getBeams().add(beam); - beam = new Beam(lofarObservation); - beam.setRa(85.650575); - beam.setDec(49.852009); - beam.setEquinox("J2000"); - beam.setDuration(42); - beam.setSubbands("[1,2,3,4]"); - lofarObservation.getBeams().add(beam); - repository.store(lofarObservation); - - } +// @Test +// public void testStore() throws RepositoryException{ +// LofarObservation lofarObservation = new LofarObservation(); +// lofarObservation.setMom2Id(3); +// lofarObservation.setStatus("being specified"); +// lofarObservation.setAntennaArray("HBA"); +// lofarObservation.setAntennaSet("HBA_TWO"); +// lofarObservation.setBandFilter("HBA_100_190"); +// lofarObservation.setClockMode("<<Clock200"); +// lofarObservation.setStationSet("Custom"); +// lofarObservation.setStations("[CS302, CS010]"); +// lofarObservation.setIntegrationInterval(3d); +// Beam beam = new Beam(lofarObservation); +// beam.setRa(85.650575); +// beam.setDec(49.852009); +// beam.setEquinox("J2000"); +// beam.setAngleTime(0); +// beam.setDuration(423); +// beam.setSubbands("[123,124]"); +// lofarObservation.getBeams().add(beam); +// beam = new Beam(lofarObservation); +// beam.setRa(85.650575); +// beam.setDec(49.852009); +// beam.setEquinox("J2000"); +// beam.setAngleTime(423); +// beam.setDuration(42); +// beam.setSubbands("[1,2,3,4]"); +// lofarObservation.getBeams().add(beam); +// repository.store(lofarObservation); +// +// } @Test public void testGetLatestChanges() throws RepositoryException { diff --git a/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/XMLParserTest.java b/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/XMLParserTest.java index 0e86056cfc6c8aeae9af406ca8f6859dade688af..f4ab126d8805d33f0e982f2e82a1dc81125ad12e 100644 --- a/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/XMLParserTest.java +++ b/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/mom2listener/XMLParserTest.java @@ -3,7 +3,9 @@ package nl.astron.lofar.odtb.mom2otdbadapter.mom2listener; import java.io.File; import java.io.FileInputStream; +import nl.astron.lofar.odtb.mom2otdbadapter.config.OTDBConfiguration; import nl.astron.lofar.odtb.mom2otdbadapter.data.LofarObservation; +import nl.astron.lofar.odtb.mom2otdbadapter.data.OTDBRepository; import nl.astron.util.XMLConverter; import org.junit.Test; @@ -18,6 +20,12 @@ public class XMLParserTest { InputSource inputSource = new InputSource(st); Document document = XMLConverter.convertXMLToDocument(inputSource, null); LofarObservation lofarObservation = XMLParser.getLofarObservation(document); + OTDBConfiguration config =new OTDBConfiguration(); + config.setRmiHost("lofar17"); + config.setRmiPort(10500); + config.setTemplateId(5001); + OTDBRepository repository = new OTDBRepository(config); + repository.store(lofarObservation); System.out.println("YES"); } diff --git a/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/otdblistener/XMLGeneratorTest.java b/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/otdblistener/XMLGeneratorTest.java index 0546f34c0b180a102cf0f125b9e0e24b7490ec87..b09634d818db9a480c9b2cbdfce41d895c19551f 100644 --- a/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/otdblistener/XMLGeneratorTest.java +++ b/SAS/OTB/MoM-OTDB-adapter/test/nl/astron/lofar/odtb/mom2otdbadapter/otdblistener/XMLGeneratorTest.java @@ -3,62 +3,43 @@ package nl.astron.lofar.odtb.mom2otdbadapter.otdblistener; import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.util.Date; +import java.util.List; import javax.xml.parsers.ParserConfigurationException; import nl.astron.lofar.odtb.mom2otdbadapter.config.Mom2Configuration; -import nl.astron.lofar.odtb.mom2otdbadapter.data.Beam; +import nl.astron.lofar.odtb.mom2otdbadapter.config.OTDBConfiguration; import nl.astron.lofar.odtb.mom2otdbadapter.data.LofarObservation; -import nl.astron.util.AstronConverter; +import nl.astron.lofar.odtb.mom2otdbadapter.data.OTDBRepository; +import nl.astron.lofar.odtb.mom2otdbadapter.data.RepositoryException; import org.junit.Test; public class XMLGeneratorTest { @Test - public void testGetObservationXml() throws IOException, ParserConfigurationException { - - LofarObservation lofarObservation = new LofarObservation(); - lofarObservation.setMom2Id(3); - - lofarObservation.setAntennaSet("HBA_TWO"); - lofarObservation.setBandFilter("HBA_110_190"); - lofarObservation.setClockMode("<<Clock200"); - lofarObservation.setStations("[CS302, CS010]"); - lofarObservation.setStatus("finished"); - lofarObservation.setObservationId(15); - lofarObservation.setStartTime(AstronConverter.toDate("2009/06/24 13:00 UTC")); - lofarObservation.setEndTime(AstronConverter.toDate("2009/06/24 13:30 UTC")); - lofarObservation.setClockFrequency(200000000d); - lofarObservation.setSubbandWidth(195312.5d); - lofarObservation.setChannelWidth(762.93945d); - lofarObservation.setChannelsPerSubband(256); - lofarObservation.setSamplesPerSecond(196608); - lofarObservation.setFileNameMask("/data/L${YEAR}_${MSNUMBER}/L${OBSERVATION}_B${BEAM}_SB${SUBBAND}.MS" ); - Beam beam = new Beam(lofarObservation); - beam.setMom2Id(4); - beam.setRa(85.650575); - beam.setDec(49.852009); - beam.setEquinox("J2000"); - beam.setDuration(4230); - beam.setSubbands("[123,124]"); - lofarObservation.getBeams().add(beam); - beam = new Beam(lofarObservation); - beam.setMom2Id(5); - beam.setRa(85.650575); - beam.setDec(49.852009); - beam.setEquinox("J2000"); - beam.setDuration(420); - beam.setSubbands("[1,2,3,4]"); - lofarObservation.getBeams().add(beam); - Mom2Configuration config = new Mom2Configuration(); - config.setMom2SchemasUrl("C:/java/workspace/MoM-OTDB-adapter/schemas/"); - String xml = XMLGenerator.getObservationXml(lofarObservation, config); - File file = new File("examples/obs.xml"); - PrintWriter writer = new PrintWriter(file); - writer.print(xml); - writer.flush(); - writer.close(); + public void testGetObservationXml() throws IOException, ParserConfigurationException, RepositoryException { + OTDBConfiguration config = new OTDBConfiguration(); + config.setRmiHost("lofar17"); + config.setRmiPort(10500); + config.setTemplateId(5001); + OTDBRepository repository = new OTDBRepository(config); + Date startDate = new Date(); + startDate.setMonth(4); + Date endDate = new Date(); + List<LofarObservation> lofarObservations = repository.getLatestChanges(startDate, endDate); + if (lofarObservations.size() > 0) { + LofarObservation lofarObservation = lofarObservations.get(0); + Mom2Configuration mom2Config = new Mom2Configuration(); + mom2Config.setMom2SchemasUrl("C:/java/workspace/MoM-OTDB-adapter/schemas/"); + String xml = XMLGenerator.getObservationXml(lofarObservation, mom2Config); + File file = new File("examples/obs-" + lofarObservation.getMom2Id() + "-" + lofarObservation.getStatus() + ".xml"); + PrintWriter writer = new PrintWriter(file); + writer.print(xml); + writer.flush(); + writer.close(); + } } }