V2_0.java [src/java/m/example/simpleservice] Revision: d2458f1efce4484ddc7664edc851d5323859893f Date: Thu Nov 05 16:11:55 MST 2020
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package m.example.simpleservice;
import csip.ServiceException;
import javax.ws.rs.Path;
import static csip.annotations.State.*;
import csip.annotations.*;
import org.codehaus.jettison.json.JSONObject;
@Name("conv #2")
@Description("Example of an simple service")
@Documentation("https://alm.engr.colostate.edu/csip")
@State(PROTOTYPE)
@License(License.GPL3)
@VersionInfo("$Id$")
@Author(name = "od", email = "<odavid@colostate.edu>", org = "CSU")
@Category("Examples")
@Category("Climate")
@Path("m/simpleservice/2.0")
@Gzip
public class V2_0 extends csip.ModelDataService {
@Override
protected void doProcess() throws Exception {
JSONObject o = new JSONObject();
for (int i = 0; i < 100; i++) {
o.put(Integer.toHexString(i), i);
}
double temp = parameter().getDouble("temp");
String un = parameter().getUnit("temp");
if (un.equals("C")) {
results().put("temp", temp * 9 / 5 + 32, "temperature", "F");
results().put("ts", o);
return;
}
throw new ServiceException("missing unit.");
}
}