Commit 02d6e914bd2032d05ed86a49c5fdaffaf01515c5
Exists in
master
merge JMG modifications.
Showing
3 changed files
with
89 additions
and
18 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java
@@ -42,16 +42,38 @@ public class GranuleCtrl { | @@ -42,16 +42,38 @@ public class GranuleCtrl { | ||
42 | } | 42 | } |
43 | 43 | ||
44 | private String parseString(int rowId, GranuleEnum granuleEnum) { | 44 | private String parseString(int rowId, GranuleEnum granuleEnum) { |
45 | - return (String) data.getCell(rowId, granuleEnum.toString()); | 45 | + String res = ""; |
46 | + try { | ||
47 | + res = (String) data.getCell(rowId, granuleEnum.toString()); | ||
48 | + } catch (Exception e) { | ||
49 | + logger.warning(granuleEnum + "not found in the rowId" + rowId + | ||
50 | + ": return an empty string"); | ||
51 | + } | ||
52 | + return res; | ||
46 | } | 53 | } |
47 | 54 | ||
48 | private Date parseDate(int rowId, GranuleEnum granuleEnum) throws ParseException { | 55 | private Date parseDate(int rowId, GranuleEnum granuleEnum) throws ParseException { |
49 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); | 56 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); |
50 | - return sdf.parse((String) data.getCell(rowId, granuleEnum.toString())); | 57 | + Date date = new Date(); |
58 | + try { | ||
59 | + date = sdf.parse((String) data.getCell(rowId, granuleEnum.toString())); | ||
60 | + } catch (Exception e) { | ||
61 | + logger.warning(granuleEnum + "not found in the rowId" + rowId + | ||
62 | + ": return an empty Date"); | ||
63 | + } | ||
64 | + | ||
65 | + return date; | ||
51 | } | 66 | } |
52 | 67 | ||
53 | private Double parseDouble(int rowId, GranuleEnum granuleEnum) { | 68 | private Double parseDouble(int rowId, GranuleEnum granuleEnum) { |
54 | - Double d = (Double) data.getCell(rowId, granuleEnum.toString()); | 69 | + Double d = null; |
70 | + try { | ||
71 | + d = (Double) data.getCell(rowId, granuleEnum.toString()); | ||
72 | + } catch (Exception e) { | ||
73 | + logger.warning(granuleEnum + "not found in the rowId" + rowId + | ||
74 | + ": return a Double.NaN"); | ||
75 | + } | ||
76 | + | ||
55 | return d == null ? Double.NaN : d; | 77 | return d == null ? Double.NaN : d; |
56 | } | 78 | } |
57 | 79 | ||
@@ -103,7 +125,7 @@ public class GranuleCtrl { | @@ -103,7 +125,7 @@ public class GranuleCtrl { | ||
103 | g.instrumentHostName = parseString(rowId, GranuleEnum.INSTRUMENT_HOST_NAME); | 125 | g.instrumentHostName = parseString(rowId, GranuleEnum.INSTRUMENT_HOST_NAME); |
104 | g.instrumentName = parseString(rowId, GranuleEnum.INSTRUMENT_NAME); | 126 | g.instrumentName = parseString(rowId, GranuleEnum.INSTRUMENT_NAME); |
105 | g.measurementType = parseString(rowId, GranuleEnum.MEASUREMENT_TYPE); | 127 | g.measurementType = parseString(rowId, GranuleEnum.MEASUREMENT_TYPE); |
106 | - g.processingLevel = (Integer) data.getCell(rowId, GranuleEnum.PROCESSING_LEVEL.toString()); | 128 | + g.processingLevel = parseInteger(rowId); |
107 | g.creationDate = parseDate(rowId, GranuleEnum.CREATION_DATE); | 129 | g.creationDate = parseDate(rowId, GranuleEnum.CREATION_DATE); |
108 | g.modificationDate = parseDate(rowId, GranuleEnum.MODIFICATION_DATE) ; | 130 | g.modificationDate = parseDate(rowId, GranuleEnum.MODIFICATION_DATE) ; |
109 | g.releaseDate = parseDate(rowId, GranuleEnum.RELEASE_DATE) ; | 131 | g.releaseDate = parseDate(rowId, GranuleEnum.RELEASE_DATE) ; |
@@ -116,6 +138,20 @@ public class GranuleCtrl { | @@ -116,6 +138,20 @@ public class GranuleCtrl { | ||
116 | return g; | 138 | return g; |
117 | } | 139 | } |
118 | 140 | ||
141 | + /** | ||
142 | + * @param rowId | ||
143 | + * @return | ||
144 | + */ | ||
145 | + public Integer parseInteger(int rowId) { | ||
146 | + Integer val = 0; | ||
147 | + try { | ||
148 | + val = (Integer) data.getCell(rowId, GranuleEnum.PROCESSING_LEVEL.toString()); | ||
149 | + } catch (Exception e) { | ||
150 | + // TODO: handle exception | ||
151 | + } | ||
152 | + return val; | ||
153 | + } | ||
154 | + | ||
119 | public static boolean isV2(VOTableData data) { | 155 | public static boolean isV2(VOTableData data) { |
120 | return !data.isContainingColumnName("index"); | 156 | return !data.isContainingColumnName("index"); |
121 | } | 157 | } |
@@ -129,8 +165,10 @@ public class GranuleCtrl { | @@ -129,8 +165,10 @@ public class GranuleCtrl { | ||
129 | } | 165 | } |
130 | List<Granule> granules = new ArrayList<>(); | 166 | List<Granule> granules = new ArrayList<>(); |
131 | 167 | ||
132 | - for (int rowId = 0; rowId < data.getNbRows(); rowId++) { | ||
133 | - granules.add(getGranuleFromVOTableRow(rowId)); | 168 | + if (data != null){ |
169 | + for (int rowId = 0; rowId < data.getNbRows(); rowId++) { | ||
170 | + granules.add(getGranuleFromVOTableRow(rowId)); | ||
171 | + } | ||
134 | } | 172 | } |
135 | return granules; | 173 | return granules; |
136 | } | 174 | } |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java
@@ -52,20 +52,29 @@ public class DataProductTypeField extends ParamField { | @@ -52,20 +52,29 @@ public class DataProductTypeField extends ParamField { | ||
52 | */ | 52 | */ |
53 | public DataProductTypeField(RequestPanelListener requestPanelListener, String paramName) { | 53 | public DataProductTypeField(RequestPanelListener requestPanelListener, String paramName) { |
54 | super(requestPanelListener, paramName); | 54 | super(requestPanelListener, paramName); |
55 | - comboBox = new JComboBox<>(DataProductType.values()); | ||
56 | - comboBox.setSelectedItem(DataProductType.ALL); | ||
57 | - comboBox.setPreferredSize( | ||
58 | - new Dimension(ParamField.MIN_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); | ||
59 | - | ||
60 | - comboBox.addActionListener(new ActionListener() { | 55 | + this.add(getComboBox()); |
56 | + } | ||
61 | 57 | ||
62 | - @Override | ||
63 | - public void actionPerformed(ActionEvent e) { | ||
64 | - update(); | ||
65 | - } | ||
66 | - }); | 58 | + /** |
59 | + * @return | ||
60 | + */ | ||
61 | + public JComboBox<DataProductType> getComboBox() { | ||
62 | + if (comboBox == null) { | ||
63 | + comboBox = new JComboBox<>(DataProductType.values()); | ||
64 | + comboBox.setSelectedItem(DataProductType.ALL); | ||
65 | + comboBox.setPreferredSize( | ||
66 | + new Dimension(ParamField.MIN_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); | ||
67 | + | ||
68 | + comboBox.addActionListener(new ActionListener() { | ||
69 | + | ||
70 | + @Override | ||
71 | + public void actionPerformed(ActionEvent e) { | ||
72 | + update(); | ||
73 | + } | ||
74 | + }); | ||
75 | + } | ||
67 | 76 | ||
68 | - this.add(comboBox); | 77 | + return comboBox; |
69 | } | 78 | } |
70 | 79 | ||
71 | /** | 80 | /** |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java
@@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
17 | package eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield; | 17 | package eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield; |
18 | 18 | ||
19 | import java.awt.Dimension; | 19 | import java.awt.Dimension; |
20 | +import java.io.File; | ||
20 | import java.util.logging.Level; | 21 | import java.util.logging.Level; |
21 | 22 | ||
22 | import javax.swing.JComboBox; | 23 | import javax.swing.JComboBox; |
@@ -72,6 +73,29 @@ public class TargetNameField extends ParamField implements TextFieldListener { | @@ -72,6 +73,29 @@ public class TargetNameField extends ParamField implements TextFieldListener { | ||
72 | this.add(comboBox); | 73 | this.add(comboBox); |
73 | } | 74 | } |
74 | 75 | ||
76 | + public TargetNameField(String paraName) { | ||
77 | + this(new RequestPanelListener() { | ||
78 | + | ||
79 | + public void onServiceSelected(int selectedService) { | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public void onSendButtonClicked(String query) { | ||
84 | + } | ||
85 | + | ||
86 | + @Override | ||
87 | + public void onParameterRemoved(String paramName) { | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public void onParameterChanged(String paramName, Object paramValue) { | ||
92 | + } | ||
93 | + | ||
94 | + public void onDownloadButtonClicked(File outputFile) { | ||
95 | + } | ||
96 | + }, paraName); | ||
97 | + } | ||
98 | + | ||
75 | /** | 99 | /** |
76 | * This method is called each time the field is modified. | 100 | * This method is called each time the field is modified. |
77 | */ | 101 | */ |