Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev' into release and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Forostianov committed Mar 13, 2019
2 parents e2ad58d + 652785b commit 188e4dd
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion gb-backend-e2e/src/test/groovy/tests/QuerySpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class QuerySpec extends RESTSpec {
statusCode: 201,
body : [
name : 'test query',
type : 'patient',
subjectDimension : 'patient',
queryConstraint : [type: 'true'],// TODO replace with TrueConstraint representation from tm-core-api
bookmarked : true,
subscribed : false,
Expand Down
4 changes: 2 additions & 2 deletions gb-backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ buildscript {
}
}

version "0.1.0-RC1"
group "nl.thehyve.gb.backend"
version "0.2.0-RC1"
group "nl.thehyve"

apply plugin:"eclipse"
apply plugin:"idea"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package nl.thehyve.gb.backend
class Query {

String name
String type
String subjectDimension
String username
String queryConstraint
Boolean bookmarked = false
Expand All @@ -31,7 +31,7 @@ class Query {

static constraints = {
name maxSize: 1000
type maxSize: 255, nullable: false
subjectDimension maxSize: 255, nullable: false
username maxSize: 50
queryConstraint type: 'text', nullable: false
bookmarked nullable: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class NotificationsMailService {
/**
* Fetches a list of sets for all queries user subscribed to with specific frequency
* for which there were instances added or removed comparing to a previous query set
* and groups it by query type
* and groups it by query type (subject dimension).
*
* @param frequency
* @param username
* @return A map of query type to list of sets with changes
* @return A map of query subject dimension to list of sets with changes
*/
private Map<String, List<QuerySetChangesRepresentation>> getQueryTypeToQuerySetChangesRepresentations(
SubscriptionFrequency frequency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class QueryService {
query.with {
new QueryRepresentation(
id,
type,
subjectDimension,
username,
name,
queryConstraint ? BindingHelper.readFromString(queryConstraint, Object) : null,
Expand Down Expand Up @@ -97,7 +97,7 @@ class QueryService {
}
query.with {
name = representation.name
type = representation.type // TODO TMT-741 - validate query type, currently it can be any string
subjectDimension = representation.subjectDimension // TODO TMT-741 - validate query subjectDimension, currently it can be any string
queryConstraint = BindingHelper.writeAsString(representation.queryConstraint)
bookmarked = representation.bookmarked ?: false
subscribed = representation.subscribed ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class QuerySetService {
}

void createQuerySetWithQueryInstances(QueryRepresentation queryRepresentation) {
log.info "Create set of type ${queryRepresentation.type} for query ${queryRepresentation.id}"
log.info "Create set of subjectDimension ${queryRepresentation.subjectDimension} for query ${queryRepresentation.id}"
List<String> setInstances = getSetInstancesForQuery(queryRepresentation)
Query query = queryService.getQueryById(queryRepresentation.id)
QuerySet querySet = new QuerySet(
Expand Down Expand Up @@ -167,14 +167,14 @@ class QuerySetService {

private List<String> getSetInstancesForQuery(QueryRepresentation query) {
def newDimensionElements =
getDimensionElements(query.type, query.queryConstraint as Map)?.elements
listSetInstanceIds(query.type, newDimensionElements)
getDimensionElements(query.subjectDimension, query.queryConstraint as Map)?.elements
listSetInstanceIds(query.subjectDimension, newDimensionElements)
}

private List<String> getSetInstancesWithImpersonation(QueryRepresentation query) {
def newDimensionElements =
getDimensionElementsForUser(query.type, query.queryConstraint as Map, query.username)?.elements
listSetInstanceIds(query.type, newDimensionElements)
getDimensionElementsForUser(query.subjectDimension, query.queryConstraint as Map, query.username)?.elements
listSetInstanceIds(query.subjectDimension, newDimensionElements)
}

private List<QuerySet> getQuerySets(Long queryId, User currentUser, Integer maxNumberOfSets) {
Expand Down Expand Up @@ -289,7 +289,7 @@ class QuerySetService {
set.createDate,
set.query.name,
set.query.id,
set.query.type,
set.query.subjectDimension,
objectsAdded,
objectsRemoved
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class QueryServiceSpec extends Specification {
def query1Representation = new QueryRepresentation()
query1Representation.with {
name = 'test query 1'
type = 'patient'
subjectDimension = 'patient'
queryConstraint = [type: 'true']
bookmarked = true
subscribed = true
Expand All @@ -57,7 +57,7 @@ class QueryServiceSpec extends Specification {
def query2Representation = new QueryRepresentation()
query2Representation.with {
name = 'test query 2'
type = 'diagnosis'
subjectDimension = 'diagnosis'
queryConstraint = [type: 'true']
bookmarked = true
subscribed = false
Expand All @@ -67,7 +67,7 @@ class QueryServiceSpec extends Specification {
def query3Representation = new QueryRepresentation()
query3Representation.with {
name = 'test query 3'
type = 'sample1'
subjectDimension = 'sample1'
queryConstraint = [type: 'negation', arg: [type: 'true']]
bookmarked = false
subscribed = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class QuerySetServiceSpec extends Specification {
def query1_invalid = new Query()
query1_invalid.with {
name = 'fail on scan query'
type = 'patient'
subjectDimension = 'patient'
queryConstraint = '{"type": "concept", "conceptCode": "NON-EXISTENT"}'
bookmarked = true
subscribed = true
Expand All @@ -171,7 +171,7 @@ class QuerySetServiceSpec extends Specification {
def query2 = new Query()
query2.with {
name = 'test query 1'
type = 'diagnosis'
subjectDimension = 'diagnosis'
queryConstraint = '{"type": "true"}'
bookmarked = true
subscribed = true
Expand All @@ -181,7 +181,7 @@ class QuerySetServiceSpec extends Specification {
def query3 = new Query()
query3.with {
name = 'test query 2'
type = 'patient'
subjectDimension = 'patient'
queryConstraint = '{"type": "negation", "arg": {"type": "true"}}'
bookmarked = false
subscribed = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@ class EmailGenerator {
queryTypeToQuerySetsChanges.collect { type, querySetsChanges ->
String table = updatesHtmlTablePerType(querySetsChanges)
[
"For subscription of type <b>${type}</b> there are the following updates:",
"Cohort changes (type <b>${type}</b>):",
table
].join(BR)
}.join(BR)
}

protected static String updatesHtmlTablePerType(List<QuerySetChangesRepresentation> querySetsChanges) {
String queryIdHeader = 'Your Query ID'
String queryNameHeader = 'Your Query Name'
String queryNameHeader = 'Your Cohort Name'
String queryIdHeader = 'Your Cohort ID'
String addedSubjectHeader = 'Number of added instances'
String removedSubjectHeader = 'Number of removed instances'
String dateOfChangeHeader = 'Date of change'

List<String> tableRows = querySetsChanges.collect { QuerySetChangesRepresentation change ->
"<tr><td>${change.queryId}</td><td>${change.queryName}</td><td>${change.objectsAdded.size()}</td><td>${change.objectsRemoved.size()}</td><td>${DATE_TIME_FORMAT.format(change.createDate)}</td></tr>".toString()
"<tr><td>${change.queryName}</td><td>${change.queryId}</td><td>${change.objectsAdded.size()}</td><td>${change.objectsRemoved.size()}</td><td>${DATE_TIME_FORMAT.format(change.createDate)}</td></tr>".toString()
}

'<table cellpadding="10">' +
'<tr>' + th(queryIdHeader) + th(queryNameHeader) + th(addedSubjectHeader) + th(removedSubjectHeader) + th(dateOfChangeHeader) + '</tr>' +
'<tr>' + th(queryNameHeader) + th(queryIdHeader) + th(addedSubjectHeader) + th(removedSubjectHeader) + th(dateOfChangeHeader) + '</tr>' +
tableRows.join('') +
'</table>'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class QueryRepresentation {
Long id

@Size(min = 1)
String type
String subjectDimension

@Size(min = 1)
String username
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ class EmailGeneratorSpec extends Specification {
def 'body of the query subscription updates'() {
String clientAppName = 'ABC'
Map<String, List<QuerySetChangesRepresentation>> querySetChanges = [
diagnosis: [
Diagnosis: [
new QuerySetChangesRepresentation(
queryId: 36,
queryName: 'test diagnosis query',
createDate: DATE_TIME_FORMAT.parse('2019-02-07 09:59'),
queryType: 'diagnosis',
queryType: 'Diagnosis',
objectsAdded: ['d1', 'd2', 'd3'],
objectsRemoved: []
)
],
patient : [
Patient : [
new QuerySetChangesRepresentation(
queryId: 35,
queryName: 'first saved query',
createDate: DATE_TIME_FORMAT.parse('2017-05-03 13:30'),
queryType: 'patient',
queryType: 'Patient',
objectsAdded: ['subj1', 'subj2', 'subj3'],
objectsRemoved: ['subj10'],

Expand All @@ -51,7 +51,7 @@ class EmailGeneratorSpec extends Specification {
queryId: 50,
queryName: 'test query',
createDate: DATE_TIME_FORMAT.parse('2017-08-16 8:45'),
queryType: 'diagnosis',
queryType: 'Diagnosis',
objectsAdded: ['subj100', 'subj200', 'subj300', 'subj400', 'subj500', 'subj600'],
objectsRemoved: ['subj101', 'subj201'],
),
Expand All @@ -61,16 +61,16 @@ class EmailGeneratorSpec extends Specification {
def expectedContent = 'Hello,<br /><br />' +
'You have subscribed to be notified to data updates for one or more queries that you have saved in the "ABC" application.' +
'<br />In this email you will find an overview of all data updates up until October 3 2018 15:25:' +
'<p />For subscription of type <b>diagnosis</b> there are the following updates:' +
'<p />Cohort changes (type <b>Diagnosis</b>):' +
'<br /><table cellpadding="10"><tr>' +
'<th align="left">Your Query ID</th><th align="left">Your Query Name</th><th align="left">Number of added instances</th><th align="left">Number of removed instances</th><th align="left">Date of change</th></tr>' +
'<tr><td>36</td><td>test diagnosis query</td><td>3</td><td>0</td><td>February 7 2019 9:59</td></tr>' +
'<th align="left">Your Cohort Name</th><th align="left">Your Cohort ID</th><th align="left">Number of added instances</th><th align="left">Number of removed instances</th><th align="left">Date of change</th></tr>' +
'<tr><td>test diagnosis query</td><td>36</td><td>3</td><td>0</td><td>February 7 2019 9:59</td></tr>' +
'</table>' +
'<br />For subscription of type <b>patient</b> there are the following updates:' +
'<br />Cohort changes (type <b>Patient</b>):' +
'<br /><table cellpadding="10">' +
'<tr><th align="left">Your Query ID</th><th align="left">Your Query Name</th><th align="left">Number of added instances</th><th align="left">Number of removed instances</th><th align="left">Date of change</th></tr>' +
'<tr><td>35</td><td>first saved query</td><td>3</td><td>1</td><td>May 3 2017 13:30</td></tr>' +
'<tr><td>50</td><td>test query</td><td>6</td><td>2</td><td>August 16 2017 8:45</td></tr>' +
'<tr><th align="left">Your Cohort Name</th><th align="left">Your Cohort ID</th><th align="left">Number of added instances</th><th align="left">Number of removed instances</th><th align="left">Date of change</th></tr>' +
'<tr><td>first saved query</td><td>35</td><td>3</td><td>1</td><td>May 3 2017 13:30</td></tr>' +
'<tr><td>test query</td><td>50</td><td>6</td><td>2</td><td>August 16 2017 8:45</td></tr>' +
'</table>' +
'<p />You can login to ABC to reload your queries and review the new data available.' +
'<br />Regards,<br /><br />ABC'
Expand Down

0 comments on commit 188e4dd

Please sign in to comment.