git_sitools_idoc / sitools-idoc / hesiod / javaExt / src / fr / ias / sitools / vo / tap / TableAccessProtocolInputParameters.java @ 779bac69
1 |
/*
|
---|---|
2 |
* To change this license header, choose License Headers in Project Properties.
|
3 |
* To change this template file, choose Tools | Templates
|
4 |
* and open the template in the editor.
|
5 |
*/
|
6 |
|
7 |
package fr.ias.sitools.vo.tap; |
8 |
|
9 |
import fr.cnes.sitools.dataset.DataSetApplication; |
10 |
import fr.cnes.sitools.plugins.resources.model.ResourceModel; |
11 |
import java.util.ArrayList; |
12 |
import java.util.Collections; |
13 |
import java.util.HashMap; |
14 |
import java.util.List; |
15 |
import java.util.Map; |
16 |
import java.util.logging.Level; |
17 |
import net.ivoa.xml.votable.v1.Info; |
18 |
import org.restlet.Context; |
19 |
import org.restlet.Request; |
20 |
|
21 |
/**
|
22 |
*
|
23 |
* @author marc
|
24 |
*/
|
25 |
public class TableAccessProtocolInputParameters implements DataModelInterface { |
26 |
|
27 |
/**
|
28 |
* Data model that stores the metadata response of the service.
|
29 |
*/
|
30 |
private final transient Map dataModel = new HashMap(); |
31 |
/**
|
32 |
* Request.
|
33 |
*/
|
34 |
private final transient Request request; |
35 |
/**
|
36 |
* Context.
|
37 |
*/
|
38 |
private final transient Context context; |
39 |
/**
|
40 |
* Application where this resources is linked.
|
41 |
*/
|
42 |
private final transient DataSetApplication datasetApp; |
43 |
/**
|
44 |
* Configuration parameters of this resource.
|
45 |
*/
|
46 |
private final transient ResourceModel resourceModel; |
47 |
|
48 |
private final String query; |
49 |
private final String format; |
50 |
|
51 |
|
52 |
/**
|
53 |
* Constructs the objet that returns the metadata of the service.
|
54 |
* @param datasetAppVal application
|
55 |
* @param requestVal request
|
56 |
* @param contextVal context
|
57 |
* @param resourceModelVal configuration parameters
|
58 |
*/
|
59 |
public TableAccessProtocolInputParameters(final DataSetApplication datasetAppVal, final Request requestVal, final Context contextVal, final ResourceModel resourceModelVal) { |
60 |
this.request = requestVal;
|
61 |
this.context = contextVal;
|
62 |
this.datasetApp = datasetAppVal;
|
63 |
this.resourceModel = resourceModelVal;
|
64 |
final String requestType = this.request.getResourceRef().getQueryAsForm().getFirstValue(TableAccessProtocolLibrary.REQUEST); |
65 |
final String langRequest = this.request.getResourceRef().getQueryAsForm().getFirstValue(TableAccessProtocolLibrary.LANG); |
66 |
final String phase = this.request.getResourceRef().getQueryAsForm().getFirstValue(TableAccessProtocolLibrary.PHASE); |
67 |
this.query = this.request.getResourceRef().getQueryAsForm().getFirstValue(TableAccessProtocolLibrary.QUERY); |
68 |
this.format = this.request.getResourceRef().getQueryAsForm().getFirstValue(TableAccessProtocolLibrary.FORMAT); |
69 |
//if(langRequestTableAccessProtocolLibrary.langSupported.)
|
70 |
//fillMetadataFormat();
|
71 |
} |
72 |
|
73 |
/**
|
74 |
* Fills metadata response.
|
75 |
*/
|
76 |
private void fillMetadataFormat() { |
77 |
|
78 |
this.dataModel.put("description", this.resourceModel.getParameterByName(TableAccessProtocolLibrary.DESCRIPTION).getValue()); |
79 |
|
80 |
final Info info = new Info(); |
81 |
info.setName("QUERY_STATUS");
|
82 |
info.setValueAttribute("OK");
|
83 |
final List<Info> listInfos = new ArrayList<Info>(); |
84 |
listInfos.add(info); |
85 |
this.dataModel.put("infos", listInfos); |
86 |
|
87 |
/* ON EN N'A PAS BESOIN
|
88 |
final List<Param> listParam = new ArrayList<Param>();
|
89 |
Param param = new Param();
|
90 |
param.setName("INPUT:POS");
|
91 |
param.setValue("0,0");
|
92 |
param.setDatatype(DataType.DOUBLE);
|
93 |
AnyTEXT anyText = new AnyTEXT();
|
94 |
anyText.getContent().add("Search Position in the form ra,dec where ra and dec are given in decimal degrees in the ICRS coordinate system.");
|
95 |
param.setDESCRIPTION(anyText);
|
96 |
listParam.add(param);
|
97 |
|
98 |
param = new Param();
|
99 |
param.setName("INPUT:SIZE");
|
100 |
param.setValue("0.05");
|
101 |
param.setDatatype(DataType.DOUBLE);
|
102 |
anyText = new AnyTEXT();
|
103 |
anyText.getContent().add("Size of search region in the RA and Dec directions.");
|
104 |
param.setDESCRIPTION(anyText);
|
105 |
listParam.add(param);
|
106 |
|
107 |
param = new Param();
|
108 |
param.setName("INPUT:FORMAT");
|
109 |
param.setValue(TableAccessProtocolLibrary.ParamStandardFormat.ALL.name());
|
110 |
param.setDatatype(DataType.CHAR);
|
111 |
param.setArraysize("*");
|
112 |
AnyTEXT anyText = new AnyTEXT();
|
113 |
anyText.getContent().add("Requested format of result.");
|
114 |
param.setDESCRIPTION(anyText);
|
115 |
|
116 |
|
117 |
//TODO : le faire pour chaque format
|
118 |
listParam.add(param);
|
119 |
ON EN N'A PAS BESOIN
|
120 |
param = new Param();
|
121 |
param.setName("INPUT:INTERSECT");
|
122 |
param.setValue(this.resourceModel.getParameterByName(TableAccessProtocolLibrary.INTERSECT).getValue());
|
123 |
param.setDatatype(DataType.CHAR);
|
124 |
anyText = new AnyTEXT();
|
125 |
anyText.getContent().add("Choice of overlap with requested region.");
|
126 |
param.setDESCRIPTION(anyText);
|
127 |
listParam.add(param);
|
128 |
|
129 |
param = new Param();
|
130 |
param.setName("INPUT:VERB");
|
131 |
param.setValue(this.resourceModel.getParameterByName(TableAccessProtocolLibrary.VERB).getValue());
|
132 |
param.setDatatype(DataType.INT);
|
133 |
anyText = new AnyTEXT();
|
134 |
anyText.getContent().add("Verbosity level, controlling the number of columns returned.");
|
135 |
param.setDESCRIPTION(anyText);
|
136 |
listParam.add(param);
|
137 |
|
138 |
dataModel.put("params", listParam);
|
139 |
|
140 |
String dictionaryName = resourceModel.getParameterByName(TableAccessProtocolLibrary.DICTIONARY).getValue();
|
141 |
final List<String> columnList = new ArrayList<String>();
|
142 |
List<Field> fieldList = new ArrayList<Field>();
|
143 |
try {
|
144 |
List<ColumnConceptMappingDTO> mappingList = getDicoFromConfiguration(datasetApp, dictionaryName);
|
145 |
setFields(fieldList, columnList, mappingList);
|
146 |
}catch (SitoolsException ex) {
|
147 |
|
148 |
}
|
149 |
*/
|
150 |
} |
151 |
|
152 |
@Override
|
153 |
public final Map getDataModel() { |
154 |
return Collections.unmodifiableMap(this.dataModel); |
155 |
} |
156 |
|
157 |
/* GETTER DE LA CLASSE */
|
158 |
public String getQuery() { |
159 |
return query;
|
160 |
} |
161 |
public String getFormat() { |
162 |
return format;
|
163 |
} |
164 |
public Context getContext() { |
165 |
return context;
|
166 |
} |
167 |
|
168 |
public Request getRequest() {
|
169 |
return request;
|
170 |
} |
171 |
public DataSetApplication getDatasetApp() {
|
172 |
return datasetApp;
|
173 |
} |
174 |
|
175 |
public ResourceModel getResourceModel() {
|
176 |
return resourceModel;
|
177 |
} |
178 |
|
179 |
} |