Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented run date time override for file name. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/main/java/jasquel/run/manager/RunManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,22 @@ public RunManager(File runDirectory) {
runOutputFiles = new HashMap<>();
}

private synchronized File createSharedRunFile(String description) throws IOException {
private synchronized File createSharedRunFile(String description, LocalDateTime runDateTimeOverride) throws IOException {

if (description == null)
description = "";
else if (description.length() > 0)
description = "-" + description.toLowerCase().replaceAll("[^a-z0-9-_\\.]", "_");

LocalDateTime now = LocalDateTime.now();
LocalDateTime runDateTime;

String baseName = now.format(
if(runDateTimeOverride != null) {
runDateTime = runDateTimeOverride;
} else {
runDateTime = LocalDateTime.now();
}

String baseName = runDateTime.format(
DateTimeFormatter.ofPattern("yyyy_MM_dd-HH_mm_ss")
) + "%s%s.run";

Expand All @@ -68,13 +74,13 @@ else if (description.length() > 0)

}

public ActiveRun startRun(boolean shared, String environment, String description) throws IOException {
public ActiveRun startRun(boolean shared, String environment, String description, LocalDateTime runDateTimeOverride) throws IOException {

String id;
File file = null;

if (shared) {
file = createSharedRunFile(description);
file = createSharedRunFile(description, runDateTimeOverride);
id = FilenameUtils.removeExtension(file.getName());
} else
id = UUID.randomUUID().toString();
Expand All @@ -95,7 +101,7 @@ public ActiveRun startRun(boolean shared, String environment, String description
}

public ActiveRun startRun(String environment) throws IOException {
return startRun(false, environment, null);
return startRun(false, environment, null, null);
}

public void finishRun(ActiveRun run) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/jasquel/server/JasquelServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ else if (!project.getEnvironmentList().contains(runRequest.environment))
ActiveRun run = runManager.startRun(
runRequest.shared,
runRequest.environment,
runRequest.description
runRequest.description,
runRequest.runDateTimeOverride
);

FileRunner runner = new FileRunner(
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/jasquel/server/RunRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package jasquel.server;

import java.time.LocalDateTime;
import java.util.List;

/**
Expand All @@ -18,5 +19,6 @@ public class RunRequest {
public int threads;
public List<String> paths;
boolean shared;
LocalDateTime runDateTimeOverride;

}