package be.cytomine.client.abst;
import be.cytomine.client.*;
import java.util.*;
import org.json.simple.*;
import java.util.Date;
import be.cytomine.client.AnnotationTerm;
import be.cytomine.client.Server;
import org.json.simple.JSONObject;
/**
* Term added to an annotation by a real user (not a job!). Many user can add a term to a single annotation (not only the user that created this annotation)
*
* @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 AbstractAnnotationTerm
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 annotation id
*
*/
protected Long userannotation;
/**
* The term id
*
*/
protected Long term;
/**
* The user id
*
*/
protected Long user;
/**
*
* @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 annotation id
*/
public Long getUserannotation()
throws Exception
{
return userannotation;
}
/**
*
* @param userannotation
* The annotation id
*/
public void setUserannotation(Long userannotation)
throws Exception
{
this.userannotation = userannotation;
}
/**
*
* @return
* The term id
*/
public Long getTerm()
throws Exception
{
return term;
}
/**
*
* @param term
* The term id
*/
public void setTerm(Long term)
throws Exception
{
this.term = term;
}
/**
*
* @return
* The user id
*/
public Long getUser()
throws Exception
{
return user;
}
/**
*
* @param user
* The user id
*/
public void setUser(Long user)
throws Exception
{
this.user = user;
}
public void build(Long userannotation, Long term)
throws Exception
{
this.userannotation=userannotation;
this.term=term;
}
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.userannotation =JSONUtils.extractJSONLong(json.get("userannotation"));
this.term =JSONUtils.extractJSONLong(json.get("term"));
this.user =JSONUtils.extractJSONLong(json.get("user"));
}
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("userannotation",JSONUtils.formatJSON(this.userannotation));
json.put("term",JSONUtils.formatJSON(this.term));
json.put("user",JSONUtils.formatJSON(this.user));
return json;
}
public static AnnotationTerm get(Server server, Long idannotation, Long idterm)
throws Exception
{
String path = "/api/annotation/{idannotation}/term/{idterm}/user/{idUser}.json?";
path = path.replace("{idannotation}",idannotation+"");
path = path.replace("{idterm}",idterm+"");
JSONObject json = server.doGET(path);
AnnotationTerm domain = new AnnotationTerm();
domain.build(json);
return domain;
}
public static AnnotationTerm listTermByAnnotation(Server server, Long idannotation, Long idUser, Integer max, Integer offset)
throws Exception
{
throw new Exception("Not yet implemented");
}
public static AnnotationTerm listAnnotationTermByUserNot(Server server, Long idannotation, Long idNotUser, Integer max, Integer offset)
throws Exception
{
throw new Exception("Not yet implemented");
}
public static AnnotationTerm addWithDeletingOldTerm(Server server, Long idannotation, Long idterm, Boolean clearForAll)
throws Exception
{
throw new Exception("Not yet implemented");
}
public void add(Server server)
throws Exception
{
String path = "/api/annotation/{idannotation}/term/{idterm}.json?";
JSONObject json = server.doPOST(path,this.toJSON());
this.build((JSONObject)json.get("annotationterm"));
}
public void delete(Server server)
throws Exception
{
String path = "/api/annotation/{idannotation}/term/{idterm}/user/{idUser}.json?";
path = path.replace("{idannotation}",getIdannotation()+"");
path = path.replace("{idterm}",getIdterm()+"");
server.doDELETE(path);
build(new JSONObject());
}
}