Skip to content

Commit

Permalink
finalized testing for #1105
Browse files Browse the repository at this point in the history
  • Loading branch information
ppazos committed Jun 25, 2022
1 parent e5bfd16 commit f4c4155
Show file tree
Hide file tree
Showing 63 changed files with 3,517 additions and 6,723 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ class RestController {
return
}

def opt_out = optService.getOPTContents(opt)
def opt_out = optService.getOPTContents(opt, -1)

withFormat {
xml {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,20 @@ class OperationalTemplateController {
def opt = OperationalTemplateIndex.findByLocalUidAndOrganizationUid(uid, session.organization.uid)
if (!opt)
{
println "no opt"
flash.message = message(code:"opt.common.error.templateNotFound")
redirect action:'index'
return
}
if (!opt.lastVersion)
{
println "no last version"
flash.message = message(code:"opt.common.error.templateNotLastVersion")
redirect action:'index'
return
}

def opt_xml = optService.getOPTContents(opt)
def opt_xml = optService.getOPTContents(opt, -1)

// get all versions of the OPT, including last (current opt uid)
def versions = OperationalTemplateIndex.findAllBySetId(opt.setId, [sort: 'versionNumber', order: 'desc'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ class OperationalTemplateIndexerJob {

opts.each { optIndex ->

println "Indexing ${optIndex.templateId}"
println "Indexing ${optIndex.templateId} ${optIndex.fileLocation}"

// FIXME: this is a terrible way of saying "do not create the OPTIndex", that should be a parameter or something else...
// Generates OPT and archetype item indexes just for the uploaded OPT
operationalTemplateIndexerService.templateIndex = optIndex // avoids creating another opt index internally and use the one created here


xml = optService.getOPTContents(optIndex)
xml = optService.getOPTContents(optIndex, -1)
println xml

template = slurper.parseText(xml)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class OptFSService {
String getOPTContents(OperationalTemplateIndex opt, int max_bytes_to_return = 1000000)
{
// avoid returning files that are too big
if (new File(opt.fileLocation).length() > max_bytes_to_return)
if (max_bytes_to_return > 0 && opt.size > max_bytes_to_return)
{
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OptS3Service {

def operationalTemplateIndexer

// TODO: refactor, these are the same as the ones in VersionFSRepoService, just the repo field changes.
// TODO: refactor, these methods are implemented in OptRepositoryS3Impl, we could use that one instead of repeating the code
AmazonS3 s3

// this initalizes the S3 connection when the service is created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ class SyncParserService {
return eq
}

// FIXME: sync should send the OPT files and generate these indexes in the slave server, instead of creating them in the master and send them.
OperationalTemplateIndex toJSONOpt(JSONObject j)
{
def templateIndex = new OperationalTemplateIndex(
Expand All @@ -344,7 +345,8 @@ class SyncParserService {
setId: j.setId,
versionNumber: j.versionNumber,
lastVersion: j.lastVersion,
fileLocation: j.fileLocation
fileLocation: j.fileLocation,
size: j.size
)

def xml = j.opt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class OperationalTemplateIndexerService {
opt.isActive = true
opt.save(flush: true, failOnError: true)

def opt_xml = optService.getOPTContents(opt)
def opt_xml = optService.getOPTContents(opt, -1)
def org = Organization.findByUid(opt.organizationUid)

def clean_opt_xml = FileUtils.removeBOM(opt_xml.getBytes())
Expand Down Expand Up @@ -450,6 +450,8 @@ class OperationalTemplateIndexerService {
// if it is not coming from an alraedy indexed OPT
if (!this.templateIndex)
{
def fileLocation = optService.newOPTFileLocation(org.uid, templateId)

this.templateIndex = new OperationalTemplateIndex(
localTemplateId: localTemplateId,
templateId: templateId,
Expand All @@ -459,7 +461,8 @@ class OperationalTemplateIndexerService {
archetypeId: archetypeId,
archetypeConcept: archetypeConcept,
organizationUid: org.uid,
fileLocation: optService.newOPTFileLocation(org.uid, templateId)
fileLocation: fileLocation,
size: new File(fileLocation).length() // FIXME: this doesn't work for S3 storage!
)

// TODO: log errors and throw except
Expand Down
8 changes: 6 additions & 2 deletions grails-app/views/operationalTemplate/upload.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@
var input = $(this).parents('.input-group').find(':text'),
log = numFiles > 1 ? numFiles + ' files selected' : label;
if( input.length ) {
if (input.length)
{
input.val(log);
} else {
}
else
{
if (log)
{
new PNotify({
Expand Down Expand Up @@ -169,6 +172,7 @@
'<div class="alert alert-info alert-dismissible" role="alert" style="position: fixed; top: 10px; z-index: 1099; display: block; width:80%; left:10%;"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> '+
data.message +'</div>'
);
console.log("redirect: ", data);
location.href = '${createLink("action": "show")}/'+ data.opt.localUid;
}
else if (data.status == "error")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions opts/base_opts/tmp/vital_signs_summary.en.v1.opt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--Operational template XML automatically generated by Ocean Template Designer Version 2.8.94Beta-->
<template xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.openehr.org/v1">
<language>
Expand Down Expand Up @@ -6638,7 +6638,7 @@
<value>openEHR-EHR-COMPOSITION.health_summary.v1</value>
</archetype_id>
<template_id>
<value>vital_signs_summary.en.v1</value>
<value>Vital_Signs_Summary.EN.v1</value>
</template_id>
<term_definitions code="at0000">
<items id="description">Generic document containing a summary of health information about an individual.</items>
Expand Down Expand Up @@ -6706,4 +6706,4 @@
</items>
</constraints>
</view>
</template>
</template>
Loading

0 comments on commit f4c4155

Please sign in to comment.