22 * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33 */
44
5- /*
6- * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
7- */
8-
95package edu .caltech .ipac .firefly .data ;
106
11-
127import edu .caltech .ipac .firefly .visualize .RequestType ;
138import edu .caltech .ipac .firefly .visualize .WebPlotRequest ;
14-
159import java .io .Serializable ;
1610import java .util .HashMap ;
1711import java .util .Map ;
@@ -26,66 +20,100 @@ public class RelatedData implements Serializable {
2620
2721 private String dataType = "" ; // image or table
2822 private String desc ;
23+ /** related dataKey should be a unique string for a fits file */
24+ private String dataKey ;
2925 private Map <String ,String > searchParams = new HashMap <>();
3026 private Map <String ,String > availableMask = new HashMap <>();
3127
3228
3329 private RelatedData () {}
3430
35- public static RelatedData makeMaskRelatedData (String fileName , Map <String ,String > availableMask , int extensionNumber ) {
36- RelatedData d = new RelatedData ();
37- d .dataType = IMAGE_MASK ;
38- d .availableMask = availableMask ;
39-
40- d .desc = "Mask" ;
41- d .searchParams .put (WebPlotRequest .FILE , fileName );
42- d .searchParams .put (WebPlotRequest .PLOT_AS_MASK , "true" );
43- d .searchParams .put (WebPlotRequest .TYPE , RequestType .FILE +"" );
44- d .searchParams .put (WebPlotRequest .MULTI_IMAGE_IDX , extensionNumber +"" );
45-
46- return d ;
31+ /**
32+ * Factory method to create mask related data
33+ * @param fileName - fits file name on the server
34+ * @param availableMask - a map with the key to be the bits number (as a string) and the value to be a description
35+ * @param extensionNumber - extension number of the fits file
36+ * @param dataKey - should be a unique string for a fits file
37+ * @return RelatedData
38+ */
39+ public static RelatedData makeMaskRelatedData (String fileName , Map <String ,String > availableMask , int extensionNumber , String dataKey ) {
40+ Map <String ,String > searchParams = new HashMap <>();
41+ searchParams .put (WebPlotRequest .FILE , fileName );
42+ searchParams .put (WebPlotRequest .PLOT_AS_MASK , "true" );
43+ searchParams .put (WebPlotRequest .TYPE , RequestType .FILE +"" );
44+ searchParams .put (WebPlotRequest .MULTI_IMAGE_IDX , extensionNumber +"" );
45+ return makeMaskRelatedData (searchParams , availableMask , dataKey );
4746 }
4847
49-
50- public static RelatedData makeMaskRelatedData (Map <String ,String > searchParams , Map <String ,String > availableMask ) {
48+ /**
49+ * Factory method to create mask related data
50+ * @param searchParams- parameters used to make a WebPlotRequest search
51+ * @param availableMask - a map with the key to be the bits number (as a string) and the value to be a description
52+ * @param dataKey - should be a unique string for a fits file
53+ * @return RelatedData
54+ */
55+ public static RelatedData makeMaskRelatedData (Map <String ,String > searchParams , Map <String ,String > availableMask , String dataKey ) {
5156 RelatedData d = new RelatedData ();
5257 d .dataType = IMAGE_MASK ;
5358 d .availableMask = availableMask ;
5459
5560 d .desc = "Mask" ;
61+ d .dataKey = dataKey ;
5662 d .searchParams = searchParams ;
5763 return d ;
5864 }
5965
60- public static RelatedData makeImageOverlayRelatedData (String fileName , String desc , int extensionNumber ) {
61- RelatedData d = new RelatedData ();
62- d .dataType = IMAGE_OVERLAY ;
63- d .desc = desc ;
64-
65- d .searchParams .put (WebPlotRequest .FILE , fileName );
66- d .searchParams .put (WebPlotRequest .TYPE , RequestType .FILE +"" );
67- d .searchParams .put (WebPlotRequest .MULTI_IMAGE_IDX , extensionNumber +"" );
68- return d ;
66+ /**
67+ * Factory method to create image overlay related data
68+ * @param fileName - name of the fits file
69+ * @param dataKey - should be a unique string for a fits file
70+ * @param desc - description of the data
71+ * @param extensionNumber - extenions number in the fits file
72+ * @return RelatedData
73+ */
74+ public static RelatedData makeImageOverlayRelatedData (String fileName , String dataKey , String desc , int extensionNumber ) {
75+ Map <String ,String > searchParams = new HashMap <>();
76+ searchParams .put (WebPlotRequest .FILE , fileName );
77+ searchParams .put (WebPlotRequest .TYPE , RequestType .FILE +"" );
78+ searchParams .put (WebPlotRequest .MULTI_IMAGE_IDX , extensionNumber +"" );
79+ return makeImageOverlayRelatedData (searchParams ,dataKey ,desc );
6980 }
7081
71- public static RelatedData makeImageOverlayRelatedData (Map <String ,String > searchParams , String desc ) {
82+ /**
83+ * Factory method to create image overlay related data
84+ * @param searchParams - parameters used to make a WebPlotRequest search
85+ * @param dataKey - should be a unique string for a fits file
86+ * @param desc - description of the data
87+ * @return RelatedData
88+ */
89+ public static RelatedData makeImageOverlayRelatedData (Map <String ,String > searchParams , String dataKey , String desc ) {
7290 RelatedData d = new RelatedData ();
7391 d .dataType = IMAGE_OVERLAY ;
7492 d .desc = desc ;
93+ d .dataKey = dataKey ;
7594 d .searchParams = searchParams ;
7695 return d ;
7796 }
7897
79- public static RelatedData makeTabularRelatedData (Map <String ,String > searchParams , String desc ) {
98+ /**
99+ * Factory method to create tabular related data
100+ * @param searchParams - parameters us to make a table file type server request
101+ * @param dataKey - should be a unique string for a fits file
102+ * @param desc - description of the data
103+ * @return RelatedData
104+ */
105+ public static RelatedData makeTabularRelatedData (Map <String ,String > searchParams , String dataKey , String desc ) {
80106 RelatedData d = new RelatedData ();
81107 d .dataType = TABLE ;
82108 d .searchParams = searchParams ;
109+ d .dataKey = dataKey ;
83110 d .desc = desc ;
84111 return d ;
85112 }
86113
87114
88115 public String getDataType () { return dataType ;}
116+ public String getDataKey () { return dataKey ;}
89117 public Map <String ,String > getAvailableMask () { return availableMask ;}
90118 public String getDesc () { return desc ;}
91119 public Map <String ,String > getSearchParams () { return searchParams ;}
0 commit comments