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.AnnotationFilter;
import be.cytomine.client.Server;
import org.json.simple.JSONObject;
/**
* Define a set of filter for annotation listing
*
* @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 AbstractAnnotationFilter
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 filter name
*
*/
protected String name;
/**
* The user that create the filter (auto field)
*
*/
protected Long user;
/**
* The project of the filter
*
*/
protected Long project;
/**
* Terms filter id
*
*/
protected List terms;
/**
* Users filter id
*
*/
protected List users;
/**
*
* @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 filter name
*/
public String getName()
throws Exception
{
return name;
}
/**
*
* @param name
* The filter name
*/
public void setName(String name)
throws Exception
{
this.name = name;
}
/**
*
* @return
* The user that create the filter (auto field)
*/
public Long getUser()
throws Exception
{
return user;
}
/**
*
* @return
* The project of the filter
*/
public Long getProject()
throws Exception
{
return project;
}
/**
*
* @param project
* The project of the filter
*/
public void setProject(Long project)
throws Exception
{
this.project = project;
}
/**
*
* @return
* Terms filter id
*/
public List getTerms()
throws Exception
{
return terms;
}
/**
*
* @param terms
* Terms filter id
*/
public void setTerms(List terms)
throws Exception
{
this.terms = terms;
}
/**
*
* @return
* Users filter id
*/
public List getUsers()
throws Exception
{
return users;
}
/**
*
* @param users
* Users filter id
*/
public void setUsers(List users)
throws Exception
{
this.users = users;
}
public void build(String name, Long project)
throws Exception
{
this.name=name;
this.project=project;
}
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.user =JSONUtils.extractJSONLong(json.get("user"));
this.project =JSONUtils.extractJSONLong(json.get("project"));
this.terms =JSONUtils.extractJSONList(json.get("terms"));
this.users =JSONUtils.extractJSONList(json.get("users"));
}
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("user",JSONUtils.formatJSON(this.user));
json.put("project",JSONUtils.formatJSON(this.project));
json.put("terms",JSONUtils.formatJSON(this.terms));
json.put("users",JSONUtils.formatJSON(this.users));
return json;
}
public static AnnotationFilter get(Server server, Long id)
throws Exception
{
String path = "/api/annotationfilter/{id}.json?";
path = path.replace("{id}",id+"");
JSONObject json = server.doGET(path);
AnnotationFilter domain = new AnnotationFilter();
domain.build(json);
return domain;
}
public static AnnotationFilter listByOntology(Server server, Long idOntology, Integer max, Integer offset)
throws Exception
{
throw new Exception("Not yet implemented");
}
public static AnnotationFilter listByProject(Server server, Long project, Integer max, Integer offset)
throws Exception
{
throw new Exception("Not yet implemented");
}
public void add(Server server)
throws Exception
{
String path = "/api/annotationfilter.json?";
JSONObject json = server.doPOST(path,this.toJSON());
this.build((JSONObject)json.get("annotationfilter"));
}
public void delete(Server server)
throws Exception
{
String path = "/api/annotationfilter/{id}.json?";
path = path.replace("{id}",getId()+"");
server.doDELETE(path);
build(new JSONObject());
}
public void edit(Server server)
throws Exception
{
String path = "/api/annotationfilter/{id}.json?";
path = path.replace("{id}",getId()+"");
JSONObject json = server.doPUT(path,this.toJSON());
this.build((JSONObject)json.get("annotationfilter"));
}
}