From 2eda27c00b8a73f6901e16c2e573c3155a727aaa Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Wed, 20 Apr 2016 17:45:25 +0200 Subject: [PATCH] Start VOResource management implementation. --- src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java | 4 ++-- src/main/java/eu/omp/irap/vespa/epntapclient/lib/EpnTapService.java | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/lib/ServicesManager.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceException.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceParser.java | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 355 insertions(+), 2 deletions(-) create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/lib/EpnTapService.java create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/lib/ServicesManager.java create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceException.java create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceParser.java diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java index 35b1d1e..cf78e1f 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java @@ -23,8 +23,8 @@ import java.nio.file.Paths; import java.util.logging.Level; import java.util.logging.Logger; -import eu.omp.irap.vespa.epntapclient.epnTapLib.EpnTapController; -import eu.omp.irap.vespa.epntapclient.epnTapLib.Queries; +import eu.omp.irap.vespa.epntapclient.lib.EpnTapController; +import eu.omp.irap.vespa.epntapclient.lib.Queries; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/lib/EpnTapService.java b/src/main/java/eu/omp/irap/vespa/epntapclient/lib/EpnTapService.java new file mode 100644 index 0000000..a3e2d37 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/lib/EpnTapService.java @@ -0,0 +1,183 @@ +/* + * This file is a part of EpnTAPClient. + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. + * + * This program is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of + * the GNU General Public License along with this program. If not, see + * . + */ + +package eu.omp.irap.vespa.epntapclient.lib; + +import java.util.Date; + +/** + * @author N. Jourdane + */ +public class EpnTapService { + + public String granuleUid; + + public String granuleGid; + + public String obsId; + + public String dataproductType; + + public String targetName; + + public String targetClass; + + public double timeMin; + + public double timeMax; + + public double timeSamplingStepMin; + + public double timeSamplingStepMax; + + public double timeExpMin; + + public double timeExpMax; + + public double spectralRangeMin; + + public double spectralRangeMax; + + public double spectralSamplingStepMin; + + public double spectralSamplingStepMax; + + public double spectralResolutionMin; + + public double spectralResolutionMax; + + public double c1Min; + + public double c1Max; + + public double c2Min; + + public double c2Max; + + public double c3Min; + + public double c3Max; + + public double c1ResolMin; + + public double c1ResolMax; + + public double c2ResolMin; + + public double c2ResolMax; + + public double c3ResolMin; + + public double c3ResolMax; + + public String spatialFrameType; + + public double incidenceMin; + + public double incidenceMax; + + public double emergenceMin; + + public double emergenceMax; + + public double phaseMin; + + public double phaseMax; + + public String instrumentHostName; + + public String instrumentName; + + public String measurementType; + + public int processingLevel; + + public Date creationDate; + + public Date modificationDate; + + public Date releaseDate; + + public String serviceTitle; + + public String accessUrl; + + public String accessFormat; + + public int accessEstsize; + + public String dataAccessUrl; + + public String accessMd5; + + public String thumbnailUrl; + + public String fileName; + + public String species; + + public String altTargetName; + + public String targetRegion; + + public String featureName; + + public String bibReference; + + public double ra; + + public double dec; + + public double solarLongitudeMin; + + public double solarLongitudeMax; + + public double localTimeMin; + + public double localTimeMax; + + public double targetDistanceMin; + + public double targetDistanceMax; + + public double targetTimeMin; + + public double targetTimeMax; + + public String particleSpectralType; + + public double particleSpectralRangeMin; + + public double particleSpectralRangeMax; + + public double particleSpectralSamplingStepMin; + + public double particleSpectralSamplingStepMax; + + public double particleSpectralResolutionMin; + + public double particleSpectralResolutionMax; + + public String publisher; + + public String spatialCoordinateDescription; + + public String spatialOrigin; + + public String timeOrigin; + + public String timeScale; +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/lib/ServicesManager.java b/src/main/java/eu/omp/irap/vespa/epntapclient/lib/ServicesManager.java new file mode 100644 index 0000000..eb7c595 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/lib/ServicesManager.java @@ -0,0 +1,53 @@ +/* + * This file is a part of EpnTAPClient. + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. + * + * This program is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of + * the GNU General Public License along with this program. If not, see + * . + */ + +package eu.omp.irap.vespa.epntapclient.lib; + +import java.util.logging.Logger; + +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableController; +import eu.omp.irap.vespa.epntapclient.votable.utils.Consts; + +/** + * @author N. Jourdane + */ +public class ServicesManager { + + /** The logger for the class ServicesManager. */ + private static final Logger logger = Logger.getLogger(ServicesManager.class.getName()); + + + public enum ResourceType { + EPN_TAP, OBSCORE, OBSPM + }; + + + ServicesManager(ResourceType resourceType) { + if (resourceType == ResourceType.EPN_TAP) { + VOTableController servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, + "ADQL", + Queries.GET_EPN_TAP_SERVICES); + } else if (resourceType == ResourceType.OBSCORE) { + VOTableController servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, + "ADQL", + Queries.GET_TAP_OBSCOR_SERVICES); + } else if (resourceType == ResourceType.OBSPM) { + VOTableController servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, + "ADQL", + Queries.GET_VO_RESOURCES); + } + } +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceException.java b/src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceException.java new file mode 100644 index 0000000..4ef4793 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceException.java @@ -0,0 +1,55 @@ +/* + * This file is a part of EpnTAPClient. + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. + * + * This program is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of + * the GNU General Public License along with this program. If not, see + * . + */ + +package eu.omp.irap.vespa.epntapclient.lib.resource; + +/** + * @author N. Jourdane + */ +public class VOResourceException extends Exception { + + /** + * @param message The message describing the exception displayed in the error dialog. + */ + public VOResourceException(String message) { + super(message); + } + + /** + * @param message The message describing the exception displayed in the error dialog. + * @param e The exception thrown. + */ + public VOResourceException(String message, Exception e) { + super(message, e); + } + + + public static class VOResourceIsNotValidException extends VOResourceException { + + /** */ + private static final long serialVersionUID = 1L; + + + /** + * @param voTablePath The path of the VOTable. + * @param e The exception thrown. + */ + public VOResourceIsNotValidException(String voResourcePath, Exception e) { + super("Can not parse the VOResource because it doesn't match with the VOResource schema." + + "\n See the VOResource file for more details: " + voResourcePath, e); + } + } +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceParser.java b/src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceParser.java new file mode 100644 index 0000000..c6bf10d --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/lib/resource/VOResourceParser.java @@ -0,0 +1,62 @@ +/* + * This file is a part of EpnTAPClient. + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. + * + * This program is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of + * the GNU General Public License along with this program. If not, see + * . + */ + +package eu.omp.irap.vespa.epntapclient.lib.resource; + +import java.io.File; +import java.util.logging.Logger; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import eu.omp.irap.vespa.epntapclient.lib.resource.VOResourceException.VOResourceIsNotValidException; +import eu.omp.irap.vespa.epntapclient.voresource.model.Resource; + +/** + * @author N. Jourdane + */ +public class VOResourceParser { + + /** The logger for the class VOResourceParser. */ + private static final Logger logger = Logger.getLogger(VOResourceParser.class.getName()); + + private static final String VORESOURCE_MODEL_PACKAGE = "eu.omp.irap.vespa.epntapclient.voresource.model"; + + private static final String GET_VORESOURCE_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources.xml?identifier="; + + + public static Resource parseRemoteVOResource(String identifier) { + // VOResourceParser.parseVOResource(String voResourcePath); + return null; + } + + public static Resource parseVOResource(String voResourcePath) + throws VOResourceIsNotValidException { + Resource voResource; + JAXBContext jc; + try { + jc = JAXBContext.newInstance(VOResourceParser.VORESOURCE_MODEL_PACKAGE); + Unmarshaller unmarshaller = jc.createUnmarshaller(); + voResource = (Resource) unmarshaller.unmarshal(new File(voResourcePath)); + } catch (JAXBException e) { + throw new VOResourceIsNotValidException(voResourcePath, e); + } + + return voResource; + } + +} -- libgit2 0.21.2