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.Property; import be.cytomine.client.Server; import org.json.simple.JSONObject; /** * A key-value entry that can be map to a domain (project, image, 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 AbstractProperty 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 domain identifier (id) * */ protected Long domainIdent; /** * The domain class * */ protected String domainClassName; /** * The property key * */ protected String key; /** * The property value * */ protected String value; /** * * @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 domain identifier (id) */ public Long getDomainIdent() throws Exception { return domainIdent; } /** * * @param domainIdent * The domain identifier (id) */ public void setDomainIdent(Long domainIdent) throws Exception { this.domainIdent = domainIdent; } /** * * @return * The domain class */ public String getDomainClassName() throws Exception { return domainClassName; } /** * * @param domainClassName * The domain class */ public void setDomainClassName(String domainClassName) throws Exception { this.domainClassName = domainClassName; } /** * * @return * The property key */ public String getKey() throws Exception { return key; } /** * * @param key * The property key */ public void setKey(String key) throws Exception { this.key = key; } /** * * @return * The property value */ public String getValue() throws Exception { return value; } /** * * @param value * The property value */ public void setValue(String value) throws Exception { this.value = value; } public void build(Long domainIdent, String domainClassName, String key, String value) throws Exception { this.domainIdent=domainIdent; this.domainClassName=domainClassName; this.key=key; this.value=value; } 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.key =JSONUtils.extractJSONString(json.get("key")); this.value =JSONUtils.extractJSONString(json.get("value")); } 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("key",JSONUtils.formatJSON(this.key)); json.put("value",JSONUtils.formatJSON(this.value)); return json; } public static List listByImageInstance(Server server, Long idImageInstance) throws Exception { String path = "/api/imageinstance/{idImageInstance}/property.json?"; path = path.replace("{idImageInstance}",idImageInstance+""); JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listByImageInstance(Server server, Long idImageInstance, Integer max, Integer offset) throws Exception { String path = "/api/imageinstance/{idImageInstance}/property.json?"; path = path.replace("{idImageInstance}",idImageInstance+""); path = path + "&max=" + max; path = path + "&offset=" + offset; JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listKeyForAnnotation(Server server, Long idProject, Long idImage) throws Exception { String path = "/api/annotation/property/key.json?"; path = path + "&idProject=" + idProject; path = path + "&idImage=" + idImage; JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listKeyForAnnotation(Server server, Long idProject, Long idImage, Integer max, Integer offset) throws Exception { String path = "/api/annotation/property/key.json?"; path = path + "&idProject=" + idProject; path = path + "&idImage=" + idImage; path = path + "&max=" + max; path = path + "&offset=" + offset; JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listKeyForImageInstance(Server server, Long idProject) throws Exception { String path = "/api/imageinstance/property/key.json?"; path = path + "&idProject=" + idProject; JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listKeyForImageInstance(Server server, Long idProject, Integer max, Integer offset) throws Exception { String path = "/api/imageinstance/property/key.json?"; path = path + "&idProject=" + idProject; path = path + "&max=" + max; path = path + "&offset=" + offset; JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listAnnotationPosition(Server server, Long idImage, Long idUser, Long key, String bbox) throws Exception { String path = "/api/user/{idUser}/imageinstance/{idImage}/annotationposition.json?"; path = path.replace("{idImage}",idImage+""); path = path.replace("{idUser}",idUser+""); path = path + "&key=" + key; path = path + "&bbox=" + bbox; JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listAnnotationPosition(Server server, Long idImage, Long idUser, Long key, String bbox, Integer max, Integer offset) throws Exception { String path = "/api/user/{idUser}/imageinstance/{idImage}/annotationposition.json?"; path = path.replace("{idImage}",idImage+""); path = path.replace("{idUser}",idUser+""); path = path + "&key=" + key; path = path + "&bbox=" + bbox; path = path + "&max=" + max; path = path + "&offset=" + offset; JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static Property showProject(Server server, Long idProject, Long id, Long key) throws Exception { throw new Exception("Not yet implemented"); } public static Property showAnnotation(Server server, Long idAnnotation, Long id, Long key) throws Exception { throw new Exception("Not yet implemented"); } public static Property showImageInstance(Server server, Long idImageInstance, Long id, Long key) throws Exception { throw new Exception("Not yet implemented"); } public static Property addPropertyProject(Server server, Long idProject) throws Exception { throw new Exception("Not yet implemented"); } public static Property addPropertyAnnotation(Server server, Long idAnnotation) throws Exception { throw new Exception("Not yet implemented"); } public static Property addPropertyImageInstance(Server server, Long idImageInstance) throws Exception { throw new Exception("Not yet implemented"); } public static List listByAnnotation(Server server, Long idAnnotation) throws Exception { String path = "/api/annotation/{idAnnotation}/property.json?"; path = path.replace("{idAnnotation}",idAnnotation+""); JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listByAnnotation(Server server, Long idAnnotation, Integer max, Integer offset) throws Exception { String path = "/api/annotation/{idAnnotation}/property.json?"; path = path.replace("{idAnnotation}",idAnnotation+""); path = path + "&max=" + max; path = path + "&offset=" + offset; JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listByProject(Server server, Long idProject) throws Exception { String path = "/api/project/{idProject}/property.json?"; path = path.replace("{idProject}",idProject+""); JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public static List listByProject(Server server, Long idProject, Integer max, Integer offset) throws Exception { String path = "/api/project/{idProject}/property.json?"; path = path.replace("{idProject}",idProject+""); path = path + "&max=" + max; path = path + "&offset=" + offset; JSONArray json = server.doGETList(path); List<Property> domains = new ArrayList<Property>(); for(int i=0;i<json.size();i++) { Property domain = new Property(); domain.build((JSONObject)json.get(i)); domains.add(domain); } return domains; } public void delete(Server server) throws Exception { String path = "/api/imageinstance/{idImageInstance}/property/{id}.json?"; path = path.replace("{id}",getId()+""); server.doDELETE(path); build(new JSONObject()); } public void edit(Server server) throws Exception { String path = "/api/imageinstance/{idImageInstance}/property/{id}.json?"; path = path.replace("{idAnnotation}",getIdAnnotation()+""); path = path.replace("{idImageInstance}",getIdImageInstance()+""); path = path.replace("{idProject}",getIdProject()+""); JSONObject json = server.doPUT(path,this.toJSON()); this.build((JSONObject)json.get("property")); } }