Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
eburtin committed Jun 13, 2019
2 parents d5d5b52 + 0d738fd commit 98bc45f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/main/java/be/cytomine/client/Cytomine.java
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ public UploadedFile addUploadedFile(String originalFilename, String realFilename

public UploadedFileCollection getUploadedFiles(boolean deleted) throws CytomineException {
UploadedFileCollection files = new UploadedFileCollection(offset, max);
files.addParams("deleted", "true");
files.addParams("deleted", ""+deleted);
return fetchCollection(files);
}

Expand Down Expand Up @@ -1530,6 +1530,11 @@ public UploadedFile getUploadedFile(Long id) throws CytomineException {
uploadedFile.set("id", id);
return fetchModel(uploadedFile);
}
public UploadedFile getUploadedFileByAbstractImage(Long idAbstractImage) throws CytomineException {
UploadedFile uploadedFile = new UploadedFile();
uploadedFile.set("baseImage", idAbstractImage);
return fetchModel(uploadedFile);
}

public String clearAbstractImageProperties(Long idImage) throws CytomineException {
return doPost("/api/abstractimage/" + idImage + "/properties/clear.json", "");
Expand Down Expand Up @@ -1697,4 +1702,11 @@ public AmqpQueueCollection getAmqpQueue() throws CytomineException {
return fetchCollection(queues);
}

public DeleteCommandCollection getDeleteCommandByDomainAndAfterDate(String domain, Long timestamp) throws CytomineException {
DeleteCommandCollection commands = new DeleteCommandCollection(offset, max);
commands.addParams("domain","uploadedFile");
commands.addParams("after",timestamp.toString());
return fetchCollection(commands);
}

}
4 changes: 3 additions & 1 deletion src/main/java/be/cytomine/client/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ public int get(String url, String dest) throws IOException {
}
HttpEntity entity = response.getEntity();
if (entity != null) {
entity.writeTo(new FileOutputStream(dest));
FileOutputStream fos = new FileOutputStream(dest);
entity.writeTo(fos);
fos.close();
}
return code;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package be.cytomine.client.collections;

public class DeleteCommandCollection extends Collection {

public DeleteCommandCollection(int max, int offset) {
super(max, offset);
}

@Override
public String toURL() {
return getJSONResourceURL();
}

@Override
public String getDomainName() {
return "deletecommand";
}
}
8 changes: 8 additions & 0 deletions src/main/java/be/cytomine/client/models/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package be.cytomine.client.models;

public class DeleteCommand extends Model {
@Override
public String getDomainName() {
return "deletecommand";
}
}
12 changes: 12 additions & 0 deletions src/main/java/be/cytomine/client/models/UploadedFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ public String getAbsolutePath() {
return this.get("path") + File.separator + this.get("filename");
}


public String toURL() {

Long id = (Long) get("id");
Long baseImage = (Long) get("baseImage");
if (id ==null && baseImage != null) {
return "/api/uploadedfile/image/"+baseImage+".json";
}

return super.toURL();
}

}

0 comments on commit 98bc45f

Please sign in to comment.