package be.cytomine.client.abst; import be.cytomine.client.*; import java.util.*; import org.json.simple.*; import java.util.Date; import be.cytomine.client.AttachedFile; import be.cytomine.client.Server; import org.json.simple.JSONObject; /** * A file that may be attached to any Cytomine domain. Usefull to include file into description. * * @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 AbstractAttachedFile 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; /** * Domain id * */ protected Long domainIdent; /** * Domain class name * */ protected String domainClassName; /** * URL to get this file * */ protected String url; /** * File name with ext * */ protected String filename; /** * * @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 * Domain id */ public Long getDomainIdent() throws Exception { return domainIdent; } /** * * @param domainIdent * Domain id */ public void setDomainIdent(Long domainIdent) throws Exception { this.domainIdent = domainIdent; } /** * * @return * Domain class name */ public String getDomainClassName() throws Exception { return domainClassName; } /** * * @param domainClassName * Domain class name */ public void setDomainClassName(String domainClassName) throws Exception { this.domainClassName = domainClassName; } /** * * @return * URL to get this file */ public String getUrl() throws Exception { return url; } /** * * @return * File name with ext */ public String getFilename() throws Exception { return filename; } /** * * @param filename * File name with ext */ public void setFilename(String filename) throws Exception { this.filename = filename; } public void build(Long domainIdent, String domainClassName, String filename) throws Exception { this.domainIdent=domainIdent; this.domainClassName=domainClassName; this.filename=filename; } 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.domainIdent =JSONUtils.extractJSONLong(json.get("domainIdent")); this.domainClassName =JSONUtils.extractJSONString(json.get("domainClassName")); this.url =JSONUtils.extractJSONString(json.get("url")); this.filename =JSONUtils.extractJSONString(json.get("filename")); } 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("domainIdent",JSONUtils.formatJSON(this.domainIdent)); json.put("domainClassName",JSONUtils.formatJSON(this.domainClassName)); json.put("url",JSONUtils.formatJSON(this.url)); json.put("filename",JSONUtils.formatJSON(this.filename)); return json; } public static AttachedFile get(Server server, Long id) throws Exception { String path = "/api/attachedfile/{id}.json?"; path = path.replace("{id}",id+""); JSONObject json = server.doGET(path); AttachedFile domain = new AttachedFile(); domain.build(json); return domain; } public static Object download(Server server, Long id) throws Exception { throw new Exception("Not yet implemented"); } public static AttachedFile upload(Server server, Long domainIdent, String domainClassName) throws Exception { throw new Exception("Not yet implemented"); } public static AttachedFile listByDomain(Server server, Long domainIdent, String domainClassName, Integer max, Integer offset) throws Exception { throw new Exception("Not yet implemented"); } public static AttachedFile uploadFromCKEditor(Server server, Long domainIdent, String domainClassName) throws Exception { throw new Exception("Not yet implemented"); } public static AttachedFile list(Server server, Integer max, Integer offset) throws Exception { throw new Exception("Not yet implemented"); } }