diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4a8da3bc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.gradle \ No newline at end of file diff --git a/le/build.gradle b/le/build.gradle index 04791552..e34f141f 100644 --- a/le/build.gradle +++ b/le/build.gradle @@ -1,141 +1,339 @@ +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import org.apache.tools.ant.filters.ReplaceTokens import org.apache.tools.ant.taskdefs.condition.Os -import static groovy.io.FileType.FILES -apply plugin: 'java' -apply plugin: 'eclipse' +def getTodayDate() { + def today = new Date() + return String.valueOf(today.getTime()) +} + +def getCommitRevision() { + def revCmd = "git rev-parse --short HEAD" + def revision = revCmd.execute() + return revision.text.trim() +} -jar { - baseName = 'os-le' - version = '1.0.0' +def getBranch() { + def branchCmd = "git symbolic-ref -q --short HEAD"; + def branch = branchCmd.execute().text.trim(); - manifest { - attributes("os-plugin-name": "le") + if (branch.length() == 0) { + branchCmd = "git describe --tags --exact-match"; + branch = branchCmd.execute().text.trim(); } - - doFirst { - from ('./src/main/webapp/dist') { - include '**/**' + return branch; +} + +projects { + apply plugin: 'java' + apply plugin: 'eclipse' + apply plugin: 'idea' + + sourceCompatibility = 17 + targetCompatibility = 17 + + repositories { + mavenCentral() + } + + configurations { + ajc + aspects + aspectCompile - into 'META-INF/resources/le' + providedCompile + + compile { + extendsFrom aspects + } + } + + configurations.all { + transitive = false + } + + sourceSets { + main.compileClasspath += configurations.providedCompile + test.compileClasspath += configurations.providedCompile + test.runtimeClasspath += configurations.providedCompile + } + + idea { + module { + scopes.PROVIDED.plus += [configurations.providedCompile] } + } - from('./src/main/webapp') { - include 'def.json' + def springVersion = "5.3.22" - into 'META-INF/resources/le' + dependencies { + implementation 'log4j:log4j:1.2.16' + ajc "org.aspectj:aspectjtools:1.9.19" + implementation "org.aspectj:aspectjrt:1.9.19" + aspects "org.springframework:spring-aspects:5.3.22" + aspects fileTree(dir: rootDir.absolutePath + '/lib', include: ['openspecimen.jar']) - def scriptHash = "-1", styleHash = "-1" - new File('./src/main/webapp/dist/').eachFileRecurse(FILES) { - if (it.name.startsWith("scripts") && it.name.endsWith("js")) { - def parts = it.name.split(/\./); - scriptHash = parts[1] - } else if (it.name.startsWith("app") && it.name.endsWith("css")) { - def parts = it.name.split(/\./) - styleHash = parts[1] - } + implementation fileTree(dir: rootDir.absolutePath + '/lib', include: ['openspecimen.jar', 'os-dynamic-forms-trunk.jar']) + implementation files('../lib/openspecimen.jar') + + implementation group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2' + implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1' + implementation group: 'javax.jms', name: 'javax.jms-api', version: '2.0.1' + + implementation group: 'asm', name: 'asm', version:'3.3.1' + implementation group: 'org.aspectj', name: 'aspectjweaver', version:'1.9.19' + implementation group: 'org.javassist', name: 'javassist', version:'3.19.0-GA' + implementation group: 'cglib', name: 'cglib', version:'3.1' + + implementation group: 'commons-io', name: 'commons-io', version:'2.11.0' + implementation group: 'org.apache.commons', name: 'commons-lang3', version:'3.12.0' + implementation group: 'org.apache.commons', name: 'commons-collections4', version:'4.4' + + implementation group: 'org.hibernate.common', name: 'hibernate-commons-annotations', version:'6.0.4.Final' + implementation group: 'org.hibernate', name: 'hibernate-core', version:'5.6.11.Final' + implementation group: 'org.hibernate', name: 'hibernate-envers', version:'5.6.11.Final' + + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version:'2.13.1' + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version:'2.13.1' + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.13.1' + + implementation group: 'net.sf.opencsv', name: 'opencsv', version:'2.3' + implementation group: 'org.liquibase', name: 'liquibase-core', version:'4.8.0' + + implementation group: 'org.springframework', name: 'spring-aspects', version:springVersion + implementation group: 'org.springframework', name: 'spring-aop', version:springVersion + implementation group: 'org.springframework', name: 'spring-beans', version:springVersion + implementation group: 'org.springframework', name: 'spring-context', version:springVersion + implementation group: 'org.springframework', name: 'spring-context-support', version:springVersion + implementation group: 'org.springframework', name: 'spring-core', version:springVersion + implementation group: 'org.springframework', name: 'spring-jdbc', version:springVersion + implementation group: 'org.springframework', name: 'spring-tx', version:springVersion + implementation group: 'org.springframework', name: 'spring-web', version:springVersion + implementation group: 'org.springframework', name: 'spring-webmvc', version:springVersion + implementation group: 'org.springframework', name: 'spring-orm', version:springVersion + implementation group: 'org.springframework', name: 'spring-jms', version:springVersion + implementation group: 'org.springframework.security', name: 'spring-security-core', version: '5.7.3' + implementation group: 'org.springframework.security', name: 'spring-security-web', version: '5.7.3' + } + + sourceSets.main.compileClasspath += configurations.providedCompile + sourceSets.test.compileClasspath += configurations.providedCompile + sourceSets.test.runtimeClasspath += configurations.providedCompile + + compileJava { + afterEvaluate { + tasks.withType(JavaCompile) { + options.compilerArgs += ['-Xlint:deprecation', '-Xmaxwarns', '10000', '-Xmaxerrs', '2000'] } + } - filter(ReplaceTokens, tokens: [script_hash: scriptHash, style_hash: styleHash]) + doLast{ + ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", + classpath: configurations.ajc.asPath) + + ant.iajc( + source: 14, + target: 14, + destDir: sourceSets.main.output.classesDirs.asPath, + maxmem: "512m", + fork: "true", + aspectPath: configurations.aspects.asPath, + sourceRootCopyFilter: "**/*.java", + classpath: "${configurations.compileClasspath.asPath};${configurations.providedCompile.asPath};${configurations.aspectCompile.asPath}") { + sourceroots { + sourceSets.main.java.srcDirs.each { + pathelement(location:it.absolutePath) + } + } + } } } -} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 + def grunt_cmd = "grunt" -repositories { - mavenCentral() -} + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + grunt_cmd = "grunt.cmd" + } -configurations { - ajc - aspects - aspectCompile - - compile { - extendsFrom aspects + task grunt_build { + if (project.file('./src/main/webapp/Gruntfile.js').exists()) { + doFirst { + exec { + workingDir './src/main/webapp' + commandLine grunt_cmd, 'build' + } + } + } } -} -configurations.all { - transitive = false -} + task grunt_clean { + if (project.file('./src/main/webapp/Gruntfile.js').exists()) { + doFirst { + exec { + workingDir './src/main/webapp' + commandLine grunt_cmd, 'clean' + } + } + } + } -def springVersion = "3.2.13.RELEASE" - -dependencies { - ajc "org.aspectj:aspectjtools:1.8.6" - compile "org.aspectj:aspectjrt:1.8.6" - compile "javax.persistence:persistence-api:1.0.2" - aspects "org.springframework:spring-aspects:3.2.13.RELEASE" - aspects fileTree(dir: '../lib', include: ['openspecimen.jar']) - - compile group: 'asm', name: 'asm', version:'3.3.1' - compile group: 'org.aspectj', name: 'aspectjweaver', version:'1.8.6' - compile group: 'org.javassist', name: 'javassist', version:'3.19.0-GA' - compile group: 'cglib', name: 'cglib', version:'3.1' - - compile group: 'commons-collections', name: 'commons-collections', version:'3.2.1' - compile group: 'commons-logging', name: 'commons-logging', version:'1.2' - compile group: 'commons-lang', name: 'commons-lang', version:'2.6' - compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12' - compile group: 'log4j', name: 'log4j', version:'1.2.16' - - compile group: 'org.hibernate', name: 'hibernate-envers', version:'4.2.18.Final' - - compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version:'2.5.3' - compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version:'2.5.3' - compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.5.3' - - compile group: 'org.springframework', name: 'spring-aop', version:springVersion - compile group: 'org.springframework', name: 'spring-beans', version:springVersion - compile group: 'org.springframework', name: 'spring-context', version:springVersion - compile group: 'org.springframework', name: 'spring-core', version:springVersion - compile group: 'org.springframework.security', name: 'spring-security-core', version:'3.2.7.RELEASE' - compile group: 'org.springframework', name: 'spring-tx', version:springVersion - compile group: 'org.springframework', name: 'spring-web', version:springVersion - compile group: 'org.springframework', name: 'spring-webmvc', version:springVersion -} + task vue_build { + if (project.file('./src/main/ui').exists()) { + doFirst { + exec { + workingDir './src/main/ui' + commandLine 'npm', 'run', 'build-bundle' + } + } + } + } -compileJava { - doLast{ - ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", - classpath: configurations.ajc.asPath) + task copy_ui_resources { + dependsOn grunt_build, vue_build - ant.iajc( - source: 1.8, target: 1.8, - destDir: sourceSets.main.output.classesDir.absolutePath, - maxmem: "512m", fork: "true", - aspectPath: configurations.aspects.asPath, - sourceRootCopyFilter: "**/*.java", - classpath: "${configurations.compile.asPath};${configurations.aspectCompile.asPath}") { - sourceroots { - sourceSets.main.java.srcDirs.each { - pathelement(location:it.absolutePath) + doLast { + println "Copying UI Resources" + + configure(tasks.'jar') { + from ('./src/main/webapp/dist') { + include '**/**' + + into 'META-INF/resources/' + osPluginName + } + + from('./src/main/webapp') { + include 'def.json' + + into 'META-INF/resources/' + osPluginName + + def scriptHash = "-1", styleHash = "-1" + fileTree('./src/main/webapp/dist/').visit { FileVisitDetails details -> + if (details.name.startsWith("scripts") && details.name.endsWith("js")) { + def parts = details.name.split(/\./); + scriptHash = parts[1]; + } else if (details.name.startsWith("app") && details.name.endsWith("css")) { + def parts = details.name.split(/\./) + styleHash = parts[1] + } } + + filter(ReplaceTokens, tokens: [script_hash: scriptHash, style_hash: styleHash]) + } + + } + } + } + + jar { + dependsOn copy_ui_resources + + archiveBaseName = osPluginJarName + archiveVersion = project.hasProperty('version') ? project['version'] : '1.0.0' + + manifest { + attributes("os-plugin-name": osPluginName) + attributes("built-on": getTodayDate()) + attributes("commit": getCommitRevision()) + attributes("version": project.hasProperty('version') ? project['version'] : '1.0.0') + } + + + + if (project.hasProperty('includeJars')) { + from { + def includeJars = project.properties['includeJars'].split(',') + configurations.compileClasspath.filter { d -> + includeJars.find { incJar -> d.absolutePath.contains(incJar) } + }.collect { + println 'Adding ' + it.absolutePath + it.isDirectory() ? it : zipTree(it) } } + } } -} -def grunt_cmd = "grunt" + clean.dependsOn grunt_clean -if (Os.isFamily(Os.FAMILY_WINDOWS)) { - grunt_cmd = "grunt.cmd" + jar.dependsOn grunt_build, vue_build + build.dependsOn jar } -task grunt_build(type: Exec) { - workingDir './src/main/webapp' - commandLine grunt_cmd, 'build' -} -task grunt_clean(type: Exec) { - workingDir './src/main/webapp' - commandLine grunt_cmd, 'clean' +task setup_node_modules { + if (coreAppDir == null || coreAppDir.trim().isEmpty()) { + println "Absolute path of the core app source required" + throw new GradleException("Absolute path of the core app source required"); + } + + if (!coreAppDir.endsWith("/")) { + coreAppDir += "/"; + } + + def ngNodeModules = Paths.get(coreAppDir, "www/node_modules"); + def ngBowerComps = Paths.get(coreAppDir, "www/bower_components"); + def vueNodeModules = Paths.get(coreAppDir, "ui/node_modules"); + + file('.').eachDir { project -> + if (project.name.startsWith('.')) { + return; + } + + def ngUi = project.absolutePath + "/src/main/webapp"; + if (file(ngUi).exists()) { + def ngUiNmLnk = Paths.get(ngUi, "node_modules"); + if (!ngUiNmLnk.toFile().exists()) { + println "Creating symbolic link " + ngUiNmLnk + " to " + ngNodeModules; + def result = Files.createSymbolicLink(ngUiNmLnk, ngNodeModules); + if (!result.toFile().exists()) { + throw GradleException("Failed to create the symbolic link to node_modules " + ngUiNmLnk); + } + } + + def ngUiBcLnk = Paths.get(ngUi, "bower_components"); + if (!ngUiBcLnk.toFile().exists()) { + println "Creating symbolic link " + ngUiBcLnk + " to " + ngBowerComps; + def result = Files.createSymbolicLink(ngUiBcLnk, ngBowerComps); + if (!result.toFile().exists()) { + throw GradleException("Failed to create the symbolic link to bower_components " + ngUiBcLnk); + } + } + } + + def vuUi = project.absolutePath + "/src/main/ui"; + if (file(vuUi).exists()) { + def vuUiNmLnk = Paths.get(vuUi, "node_modules"); + if (!vuUiNmLnk.toFile().exists()) { + println "Creating symbolic link " + vuUiNmLnk + " to " + vueNodeModules; + def result = Files.createSymbolicLink(vuUiNmLnk, vueNodeModules); + if (!result.toFile().exists()) { + throw GradleException("Failed to create the symbolic link to node_modules " + vuUiNmLnk); + } + } + } + } } -clean.dependsOn grunt_clean +task cleanup_node_modules { + doLast { + file('.').eachDir { project -> + if (project.name.startsWith('.')) { + return; + } + + def ngUi = project.absolutePath + "/src/main/webapp"; + if (file(ngUi).exists()) { + def ngUiNmLnk = Paths.get(ngUi, "node_modules"); + ngUiNmLnk.toFile().delete(); + + def ngUiBcLnk = Paths.get(ngUi, "bower_components"); + ngUiBcLnk.toFile().delete(); + } -jar.dependsOn grunt_build -build.dependsOn jar + def vuUi = project.absolutePath + "/src/main/ui"; + def vuUiNmLnk = Paths.get(vuUi, "node_modules"); + vuUiNmLnk.toFile().delete(); + } + } +} diff --git a/le/gradle.properties b/le/gradle.properties new file mode 100644 index 00000000..2f72e4a3 --- /dev/null +++ b/le/gradle.properties @@ -0,0 +1,4 @@ +coreAppDir= +osPluginName=le +osPluginJarName=os-le +version=1.0.0 diff --git a/le/src/main/java/com/krishagni/openspecimen/le/services/impl/CprServiceImpl.java b/le/src/main/java/com/krishagni/openspecimen/le/services/impl/CprServiceImpl.java index 9428fc2f..298f63b1 100644 --- a/le/src/main/java/com/krishagni/openspecimen/le/services/impl/CprServiceImpl.java +++ b/le/src/main/java/com/krishagni/openspecimen/le/services/impl/CprServiceImpl.java @@ -5,7 +5,8 @@ import java.util.Date; import java.util.List; -import org.apache.commons.lang.StringUtils; +import com.krishagni.catissueplus.core.biospecimen.domain.BaseEntity; +import org.apache.commons.lang3.StringUtils; import com.krishagni.catissueplus.core.biospecimen.domain.CollectionProtocol; import com.krishagni.catissueplus.core.biospecimen.domain.CollectionProtocolRegistration; @@ -25,12 +26,20 @@ import com.krishagni.openspecimen.le.events.BulkParticipantRegDetail; import com.krishagni.openspecimen.le.events.ParticipantRegDetail; import com.krishagni.openspecimen.le.services.CprService; +import org.springframework.transaction.annotation.Transactional; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + public class CprServiceImpl implements CprService { - + private DaoFactory daoFactory; - - private LabelGenerator labelGenerator; + + @PersistenceContext + private EntityManager em; + + private LabelGenerator labelGenerator; public void setDaoFactory(DaoFactory daoFactory) { this.daoFactory = daoFactory; @@ -40,15 +49,17 @@ public void setLabelGenerator(LabelGenerator labelGenerator) { this.labelGenerator = labelGenerator; } - @Override - @PlusTransactional + @Transactional + @PlusTransactional public ResponseEvent registerParticipants(RequestEvent req) { try { BulkParticipantRegDetail detail = req.getPayload(); OpenSpecimenException ose = new OpenSpecimenException(ErrorType.USER_ERROR); + CollectionProtocol cp = daoFactory.getCollectionProtocolDao().getById(detail.getCpId()); + if (cp == null) { return ResponseEvent.userError(CpErrorCode.NOT_FOUND); } @@ -110,6 +121,8 @@ private ParticipantRegDetail registerParticipant(CollectionProtocol cp, Particip cpr.setPpid(ppid); cpr.setCollectionProtocol(cp); cpr.setParticipant(participant); + cpr.setDataEntryStatus(BaseEntity.DataEntryStatus.COMPLETE); + Date regDate = detail.getRegDate(); if (regDate == null) { diff --git a/le/src/main/java/com/krishagni/openspecimen/le/services/impl/CprServiceImpl.java_old b/le/src/main/java/com/krishagni/openspecimen/le/services/impl/CprServiceImpl.java_old new file mode 100644 index 00000000..304ded19 --- /dev/null +++ b/le/src/main/java/com/krishagni/openspecimen/le/services/impl/CprServiceImpl.java_old @@ -0,0 +1,163 @@ +package com.krishagni.openspecimen.le.services.impl; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; + +import com.krishagni.catissueplus.core.biospecimen.domain.CollectionProtocol; +import com.krishagni.catissueplus.core.biospecimen.domain.CollectionProtocolRegistration; +import com.krishagni.catissueplus.core.biospecimen.domain.Participant; +import com.krishagni.catissueplus.core.biospecimen.domain.factory.CpErrorCode; +import com.krishagni.catissueplus.core.biospecimen.domain.factory.CprErrorCode; +import com.krishagni.catissueplus.core.biospecimen.domain.factory.ParticipantErrorCode; +import com.krishagni.catissueplus.core.biospecimen.domain.factory.ParticipantUtil; +import com.krishagni.catissueplus.core.biospecimen.repository.DaoFactory; +import com.krishagni.catissueplus.core.common.PlusTransactional; +import com.krishagni.catissueplus.core.common.access.AccessCtrlMgr; +import com.krishagni.catissueplus.core.common.errors.ErrorType; +import com.krishagni.catissueplus.core.common.errors.OpenSpecimenException; +import com.krishagni.catissueplus.core.common.events.RequestEvent; +import com.krishagni.catissueplus.core.common.events.ResponseEvent; +import com.krishagni.catissueplus.core.common.service.LabelGenerator; +import com.krishagni.openspecimen.le.events.BulkParticipantRegDetail; +import com.krishagni.openspecimen.le.events.ParticipantRegDetail; +import com.krishagni.openspecimen.le.services.CprService; + +public class CprServiceImpl implements CprService { + + private DaoFactory daoFactory; + + private LabelGenerator labelGenerator; + + public void setDaoFactory(DaoFactory daoFactory) { + this.daoFactory = daoFactory; + } + + public void setLabelGenerator(LabelGenerator labelGenerator) { + this.labelGenerator = labelGenerator; + } + + + @Override + @PlusTransactional + public ResponseEvent registerParticipants(RequestEvent req) { + try { + BulkParticipantRegDetail detail = req.getPayload(); + + OpenSpecimenException ose = new OpenSpecimenException(ErrorType.USER_ERROR); + CollectionProtocol cp = daoFactory.getCollectionProtocolDao().getById(detail.getCpId()); + if (cp == null) { + return ResponseEvent.userError(CpErrorCode.NOT_FOUND); + } + + List result = new ArrayList(); + for (ParticipantRegDetail regDetail : detail.getRegistrations()) { + regDetail = registerParticipant(cp, regDetail, ose); + ose.checkAndThrow(); + + result.add(regDetail); + } + + return ResponseEvent.response(new BulkParticipantRegDetail(detail.getCpId(), result)); + } catch (OpenSpecimenException ose) { + return ResponseEvent.error(ose); + } catch (Exception e) { + return ResponseEvent.serverError(e); + } + } + + private ParticipantRegDetail registerParticipant(CollectionProtocol cp, ParticipantRegDetail detail, OpenSpecimenException ose) { + String empi = detail.getEmpi(); + if (StringUtils.isBlank(empi)) { + ose.addError(ParticipantErrorCode.EMPI_REQUIRED); + return null; + } + + if (!ParticipantUtil.isValidMpi(empi, ose)) { + return null; + } + + String ppid = detail.getPpid(); + if (StringUtils.isBlank(ppid)) { + ose.addError(CprErrorCode.PPID_REQUIRED); + return null; + } + + Participant participant = daoFactory.getParticipantDao().getByEmpi(empi); + if (participant == null) { + participant = new Participant(); + participant.setEmpi(empi); + } + + CollectionProtocolRegistration cpr = daoFactory.getCprDao().getCprByPpid(cp.getId(), ppid); + if (cpr != null && !cpr.getParticipant().equals(participant)) { + ose.addError(CprErrorCode.DUP_PPID, ppid); + return detail; + } + + if (cpr == null && participant.getId() != null) { + cpr = daoFactory.getCprDao().getCprByParticipantId(cp.getId(), participant.getId()); + } + + if (cpr != null) { + return ParticipantRegDetail.from(cpr); + } + + cpr = new CollectionProtocolRegistration(); + cpr.setPpid(ppid); + cpr.setCollectionProtocol(cp); + cpr.setParticipant(participant); + + Date regDate = detail.getRegDate(); + if (regDate == null) { + regDate = Calendar.getInstance().getTime(); + } + cpr.setRegistrationDate(regDate); + + ensureValidAndUniquePpid(cpr, ose); + + if (participant.getId() == null) { + daoFactory.getParticipantDao().saveOrUpdate(participant); + } + + AccessCtrlMgr.getInstance().ensureUpdateCprRights(cpr); + daoFactory.getCprDao().saveOrUpdate(cpr); + return ParticipantRegDetail.from(cpr); + } + + private void ensureValidAndUniquePpid(CollectionProtocolRegistration cpr, OpenSpecimenException ose) { + CollectionProtocol cp = cpr.getCollectionProtocol(); + boolean ppidReq = cp.isManualPpidEnabled() || StringUtils.isBlank(cp.getPpidFormat()); + + String ppid = cpr.getPpid(); + if (StringUtils.isBlank(ppid)) { + if (ppidReq) { + ose.addError(CprErrorCode.PPID_REQUIRED); + } + + return; + } + + if (StringUtils.isNotBlank(cp.getPpidFormat())) { + // + // PPID format is specified + // + if (!cp.isManualPpidEnabled()) { + ose.addError(CprErrorCode.MANUAL_PPID_NOT_ALLOWED); + return; + } + + if (!labelGenerator.validate(cp.getPpidFormat(), cpr, ppid)) { + ose.addError(CprErrorCode.INVALID_PPID, ppid); + return; + } + } + + if (daoFactory.getCprDao().getCprByPpid(cp.getId(), ppid) != null) { + ose.addError(CprErrorCode.DUP_PPID, ppid); + } + } +} diff --git a/le/src/main/java/com/krishagni/openspecimen/le/services/impl/SpecimenCollectionServiceImpl.java b/le/src/main/java/com/krishagni/openspecimen/le/services/impl/SpecimenCollectionServiceImpl.java index 4de2bd04..a1b74663 100644 --- a/le/src/main/java/com/krishagni/openspecimen/le/services/impl/SpecimenCollectionServiceImpl.java +++ b/le/src/main/java/com/krishagni/openspecimen/le/services/impl/SpecimenCollectionServiceImpl.java @@ -22,92 +22,96 @@ import com.krishagni.openspecimen.le.events.SpecimenAndFrozenEventDetail; import com.krishagni.openspecimen.le.events.SpecimenAndFrozenEventDetail.EventDetail; import com.krishagni.openspecimen.le.services.SpecimenCollectionService; +import org.springframework.transaction.annotation.Transactional; + public class SpecimenCollectionServiceImpl implements SpecimenCollectionService { - + private VisitService visitService; - + private SpecimenService specimenSvc; - + private ConfigurationService cfgSvc; - + public void setVisitService(VisitService visitService) { this.visitService = visitService; } - + public void setSpecimenSvc(SpecimenService specimenSvc) { this.specimenSvc = specimenSvc; } - + public void setCfgSvc(ConfigurationService cfgSvc) { this.cfgSvc = cfgSvc; } @Override + @Transactional @PlusTransactional public ResponseEvent> collectVisitsAndSpecimens(RequestEvent> req) { List responses = new ArrayList(); - + for (VisitSpecimenDetail detail : req.getPayload()) { RequestEvent subReq = new RequestEvent(detail); ResponseEvent subResp = visitService.collectVisitAndSpecimens(subReq); if (!subResp.isSuccessful()) { return ResponseEvent.error(subResp.getError()); } - + responses.add(subResp.getPayload()); } - + return new ResponseEvent>(responses); } - + @Override + @Transactional @PlusTransactional public ResponseEvent collectChildSpecimens(RequestEvent req) { - try { + try { SpecimenAndFrozenEventDetail detail = req.getPayload(); - + // // Step 1: collect child specimens // RequestEvent> collectChildSpmnsReq = new RequestEvent>(detail.getSpecimens()); ResponseEvent> collectChildSpmnsResp = specimenSvc.collectSpecimens(collectChildSpmnsReq); collectChildSpmnsResp.throwErrorIfUnsuccessful(); - + // // Step 2: add frozen events // addFrozenEvents(getReqSpecimenIdMap(collectChildSpmnsResp.getPayload()), detail.getEvents()); - + // // Step 3: construct response - // + // SpecimenAndFrozenEventDetail respDetail = new SpecimenAndFrozenEventDetail(); respDetail.setSpecimens(collectChildSpmnsResp.getPayload()); respDetail.setEvents(detail.getEvents()); - return ResponseEvent.response(respDetail); + return ResponseEvent.response(respDetail); } catch (OpenSpecimenException ose) { return ResponseEvent.error(ose); } catch (Exception e) { return ResponseEvent.serverError(e); } } - + private Map getReqSpecimenIdMap(List specimens) { Map result = new HashMap(); - + if (specimens == null) { return result; } - + for (SpecimenDetail specimen : specimens) { result.put(specimen.getVisitId() + "-" + specimen.getReqId(), specimen.getId()); - result.putAll(getReqSpecimenIdMap(specimen.getChildren())); + result.putAll(getReqSpecimenIdMap(specimen.getChildren())); } - + return result; } - + private void addFrozenEvents(Map reqSpecimenIdMap, List events) { for (EventDetail event : events) { Long specimenId = event.getSpecimenId(); @@ -119,25 +123,26 @@ private void addFrozenEvents(Map reqSpecimenIdMap, List values = new HashMap(); values.put("user", userId); - values.put("time", new SimpleDateFormat(cfgSvc.getDeDateTimeFormat()).format(time)); - return DeObject.saveFormData("SpecimenFrozenEvent", "SpecimenEvent", -1L, specimenId, values); + values.put("time", new SimpleDateFormat(cfgSvc.getDeDateTimeFormat()).format(time)); + values.put("frozenMethod", "Not Specified"); + return DeObject.saveFormData("SpecimenFrozenEvent", "SpecimenEvent", -1L, specimenId, values); } } diff --git a/le/src/main/resources/pluginContext.xml b/le/src/main/resources/pluginContext.xml index 37ae30aa..f5e15c7d 100644 --- a/le/src/main/resources/pluginContext.xml +++ b/le/src/main/resources/pluginContext.xml @@ -18,6 +18,7 @@ http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> + @@ -29,4 +30,5 @@ + diff --git a/le/src/main/webapp/app/specimen-box.js b/le/src/main/webapp/app/specimen-box.js index dbfa711c..246e30d4 100644 --- a/le/src/main/webapp/app/specimen-box.js +++ b/le/src/main/webapp/app/specimen-box.js @@ -1,5 +1,5 @@ angular.module('os.plugins.le') - .directive('leSpecimenBox', function(SpecimenUnitSvc) { + .directive('leSpecimenBox', function(SpecimenPropsSvc) { function drawBox(opts, element) { var dimension = opts.dimension; var specimens = opts.specimens; @@ -39,7 +39,7 @@ angular.module('os.plugins.le') angular.element('
') .append(angular.element('
').append(specimen.type)) .append(angular.element('').append(specimen.initialQty)) - .append(getUnit(specimen)).append(angular.element('').append(' ')) + .append(getProps(specimen)).append(angular.element('').append(' ')) .append(angular.element('').append(specimen.collectionContainer)) ); @@ -61,7 +61,7 @@ angular.module('os.plugins.le') boxContent.append(row); } - + if (labelPresent) { boxContent.addClass('show-not-collected'); } @@ -78,16 +78,16 @@ angular.module('os.plugins.le') if (specimens[startIdx].storageType != 'Virtual') { return startIdx; } - + startIdx++; } return -1; } - function getUnit(specimen) { + function getProps(specimen) { var unitEl = angular.element(''); - SpecimenUnitSvc.getUnit(specimen.specimenClass, specimen.type).then( + SpecimenPropsSvc.getProps(specimen.specimenClass, specimen.type).then( function(unit) { unitEl.html(unit.qtyHtmlDisplayCode || unit.qtyUnit) } @@ -105,7 +105,7 @@ angular.module('os.plugins.le') scope: { opts: '=', - ctrl: '=' + ctrl: '=' }, controller: function($scope, $element) { diff --git a/le/src/main/webapp/package.json b/le/src/main/webapp/package.json index 6d9df5a6..8b7ab7f5 100644 --- a/le/src/main/webapp/package.json +++ b/le/src/main/webapp/package.json @@ -31,7 +31,7 @@ "grunt-contrib-copy": "^0.7.0", "grunt-contrib-cssmin": "^0.10.0", "grunt-contrib-htmlmin": "^0.3.0", - "grunt-contrib-imagemin": "^0.9.1", + "grunt-contrib-imagemin": "1.0.0", "grunt-contrib-uglify": "^0.6.0", "grunt-contrib-watch": "^0.6.1", "grunt-filerev": "^2.1.1", diff --git a/lib/log4j-1.2-api-2.17.1.jar b/lib/log4j-1.2-api-2.17.1.jar new file mode 100644 index 00000000..ef4f08dc Binary files /dev/null and b/lib/log4j-1.2-api-2.17.1.jar differ diff --git a/lib/log4j-api-2.17.1.jar b/lib/log4j-api-2.17.1.jar new file mode 100644 index 00000000..1aae243b Binary files /dev/null and b/lib/log4j-api-2.17.1.jar differ diff --git a/lib/log4j-core-2.17.1.jar b/lib/log4j-core-2.17.1.jar new file mode 100644 index 00000000..46825278 Binary files /dev/null and b/lib/log4j-core-2.17.1.jar differ diff --git a/lib/openspecimen.jar b/lib/openspecimen.jar index 213472e9..6e0c958c 100644 Binary files a/lib/openspecimen.jar and b/lib/openspecimen.jar differ