package be.cytomine.client.abst;
import be.cytomine.client.*;
import java.util.*;
import org.json.simple.*;
import java.util.Date;
import be.cytomine.client.Server;
import be.cytomine.client.SoftwareParameter;
import org.json.simple.JSONObject;
/**
* A parameter for a software. It's a template to create job parameter. When job is init, we create job parameter list based on software parameter list.
*
* @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 AbstractSoftwareParameter
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 parameter name
*
*/
protected String name;
/**
* The parameter data type (Number, String, Date, Boolean, Domain (e.g: image instance id,...), ListDomain )
*
*/
protected String type;
/**
* Default value when creating job parameter
*
*/
protected String defaultParamValue;
/**
* Flag if value is mandatory
*
*/
protected Boolean required;
/**
* The software of the parameter
*
*/
protected Long software;
/**
* Index for parameter position. When launching software, parameter will be send ordered by index (asc).
*
*/
protected Integer index;
/**
* Used for UI. If parameter has '(List)Domain' type, the URI will provide a list of choice. E.g. if uri is 'api/project.json', the choice list will be cytomine project list
*
*/
protected String uri;
/**
* Used for UI. JSON Fields to print in choice list. E.g. if uri is api/project.json and uriPrintAttribut is 'name', the choice list will contains project name
*
*/
protected String uriPrintAttribut;
/**
* Used for UI. JSON Fields used to sort choice list. E.g. if uri is api/project.json and uriSortAttribut is 'id', projects will be sort by id (not by name)
*
*/
protected String uriSortAttribut;
/**
* Indicated if the field is autofilled by the server
*
*/
protected Boolean setByServer;
/**
*
* @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 parameter name
*/
public String getName()
throws Exception
{
return name;
}
/**
*
* @param name
* The parameter name
*/
public void setName(String name)
throws Exception
{
this.name = name;
}
/**
*
* @return
* The parameter data type (Number, String, Date, Boolean, Domain (e.g: image instance id,...), ListDomain )
*/
public String getType()
throws Exception
{
return type;
}
/**
*
* @param type
* The parameter data type (Number, String, Date, Boolean, Domain (e.g: image instance id,...), ListDomain )
*/
public void setType(String type)
throws Exception
{
this.type = type;
}
/**
*
* @return
* Default value when creating job parameter
*/
public String getDefaultParamValue()
throws Exception
{
return defaultParamValue;
}
/**
*
* @param defaultParamValue
* Default value when creating job parameter
*/
public void setDefaultParamValue(String defaultParamValue)
throws Exception
{
this.defaultParamValue = defaultParamValue;
}
/**
*
* @return
* Flag if value is mandatory
*/
public Boolean getRequired()
throws Exception
{
return required;
}
/**
*
* @param required
* Flag if value is mandatory
*/
public void setRequired(Boolean required)
throws Exception
{
this.required = required;
}
/**
*
* @return
* The software of the parameter
*/
public Long getSoftware()
throws Exception
{
return software;
}
/**
*
* @param software
* The software of the parameter
*/
public void setSoftware(Long software)
throws Exception
{
this.software = software;
}
/**
*
* @return
* Index for parameter position. When launching software, parameter will be send ordered by index (asc).
*/
public Integer getIndex()
throws Exception
{
return index;
}
/**
*
* @param index
* Index for parameter position. When launching software, parameter will be send ordered by index (asc).
*/
public void setIndex(Integer index)
throws Exception
{
this.index = index;
}
/**
*
* @return
* Used for UI. If parameter has '(List)Domain' type, the URI will provide a list of choice. E.g. if uri is 'api/project.json', the choice list will be cytomine project list
*/
public String getUri()
throws Exception
{
return uri;
}
/**
*
* @param uri
* Used for UI. If parameter has '(List)Domain' type, the URI will provide a list of choice. E.g. if uri is 'api/project.json', the choice list will be cytomine project list
*/
public void setUri(String uri)
throws Exception
{
this.uri = uri;
}
/**
*
* @return
* Used for UI. JSON Fields to print in choice list. E.g. if uri is api/project.json and uriPrintAttribut is 'name', the choice list will contains project name
*/
public String getUriPrintAttribut()
throws Exception
{
return uriPrintAttribut;
}
/**
*
* @param uriPrintAttribut
* Used for UI. JSON Fields to print in choice list. E.g. if uri is api/project.json and uriPrintAttribut is 'name', the choice list will contains project name
*/
public void setUriPrintAttribut(String uriPrintAttribut)
throws Exception
{
this.uriPrintAttribut = uriPrintAttribut;
}
/**
*
* @return
* Used for UI. JSON Fields used to sort choice list. E.g. if uri is api/project.json and uriSortAttribut is 'id', projects will be sort by id (not by name)
*/
public String getUriSortAttribut()
throws Exception
{
return uriSortAttribut;
}
/**
*
* @param uriSortAttribut
* Used for UI. JSON Fields used to sort choice list. E.g. if uri is api/project.json and uriSortAttribut is 'id', projects will be sort by id (not by name)
*/
public void setUriSortAttribut(String uriSortAttribut)
throws Exception
{
this.uriSortAttribut = uriSortAttribut;
}
/**
*
* @return
* Indicated if the field is autofilled by the server
*/
public Boolean getSetByServer()
throws Exception
{
return setByServer;
}
/**
*
* @param setByServer
* Indicated if the field is autofilled by the server
*/
public void setSetByServer(Boolean setByServer)
throws Exception
{
this.setByServer = setByServer;
}
public void build(String name, String type, Long software)
throws Exception
{
this.name=name;
this.type=type;
this.software=software;
}
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.type =JSONUtils.extractJSONString(json.get("type"));
this.defaultParamValue =JSONUtils.extractJSONString(json.get("defaultParamValue"));
this.required =JSONUtils.extractJSONBoolean(json.get("required"));
this.software =JSONUtils.extractJSONLong(json.get("software"));
this.index =JSONUtils.extractJSONInteger(json.get("index"));
this.uri =JSONUtils.extractJSONString(json.get("uri"));
this.uriPrintAttribut =JSONUtils.extractJSONString(json.get("uriPrintAttribut"));
this.uriSortAttribut =JSONUtils.extractJSONString(json.get("uriSortAttribut"));
this.setByServer =JSONUtils.extractJSONBoolean(json.get("setByServer"));
}
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("type",JSONUtils.formatJSON(this.type));
json.put("defaultParamValue",JSONUtils.formatJSON(this.defaultParamValue));
json.put("required",JSONUtils.formatJSON(this.required));
json.put("software",JSONUtils.formatJSON(this.software));
json.put("index",JSONUtils.formatJSON(this.index));
json.put("uri",JSONUtils.formatJSON(this.uri));
json.put("uriPrintAttribut",JSONUtils.formatJSON(this.uriPrintAttribut));
json.put("uriSortAttribut",JSONUtils.formatJSON(this.uriSortAttribut));
json.put("setByServer",JSONUtils.formatJSON(this.setByServer));
return json;
}
public static SoftwareParameter get(Server server, Long id)
throws Exception
{
String path = "/api/softwareparameter/{id}.json?";
path = path.replace("{id}",id+"");
JSONObject json = server.doGET(path);
SoftwareParameter domain = new SoftwareParameter();
domain.build(json);
return domain;
}
public static SoftwareParameter listBySoftware(Server server, Long id, Boolean setByServer, Integer max, Integer offset)
throws Exception
{
throw new Exception("Not yet implemented");
}
public void add(Server server)
throws Exception
{
String path = "/api/softwareparameter.json?";
JSONObject json = server.doPOST(path,this.toJSON());
this.build((JSONObject)json.get("softwareparameter"));
}
public static SoftwareParameter list(Server server, Integer max, Integer offset)
throws Exception
{
throw new Exception("Not yet implemented");
}
public void delete(Server server)
throws Exception
{
String path = "/api/softwareparameter/{id}.json?";
path = path.replace("{id}",getId()+"");
server.doDELETE(path);
build(new JSONObject());
}
public void edit(Server server)
throws Exception
{
String path = "/api/softwareparameter/{id}.json?";
path = path.replace("{id}",getId()+"");
JSONObject json = server.doPUT(path,this.toJSON());
this.build((JSONObject)json.get("softwareparameter"));
}
}