Skip to content

Commit

Permalink
linked comments from reproVIP form with structured json
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcornier committed Oct 27, 2023
1 parent aea03f1 commit 5c948c1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public static ReproVipServiceAsync getInstance() {
public void executionAdminEmail(Execution execution);
void addExecution(Execution execution) throws CoreException;
void updateExecution(String executionID, String newStatus) throws CoreException;
String createReproVipDirectory(String executionName, String executionID, String version) throws CoreException;
String createReproVipDirectory(String executionName, String executionID, String version, String comments) throws CoreException;
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public interface ReproVipServiceAsync {
void executionAdminEmail(Execution execution, AsyncCallback<Void> callback);
void addExecution(Execution execution, AsyncCallback<Void> asyncCallback);
void updateExecution(String executionID, String newStatus, AsyncCallback<Void> asyncCallback);
void createReproVipDirectory(String executionName, String execution, String version, AsyncCallback<String> callback);
void createReproVipDirectory(String executionName, String execution, String version, String comments, AsyncCallback<String> callback);
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ExecutionsContextMenu extends Menu {
private String executionID;
private ReproVipServiceAsync reproVipServiceAsync = ReproVipService.Util.getInstance();
private ReproVipService reproVipService;

Check warning

Code scanning / PMD

Avoid unused private fields such as 'classBusiness'. Warning

Avoid unused private fields such as 'reproVipService'.
public ExecutionsContextMenu(ModalWindow modal, String executionName, String executionID, String version){
public ExecutionsContextMenu(ModalWindow modal, String executionName, String executionID, String version, String comments){
this.modal = modal;
this.executionID = executionID;
this.setShowShadow(true);
Expand All @@ -31,7 +31,7 @@ public ExecutionsContextMenu(ModalWindow modal, String executionName, String exe
OptionPublicExecutionItem.addClickHandler(new ClickHandler() {
@Override
public void onClick(MenuItemClickEvent event) {
createReproVipDirectory(executionName, executionID, version);
createReproVipDirectory(executionName, executionID, version, comments);
}
});

Expand All @@ -53,8 +53,8 @@ public void onSuccess(Void result) {
modal.show("Make execution public", true);
reproVipServiceAsync.updateExecution(executionID, "Public", callback);
}
public void createReproVipDirectory(String executionName, String executionID, String version) {
reproVipServiceAsync.createReproVipDirectory(executionName, executionID, version, new AsyncCallback<String>() {
public void createReproVipDirectory(String executionName, String executionID, String version, String comments) {
reproVipServiceAsync.createReproVipDirectory(executionName, executionID, version, comments, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
SC.warn("Error creating ReproVip directory: " + caught.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public void onRowContextClick(RowContextClickEvent event) {
String executionName = selectedRecord.getAttribute("application_name");
String executionId = selectedRecord.getAttribute("id");
String version = selectedRecord.getAttribute("version");
new ExecutionsContextMenu(modal, executionName, executionId, version).showContextMenu();
String comments = selectedRecord.getAttribute("comments");
new ExecutionsContextMenu(modal, executionName, executionId, version, comments).showContextMenu();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public ExecutionJobTaskData getExecutionJobTaskData(String executionID) throws B
}
return new ExecutionJobTaskData(jobList);
}
public String generateReprovipJson(Path reproVipDir, String executionName, String executionID, String version, User currentUser, List<Path> provenanceFiles)
public String generateReprovipJson(Path reproVipDir, String executionName, String executionID, String version, String comments, User currentUser, List<Path> provenanceFiles)
throws BusinessException {
List<String> filesToDownload = getFilesToCopyPaths(executionName, executionID, version);

Expand All @@ -124,7 +124,7 @@ public String generateReprovipJson(Path reproVipDir, String executionName, Strin

metadataInner.put("title", "your title");
metadataInner.put("upload_type", "workflow");
metadataInner.put("description", "your description");
metadataInner.put("description", comments);

List<Map<String, String>> creators = new ArrayList<>();
Map<String, String> creator = new LinkedHashMap<>();
Expand Down Expand Up @@ -153,7 +153,7 @@ public String generateReprovipJson(Path reproVipDir, String executionName, Strin
public void saveJsonToFile(String jsonContent, Path filePath) throws IOException {
Files.writeString(filePath, jsonContent);
}
public String createReproVipDirectory(String executionName, String executionID, String version, User currentUser) throws BusinessException {
public String createReproVipDirectory(String executionName, String executionID, String version, String comments, User currentUser) throws BusinessException {
Path reproVipDir = Paths.get("/vip/ReproVip/" + executionID);
logger.info("Creating reprovip dir : {}", reproVipDir);
try {
Expand All @@ -166,7 +166,7 @@ public String createReproVipDirectory(String executionName, String executionID,
throw new RuntimeException(e);
}
List<Path> provenanceFiles = copyProvenanceFiles(reproVipDir, executionID);
return generateReprovipJson(reproVipDir, executionName, executionID, version, currentUser, provenanceFiles);
return generateReprovipJson(reproVipDir, executionName, executionID, version, comments, currentUser, provenanceFiles);
}

public List<Path> copyProvenanceFiles(Path reproVipDir, String executionID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public void updateExecution(String executionID, String newStatus) throws CoreExc
throw new CoreException("Failed to update execution", e);
}
}
public String createReproVipDirectory(String executionName, String executionID, String version) {
public String createReproVipDirectory(String executionName, String executionID, String version, String comments) {
try {
User currentUser = getSessionUser();
return reproVipBusiness.createReproVipDirectory(executionName, executionID, version, currentUser);
return reproVipBusiness.createReproVipDirectory(executionName, executionID, version, comments, currentUser);
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 5c948c1

Please sign in to comment.