-
Notifications
You must be signed in to change notification settings - Fork 23
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
Refresh IG Group file POST addition & messaging improvements #506
Merged
JPercival
merged 24 commits into
cqframework:master
from
echicoine-icf:refresh-messaging-improvements
Mar 18, 2024
Merged
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f03274a
Refresh IG POST expanded to include other resources such as group files.
93c4982
Tracking POST tasks via IBaseResource as key rather than resourceID t…
1f6aa65
Corrected formatting of cql processing summary.
ed0acb4
Code cleanup.
cbff38d
users
03539eb
Adjusted over to exception handling rather than boolean return for va…
ee2e580
Merge branch 'refresh-messaging-improvements' of https://github.com/e…
62b356a
Safeguarding lists against concurrency issues.
0278789
Adjusted some Maps in IOUtils to be concurrent safe, clarified POST s…
0825b15
Moved start/end messages for bundle process from igbundleprocessor to…
ac43428
Consistent titling of sections in console (ie [Bundling Measures]
d9570c8
Group file creation bug resolved.
f352f9a
Added Group file verification during Refresh IG test.
e22f9ca
Added failed test tracking so we don't have to delete any test files …
5a44f38
Moving some hard coded strings to constants
b7ef5f9
Added failed POST logging so users can retain a log of what files fai…
9321b0f
Sorting all summary lists at end of bundle process. Moved summary mes…
7df3885
applying a timestamp to the httpfail log filename
21cd226
Sorting the test case refresh summary for readability.
cb6ef87
Using SLF4J provider ch.qos.logback.classic.spi.LogbackServiceProvide…
53ec57a
Merge branch 'master' into refresh-messaging-improvements
JPercival cd9af26
Merge branch 'master' into refresh-messaging-improvements
JPercival 69091a7
Using logger over System.out
3999567
Merge branch 'master' into refresh-messaging-improvements
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
tooling/src/main/java/org/opencds/cqf/tooling/cql/exception/CQLTranslatorException.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
tooling/src/main/java/org/opencds/cqf/tooling/cql/exception/CqlTranslatorException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.opencds.cqf.tooling.cql.exception; | ||
|
||
import org.cqframework.cql.cql2elm.CqlCompilerException; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Custom exception to pass the list of errors returned by the translator to calling methods. | ||
*/ | ||
public class CqlTranslatorException extends Exception implements Serializable { | ||
private static final long serialVersionUID = 20600L; | ||
|
||
/** | ||
* Using Set to avoid duplicate entries. | ||
*/ | ||
private final transient List<CqlCompilerException> errors = new ArrayList<>(); | ||
|
||
public CqlTranslatorException(Exception e) { | ||
super("CQL Translation Error(s): " + e.getMessage()); | ||
} | ||
|
||
public CqlTranslatorException(List<CqlCompilerException> errors) { | ||
super("CQL Translation Error(s)"); | ||
this.errors.addAll(errors); | ||
} | ||
|
||
public CqlTranslatorException(List<String> errorsInput, CqlCompilerException.ErrorSeverity errorSeverity) { | ||
super("CQL Translation Error(s)"); | ||
for (String error : errorsInput){ | ||
errors.add(new CqlCompilerException(error, errorSeverity)); | ||
} | ||
} | ||
|
||
public CqlTranslatorException(String message) { | ||
super("CQL Translation Error(s): " + message); | ||
} | ||
|
||
public List<CqlCompilerException> getErrors() { | ||
if (errors.isEmpty()) { | ||
errors.add(new CqlCompilerException(this.getMessage())); | ||
} | ||
return errors; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,21 +48,23 @@ | |
public class LibraryProcessor extends BaseProcessor { | ||
private static final Logger logger = LoggerFactory.getLogger(LibraryProcessor.class); | ||
public static final String ResourcePrefix = "library-"; | ||
|
||
public static String getId(String baseId) { | ||
return ResourcePrefix + baseId; | ||
} | ||
|
||
private static Pattern pattern; | ||
|
||
private static Pattern getPattern() { | ||
if(pattern == null) { | ||
if (pattern == null) { | ||
String regex = "^[a-zA-Z]+[a-zA-Z0-9_\\-\\.]*"; | ||
pattern = Pattern.compile(regex); | ||
} | ||
return pattern; | ||
} | ||
|
||
public static void validateIdAlphaNumeric(String id) { | ||
if(!getPattern().matcher(id).find()) { | ||
if (!getPattern().matcher(id).find()) { | ||
throw new RuntimeException("The library id format is invalid."); | ||
} | ||
} | ||
|
@@ -76,8 +78,7 @@ public List<String> refreshIgLibraryContent(BaseProcessor parentContext, Encodin | |
} | ||
|
||
public List<String> refreshIgLibraryContent(BaseProcessor parentContext, Encoding outputEncoding, String libraryPath, String libraryOutputDirectory, Boolean versioned, FhirContext fhirContext, Boolean shouldApplySoftwareSystemStamp) { | ||
System.out.println("Refreshing libraries..."); | ||
// ArrayList<String> refreshedLibraryNames = new ArrayList<String>(); | ||
System.out.println("\r\n[Refreshing Libraries]\r\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be better to use logger here |
||
|
||
LibraryProcessor libraryProcessor; | ||
switch (fhirContext.getVersion().getVersion()) { | ||
|
@@ -93,9 +94,8 @@ public List<String> refreshIgLibraryContent(BaseProcessor parentContext, Encodin | |
} | ||
|
||
if (libraryPath == null) { | ||
libraryPath = FilenameUtils.concat(parentContext.getRootDir(), IGProcessor.libraryPathElement); | ||
} | ||
else if (!Utilities.isAbsoluteFileName(libraryPath)) { | ||
libraryPath = FilenameUtils.concat(parentContext.getRootDir(), IGProcessor.LIBRARY_PATH_ELEMENT); | ||
} else if (!Utilities.isAbsoluteFileName(libraryPath)) { | ||
libraryPath = FilenameUtils.concat(parentContext.getRootDir(), libraryPath); | ||
} | ||
RefreshLibraryParameters params = new RefreshLibraryParameters(); | ||
|
@@ -117,64 +117,51 @@ else if (!Utilities.isAbsoluteFileName(libraryPath)) { | |
* Bundles library dependencies for a given FHIR library file and populates the provided resource map. | ||
* This method executes asynchronously by invoking the associated task queue. | ||
* | ||
* @param path The path to the FHIR library file. | ||
* @param fhirContext The FHIR context to use for processing resources. | ||
* @param resources The map to populate with library resources. | ||
* @param encoding The encoding to use for reading and processing resources. | ||
* @param versioned A boolean indicating whether to consider versioned resources. | ||
* @return True if the bundling of library dependencies is successful; false otherwise. | ||
* @param path The path to the FHIR library file. | ||
* @param fhirContext The FHIR context to use for processing resources. | ||
* @param resources The map to populate with library resources. | ||
* @param encoding The encoding to use for reading and processing resources. | ||
* @param versioned A boolean indicating whether to consider versioned resources. | ||
*/ | ||
public Boolean bundleLibraryDependencies(String path, FhirContext fhirContext, Map<String, IBaseResource> resources, | ||
Encoding encoding, boolean versioned) { | ||
try{ | ||
Queue<Callable<Void>> bundleLibraryDependenciesTasks = bundleLibraryDependenciesTasks(path, fhirContext, resources, encoding, versioned); | ||
ThreadUtils.executeTasks(bundleLibraryDependenciesTasks); | ||
return true; | ||
}catch (Exception e){ | ||
return false; | ||
} | ||
|
||
public void bundleLibraryDependencies(String path, FhirContext fhirContext, Map<String, IBaseResource> resources, | ||
Encoding encoding, boolean versioned) throws Exception { | ||
Queue<Callable<Void>> bundleLibraryDependenciesTasks = bundleLibraryDependenciesTasks(path, fhirContext, resources, encoding, versioned); | ||
ThreadUtils.executeTasks(bundleLibraryDependenciesTasks); | ||
} | ||
|
||
/** | ||
* Recursively bundles library dependencies for a given FHIR library file and populates the provided resource map. | ||
* Each dependency is added as a Callable task to be executed asynchronously. | ||
* | ||
* @param path The path to the FHIR library file. | ||
* @param fhirContext The FHIR context to use for processing resources. | ||
* @param resources The map to populate with library resources. | ||
* @param encoding The encoding to use for reading and processing resources. | ||
* @param versioned A boolean indicating whether to consider versioned resources. | ||
* @param path The path to the FHIR library file. | ||
* @param fhirContext The FHIR context to use for processing resources. | ||
* @param resources The map to populate with library resources. | ||
* @param encoding The encoding to use for reading and processing resources. | ||
* @param versioned A boolean indicating whether to consider versioned resources. | ||
* @return A queue of Callable tasks, each representing the bundling of a library dependency. | ||
* The Callable returns null (Void) and is meant for asynchronous execution. | ||
* The Callable returns null (Void) and is meant for asynchronous execution. | ||
*/ | ||
public Queue<Callable<Void>> bundleLibraryDependenciesTasks(String path, FhirContext fhirContext, Map<String, IBaseResource> resources, | ||
Encoding encoding, boolean versioned) { | ||
Encoding encoding, boolean versioned) throws Exception { | ||
|
||
Queue<Callable<Void>> returnTasks = new ConcurrentLinkedQueue<>(); | ||
|
||
String fileName = FilenameUtils.getName(path); | ||
boolean prefixed = fileName.toLowerCase().startsWith("library-"); | ||
try { | ||
Map<String, IBaseResource> dependencies = ResourceUtils.getDepLibraryResources(path, fhirContext, encoding, versioned, logger); | ||
// String currentResourceID = IOUtils.getTypeQualifiedResourceId(path, fhirContext); | ||
for (IBaseResource resource : dependencies.values()) { | ||
returnTasks.add(() -> { | ||
resources.putIfAbsent(resource.getIdElement().getIdPart(), resource); | ||
Map<String, IBaseResource> dependencies = ResourceUtils.getDepLibraryResources(path, fhirContext, encoding, versioned, logger); | ||
// String currentResourceID = IOUtils.getTypeQualifiedResourceId(path, fhirContext); | ||
for (IBaseResource resource : dependencies.values()) { | ||
returnTasks.add(() -> { | ||
resources.putIfAbsent(resource.getIdElement().getIdPart(), resource); | ||
|
||
// NOTE: Assuming dependency library will be in directory of dependent. | ||
String dependencyPath = IOUtils.getResourceFileName(IOUtils.getResourceDirectory(path), resource, encoding, fhirContext, versioned, prefixed); | ||
// NOTE: Assuming dependency library will be in directory of dependent. | ||
String dependencyPath = IOUtils.getResourceFileName(IOUtils.getResourceDirectory(path), resource, encoding, fhirContext, versioned, prefixed); | ||
|
||
returnTasks.addAll(bundleLibraryDependenciesTasks(dependencyPath, fhirContext, resources, encoding, versioned)); | ||
returnTasks.addAll(bundleLibraryDependenciesTasks(dependencyPath, fhirContext, resources, encoding, versioned)); | ||
|
||
//return statement needed for Callable<Void> | ||
return null; | ||
}); | ||
} | ||
} catch (Exception e) { | ||
logger.error(path, e); | ||
//purposely break addAll: | ||
return null; | ||
//return statement needed for Callable<Void> | ||
return null; | ||
}); | ||
} | ||
return returnTasks; | ||
} | ||
|
@@ -259,7 +246,7 @@ protected void setTranslatorOptions(Library sourceLibrary, CqlTranslatorOptions | |
optionsReferenceValue = "#options"; | ||
optionsReference.setReference(optionsReferenceValue); | ||
} | ||
Parameters optionsParameters = (Parameters)sourceLibrary.getContained(optionsReferenceValue); | ||
Parameters optionsParameters = (Parameters) sourceLibrary.getContained(optionsReferenceValue); | ||
if (optionsParameters == null) { | ||
optionsParameters = new Parameters(); | ||
optionsParameters.setId(optionsReferenceValue.substring(1)); | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we apply this change on the main pom.xml and do a refactoring of logger to complete this ticket : #333 @JPercival ?