Skip to content

Commit

Permalink
Merge pull request #413 from ZihengSun/master
Browse files Browse the repository at this point in the history
fix a few more issues
  • Loading branch information
ZihengSun authored Oct 22, 2023
2 parents 30bb4fe + e0ac55a commit 716ce0c
Show file tree
Hide file tree
Showing 20 changed files with 785 additions and 501 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>com.gw</groupId>
<artifactId>geoweaver</artifactId>
<version>1.1.1</version>
<version>1.2.1</version>
<name>geoweaver</name>
<description>A lightweight workflow management software for organizing data analysis workflows,
preserving history of every workflow run, and improving scientist producitvity and workflow FAIRness,
Expand Down Expand Up @@ -173,7 +173,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230227</version>
<version>20231013</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/gw/GeoweaverApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ public static void addDefaultPublicUser(){

}

logger.debug("test what is going on");

//set everything that doesn't have an owner to this user
ut.belongToPublicUser();

Expand Down
55 changes: 37 additions & 18 deletions src/main/java/com/gw/database/EnvironmentRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,41 @@

import com.gw.jpa.Environment;

public interface EnvironmentRepository extends CrudRepository<Environment, String>{

// new StringBuffer("select * from environment where host = '").append(hostid)
// .append("' and bin = '").append(bin).append("' and pyenv = '")
// .append(env).append("' and basedir = '").append(basedir).append("';");
@Query(value = "select * from environment where hostid = ?1 and bin = ?2 and pyenv = ?3 and basedir = ?4 ",
nativeQuery = true)
Collection<Environment> findEnvByID_BIN_ENV_BaseDir(String hostid, String bin, String pyenv, String basedir);

@Query(value = "select * from environment where hostid = ?1 and bin = ?2",
nativeQuery = true)
Collection<Environment> findEnvByID_BIN(String hostid, String bin);


@Query(value = "select * from environment where hostid = ?1 ",
nativeQuery = true)
Collection<Environment> findEnvByHost(String hostid);

/**
* The EnvironmentRepository interface provides methods for querying environment configurations from a database.
* It extends the CrudRepository interface to handle database operations for the Environment entity.
*/
public interface EnvironmentRepository extends CrudRepository<Environment, String> {

/**
* Find environment configurations based on the provided host ID, binary path, Python environment, and base directory.
*
* @param hostid The ID of the host.
* @param bin The binary path.
* @param pyenv The Python environment.
* @param basedir The base directory.
* @return A collection of environment configurations matching the specified criteria.
*/
@Query(value = "select * from environment where hostid = ?1 and bin = ?2 and pyenv = ?3 and basedir = ?4", nativeQuery = true)
Collection<Environment> findEnvByID_BIN_ENV_BaseDir(String hostid, String bin, String pyenv, String basedir);

/**
* Find environment configurations based on the provided host ID and binary path.
*
* @param hostid The ID of the host.
* @param bin The binary path.
* @return A collection of environment configurations matching the specified host and binary path.
*/
@Query(value = "select * from environment where hostid = ?1 and bin = ?2", nativeQuery = true)
Collection<Environment> findEnvByID_BIN(String hostid, String bin);

/**
* Find environment configurations based on the provided host ID.
*
* @param hostid The ID of the host.
* @return A collection of environment configurations associated with the specified host.
*/
@Query(value = "select * from environment where hostid = ?1", nativeQuery = true)
Collection<Environment> findEnvByHost(String hostid);
}

189 changes: 125 additions & 64 deletions src/main/java/com/gw/database/HistoryRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,129 @@

import com.gw.jpa.History;

public interface HistoryRepository extends JpaRepository<History, String>{

@Query(value="select * from history where host_id = ?1 ORDER BY history_begin_time DESC limit ?2",
nativeQuery = true)
Collection<History> findRecentHistory(String hostid, int limit);

@Query(value="select * from history where indicator='Running' ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<History> findAllRunningResource();

@Query(value="select * from history, workflow where history.history_process = workflow.id and history.indicator = 'Running' ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<Object[]> findRunningWorkflow();

@Query(value="select * from history, workflow where history.history_process = workflow.id and history.indicator = 'Failed' ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<Object[]> findFailedWorkflow();

@Query(value="select * from history, workflow where history.history_process = workflow.id and history.indicator = 'Done' ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<Object[]> findSuccessWorkflow();

@Query(value="select * from history, gwprocess where history.history_process = gwprocess.id and history.indicator = 'Running' ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<Object[]> findRunningProcess();

@Query(value="select * from history, gwprocess where history.history_process = gwprocess.id and history.indicator = 'Failed' ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<Object[]> findFailedProcess();

@Query(value="select * from history, gwprocess where history.history_process = gwprocess.id and history.indicator = 'Done' ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<Object[]> findSuccessProcess();

@Query(value="select * from history where history.history_process = ?1 ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<History> findByProcessId(String pid);

@Query(value="select * from history where history.history_process = ?1 and history.indicator != 'Skipped' ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<History> findByProcessIdIgnoreUnknown(String pid);

@Query(value="select * from history where history.history_process = ?1 ORDER BY history_begin_time DESC;",
nativeQuery = true)
List<History> findByWorkflowId(String wid);


@Query(value="select * from history, workflow where workflow.id = history.history_process ORDER BY history_begin_time DESC limit ?1",
nativeQuery = true)
List<Object[]> findRecentWorkflow(int limit);


@Query(value="select * from history, gwprocess where gwprocess.id = history.history_process ORDER BY history_begin_time DESC limit ?1",
nativeQuery = true)
List<Object[]> findRecentProcess(int limit);

@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);





/**
* The HistoryRepository interface provides methods for querying historical execution data (history) from a database.
* It extends the JpaRepository interface to handle database operations.
*/
public interface HistoryRepository extends JpaRepository<History, String> {

/**
* Find recent history records for a specific host, limited by the specified count.
*
* @param hostid The ID of the host.
* @param limit The maximum number of history records to retrieve.
* @return A collection of recent history records for the host.
*/
@Query(value = "select * from history where host_id = ?1 ORDER BY history_begin_time DESC limit ?2", nativeQuery = true)
Collection<History> findRecentHistory(String hostid, int limit);

/**
* Find all running history records.
*
* @return A list of all running history records.
*/
@Query(value = "select * from history where indicator='Running' ORDER BY history_begin_time DESC;", nativeQuery = true)
List<History> findAllRunningResource();

/**
* Find all running workflows.
*
* @return A list of all running workflow records with additional information.
*/
@Query(value = "select * from history, workflow where history.history_process = workflow.id and history.indicator = 'Running' ORDER BY history_begin_time DESC;", nativeQuery = true)
List<Object[]> findRunningWorkflow();

/**
* Find all failed workflows.
*
* @return A list of all failed workflow records with additional information.
*/
@Query(value = "select * from history, workflow where history.history_process = workflow.id and history.indicator = 'Failed' ORDER BY history_begin_time DESC;", nativeQuery = true)
List<Object[]> findFailedWorkflow();

/**
* Find all successfully completed workflows.
*
* @return A list of all successful workflow records with additional information.
*/
@Query(value = "select * from history, workflow where history.history_process = workflow.id and history.indicator = 'Done' ORDER BY history_begin_time DESC;", nativeQuery = true)
List<Object[]> findSuccessWorkflow();

/**
* Find all running processes.
*
* @return A list of all running process records with additional information.
*/
@Query(value = "select * from history, gwprocess where history.history_process = gwprocess.id and history.indicator = 'Running' ORDER BY history_begin_time DESC;", nativeQuery = true)
List<Object[]> findRunningProcess();

/**
* Find all failed processes.
*
* @return A list of all failed process records with additional information.
*/
@Query(value = "select * from history, gwprocess where history.history_process = gwprocess.id and history.indicator = 'Failed' ORDER BY history_begin_time DESC;", nativeQuery = true)
List<Object[]> findFailedProcess();

/**
* Find all successfully completed processes.
*
* @return A list of all successful process records with additional information.
*/
@Query(value = "select * from history, gwprocess where history.history_process = gwprocess.id and history.indicator = 'Done' ORDER BY history_begin_time DESC;", nativeQuery = true)
List<Object[]> findSuccessProcess();

/**
* Find history records by process ID.
*
* @param pid The ID of the process.
* @return A list of history records associated with the specified process ID.
*/
@Query(value = "select * from history where history.history_process = ?1 ORDER BY history_begin_time DESC;", nativeQuery = true)
List<History> findByProcessId(String pid);

/**
* Find history records by process ID, excluding 'Skipped' indicator.
*
* @param pid The ID of the process.
* @return A list of history records associated with the specified process ID, excluding 'Skipped' records.
*/
@Query(value = "select * from history where history.history_process = ?1 and history.indicator != 'Skipped' ORDER BY history_begin_time DESC;", nativeQuery = true)
List<History> findByProcessIdIgnoreUnknown(String pid);

/**
* Find history records by workflow ID.
*
* @param wid The ID of the workflow.
* @return A list of history records associated with the specified workflow ID.
*/
@Query(value = "select * from history where history.history_process = ?1 ORDER BY history_begin_time DESC;", nativeQuery = true)
List<History> findByWorkflowId(String wid);

/**
* Find recent workflow records, limited by the specified count.
*
* @param limit The maximum number of recent workflow records to retrieve.
* @return A list of recent workflow records with additional information.
*/
@Query(value = "select * from history, workflow where workflow.id = history.history_process ORDER BY history_begin_time DESC limit ?1", nativeQuery = true)
List<Object[]> findRecentWorkflow(int limit);

/**
* Find recent process records, limited by the specified count.
*
* @param limit The maximum number of recent process records to retrieve.
* @return A list of recent process records with additional information.
*/
@Query(value = "select * from history, gwprocess where gwprocess.id = history.history_process ORDER BY history_begin_time DESC limit ?1", nativeQuery = true)
List<Object[]> findRecentProcess(int limit);

/**
* Find a history record associated with a specific history ID.
*
* @param history_id The ID of the history record.
* @return A list containing a history record and additional information about the associated process.
*/
@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);
}
Loading

0 comments on commit 716ce0c

Please sign in to comment.