Skip to content

DM-5792: Support artifacts on all images that have them (currently wise and 2mass) #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/firefly/java/edu/caltech/ipac/firefly/data/FileInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,18 @@ public static FileInfo blankFilePlaceholder() {
public int getResponseCode() { return StringUtils.getInt(attributes.get(RESPONSE_CODE), 200); }
public String getResponseCodeMsg() { return attributes.get(RESPONSE_CODE_MSG); }


public void addRelatedDataList(List<RelatedData> rDataList) {
if (rDataList==null) return;
for(RelatedData rd : rDataList) addRelatedData(rd);
}


public void addRelatedData(RelatedData rData) {
if (relatedData==null) relatedData= new ArrayList<>();
relatedData.add(rData);
if (rData!=null) {
if (relatedData==null) relatedData= new ArrayList<>();
relatedData.add(rData);
}
}

public List<RelatedData> getRelatedData() { return relatedData; }
Expand Down
90 changes: 59 additions & 31 deletions src/firefly/java/edu/caltech/ipac/firefly/data/RelatedData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

/*
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/

package edu.caltech.ipac.firefly.data;


import edu.caltech.ipac.firefly.visualize.RequestType;
import edu.caltech.ipac.firefly.visualize.WebPlotRequest;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -26,66 +20,100 @@ public class RelatedData implements Serializable {

private String dataType= ""; // image or table
private String desc;
/** related dataKey should be a unique string for a fits file */
private String dataKey;
private Map<String,String> searchParams= new HashMap<>();
private Map<String,String> availableMask= new HashMap<>();


private RelatedData() {}

public static RelatedData makeMaskRelatedData(String fileName, Map<String,String> availableMask, int extensionNumber) {
RelatedData d= new RelatedData();
d.dataType= IMAGE_MASK;
d.availableMask= availableMask;

d.desc= "Mask";
d.searchParams.put(WebPlotRequest.FILE, fileName);
d.searchParams.put(WebPlotRequest.PLOT_AS_MASK, "true");
d.searchParams.put(WebPlotRequest.TYPE, RequestType.FILE+"");
d.searchParams.put(WebPlotRequest.MULTI_IMAGE_IDX, extensionNumber+"");

return d;
/**
* Factory method to create mask related data
* @param fileName - fits file name on the server
* @param availableMask - a map with the key to be the bits number (as a string) and the value to be a description
* @param extensionNumber - extension number of the fits file
* @param dataKey - should be a unique string for a fits file
* @return RelatedData
*/
public static RelatedData makeMaskRelatedData(String fileName, Map<String,String> availableMask, int extensionNumber, String dataKey) {
Map<String,String> searchParams= new HashMap<>();
searchParams.put(WebPlotRequest.FILE, fileName);
searchParams.put(WebPlotRequest.PLOT_AS_MASK, "true");
searchParams.put(WebPlotRequest.TYPE, RequestType.FILE+"");
searchParams.put(WebPlotRequest.MULTI_IMAGE_IDX, extensionNumber+"");
return makeMaskRelatedData(searchParams, availableMask, dataKey);
}


public static RelatedData makeMaskRelatedData(Map<String,String> searchParams, Map<String,String> availableMask) {
/**
* Factory method to create mask related data
* @param searchParams- parameters used to make a WebPlotRequest search
* @param availableMask - a map with the key to be the bits number (as a string) and the value to be a description
* @param dataKey - should be a unique string for a fits file
* @return RelatedData
*/
public static RelatedData makeMaskRelatedData(Map<String,String> searchParams, Map<String,String> availableMask, String dataKey) {
RelatedData d= new RelatedData();
d.dataType= IMAGE_MASK;
d.availableMask= availableMask;

d.desc= "Mask";
d.dataKey = dataKey;
d.searchParams= searchParams;
return d;
}

public static RelatedData makeImageOverlayRelatedData(String fileName, String desc, int extensionNumber) {
RelatedData d= new RelatedData();
d.dataType= IMAGE_OVERLAY;
d.desc= desc;

d.searchParams.put(WebPlotRequest.FILE, fileName);
d.searchParams.put(WebPlotRequest.TYPE, RequestType.FILE+"");
d.searchParams.put(WebPlotRequest.MULTI_IMAGE_IDX, extensionNumber+"");
return d;
/**
* Factory method to create image overlay related data
* @param fileName - name of the fits file
* @param dataKey - should be a unique string for a fits file
* @param desc - description of the data
* @param extensionNumber - extenions number in the fits file
* @return RelatedData
*/
public static RelatedData makeImageOverlayRelatedData(String fileName, String dataKey, String desc, int extensionNumber) {
Map<String,String> searchParams= new HashMap<>();
searchParams.put(WebPlotRequest.FILE, fileName);
searchParams.put(WebPlotRequest.TYPE, RequestType.FILE+"");
searchParams.put(WebPlotRequest.MULTI_IMAGE_IDX, extensionNumber+"");
return makeImageOverlayRelatedData(searchParams,dataKey,desc);
}

public static RelatedData makeImageOverlayRelatedData(Map<String,String> searchParams, String desc) {
/**
* Factory method to create image overlay related data
* @param searchParams - parameters used to make a WebPlotRequest search
* @param dataKey - should be a unique string for a fits file
* @param desc - description of the data
* @return RelatedData
*/
public static RelatedData makeImageOverlayRelatedData(Map<String,String> searchParams, String dataKey, String desc) {
RelatedData d= new RelatedData();
d.dataType= IMAGE_OVERLAY;
d.desc= desc;
d.dataKey = dataKey;
d.searchParams= searchParams;
return d;
}

public static RelatedData makeTabularRelatedData(Map<String,String> searchParams, String desc) {
/**
* Factory method to create tabular related data
* @param searchParams - parameters us to make a table file type server request
* @param dataKey - should be a unique string for a fits file
* @param desc - description of the data
* @return RelatedData
*/
public static RelatedData makeTabularRelatedData(Map<String,String> searchParams, String dataKey, String desc) {
RelatedData d= new RelatedData();
d.dataType= TABLE;
d.searchParams= searchParams;
d.dataKey = dataKey;
d.desc= desc;
return d;
}


public String getDataType() { return dataType;}
public String getDataKey() { return dataKey;}
public Map<String,String> getAvailableMask() { return availableMask;}
public String getDesc() { return desc;}
public Map<String,String> getSearchParams() { return searchParams;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@
import edu.caltech.ipac.astro.ibe.IBE;
import edu.caltech.ipac.astro.ibe.IbeDataParam;
import edu.caltech.ipac.astro.ibe.IbeDataSource;
import edu.caltech.ipac.firefly.data.FileInfo;
import edu.caltech.ipac.firefly.data.RelatedData;
import edu.caltech.ipac.firefly.data.ServerRequest;
import edu.caltech.ipac.firefly.server.ServerContext;
import edu.caltech.ipac.firefly.data.FileInfo;
import edu.caltech.ipac.firefly.server.query.BaseFileInfoProcessor;
import edu.caltech.ipac.firefly.server.query.DataAccessException;
import edu.caltech.ipac.firefly.server.query.ParamDoc;
import edu.caltech.ipac.firefly.server.query.SearchProcessorImpl;
import edu.caltech.ipac.firefly.server.query.ibe.IbeQueryArtifact;
import edu.caltech.ipac.visualize.plot.WorldPt;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;


@SearchProcessorImpl(id = "ibe_file_retrieve", params =
{@ParamDoc(name = "mission", desc = "mission"),
})
Expand All @@ -48,13 +53,37 @@ protected FileInfo loadData(ServerRequest request) throws IOException, DataAcces
} else {
Map<String, String> cookies = ServerContext.getRequestOwner().getIdentityCookies();
ofile.setCookies(cookies);
ofile.addRelatedDataList( findRelatedDataList(request));
return ofile;
}
} catch (Exception e) {
throw new DataAccessException(e.getMessage(), e);
}
}

private List<RelatedData> findRelatedDataList(ServerRequest r) {
String mission = r.getParam(MISSION);
WorldPt wp= getWorldPtFromCenterParam(r.getParam("center"));
String subsize= r.getParam("subsize");
if (wp==null || mission==null || subsize==null) return null;

switch (mission.toLowerCase()) {
case "wise":
return IbeQueryArtifact.getWiseRelatedData(wp, subsize,r.getParam("band"));
case "2mass":
return IbeQueryArtifact.get2MassRelatedData(wp, subsize);
default:
return null;
}
}

private static WorldPt getWorldPtFromCenterParam(String cen) {
if (cen==null) return null;
String parts[]= cen.split(",");
if (parts.length!=2) return null;
return WorldPt.parse(parts[0]+';' + parts[1]+";J2000");
}

protected File makeOutputFile(IbeDataParam params) throws IOException {
String fname = params.getFileName();
if (fname.contains(".tbl")) {
Expand Down
Loading