Skip to content

Commit

Permalink
Merge pull request #4 from cc-ar-emr/actionutils-missing-method
Browse files Browse the repository at this point in the history
Add missing method to ActionUtils
  • Loading branch information
yingbull authored Nov 1, 2024
2 parents 9d373b1 + f7a07b9 commit 5ea1af2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ public int compare(File f1, File f2) {
}
}

public static void createOnEDTOutboxDir() {
OscarProperties props = OscarProperties.getInstance();
File dateDir = new File(props.getProperty("ONEDT_OUTBOX", ""));
if (!dateDir.exists()) dateDir.mkdirs();
}

public static Date getOutboxTimestamp() {
Date startDate = new Date();
try {
Expand Down
48 changes: 24 additions & 24 deletions src/main/java/oscar/oscarReport/data/ObecData.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,28 @@ public static String space(String oldString, int leng) {
return outputString;
}

public String writeFile(String value1, Properties pp) {
String obecFilename = "";
try {
String oscarHome = pp.getProperty("DOCUMENT_DIR");

String outbox = pp.getProperty("ONEDT_OUTBOX", "");
Path outboxPath = Paths.get(outbox);
File outboxFile = outboxPath.toFile();

// Construct the filename
obecFilename = "OBECE" + System.currentTimeMillis() + ".TXT";
File srcFile = Paths.get(oscarHome, obecFilename).toFile();

// Write the content to the file
Files.write(srcFile.toPath(), value1.getBytes(), StandardOpenOption.CREATE);

// Copy the file to the EDT outbox directory
if (!outboxFile.exists()) { ActionUtils.createOnEDTOutboxDir(); }
ActionUtils.copyFileToDirectory(srcFile, outboxFile, false, true);
} catch (Exception e) {
logger.error("Error writing or copying file", e);
}
return obecFilename;
}
public String writeFile(String value1, Properties pp) {
String obecFilename = "";
try {
String oscarHome = pp.getProperty("DOCUMENT_DIR");

String outbox = pp.getProperty("ONEDT_OUTBOX", "");
Path outboxPath = Paths.get(outbox);
File outboxFile = outboxPath.toFile();

// Construct the filename
obecFilename = "OBECE" + System.currentTimeMillis() + ".TXT";
File srcFile = Paths.get(oscarHome, obecFilename).toFile();

// Write the content to the file
Files.write(srcFile.toPath(), value1.getBytes(), StandardOpenOption.CREATE);

// Copy the file to the EDT outbox directory
if (!outboxFile.exists()) { ActionUtils.createOnEDTOutboxDir(); }
ActionUtils.copyFileToDirectory(srcFile, outboxFile, false, true);
} catch (Exception e) {
logger.error("Error writing or copying file", e);
}
return obecFilename;
}
};

0 comments on commit 5ea1af2

Please sign in to comment.