Skip to content

Commit

Permalink
✨ FEAT - added support for removing failed history from a process
Browse files Browse the repository at this point in the history
  • Loading branch information
gokulprathin8 committed Aug 23, 2024
1 parent 70a0fad commit 394c246
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/gw/GeoweaverApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class GeoweaverApplication {
private static String workspace;

public static void main(String[] args) {

// if we have a command line argument, we assume it is a command
if (args.length > 0) {

Expand Down Expand Up @@ -74,6 +73,7 @@ public static void main(String[] args) {

addLocalhost();


System.out.println("GeoWeaver is started and ready for use..");
System.out.println("URL: http://localhost:"+BaseTool.get_current_port()+"/Geoweaver");
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/gw/database/HistoryRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Collection;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
Expand Down Expand Up @@ -163,4 +164,8 @@ public interface HistoryRepository extends JpaRepository<History, String> {
@Query(value = "SELECT * FROM history, gwprocess WHERE history.history_id = ?1 AND history.history_process = gwprocess.id", nativeQuery = true)
List<Object[]> findOneHistoryofProcess(String history_id);


@Modifying
@Query(value = "DELETE FROM history WHERE history_process = ?1 AND indicator = ?2", nativeQuery = true)
void deleteByProcessAndIndicator(String historyProcess, String indicator);
}
5 changes: 5 additions & 0 deletions src/main/java/com/gw/tools/HistoryTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ public void stop(String history_id) {
}
}


public void deleteFailedHistory(String processId) {
historyrepository.deleteByProcessAndIndicator(processId, ExecutionStatus.FAILED);
}

public void saveSkippedHisotry(String historyid, String workflow_process_id, String hostid) {

try {
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/com/gw/web/GeoweaverController.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import javax.annotation.PreDestroy;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -64,6 +59,7 @@
import org.springframework.core.io.Resource;
import org.springframework.data.repository.query.Param;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
Expand Down Expand Up @@ -1638,4 +1634,16 @@ public ResponseEntity<String> authenticateUser(ModelMap model, WebRequest reques

return resp;
}

@DeleteMapping("/delete-failed")
public ResponseEntity<Map<String, Boolean>> deleteFailedProcesses(@RequestParam(required = false) String processId) {
Map<String, Boolean> response = new HashMap<>();
if (processId == null || processId.trim().isEmpty()) {
response.put("failed", false);
return new ResponseEntity<>(response, HttpStatus.FORBIDDEN);
}
hist.deleteFailedHistory(processId);
response.put("success", true);
return new ResponseEntity<>(response, HttpStatus.OK);
}
}
Empty file.
14 changes: 14 additions & 0 deletions src/main/resources/static/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,17 @@
display: inline-block;
margin: 10px;
}

.history-remove-failed {
background: indianred;
border: 0;
margin-right: 15px;
padding: 4px 10px;
border-radius: 8px;
transition: transform 0.3s ease, background 0.3s ease;
}

.history-remove-failed:hover {
cursor: pointer;
transform: scale(1.05);
}
13 changes: 12 additions & 1 deletion src/main/resources/static/js/gw.history.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,16 @@ GW.history = {
},



removeFailedHistory: function(processId) {
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({"processId": processId})
}
fetch("delete-failed", options)
},
/**
* Generates an HTML table with process execution history data.
*
Expand All @@ -216,6 +225,8 @@ GW.history = {
</div>
<div id="statusFilterContainer">
<button class="history-remove-failed">Remove Failed History</button>
<label for="statusFilter">Status:</label>
<select id="statusFilter" style="color: black;">
<option value="">All</option> <!-- Changed to "All" -->
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/fragments/config/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
<script src="../js/gw.menu.js"></script>
<script src="../js/gw.home.js"></script>
<script src="../js/gw.main.js"></script>

<link rel="stylesheet" href="../css/common.css" />

0 comments on commit 394c246

Please sign in to comment.