-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix groups api calls #61
Draft
edeati
wants to merge
71
commits into
IHTSDO:develop
Choose a base branch
from
aehrc:groups-api-fix
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
a516217
Added some build variations for M1 chip Mac
lukeswindale bffa555
Added a script which will setup and run a test of the RC
lukeswindale ceba4a3
Added the ability to provide some pre-requisite sql, which runs AFTER…
lukeswindale f63d18c
Reverting unintended commits
lukeswindale 42d29ce
Fix groups api calls
edeati d50db64
Azure pipelines build file
edeati 162b040
Set up CI with Azure Pipelines
edeati 82c8dcf
Update azure-pipelines.yml for Azure Pipelines
edeati 5705929
Push to acr
edeati bc51061
Add variable for the acr repo
edeati af2be2b
Revert "Reverting unintended commits"
lukeswindale 92a61c4
Revert "Added the ability to provide some pre-requisite sql, which ru…
lukeswindale a9d213f
Revert "Added a script which will setup and run a test of the RC"
lukeswindale e8bb6de
Revert "Added some build variations for M1 chip Mac"
lukeswindale 4e4d12d
-DalsoPush doesn't work
edeati ff6a174
Add docker login step
edeati b4d7e5b
Make a variable for the acr login too
edeati 19aa5c5
Repository property is dockerfile.repository as per https://github.co…
edeati 18279d3
docker.image.prefix is used for repository definition by the pom
edeati 0517e9c
Support functions with sql statements
senjo-aehrc 6f84a1e
Added support for pre-requisites sql
senjo-aehrc 1079e09
Added support for pre-requisites sql
senjo-aehrc 30cc621
Include support-stored-proc-file branch
edeati 535545e
Include support-stored-proc-file branch
edeati d1c4eb0
Fix typo
senjo-aehrc a248e81
Fix regex compatibility
senjo-aehrc fc89311
Merge pull request #6 from aehrc/feature-support-functions
lukeswindale 3f7c26f
Merge pull request #7 from aehrc/support-stored-proc-file
lukeswindale 83a5d1c
Increasing the column size
senjo-aehrc 01a555e
Provided filename mappings for currently unsupported files
lukeswindale deaa14b
Provided filename mappings for integer simple map refset
lukeswindale 6384e06
Provided filename mappings for ccs and cci type refsets
lukeswindale a4842d8
Added the create table scripts for the new tables
lukeswindale 7198ddc
Check mysql engine exists before appending
senjo-aehrc 715fee9
Added crefset
lukeswindale caeb8c4
Merge branch 'support-stored-proc-file' of https://github.com/aehrc/r…
lukeswindale 78ddbba
Ignore the the failing tests(Need to come back)
senjo-aehrc f155f20
Merge pull request #8 from IHTSDO/master
edeati c5d19b4
Fix the failing test
senjo-aehrc 6d56fc5
Merge pull request #9 from aehrc/support-stored-proc-file
lukeswindale 5d18e1a
Merge branch 'master-ihtsdo'
lukeswindale 9de6b0b
Merge branch 'master' into groups-api-fix
lukeswindale e2ebc56
Increased the term size for descriptions
lukeswindale e6f3684
Increased the term size for descriptions to 2048
lukeswindale 32e63a6
reduced the varchar max size from 2048 to 1000
lukeswindale 64b9314
reduced the varchar max size from 1000 to 333 (1000 bytes)
lukeswindale 0d96d7c
if term is greater than the max length (333) replace with hash
lukeswindale 9865b98
if term is greater than the max length (333) replace with hash
lukeswindale 2028a1f
Fixed the conditional hash function
lukeswindale 5197d6e
reverting my truncation hanlder in the load scripts. will solve anoth…
lukeswindale 4bb698c
Fixing the text definition column length
lukeswindale 766c3a5
doubled the max-file-size and max-request-size
lukeswindale fceb2ca
Merge branch 'IHTSDO:master' into master
dionmcm ca9d8f2
Merging from SI into our code
lukeswindale f320c99
test fix
dionmcm 6a8890a
Fixed merge error
lukeswindale ae79644
fix java version
dionmcm 5dcf9a7
Merge remote-tracking branch 'origin/groups-api-fix' into groups-api-fix
dionmcm e6e9476
updated runtime docker image to support jdk17
dionmcm 013f1d3
shot at fixing over-replacement of the schema/table name
dionmcm 899c5e9
added logging for the config map
dionmcm 4df5a52
Fixing up the config properties in the code merged from SI
lukeswindale f75454f
Merge branch 'master-ihtsdo'
lukeswindale 60311ac
Merge branch 'master' into groups-api-fix
lukeswindale d1159f0
Correcting droolsRulesGroups property so it's consistent
lukeswindale e02b9cc
Revert "Correcting droolsRulesGroups property so it's consistent"
lukeswindale 24b6658
update ALL term varchar to be 4096
MattCordell f55d094
Add OWASP plugin to pom
MattCordell 9643b9a
Revert "update ALL term varchar to be 4096"
MattCordell 882022c
Revert "Add OWASP plugin to pom"
MattCordell 8078e43
Add owasp back (again...) Won't run without...
MattCordell 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ COPY . /usr/src/app | |
WORKDIR /usr/src/app | ||
RUN mvn clean install -DskipTests=true | ||
|
||
FROM adoptopenjdk/openjdk11:alpine | ||
FROM aehrc/jre:openjdk-17 | ||
LABEL maintainer="SNOMED International <[email protected]>" | ||
|
||
ARG SUID=1042 | ||
|
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,48 @@ | ||
name: rvf-$(Date:yyyyMMdd)$(Rev:.r) | ||
|
||
trigger: | ||
branches: | ||
include: | ||
- 'groups-api-fix' | ||
- 'support-stored-proc-file' | ||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
variables: | ||
mavenCache: $(Pipeline.Workspace)/.m2/repository | ||
mavenOptions: '-Dmaven.repo.local=$(mavenCache)' | ||
|
||
stages: | ||
- stage: build | ||
displayName: Build | ||
jobs: | ||
- job: build | ||
displayName: Build | ||
steps: | ||
- task: Cache@2 | ||
displayName: Cache Maven local repo | ||
inputs: | ||
key: 'maven | "$(Agent.OS)" | **/pom.xml' | ||
restoreKeys: | | ||
maven | "$(Agent.OS)" | ||
maven | ||
path: $(mavenCache) | ||
- task: MavenAuthenticate@0 | ||
inputs: | ||
artifactsFeeds: 'mavenbuild' | ||
- task: Docker@2 | ||
inputs: | ||
containerRegistry: $(acr_registry) | ||
command: 'login' | ||
- task: Maven@3 | ||
displayName: Build and verify | ||
inputs: | ||
mavenPomFile: 'pom.xml' | ||
options: '-Ddocker.image.prefix=$(acr_repo)' | ||
mavenOptions: '$(mavenOptions)' | ||
javaHomeOption: 'JDKVersion' | ||
jdkVersionOption: '1.17' | ||
jdkArchitectureOption: 'x64' | ||
publishJUnitResults: true | ||
testResultsFiles: '**/surefire-reports/TEST-*.xml' | ||
goals: 'clean install dockerfile:build dockerfile:push' |
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
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
129 changes: 129 additions & 0 deletions
129
src/main/java/org/ihtsdo/rvf/core/service/util/MySqlQueryTransformer.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,129 @@ | ||
package org.ihtsdo.rvf.core.service.util; | ||
|
||
import com.facebook.presto.sql.parser.StatementSplitter; | ||
import com.google.common.collect.ImmutableSet; | ||
import org.apache.commons.dbcp.BasicDataSource; | ||
import org.ihtsdo.otf.rest.exception.BusinessServiceException; | ||
import org.ihtsdo.rvf.core.data.model.Assertion; | ||
import org.ihtsdo.rvf.core.service.config.MysqlExecutionConfig; | ||
import org.ihtsdo.rvf.importer.AssertionGroupImporter; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.util.StringUtils; | ||
|
||
import javax.naming.ConfigurationException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Collectors; | ||
|
||
public class MySqlQueryTransformer { | ||
private final Logger logger = LoggerFactory.getLogger(MySqlQueryTransformer.class); | ||
|
||
private static final String FAILED_TO_FIND_RVF_DB_SCHEMA = "Failed to find rvf db schema for "; | ||
|
||
private String deltaTableSuffix = "d"; | ||
private String snapshotTableSuffix = "s"; | ||
private String fullTableSuffix = "f"; | ||
private static final String DEFAULT_DELIMITER = ";"; | ||
private static final String DELIMITER_REGEX_PATTERN = "^[ ]*(delimiter|DELIMITER)"; | ||
|
||
public List<String> transformSql(String[] parts, MysqlExecutionConfig config, final Map<String, String> configMap) | ||
throws ConfigurationException { | ||
|
||
logger.info("Config Map contains " + configMap.entrySet().stream().map(e -> e.getKey() + " : " + e.getValue()).collect(Collectors.joining(","))); | ||
|
||
List<String> result = new ArrayList<>(); | ||
String prospectiveSchema = config.getProspectiveVersion(); | ||
String previousReleaseSchema = config.getPreviousVersion(); | ||
String dependencyReleaseSchema = config.getExtensionDependencyVersion(); | ||
|
||
//We need both these schemas to exist | ||
if (prospectiveSchema == null) { | ||
throw new ConfigurationException (FAILED_TO_FIND_RVF_DB_SCHEMA + prospectiveSchema); | ||
} | ||
|
||
if (config.isReleaseValidation() && !config.isFirstTimeRelease() && previousReleaseSchema == null) { | ||
throw new ConfigurationException (FAILED_TO_FIND_RVF_DB_SCHEMA + previousReleaseSchema); | ||
} | ||
|
||
final String[] nameParts = config.getProspectiveVersion().split("_"); | ||
String version = (nameParts.length >= 3 ? nameParts[2] : "NOT_SUPPLIED"); | ||
String includedModules = config.getIncludedModules().stream().collect(Collectors.joining(",")); | ||
String defaultModuleId = StringUtils.hasLength(config.getDefaultModuleId()) ? config.getDefaultModuleId() : (nameParts.length >= 2 ? AssertionGroupImporter.ProductName.toModuleId(nameParts[1]) : "NOT_SUPPLIED"); | ||
for( String part : parts) { | ||
if ((part.contains("<PREVIOUS>") && previousReleaseSchema == null) | ||
|| (part.contains("<DEPENDENCY>") && dependencyReleaseSchema == null)) { | ||
continue; | ||
} | ||
|
||
logger.debug("Original sql statement: {}", part); | ||
// remove all SQL comments - //TODO might throw errors for -- style comments | ||
final Pattern commentPattern = Pattern.compile("/\\*.*?\\*/", Pattern.DOTALL); | ||
part = commentPattern.matcher(part).replaceAll(""); | ||
// replace all substitutions for exec | ||
part = part.replaceAll("<RUNID>", String.valueOf(config.getExecutionId())); | ||
part = part.replaceAll("<ASSERTIONUUID>", configMap.get("<ASSERTIONUUID>")); | ||
part = part.replaceAll("<MODULEID>", defaultModuleId); | ||
part = part.replaceAll("<MODULEIDS>", includedModules); | ||
part = part.replaceAll("<VERSION>", version); | ||
// watch out for any 's that users might have introduced | ||
part = part.replaceAll("qa_result", configMap.get("qa_result")); | ||
part = part.replaceAll("<PROSPECTIVE>", prospectiveSchema); | ||
part = part.replaceAll("<TEMP>", prospectiveSchema); | ||
if (previousReleaseSchema != null) { | ||
part = part.replaceAll("<PREVIOUS>", previousReleaseSchema); | ||
} | ||
if (dependencyReleaseSchema != null) { | ||
part = part.replaceAll("<DEPENDENCY>", dependencyReleaseSchema); | ||
} | ||
part = part.replaceAll("<DELTA>", deltaTableSuffix); | ||
part = part.replaceAll("<SNAPSHOT>", snapshotTableSuffix); | ||
part = part.replaceAll("<FULL>", fullTableSuffix); | ||
part = part.replaceAll(Pattern.quote("[[:<:]]"),"\\\\b" ); | ||
part = part.replaceAll(Pattern.quote("[[:>:]]"),"\\\\b" ); | ||
for(Map.Entry<String, String> configMapEntry: configMap.entrySet()){ | ||
if (configMapEntry.getKey().matches("^<[^>]+>$")) { | ||
part = part.replaceAll(configMapEntry.getKey(), configMapEntry.getValue()); | ||
} | ||
} | ||
part.trim(); | ||
logger.debug("Transformed sql statement: {}", part); | ||
result.add(part); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Convert given sql file content to multiple statements | ||
* @param sqlFileContent | ||
* @return | ||
*/ | ||
public List<String> transformToStatements(String sqlFileContent) throws BusinessServiceException { | ||
String delimiter = DEFAULT_DELIMITER; | ||
List<String> result = new ArrayList<>(); | ||
String[] sqlChunks = sqlFileContent.trim().split(DELIMITER_REGEX_PATTERN, Pattern.MULTILINE); | ||
for (int i = 0; i < sqlChunks.length; i++) { | ||
String sqlChunk = sqlChunks[i].trim(); | ||
if (!sqlChunk.isEmpty()) { | ||
if (i > 0) { | ||
delimiter = sqlChunk.trim().replaceAll("(?s)^([^ \r\n]+).*$", "$1"); | ||
sqlChunk = sqlChunk.trim().replaceAll("(?s)^[^ \r\n]+(.*)$", "$1").trim(); | ||
} | ||
if (!sqlChunk.isEmpty()) { | ||
logger.debug("Executing pre-requisite SQL: " + sqlChunk); | ||
final StatementSplitter splitter = new StatementSplitter(sqlChunk, ImmutableSet.of(delimiter)); | ||
if (splitter.getCompleteStatements() == null || splitter.getCompleteStatements().isEmpty()) { | ||
String errorMsg = String.format("SQL statements not ending with %s %s",delimiter, sqlChunk); | ||
logger.error( errorMsg); | ||
throw new BusinessServiceException(errorMsg); | ||
} | ||
result= splitter.getCompleteStatements().stream().map(s -> s.statement()).collect(Collectors.toList()); | ||
|
||
} | ||
} | ||
|
||
} | ||
return result; | ||
} | ||
} |
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.
Good idea