Skip to content

Commit

Permalink
Added DataLink support
Browse files Browse the repository at this point in the history
  • Loading branch information
mmpcn committed Feb 27, 2014
1 parent 608fe7c commit 5c52cef
Showing 1 changed file with 53 additions and 19 deletions.
72 changes: 53 additions & 19 deletions splat/src/main/uk/ac/starlink/splat/iface/SpectrumIO.java
Expand Up @@ -356,9 +356,13 @@ public static class Props
protected String dataColumn;
protected String coordColumn;
protected String errorColumn;
protected String pubdidValue;
protected String idValue;
protected String idSource;
protected String getDataRequest;
protected String getDataFormat;
protected String dataLinkRequest;
protected String dataLinkFormat;

protected String serverURL;

public Props( String spectrum )
Expand Down Expand Up @@ -386,13 +390,13 @@ public Props( String spectrum, int type, String shortName,
String errorColumn )
{
this( spectrum, type, shortName, dataUnits, coordUnits,
dataColumn, coordColumn, null, null );
dataColumn, coordColumn, null, null, null );
}

public Props( String spectrum, int type, String shortName,
String dataUnits, String coordUnits,
String dataColumn, String coordColumn,
String errorColumn, String pubdidValue )
String errorColumn, String idsrc, String idValue )
{
this.spectrum = spectrum;
this.type = type;
Expand All @@ -404,7 +408,10 @@ public Props( String spectrum, int type, String shortName,
this.errorColumn = errorColumn;
this.getDataRequest=null;
this.getDataFormat=null;
this.pubdidValue=pubdidValue;
this.dataLinkRequest=null;
this.dataLinkFormat=null;
this.idValue=idValue;
this.idSource = idsrc;
this.serverURL=null;
}

Expand All @@ -413,23 +420,28 @@ public String getSpectrum()
if (serverURL == null )
return spectrum;

if (pubdidValue != null && getDataRequest != null )
// if (pubdidValue != null && getDataRequest != null )
if (idValue != null && dataLinkRequest != null && ! dataLinkRequest.isEmpty())
if ( serverURL.endsWith("?"))
// try {
try {
//return (serverURL+"REQUEST=getData"+URLEncoder.encode(getDataRequest+"&PUBDID="+pubdidValue, "UTF-8"));
return (serverURL+"REQUEST=getData"+getDataRequest+"&PUBDID="+pubdidValue);
// } catch (UnsupportedEncodingException e1) {
return (serverURL+"ID="+URLEncoder.encode(idValue, "UTF-8")+dataLinkRequest);
// return (serverURL+"ID="+idValue+);
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
// e1.printStackTrace();
// }
e1.printStackTrace();
}
else
// try {
return (serverURL+"?REQUEST=getData"+getDataRequest+"&PUBDID="+pubdidValue);
try {
// return (serverURL+"?REQUEST=getData"+getDataRequest+"&PUBDID="+pubdidValue);

return (serverURL+ "?"+"ID="+URLEncoder.encode(idValue, "UTF-8")+dataLinkRequest);

// return (serverURL+"?REQUEST=getData"+URLEncoder.encode(getDataRequest+"&PUBDID="+pubdidValue, "UTF-8"));
// } catch (UnsupportedEncodingException e) {
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
// }
e.printStackTrace();
}

return spectrum;
}
Expand Down Expand Up @@ -523,20 +535,29 @@ public void setErrorColumn( String errorColumn )
this.errorColumn = errorColumn;
}

public String getPubdidValue()
public String getidValue()
{
return pubdidValue;
return idValue;
}

public void setPubdidValue( String pubdidValue )
public void setIdValue( String idValue )
{
this.pubdidValue = pubdidValue;
this.idValue = idValue; //!!!
}
public String getGetDataRequest()
{
return getDataRequest;
}

public void setDataLinkRequest( String dataLinkRequest )
{
this.dataLinkRequest = dataLinkRequest;
}
public String getDataLinkRequest()
{
return dataLinkRequest;
}

public void setGetDataRequest( String getDataRequest )
{
this.getDataRequest = getDataRequest;
Expand Down Expand Up @@ -636,6 +657,19 @@ public void apply( SpecData spectrum )
}
}
}

public void setDataLinkFormat(String format) {

dataLinkFormat = format;

}

public void setIdSource(String idsrc) {

idSource = idsrc;

}

}

// Inner class for loading and saving Spectra.
Expand Down

0 comments on commit 5c52cef

Please sign in to comment.