Project

General

Profile

Download (9.89 KB) Statistics
| Branch: | Revision:

git_sitools_idoc / sitools-idoc / hesiod / javaExt / src / fr / ias / sitools / resources / vo / SimpleSpectralAccessResourceModel.java @ 779bac69

1
 /*******************************************************************************
2
 * Copyright 2010-2013 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
3
 *
4
 * This file is part of SITools2.
5
 *
6
 * SITools2 is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * SITools2 is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with SITools2.  If not, see <http://www.gnu.org/licenses/>.
18
 ******************************************************************************/
19
package fr.ias.sitools.resources.vo;
20

    
21
import fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary;
22
import fr.cnes.sitools.common.validator.ConstraintViolation;
23
import fr.cnes.sitools.common.validator.ConstraintViolationLevel;
24
import fr.cnes.sitools.common.validator.Validator;
25
import fr.cnes.sitools.dataset.DataSetApplication;
26
import fr.cnes.sitools.plugins.resources.model.DataSetSelectionType;
27
import fr.cnes.sitools.plugins.resources.model.ResourceModel;
28
import fr.cnes.sitools.plugins.resources.model.ResourceParameter;
29
import fr.cnes.sitools.plugins.resources.model.ResourceParameterType;
30
import fr.cnes.sitools.util.Util;
31
import java.util.HashSet;
32
import java.util.Map;
33
import java.util.Set;
34
import java.util.logging.Logger;
35

    
36
/**
37
 * Plugin for publishing a dataset through the Simple Image Access Protocol.
38
 *
39
 * <p>
40
 * The plugin answers to the need of the following user story:<br/>
41
 * As administrator, I publish my data through SIAP so that the users can
42
 * request my images by the use of an interoperability standard.
43
 * <br/>
44
 * <img src="../../../../../../images/SIAP-usecase.png"/>
45
 * <br/>
46
 * In addition, this plugin has several dependencies with different
47
 * components:<br/>
48
 * <img src="../../../../../../images/SimpleImageAccessResourcePlugin.png"/>
49
 * <br/>
50
 * </p>
51
 *
52
 * @author Jean-Christophe Malapert <jean-christophe.malapert@cnes.fr>
53
 * @startuml SIAP-usecase.png title Publishing data through SIAP User --> (SIAP
54
 * service) : requests Admin --> (SIAP service) : adds and configures the SIAP
55
 * service from the dataset. (SIAP service) .. (dataset) : uses
56
 * @enduml
57
 * @startuml package "Services" { HTTP - [SimpleImageAccessResourcePlugin] }
58
 * database "Database" { frame "Data" { [myData] } } package "Dataset" { HTTP -
59
 * [Dataset] [VODictionary] } folder "DataStorage" { HTTP - [directory] }
60
 * [SimpleImageAccessResourcePlugin] --> [Dataset] [Dataset] --> [directory]
61
 * [Dataset] --> [myData] [Dataset] --> [VODictionary]
62
 * @enduml
63
 */
64
public class SimpleSpectralAccessResourceModel extends ResourceModel {
65

    
66
    /**
67
     * Logger.
68
     */
69
    private static final Logger LOG = Logger.getLogger(SimpleSpectralAccessResourceModel.class.getName());
70

    
71
    /**
72
     * Constructs the configuration panel of the plugin.
73
     */
74
    public SimpleSpectralAccessResourceModel() {
75
        super();
76
        setClassAuthor("Mnicoals");
77
        setClassOwner("IAS");
78
        setClassVersion("0.1");
79
        setName("Simple Spectral Access Protocol");
80
        setDescription("This plugin provides an access to your data through the Simple Image Access Protocol");
81
        setResourceClassName(fr.ias.sitools.resources.vo.SimpleSpectralAccessResource.class.getName());
82
        
83
        this.setApplicationClassName(DataSetApplication.class.getName());
84
        this.setDataSetSelection(DataSetSelectionType.SINGLE);
85
        this.getParameterByName("methods").setValue("GET");
86
        this.completeAttachUrlWith("/services/vo/ssa");
87
        setConfiguration();
88
        /*
89
        this.setApplicationClassName(DataSetApplication.class.getName());
90

91
        //we set to NONE because this is a web service for Virtual Observatory
92
        // and we do not want to see it in the web user interface
93
        this.setDataSetSelection(DataSetSelectionType.NONE);
94
        setConfiguration();*/
95
    }
96

    
97
    /**
98
     * Sets the configuration for the administrator.
99
     */
100
    private void setConfiguration() {
101
        final ResourceParameter dico = new ResourceParameter(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.DICTIONARY, "Dictionary name that sets up the service.",
102
        ResourceParameterType.PARAMETER_INTERN);
103
        dico.setValueType("xs:dictionary");
104
        this.addParam(dico);
105
        
106
        final ResourceParameter intersect = new ResourceParameter(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.INTERSECT,
107
                "how matched images should intersect the region of interest",
108
                ResourceParameterType.PARAMETER_INTERN);
109
        //String intersectEnum = "xs:enum[COVERS, ENCLOSED, CENTER, OVERLAPS]";
110
        intersect.setValueType("xs:enum[CENTER, OVERLAPS]");
111
        intersect.setValue("OVERLAPS");
112
        addParam(intersect);
113
        
114
        final ResourceParameter verb = new ResourceParameter(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.VERB,
115
                "Verbosity determines how many columns are to be returned in the resulting table",
116
                ResourceParameterType.PARAMETER_INTERN);
117
        verb.setValueType("xs:enum[0, 1, 2, 3]");
118
        verb.setValue("1");
119
        addParam(verb);
120
        
121
        final ResourceParameter responsibleParty = new ResourceParameter(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.RESPONSIBLE_PARTY,
122
                "The data provider's name and email", ResourceParameterType.PARAMETER_INTERN);
123
        addParam(responsibleParty);
124

    
125
        final ResourceParameter serviceName = new ResourceParameter(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.SERVICE_NAME,
126
                "The name of the service",
127
                ResourceParameterType.PARAMETER_INTERN);
128
        serviceName.setValueType("xs:enum[Spectral Archive Service, Spectral Cutout Service, Spectral Mosaicing Service, Spectral Extraction Service]");
129
        serviceName.setValue("Spectral Archive Service");
130
        addParam(serviceName);
131

    
132
        final ResourceParameter description = new ResourceParameter(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.DESCRIPTION,
133
                "A couple of paragraphs of text that describe the nature of the service and its wider context",
134
                ResourceParameterType.PARAMETER_INTERN);
135
        addParam(description);
136

    
137
        final ResourceParameter instrument = new ResourceParameter(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.INSTRUMENT,
138
                "The instrument that made the observations, for example STScI.HST.WFPC2",
139
                ResourceParameterType.PARAMETER_INTERN);
140
        addParam(instrument);
141
        
142
        final ResourceParameter maxQuerySize = new ResourceParameter(
143
                fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.MAX_QUERY_SIZE,
144
                "The largest search area, given in decimal degrees, that will be accepted by the service without returning an error condition."
145
                + " A value of 64800 indicates that there is no restriction",
146
                ResourceParameterType.PARAMETER_INTERN);
147
        maxQuerySize.setValue("64800");
148
        addParam(maxQuerySize);
149

    
150
        final ResourceParameter maxImageSize = new ResourceParameter(
151
                fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.MAX_IMAGE_SIZE,
152
                "The largest image area, given in decimal degrees, that will be returned by the service",
153
                ResourceParameterType.PARAMETER_INTERN);
154
        addParam(maxImageSize);
155

    
156
        final ResourceParameter maxFileSize = new ResourceParameter(
157
                fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.MAX_FILE_SIZE,
158
                "The largest file size, given in Bytes, that will be returned by the service",
159
                ResourceParameterType.PARAMETER_INTERN);
160
        addParam(maxFileSize);
161

    
162
        final ResourceParameter maxRecords = new ResourceParameter(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.MAX_RECORDS,
163
                "The largest number of records that the service will return", ResourceParameterType.PARAMETER_INTERN);
164
        maxRecords.setValue("-1");
165
        addParam(maxRecords);
166
        
167
        final ResourceParameter geoAttribut = new ResourceParameter(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.GEO_ATTRIBUT,
168
                "Geographical attribut for OVERLAPS mode. The geographical attribut must be spoly datatype from pgsphere",
169
                ResourceParameterType.PARAMETER_INTERN);
170
        geoAttribut.setValueType("xs:dataset.columnAlias");
171
        addParam(geoAttribut);
172

    
173
    }
174

    
175
    /**
176
     * Validates the configuration that has been set by the administrator.
177
     *
178
     * @return the error or warning
179
     */
180
    @Override
181
    public final Validator<ResourceModel> getValidator() {
182
        return new Validator<ResourceModel>() {
183
            @Override
184
            public final Set<ConstraintViolation> validate(final ResourceModel item) {
185
                final Set<ConstraintViolation> constraintList = new HashSet<ConstraintViolation>();
186
                final Map<String, ResourceParameter> params = item.getParametersMap();
187
                final ResourceParameter dico = params.get(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.DICTIONARY);
188

    
189
                if (!Util.isNotEmpty(dico.getValue())) {
190
                    final ConstraintViolation constraint = new ConstraintViolation();
191
                    constraint.setLevel(ConstraintViolationLevel.WARNING);
192
                    constraint.setMessage("A dictionary must be set");
193
                    constraint.setValueName(fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary.DICTIONARY);
194
                    constraintList.add(constraint);
195
                }
196
                return constraintList;
197
            }
198
        };
199
    }
200
}