package be.cytomine.client.abst;
import be.cytomine.client.*;
import java.util.*;
import org.json.simple.*;
import java.util.Date;
import java.util.List;
import be.cytomine.client.Server;
import be.cytomine.client.Software;
import org.json.simple.JSONObject;
/**
* Software is an application that can read/add/update/delete data from cytomine. Each time a software is launch, we create a job instance
*
* @author ClientBuilder (Loïc Rollus)
* @version 0.1
*
* DO NOT EDIT THIS FILE. THIS IS CODE IS BUILD AUTOMATICALY. ALL CHANGE WILL BE LOST AFTER NEXT GENERATION.
*
* IF YOU WANT TO EDIT A DOMAIN FILE (change method, add property,...), JUST EDIT THE CHILD FILE “YourDomain.java” instead of this file “AbstractYourDomain.java”. I WON'T BE CLEAR IF IT ALREADY EXIST.
*
*/
public abstract class AbstractSoftware
extends AbstractDomain
{
/**
* The full class name of the domain
*
*/
protected String clazz;
/**
* The domain id
*
*/
protected Long id;
/**
* The date of the domain creation
*
*/
protected Date created;
/**
* The date of the domain modification
*
*/
protected Date updated;
/**
* When domain was removed from Cytomine
*
*/
protected Date deleted;
/**
* The software name
*
*/
protected String name;
/**
* Service name used to load software and create job
*
*/
protected String serviceName;
/**
* For UI client: Type of result page. We load a specific page for each software to print data (charts, listing,...)
*
*/
protected String resultName;
/**
* Software info
*
*/
protected String description;
/**
* List of 'software parameter' for this software (sort by index asc)
*
*/
protected List parameters;
/**
* The number of job for this software
*
*/
protected Long numberOfJob;
/**
* The number of job not launch for this software
*
*/
protected Long numberOfNotLaunch;
/**
* The number of job in queue for this software
*
*/
protected Long numberOfInQueue;
/**
* The number of job currently running for this software
*
*/
protected Long numberOfRunning;
/**
* The number of job finished with success for this software
*
*/
protected Long numberOfSuccess;
/**
* The number of job failed for this software
*
*/
protected Long numberOfFailed;
/**
* The number of job in indeterminate status for this software
*
*/
protected Long numberOfIndeterminate;
/**
* The number of job waiting for this software
*
*/
protected Long numberOfWait;
/**
*
* @return
* The full class name of the domain
*/
public String getClazz()
throws Exception
{
return clazz;
}
/**
*
* @return
* The domain id
*/
public Long getId()
throws Exception
{
return id;
}
/**
*
* @return
* The date of the domain creation
*/
public Date getCreated()
throws Exception
{
return created;
}
/**
*
* @return
* The date of the domain modification
*/
public Date getUpdated()
throws Exception
{
return updated;
}
/**
*
* @return
* When domain was removed from Cytomine
*/
public Date getDeleted()
throws Exception
{
return deleted;
}
/**
*
* @return
* The software name
*/
public String getName()
throws Exception
{
return name;
}
/**
*
* @param name
* The software name
*/
public void setName(String name)
throws Exception
{
this.name = name;
}
/**
*
* @return
* Service name used to load software and create job
*/
public String getServiceName()
throws Exception
{
return serviceName;
}
/**
*
* @param serviceName
* Service name used to load software and create job
*/
public void setServiceName(String serviceName)
throws Exception
{
this.serviceName = serviceName;
}
/**
*
* @return
* For UI client: Type of result page. We load a specific page for each software to print data (charts, listing,...)
*/
public String getResultName()
throws Exception
{
return resultName;
}
/**
*
* @param resultName
* For UI client: Type of result page. We load a specific page for each software to print data (charts, listing,...)
*/
public void setResultName(String resultName)
throws Exception
{
this.resultName = resultName;
}
/**
*
* @return
* Software info
*/
public String getDescription()
throws Exception
{
return description;
}
/**
*
* @param description
* Software info
*/
public void setDescription(String description)
throws Exception
{
this.description = description;
}
/**
*
* @return
* List of 'software parameter' for this software (sort by index asc)
*/
public List getParameters()
throws Exception
{
return parameters;
}
/**
*
* @return
* The number of job for this software
*/
public Long getNumberOfJob()
throws Exception
{
return numberOfJob;
}
/**
*
* @return
* The number of job not launch for this software
*/
public Long getNumberOfNotLaunch()
throws Exception
{
return numberOfNotLaunch;
}
/**
*
* @return
* The number of job in queue for this software
*/
public Long getNumberOfInQueue()
throws Exception
{
return numberOfInQueue;
}
/**
*
* @return
* The number of job currently running for this software
*/
public Long getNumberOfRunning()
throws Exception
{
return numberOfRunning;
}
/**
*
* @return
* The number of job finished with success for this software
*/
public Long getNumberOfSuccess()
throws Exception
{
return numberOfSuccess;
}
/**
*
* @return
* The number of job failed for this software
*/
public Long getNumberOfFailed()
throws Exception
{
return numberOfFailed;
}
/**
*
* @return
* The number of job in indeterminate status for this software
*/
public Long getNumberOfIndeterminate()
throws Exception
{
return numberOfIndeterminate;
}
/**
*
* @return
* The number of job waiting for this software
*/
public Long getNumberOfWait()
throws Exception
{
return numberOfWait;
}
public void build(String name)
throws Exception
{
this.name=name;
}
public void build(JSONObject json)
throws Exception
{
this.clazz =JSONUtils.extractJSONString(json.get("class"));
this.id =JSONUtils.extractJSONLong(json.get("id"));
this.created =JSONUtils.extractJSONDate(json.get("created"));
this.updated =JSONUtils.extractJSONDate(json.get("updated"));
this.deleted =JSONUtils.extractJSONDate(json.get("deleted"));
this.name =JSONUtils.extractJSONString(json.get("name"));
this.serviceName =JSONUtils.extractJSONString(json.get("serviceName"));
this.resultName =JSONUtils.extractJSONString(json.get("resultName"));
this.description =JSONUtils.extractJSONString(json.get("description"));
this.parameters =JSONUtils.extractJSONList(json.get("parameters"));
this.numberOfJob =JSONUtils.extractJSONLong(json.get("numberOfJob"));
this.numberOfNotLaunch =JSONUtils.extractJSONLong(json.get("numberOfNotLaunch"));
this.numberOfInQueue =JSONUtils.extractJSONLong(json.get("numberOfInQueue"));
this.numberOfRunning =JSONUtils.extractJSONLong(json.get("numberOfRunning"));
this.numberOfSuccess =JSONUtils.extractJSONLong(json.get("numberOfSuccess"));
this.numberOfFailed =JSONUtils.extractJSONLong(json.get("numberOfFailed"));
this.numberOfIndeterminate =JSONUtils.extractJSONLong(json.get("numberOfIndeterminate"));
this.numberOfWait =JSONUtils.extractJSONLong(json.get("numberOfWait"));
}
public JSONObject toJSON()
throws Exception
{
JSONObject json=new JSONObject();
json.put("class",JSONUtils.formatJSON(this.clazz));
json.put("id",JSONUtils.formatJSON(this.id));
json.put("created",JSONUtils.formatJSON(this.created));
json.put("updated",JSONUtils.formatJSON(this.updated));
json.put("deleted",JSONUtils.formatJSON(this.deleted));
json.put("name",JSONUtils.formatJSON(this.name));
json.put("serviceName",JSONUtils.formatJSON(this.serviceName));
json.put("resultName",JSONUtils.formatJSON(this.resultName));
json.put("description",JSONUtils.formatJSON(this.description));
json.put("parameters",JSONUtils.formatJSON(this.parameters));
json.put("numberOfJob",JSONUtils.formatJSON(this.numberOfJob));
json.put("numberOfNotLaunch",JSONUtils.formatJSON(this.numberOfNotLaunch));
json.put("numberOfInQueue",JSONUtils.formatJSON(this.numberOfInQueue));
json.put("numberOfRunning",JSONUtils.formatJSON(this.numberOfRunning));
json.put("numberOfSuccess",JSONUtils.formatJSON(this.numberOfSuccess));
json.put("numberOfFailed",JSONUtils.formatJSON(this.numberOfFailed));
json.put("numberOfIndeterminate",JSONUtils.formatJSON(this.numberOfIndeterminate));
json.put("numberOfWait",JSONUtils.formatJSON(this.numberOfWait));
return json;
}
public static Software get(Server server, Long id)
throws Exception
{
String path = "/api/software/{id}.json?";
path = path.replace("{id}",id+"");
JSONObject json = server.doGET(path);
Software domain = new Software();
domain.build(json);
return domain;
}
public static Object softwareInfoForProject(Server server, Long idProject, Long idSoftware, Integer max, Integer offset)
throws Exception
{
throw new Exception("Not yet implemented");
}
public static List listByProject(Server server, Long id)
throws Exception
{
String path = "/api/project/{id}/software.json?";
path = path.replace("{id}",id+"");
JSONArray json = server.doGETList(path);
List<Software> domains = new ArrayList<Software>();
for(int i=0;i<json.size();i++) {
Software domain = new Software();
domain.build((JSONObject)json.get(i));
domains.add(domain);
}
return domains;
}
public static List listByProject(Server server, Long id, Integer max, Integer offset)
throws Exception
{
String path = "/api/project/{id}/software.json?";
path = path.replace("{id}",id+"");
path = path + "&max=" + max;
path = path + "&offset=" + offset;
JSONArray json = server.doGETList(path);
List<Software> domains = new ArrayList<Software>();
for(int i=0;i<json.size();i++) {
Software domain = new Software();
domain.build((JSONObject)json.get(i));
domains.add(domain);
}
return domains;
}
public void add(Server server)
throws Exception
{
String path = "/api/software.json?";
JSONObject json = server.doPOST(path,this.toJSON());
this.build((JSONObject)json.get("software"));
}
public static List list(Server server)
throws Exception
{
String path = "/api/software.json?";
JSONArray json = server.doGETList(path);
List<Software> domains = new ArrayList<Software>();
for(int i=0;i<json.size();i++) {
Software domain = new Software();
domain.build((JSONObject)json.get(i));
domains.add(domain);
}
return domains;
}
public static List list(Server server, Integer max, Integer offset)
throws Exception
{
String path = "/api/software.json?";
path = path + "&max=" + max;
path = path + "&offset=" + offset;
JSONArray json = server.doGETList(path);
List<Software> domains = new ArrayList<Software>();
for(int i=0;i<json.size();i++) {
Software domain = new Software();
domain.build((JSONObject)json.get(i));
domains.add(domain);
}
return domains;
}
public void delete(Server server)
throws Exception
{
String path = "/api/software/{id}.json?";
path = path.replace("{id}",getId()+"");
path = path + "&max=" + getMax();
path = path + "&offset=" + getOffset();
server.doDELETE(path);
build(new JSONObject());
}
public void edit(Server server)
throws Exception
{
String path = "/api/software/{id}.json?";
path = path.replace("{id}",getId()+"");
path = path + "&max=" + getMax();
path = path + "&offset=" + getOffset();
JSONObject json = server.doPUT(path,this.toJSON());
this.build((JSONObject)json.get("software"));
}
}