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.UploadedFile; import org.json.simple.JSONObject; /** * A file uploaded on the server, when finished, we create an 'abstract image' from this uploaded file * * @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 AbstractUploadedFile 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 user that upload the file * */ protected Long user; /** * List of project (id) that will get the image * */ protected Long projects; /** * List of storage (id) that will store the image * */ protected Long storages; /** * Upload file filename * */ protected String filename; /** * Upload file short name * */ protected String originalFilename; /** * Extension name * */ protected String ext; /** * File content type * */ protected String contentType; /** * File size * */ protected Long size; /** * Path name * */ protected String path; /** * File status (UPLOADED = 0,CONVERTED = 1,DEPLOYED = 2,ERROR_FORMAT = 3,ERROR_CONVERT = 4,UNCOMPRESSED = 5,TO_DEPLOY = 6) * */ protected Integer status; /** * Indicates if the file is uploaded * */ protected Boolean uploaded; /** * Indicates if the file is converted * */ protected Boolean converted; /** * Indicates if the file is deployed * */ protected Boolean deployed; /** * Indicates if there is a error with file format * */ protected Boolean error_format; /** * Indicates if there is an error with file conversion * */ protected Boolean error_convert; /** * Indicates if the file is not compressed * */ protected Boolean uncompressed; /** * Undefined * */ protected Object to_deploy; /** * The converted extension * */ protected String convertedExt; /** * The converted filename * */ protected String convertedFilename; /** * * @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 user that upload the file */ public Long getUser() throws Exception { return user; } /** * * @param user * The user that upload the file */ public void setUser(Long user) throws Exception { this.user = user; } /** * * @return * List of project (id) that will get the image */ public Long getProjects() throws Exception { return projects; } /** * * @param projects * List of project (id) that will get the image */ public void setProjects(Long projects) throws Exception { this.projects = projects; } /** * * @return * List of storage (id) that will store the image */ public Long getStorages() throws Exception { return storages; } /** * * @param storages * List of storage (id) that will store the image */ public void setStorages(Long storages) throws Exception { this.storages = storages; } /** * * @return * Upload file filename */ public String getFilename() throws Exception { return filename; } /** * * @param filename * Upload file filename */ public void setFilename(String filename) throws Exception { this.filename = filename; } /** * * @return * Upload file short name */ public String getOriginalFilename() throws Exception { return originalFilename; } /** * * @param originalFilename * Upload file short name */ public void setOriginalFilename(String originalFilename) throws Exception { this.originalFilename = originalFilename; } /** * * @return * Extension name */ public String getExt() throws Exception { return ext; } /** * * @param ext * Extension name */ public void setExt(String ext) throws Exception { this.ext = ext; } /** * * @param contentType * File content type */ public void setContentType(String contentType) throws Exception { this.contentType = contentType; } /** * * @return * File size */ public Long getSize() throws Exception { return size; } /** * * @param size * File size */ public void setSize(Long size) throws Exception { this.size = size; } /** * * @return * Path name */ public String getPath() throws Exception { return path; } /** * * @param path * Path name */ public void setPath(String path) throws Exception { this.path = path; } /** * * @return * File status (UPLOADED = 0,CONVERTED = 1,DEPLOYED = 2,ERROR_FORMAT = 3,ERROR_CONVERT = 4,UNCOMPRESSED = 5,TO_DEPLOY = 6) */ public Integer getStatus() throws Exception { return status; } /** * * @param status * File status (UPLOADED = 0,CONVERTED = 1,DEPLOYED = 2,ERROR_FORMAT = 3,ERROR_CONVERT = 4,UNCOMPRESSED = 5,TO_DEPLOY = 6) */ public void setStatus(Integer status) throws Exception { this.status = status; } /** * * @return * Indicates if the file is uploaded */ public Boolean getUploaded() throws Exception { return uploaded; } /** * * @return * Indicates if the file is converted */ public Boolean getConverted() throws Exception { return converted; } /** * * @return * Indicates if the file is deployed */ public Boolean getDeployed() throws Exception { return deployed; } /** * * @return * Indicates if there is a error with file format */ public Boolean getError_format() throws Exception { return error_format; } /** * * @return * Indicates if there is an error with file conversion */ public Boolean getError_convert() throws Exception { return error_convert; } /** * * @return * Indicates if the file is not compressed */ public Boolean getUncompressed() throws Exception { return uncompressed; } /** * * @return * Undefined */ public Object getTo_deploy() throws Exception { return to_deploy; } /** * * @param to_deploy * Undefined */ public void setTo_deploy(Object to_deploy) throws Exception { this.to_deploy = to_deploy; } /** * * @param convertedExt * The converted extension */ public void setConvertedExt(String convertedExt) throws Exception { this.convertedExt = convertedExt; } /** * * @param convertedFilename * The converted filename */ public void setConvertedFilename(String convertedFilename) throws Exception { this.convertedFilename = convertedFilename; } public void build(Long user, Long projects, Long storages, String filename, String originalFilename, String ext, String contentType, String path, String convertedExt, String convertedFilename) throws Exception { this.user=user; this.projects=projects; this.storages=storages; this.filename=filename; this.originalFilename=originalFilename; this.ext=ext; this.contentType=contentType; this.path=path; this.convertedExt=convertedExt; this.convertedFilename=convertedFilename; } 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.user =JSONUtils.extractJSONLong(json.get("user")); this.projects =JSONUtils.extractJSONLong(json.get("projects")); this.storages =JSONUtils.extractJSONLong(json.get("storages")); this.filename =JSONUtils.extractJSONString(json.get("filename")); this.originalFilename =JSONUtils.extractJSONString(json.get("originalFilename")); this.ext =JSONUtils.extractJSONString(json.get("ext")); this.contentType =JSONUtils.extractJSONString(json.get("contentType")); this.size =JSONUtils.extractJSONLong(json.get("size")); this.path =JSONUtils.extractJSONString(json.get("path")); this.status =JSONUtils.extractJSONInteger(json.get("status")); this.uploaded =JSONUtils.extractJSONBoolean(json.get("uploaded")); this.converted =JSONUtils.extractJSONBoolean(json.get("converted")); this.deployed =JSONUtils.extractJSONBoolean(json.get("deployed")); this.error_format =JSONUtils.extractJSONBoolean(json.get("error_format")); this.error_convert =JSONUtils.extractJSONBoolean(json.get("error_convert")); this.uncompressed =JSONUtils.extractJSONBoolean(json.get("uncompressed")); this.to_deploy =JSONUtils.extractJSONObject(json.get("to_deploy")); this.convertedExt =JSONUtils.extractJSONString(json.get("convertedExt")); this.convertedFilename =JSONUtils.extractJSONString(json.get("convertedFilename")); } 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("user",JSONUtils.formatJSON(this.user)); json.put("projects",JSONUtils.formatJSON(this.projects)); json.put("storages",JSONUtils.formatJSON(this.storages)); json.put("filename",JSONUtils.formatJSON(this.filename)); json.put("originalFilename",JSONUtils.formatJSON(this.originalFilename)); json.put("ext",JSONUtils.formatJSON(this.ext)); json.put("size",JSONUtils.formatJSON(this.size)); json.put("path",JSONUtils.formatJSON(this.path)); json.put("status",JSONUtils.formatJSON(this.status)); json.put("uploaded",JSONUtils.formatJSON(this.uploaded)); json.put("converted",JSONUtils.formatJSON(this.converted)); json.put("deployed",JSONUtils.formatJSON(this.deployed)); json.put("error_format",JSONUtils.formatJSON(this.error_format)); json.put("error_convert",JSONUtils.formatJSON(this.error_convert)); json.put("uncompressed",JSONUtils.formatJSON(this.uncompressed)); json.put("to_deploy",JSONUtils.formatJSON(this.to_deploy)); return json; } public static UploadedFile get(Server server, Long id) throws Exception { String path = "/api/uploadedfile/{id}.json?"; path = path.replace("{id}",id+""); JSONObject json = server.doGET(path); UploadedFile domain = new UploadedFile(); domain.build(json); return domain; } public static Object createImage(Server server, Long uploadedFile) throws Exception { throw new Exception("Not yet implemented"); } public static Object clearProperties(Server server, Long id) throws Exception { throw new Exception("Not yet implemented"); } public static Object populateProperties(Server server, Long id) throws Exception { throw new Exception("Not yet implemented"); } public static Object extractProperties(Server server, Long id) throws Exception { throw new Exception("Not yet implemented"); } public void add(Server server) throws Exception { String path = "/api/uploadedfile.json?"; JSONObject json = server.doPOST(path,this.toJSON()); this.build((JSONObject)json.get("uploadedfile")); } public static UploadedFile list(Server server) throws Exception { throw new Exception("Not yet implemented"); } public void delete(Server server) throws Exception { String path = "/api/uploadedfile/{id}.json?"; path = path.replace("{id}",getId()+""); server.doDELETE(path); build(new JSONObject()); } public void edit(Server server) throws Exception { String path = "/api/uploadedfile/{id}.json?"; path = path.replace("{id}",getId()+""); JSONObject json = server.doPUT(path,this.toJSON()); this.build((JSONObject)json.get("uploadedfile")); } }