From ef4b8043ac5d6273ab632fdd260b06878b7974b2 Mon Sep 17 00:00:00 2001 From: Jacques Yakoub Date: Sun, 3 Sep 2023 17:53:24 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20fix=20warnings=20=E2=99=BB=EF=B8=8F=20?= =?UTF-8?q?(#6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: fix warnings (WIP) * chore: fix warnings (WIP) * chore: fix deprecated methods * chore: fix warnings (WIP) * chore: fix warnings (WIP) * chore: fix warnings (WIP) * chore: remove TODO * ci: update Github Actions --- .github/dependabot.yml | 50 ++++++++++++++- .github/workflows/pr-comment-artifact-url.yml | 3 + .../org/imec/ivlab/core/RangeChecker.java | 13 ++-- .../ivlab/core/kmehr/KmehrMarshaller.java | 7 +- .../model/localid/util/URIConverter.java | 6 +- .../model/upload/KmehrWithReferenceList.java | 1 + .../model/upload/msentrylist/MSEntryList.java | 1 + .../upload/msentrylist/ReferenceDateUtil.java | 1 - .../org/imec/ivlab/core/util/ClassesUtil.java | 1 + .../org/imec/ivlab/core/util/DateUtils.java | 1 - .../org/imec/ivlab/core/util/FileUtil.java | 64 ++++++------------- .../org/imec/ivlab/core/util/JAXBUtils.java | 3 +- .../org/imec/ivlab/core/util/PathUtils.java | 1 - .../ivlab/core/util/ResourceResolver.java | 2 +- .../ivlab/core/util/TemplateEngineUtils.java | 6 +- .../vaccination/VaccinationMappingReader.java | 4 +- .../impl/DiaryNoteEVSRefExtractorTest.java | 4 +- .../audittrail/AuditTrailLogger.java | 23 ++++--- .../exporter/VaultExporterRunnable.java | 2 +- .../exporter/writer/TransactionSetWriter.java | 3 +- .../exporter/writer/TransactionWriter.java | 7 +- .../datagenerator/sam/MedicinExporter.java | 2 +- .../uploader/service/KmehrMatcher.java | 18 +++--- .../uploader/service/SumehrUploaderImpl.java | 4 +- .../uploader/service/queue/UploadQueue.java | 1 + .../service/queue/UploadQueueImpl.java | 4 ++ .../service/queue/config/QueueConfig.java | 1 + .../scanner/ScannedFileHandlerImpl.java | 7 +- .../ivlab/ehconnector/business/HubHelper.java | 3 +- .../business/sumehr/SumehrServiceImpl.java | 6 +- .../hub/session/SessionManager.java | 8 ++- super/pom.xml | 11 +++- .../validator/BatchKmehrValidatorFromIde.java | 2 +- .../ivlab/validator/util/RuleReporter.java | 2 +- ...ualsMedicationInMedicationTransaction.java | 1 + .../impl/R1015_AllowedValuesCdDayperiod.java | 2 +- .../R1016_AllowedValuesCdPeriodicity.java | 2 +- .../R1017_AllowedValuesCdTemporality.java | 2 +- .../viewer/converter/DailySchemeFilter.java | 6 +- .../org/imec/ivlab/viewer/pdf/MSWriter.java | 12 +++- .../imec/ivlab/viewer/pdf/TableHelper.java | 4 +- .../org/imec/ivlab/viewer/pdf/Translator.java | 8 ++- .../org/imec/ivlab/viewer/pdf/Writer.java | 6 +- 43 files changed, 186 insertions(+), 129 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 77581c5a..5aa5c482 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ version: 2 updates: -# Files stored in repository root +# Files stored in repository builder - package-ecosystem: "maven" directory: "/builder" commit-message: @@ -13,6 +13,54 @@ updates: include: "scope" schedule: interval: "weekly" +# Files stored in repository super + - package-ecosystem: "maven" + directory: "/super" + commit-message: + prefix: chore + include: "scope" + schedule: + interval: "weekly" +# Files stored in repository core + - package-ecosystem: "maven" + directory: "/core" + commit-message: + prefix: chore + include: "scope" + schedule: + interval: "weekly" +# Files stored in repository ehconnector + - package-ecosystem: "maven" + directory: "/ehconnector" + commit-message: + prefix: chore + include: "scope" + schedule: + interval: "weekly" +# Files stored in repository viewer + - package-ecosystem: "maven" + directory: "/viewer" + commit-message: + prefix: chore + include: "scope" + schedule: + interval: "weekly" +# Files stored in repository datagenerator + - package-ecosystem: "maven" + directory: "/datagenerator" + commit-message: + prefix: chore + include: "scope" + schedule: + interval: "weekly" +# Files stored in repository distribution + - package-ecosystem: "maven" + directory: "/distribution" + commit-message: + prefix: chore + include: "scope" + schedule: + interval: "weekly" # Workflow files stored in the default location of `.github/workflows` - package-ecosystem: "github-actions" directory: "/" diff --git a/.github/workflows/pr-comment-artifact-url.yml b/.github/workflows/pr-comment-artifact-url.yml index c8194773..62c68ab4 100644 --- a/.github/workflows/pr-comment-artifact-url.yml +++ b/.github/workflows/pr-comment-artifact-url.yml @@ -17,6 +17,9 @@ jobs: steps: - uses: 8BitJonny/gh-get-current-pr@2.2.0 id: PR + with: + # Only return if PR is still open. (By default it returns PRs in any state.) + filterOutClosed: true - name: Get Artifact URL & PR Info if: steps.PR.outputs.pr_found == 'true' env: diff --git a/core/src/main/java/org/imec/ivlab/core/RangeChecker.java b/core/src/main/java/org/imec/ivlab/core/RangeChecker.java index a4bd42d8..52cf34b7 100644 --- a/core/src/main/java/org/imec/ivlab/core/RangeChecker.java +++ b/core/src/main/java/org/imec/ivlab/core/RangeChecker.java @@ -22,6 +22,7 @@ import org.joda.time.Days; import org.joda.time.Months; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; @@ -447,14 +448,10 @@ public LocalDate calculateEndDateForDuration(LocalDate startDate, Duration durat } - switch (durationUnit) { - - case A: - case MO: - case WK: - case D: - endDate = endDate.minusDays(1); - + // Vitalink/EVS in the past substract one day for authorized units, to compute the endDate properly + List unitsToSubtractOneDay = Arrays.asList(TimeUnit.A, TimeUnit.MO, TimeUnit.WK, TimeUnit.D); + if (unitsToSubtractOneDay.contains(durationUnit)) { + endDate = endDate.minusDays(1); } return endDate.toLocalDate(); diff --git a/core/src/main/java/org/imec/ivlab/core/kmehr/KmehrMarshaller.java b/core/src/main/java/org/imec/ivlab/core/kmehr/KmehrMarshaller.java index d6dab5d7..57e8f311 100644 --- a/core/src/main/java/org/imec/ivlab/core/kmehr/KmehrMarshaller.java +++ b/core/src/main/java/org/imec/ivlab/core/kmehr/KmehrMarshaller.java @@ -2,7 +2,8 @@ import be.fgov.ehealth.standards.kmehr.schema.v1.Kmehrmessage; import javax.xml.bind.JAXBException; -import org.apache.commons.lang3.StringUtils; + +import org.apache.commons.lang3.RegExUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.imec.ivlab.core.exceptions.TransformationException; @@ -37,11 +38,11 @@ public static String resetNamespaces(String kmehrContent) { } private static String removeNamespaceUsage(String kmehrContent) { - return StringUtils.replacePattern(kmehrContent, "(<|<\\/)(ns\\d*:)", "$1"); + return RegExUtils.replacePattern(kmehrContent, "(<|<\\/)(ns\\d*:)", "$1"); } private static String setDefaultNamespace(String kmehrContent) { - return StringUtils.replacePattern(kmehrContent, "]*)>", KMEHRMESSAGE_TAG_WITH_DEFAULT_NAMESPACES); + return RegExUtils.replacePattern(kmehrContent, "]*)>", KMEHRMESSAGE_TAG_WITH_DEFAULT_NAMESPACES); } } diff --git a/core/src/main/java/org/imec/ivlab/core/kmehr/model/localid/util/URIConverter.java b/core/src/main/java/org/imec/ivlab/core/kmehr/model/localid/util/URIConverter.java index 7c3f92d7..dfc299c7 100644 --- a/core/src/main/java/org/imec/ivlab/core/kmehr/model/localid/util/URIConverter.java +++ b/core/src/main/java/org/imec/ivlab/core/kmehr/model/localid/util/URIConverter.java @@ -1,13 +1,13 @@ package org.imec.ivlab.core.kmehr.model.localid.util; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +//import org.apache.logging.log4j.LogManager; +//import org.apache.logging.log4j.Logger; import org.imec.ivlab.core.kmehr.model.localid.URI; import org.imec.ivlab.core.kmehr.model.localid.URIType; public class URIConverter { - private final static Logger log = LogManager.getLogger(URIConverter.class); + //private final static Logger log = LogManager.getLogger(URIConverter.class); public static URI convertToUpdate(URI uri) { diff --git a/core/src/main/java/org/imec/ivlab/core/model/upload/KmehrWithReferenceList.java b/core/src/main/java/org/imec/ivlab/core/model/upload/KmehrWithReferenceList.java index 5bbce582..06415369 100644 --- a/core/src/main/java/org/imec/ivlab/core/model/upload/KmehrWithReferenceList.java +++ b/core/src/main/java/org/imec/ivlab/core/model/upload/KmehrWithReferenceList.java @@ -17,6 +17,7 @@ public void setList(List list) { } @Override + @SuppressWarnings({"unchecked" }) public List getIdentifiables() { return list; } diff --git a/core/src/main/java/org/imec/ivlab/core/model/upload/msentrylist/MSEntryList.java b/core/src/main/java/org/imec/ivlab/core/model/upload/msentrylist/MSEntryList.java index de820a10..3b225f95 100644 --- a/core/src/main/java/org/imec/ivlab/core/model/upload/msentrylist/MSEntryList.java +++ b/core/src/main/java/org/imec/ivlab/core/model/upload/msentrylist/MSEntryList.java @@ -20,6 +20,7 @@ public void setMsEntries(List msEntries) { @Override + @SuppressWarnings({"unchecked" }) public List getIdentifiables() { return msEntries; } diff --git a/core/src/main/java/org/imec/ivlab/core/model/upload/msentrylist/ReferenceDateUtil.java b/core/src/main/java/org/imec/ivlab/core/model/upload/msentrylist/ReferenceDateUtil.java index 4b38b5c5..5a60cae7 100644 --- a/core/src/main/java/org/imec/ivlab/core/model/upload/msentrylist/ReferenceDateUtil.java +++ b/core/src/main/java/org/imec/ivlab/core/model/upload/msentrylist/ReferenceDateUtil.java @@ -26,7 +26,6 @@ public static void setReferenceDate(Kmehrmessage kmehrmessage, LocalDate referen patient = new PersonType(); } - // TODO To fix patient.setRecorddatetime( new DateTime( referenceDate.getYear(), diff --git a/core/src/main/java/org/imec/ivlab/core/util/ClassesUtil.java b/core/src/main/java/org/imec/ivlab/core/util/ClassesUtil.java index db082c79..a6f08eee 100644 --- a/core/src/main/java/org/imec/ivlab/core/util/ClassesUtil.java +++ b/core/src/main/java/org/imec/ivlab/core/util/ClassesUtil.java @@ -15,6 +15,7 @@ public class ClassesUtil { private final static Logger log = LogManager.getLogger(ClassesUtil.class); + @SuppressWarnings({ "unchecked"}) public static List> getClasses(String packagePath, Class clazzFilter) { List> testClasses = new ArrayList<>(); diff --git a/core/src/main/java/org/imec/ivlab/core/util/DateUtils.java b/core/src/main/java/org/imec/ivlab/core/util/DateUtils.java index 12ec3c1a..4b17b8aa 100644 --- a/core/src/main/java/org/imec/ivlab/core/util/DateUtils.java +++ b/core/src/main/java/org/imec/ivlab/core/util/DateUtils.java @@ -108,7 +108,6 @@ public static LocalDateTime toLocalDateTime(Calendar calendar) { return LocalDateTime.ofInstant(calendar.toInstant(), ZoneId.systemDefault()); } - // TODO issue here public static LocalDateTime toLocalDateTime(org.joda.time.DateTime calendar) { if (calendar == null) { return null; diff --git a/core/src/main/java/org/imec/ivlab/core/util/FileUtil.java b/core/src/main/java/org/imec/ivlab/core/util/FileUtil.java index e386306c..4148e3c2 100644 --- a/core/src/main/java/org/imec/ivlab/core/util/FileUtil.java +++ b/core/src/main/java/org/imec/ivlab/core/util/FileUtil.java @@ -8,10 +8,10 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; +import java.nio.file.StandardOpenOption; public class FileUtil { @@ -23,19 +23,10 @@ public static void copyFile(File sourceFile, File destFile) throws IOException { destFile.createNewFile(); } - FileChannel source = null; - FileChannel destination = null; - - try { - source = new FileInputStream(sourceFile).getChannel(); - destination = new FileOutputStream(destFile).getChannel(); - destination.transferFrom(source, 0, source.size()); - } finally { - if (source != null) { - source.close(); - } - if (destination != null) { - destination.close(); + try(FileInputStream source = new FileInputStream(sourceFile)) { + try(FileOutputStream destination = new FileOutputStream(destFile)) { + FileChannel sourceChannel = source.getChannel(); + destination.getChannel().transferFrom(sourceChannel, 0, sourceChannel.size()); } } } @@ -67,42 +58,23 @@ public static void createDirectoriesRecursively(String directoryPath) { public static boolean isLocked(File file) { - FileLock lock = null; - FileChannel channel = null; - - try { // Get a file channel for the file - channel = new RandomAccessFile(file, "rw").getChannel(); - - // Try acquiring the lock without blocking. - // lock is null or exception if the file is already locked. - try { - lock = channel.tryLock(); - } catch (OverlappingFileLockException e){ - return true; + try (FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ, StandardOpenOption.WRITE)) { + FileLock lock = channel.tryLock(); + if (lock != null) { + lock.release(); // Release the lock immediately + return false; // File is not locked + } else { + return true; // File is locked } - - } catch (Exception e) { + } catch (OverlappingFileLockException e) { + return true; + } catch (IOException e) { + // Handle any exceptions log.error("Error when checking if file is locked: ", e); - } finally { - if (lock != null && lock.isValid()) { - try { - lock.release(); - } catch (IOException e1) { - log.error("Error when trying to release lock", e1); - } - } - if (channel != null && channel.isOpen()) { - try { - channel.close(); - } catch (IOException e) { - log.error("Error when trying to close channel", e); - } - } } - return false; - - } + return false; // Unable to determine lock status, assuming not locked +} public static File appendTextToFilename(File file, String textToAppend) { return new File(FilenameUtils.getFullPath(file.getAbsolutePath()) + FilenameUtils.getBaseName(file.getAbsolutePath()) + textToAppend + "." + FilenameUtils.getExtension(file.getAbsolutePath())); diff --git a/core/src/main/java/org/imec/ivlab/core/util/JAXBUtils.java b/core/src/main/java/org/imec/ivlab/core/util/JAXBUtils.java index a2c3f82d..4dec6f9a 100644 --- a/core/src/main/java/org/imec/ivlab/core/util/JAXBUtils.java +++ b/core/src/main/java/org/imec/ivlab/core/util/JAXBUtils.java @@ -81,7 +81,8 @@ public static String marshal(Object o, String rootName) throws JAXBException { QName qName = new QName(nsURI, rootName); - JAXBElement root = new JAXBElement(qName, o.getClass(), o); + @SuppressWarnings({ "rawtypes", "unchecked" }) + JAXBElement root = new JAXBElement(qName, o.getClass(), o); jaxbMarshaller.marshal(root, writer); diff --git a/core/src/main/java/org/imec/ivlab/core/util/PathUtils.java b/core/src/main/java/org/imec/ivlab/core/util/PathUtils.java index fbeb2f2c..744c2b6d 100644 --- a/core/src/main/java/org/imec/ivlab/core/util/PathUtils.java +++ b/core/src/main/java/org/imec/ivlab/core/util/PathUtils.java @@ -62,7 +62,6 @@ public static String commonParent(String[] files) { outerloop: while (charPosition < shortestPathLength) { Character charPosFirstPath = paths[0].charAt(charPosition); - innerloop: for (int i = 0; i < paths.length; i++) { char charAtPosition = paths[i].charAt(charPosition); if (charAtPosition != charPosFirstPath) { diff --git a/core/src/main/java/org/imec/ivlab/core/util/ResourceResolver.java b/core/src/main/java/org/imec/ivlab/core/util/ResourceResolver.java index 35a84622..6c8d0ad6 100644 --- a/core/src/main/java/org/imec/ivlab/core/util/ResourceResolver.java +++ b/core/src/main/java/org/imec/ivlab/core/util/ResourceResolver.java @@ -35,7 +35,7 @@ public static File getProjectDirectoryAsFile(String relativeProjectDirectory) { // found resource inside jar File fileAsInternalResource = getProjectDirectoryJarMode(relativeProjectDirectory); if (fileAsInternalResource != null && fileAsInternalResource.exists()) { - log.info("Running as jar. Found resource: " + fileAsExternalResource.getAbsolutePath()); + log.info("Running as jar. Found resource: " + fileAsInternalResource.getAbsolutePath()); return fileAsInternalResource; } diff --git a/core/src/main/java/org/imec/ivlab/core/util/TemplateEngineUtils.java b/core/src/main/java/org/imec/ivlab/core/util/TemplateEngineUtils.java index 9d19e404..15800bf7 100644 --- a/core/src/main/java/org/imec/ivlab/core/util/TemplateEngineUtils.java +++ b/core/src/main/java/org/imec/ivlab/core/util/TemplateEngineUtils.java @@ -30,11 +30,11 @@ private TemplateEngineUtils() { public static String generate(Map ctx, String templateLocation) { VelocityContext context = new VelocityContext(); - Iterator template = ctx.entrySet().iterator(); + Iterator> template = ctx.entrySet().iterator(); while(template.hasNext()) { - Map.Entry writer = (Map.Entry)template.next(); - context.put((String)writer.getKey(), writer.getValue()); + Map.Entry writer = template.next(); + context.put(writer.getKey(), writer.getValue()); } if (!templateCache.containsKey(templateLocation)) { diff --git a/core/src/main/java/org/imec/ivlab/core/vaccination/VaccinationMappingReader.java b/core/src/main/java/org/imec/ivlab/core/vaccination/VaccinationMappingReader.java index 63a02854..9f1b7f93 100644 --- a/core/src/main/java/org/imec/ivlab/core/vaccination/VaccinationMappingReader.java +++ b/core/src/main/java/org/imec/ivlab/core/vaccination/VaccinationMappingReader.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.stream.Collectors; import lombok.Getter; -import lombok.extern.log4j.Log4j2; +//import lombok.extern.log4j.Log4j2; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row.MissingCellPolicy; @@ -24,7 +24,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.imec.ivlab.core.util.IOUtils; -@Log4j2 +//@Log4j2 @Getter public class VaccinationMappingReader { diff --git a/core/src/test/java/org/imec/ivlab/core/model/evsref/extractor/impl/DiaryNoteEVSRefExtractorTest.java b/core/src/test/java/org/imec/ivlab/core/model/evsref/extractor/impl/DiaryNoteEVSRefExtractorTest.java index 360dc371..1e2b420b 100644 --- a/core/src/test/java/org/imec/ivlab/core/model/evsref/extractor/impl/DiaryNoteEVSRefExtractorTest.java +++ b/core/src/test/java/org/imec/ivlab/core/model/evsref/extractor/impl/DiaryNoteEVSRefExtractorTest.java @@ -22,10 +22,10 @@ import be.fgov.ehealth.standards.kmehr.schema.v1.Kmehrmessage; import be.fgov.ehealth.standards.kmehr.schema.v1.TextWithLayoutType; import be.fgov.ehealth.standards.kmehr.schema.v1.TransactionType; -import lombok.extern.log4j.Log4j2; +//import lombok.extern.log4j.Log4j2; @Test -@Log4j2 +//@Log4j2 public class DiaryNoteEVSRefExtractorTest extends TestCase { private EVSREF evsref = new EVSREF("TESTREF"); diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/audittrail/AuditTrailLogger.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/audittrail/AuditTrailLogger.java index 1c8a8f59..f348642e 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/audittrail/AuditTrailLogger.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/audittrail/AuditTrailLogger.java @@ -38,22 +38,21 @@ public void logPatientAuditTrail(Patient patient, String actorId) throws Gateway if (patientAuditTrail == null || patientAuditTrail.getTransactionaccesslist() == null || patientAuditTrail.getTransactionaccesslist().getTransactionaccesses() == null) { LOG.info("No audit trail found for patient: " + patient.inReadableFormat()); - } - - for (Transactionaccess transactionaccess : patientAuditTrail.getTransactionaccesslist().getTransactionaccesses()) { - LOG.info("------------- Audit trail entry -------------"); - LOG.info("accessed at: " + transactionaccess.getAccessdatetime()); - if (transactionaccess.getHcparties() != null) { - for (HcpartyType hcpartyType : transactionaccess.getHcparties()) { - LOG.info("Accessed by: " + org.imec.ivlab.core.util.StringUtils.joinWith(" ", hcpartyType.getFirstname(), hcpartyType.getFamilyname(), hcpartyType.getName())); + } else { + for (Transactionaccess transactionaccess : patientAuditTrail.getTransactionaccesslist().getTransactionaccesses()) { + LOG.info("------------- Audit trail entry -------------"); + LOG.info("accessed at: " + transactionaccess.getAccessdatetime()); + if (transactionaccess.getHcparties() != null) { + for (HcpartyType hcpartyType : transactionaccess.getHcparties()) { + LOG.info("Accessed by: " + org.imec.ivlab.core.util.StringUtils.joinWith(" ", hcpartyType.getFirstname(), hcpartyType.getFamilyname(), hcpartyType.getName())); + } } + LOG.info("break the glass info: " + transactionaccess.getBreaktheglass()); + LOG.info("patient: " + transactionaccess.getPatient().getIds().get(0).getValue()); + LOG.info("transaction: " + transactionaccess.getTransaction().getIds().get(0).getValue()); } - LOG.info("break the glass info: " + transactionaccess.getBreaktheglass()); - LOG.info("patient: " + transactionaccess.getPatient().getIds().get(0).getValue()); - LOG.info("transaction: " + transactionaccess.getTransaction().getIds().get(0).getValue()); } - } } diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/VaultExporterRunnable.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/VaultExporterRunnable.java index 3bf48664..26fca310 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/VaultExporterRunnable.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/VaultExporterRunnable.java @@ -77,7 +77,7 @@ public void run() { boolean incurableErrorOccurred = false; Throwable incurableError = null; - boolean breakTheGlass = false; + //boolean breakTheGlass = false; File outputDirectory = new File(exportInstruction.getExportDir().getAbsolutePath() + File.separator + monitorInstruction.getPatient().getKey()); diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/writer/TransactionSetWriter.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/writer/TransactionSetWriter.java index 3043b9d7..3d4d6662 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/writer/TransactionSetWriter.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/writer/TransactionSetWriter.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.Charset; import java.util.List; public class TransactionSetWriter extends AbstractWriter implements SetWriter { @@ -77,7 +78,7 @@ protected ExportResult writeExportFile(GetTransaction File outputFile = createOutputFile(outputDirectory, filename, extension); try { - FileUtils.writeStringToFile(outputFile, getExportContent(getTransactionSetResponse)); + FileUtils. writeStringToFile(outputFile, getExportContent(getTransactionSetResponse), Charset.defaultCharset()); LOG.info("Exported to: " + outputFile); return new ExportResult<>(getTransactionSetResponse, outputFile); } catch (IOException e) { diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/writer/TransactionWriter.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/writer/TransactionWriter.java index 71d8668c..f89d7ce5 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/writer/TransactionWriter.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/exporter/writer/TransactionWriter.java @@ -30,6 +30,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; @@ -111,7 +112,7 @@ protected ExportResult writeResponse(GetTransactionRespo File outputFile = createOutputFile(outputDirectory, filename, extension); try { - FileUtils.writeStringToFile(outputFile, getExportContent(getTransactionResponse)); + FileUtils.writeStringToFile(outputFile, getExportContent(getTransactionResponse), Charset.defaultCharset()); LOG.info("Exported to: " + outputFile); return new ExportResult<>(getTransactionResponse, outputFile); } catch (IOException e) { @@ -198,7 +199,9 @@ protected String getLatestUpdateString(TransactionType transactionType) { HcParty = hubHcParty; } - String author = org.imec.ivlab.core.util.StringUtils.joinWith("-", HcParty.getFirstname(), HcParty.getFamilyname(), HcParty.getName()); + String author = (HcParty != null) + ? org.imec.ivlab.core.util.StringUtils.joinWith("-", HcParty.getFirstname(), HcParty.getFamilyname(), HcParty.getName()) + : ""; if (StringUtils.isNotBlank(author)) { if (sb.length() > 0) { sb.append("-"); diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/sam/MedicinExporter.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/sam/MedicinExporter.java index 066c0df0..32240b38 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/sam/MedicinExporter.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/sam/MedicinExporter.java @@ -16,8 +16,8 @@ import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.SerializationUtils; -import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.imec.ivlab.core.util.CollectionsUtil; diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/KmehrMatcher.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/KmehrMatcher.java index 32ef0817..ea6c4465 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/KmehrMatcher.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/KmehrMatcher.java @@ -308,20 +308,22 @@ private static Identifiable findIdentifiableByReference(ListOfIdentifiables list */ public static boolean equal(Identifiable identiableOne, Identifiable identifiableTwo) { - if ((identiableOne == null && identifiableTwo != null) || (identifiableTwo == null && identiableOne != null)) { - return false; - } - if (identiableOne == null) { + if (identiableOne == null && identifiableTwo == null) { return true; } - if ((identiableOne.getIdentifiableTransaction() == null && identifiableTwo.getIdentifiableTransaction() != null) || (identifiableTwo.getIdentifiableTransaction() == null && identiableOne.getIdentifiableTransaction() != null)) { + + if (identiableOne == null || identifiableTwo == null) { return false; } - - if (identiableOne.getIdentifiableTransaction() == null) { + + if (identiableOne.getIdentifiableTransaction() == null && identifiableTwo.getIdentifiableTransaction() == null) { return true; } - + + if (identiableOne.getIdentifiableTransaction() == null || identifiableTwo.getIdentifiableTransaction() == null) { + return false; + } + return IdentifiablesHaveSameContent(identiableOne, identifiableTwo); } diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/SumehrUploaderImpl.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/SumehrUploaderImpl.java index 669ed339..75c0959f 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/SumehrUploaderImpl.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/SumehrUploaderImpl.java @@ -24,7 +24,7 @@ import org.imec.ivlab.core.model.upload.msentrylist.exception.MultipleEVSRefsInTransactionFoundException; import org.imec.ivlab.core.util.CollectionsUtil; import org.imec.ivlab.datagenerator.uploader.exception.UploaderException; -import org.imec.ivlab.ehconnector.business.HubHelper; +//import org.imec.ivlab.ehconnector.business.HubHelper; import org.imec.ivlab.ehconnector.business.sumehr.SumehrService; import org.imec.ivlab.ehconnector.business.sumehr.SumehrServiceImpl; @@ -33,7 +33,7 @@ public class SumehrUploaderImpl implements SumehrUploader, Uploader { private final static Logger LOG = LogManager.getLogger(SumehrUploaderImpl.class); private SumehrService sumehrService; - private HubHelper hubHelper = new HubHelper(); + //private HubHelper hubHelper = new HubHelper(); private SumehrEVSRefExtractor refExtractor; public SumehrUploaderImpl() throws VitalinkException { diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/UploadQueue.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/UploadQueue.java index 2725f9bd..7ee37d32 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/UploadQueue.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/UploadQueue.java @@ -4,6 +4,7 @@ public interface UploadQueue { + @SuppressWarnings({ "rawtypes"}) void queue(T instruction); } diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/UploadQueueImpl.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/UploadQueueImpl.java index 728ddd42..abd76358 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/UploadQueueImpl.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/UploadQueueImpl.java @@ -36,6 +36,7 @@ public class UploadQueueImpl implements Runnable, UploadQueue { private final static int WAIT_TIME_IN_MILLIS_AFTER_QUEUE_IS_EMPTY = 3000; + @SuppressWarnings({ "rawtypes"}) private CopyOnWriteArrayList instructions = new CopyOnWriteArrayList<>(); private static UploadQueueImpl instance = null; @@ -53,11 +54,13 @@ public static UploadQueueImpl getInstance() throws VitalinkException { } @Override + @SuppressWarnings({ "rawtypes"}) public void queue(Instruction instruction) { instructions.add(instruction); LOG.info("Added instruction to queue: " + instruction.toString()); } + @SuppressWarnings({ "rawtypes"}) private QueueConfig getUploadQueueConfig(Instruction instruction) throws VitalinkException { if (instruction instanceof MSInstruction) { @@ -79,6 +82,7 @@ private QueueConfig getUploadQueueConfig(Instruction instruction) throws Vitalin } @Override + @SuppressWarnings({ "rawtypes", "unchecked"}) public void run() { while (true) { diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/config/QueueConfig.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/config/QueueConfig.java index eb4fea6f..fe9ac2ef 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/config/QueueConfig.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/queue/config/QueueConfig.java @@ -5,6 +5,7 @@ import org.imec.ivlab.datagenerator.uploader.exception.UploaderException; import org.imec.ivlab.datagenerator.uploader.model.instruction.Instruction; +@SuppressWarnings({ "rawtypes"}) public interface QueueConfig { public void configureUploader(T instruction); diff --git a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/scanner/ScannedFileHandlerImpl.java b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/scanner/ScannedFileHandlerImpl.java index c2e99769..c4252c4e 100644 --- a/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/scanner/ScannedFileHandlerImpl.java +++ b/datagenerator/src/main/java/org/imec/ivlab/datagenerator/uploader/service/scanner/ScannedFileHandlerImpl.java @@ -85,7 +85,8 @@ public ScannedFileHandlerImpl(boolean exportAfterUpload, boolean writeAsIs, bool - private Instruction instructionFromFile(File rootFolder, File file) throws InvalidActionException, NoQueueingNeededException, InvalidFolderStructureException, InvalidPatientException { + @SuppressWarnings({ "rawtypes", "unchecked"}) + private Instruction instructionFromFile(File rootFolder, File file) throws InvalidActionException, NoQueueingNeededException, InvalidFolderStructureException, InvalidPatientException { Path filePath = file.toPath(); Path rootPath = rootFolder.toPath(); @@ -168,7 +169,7 @@ private Instruction instructionFromFile(File rootFolder, File file) throws Inval @Override public void process(File rootFolder, File file) { - Instruction instruction = null; + Instruction instruction = null; try { instruction = instructionFromFile(rootFolder, file); @@ -219,7 +220,7 @@ private Action initiateAction(TransactionType transactionType, String actionName } - private AbstractInstruction initiateInstruction(TransactionType transactionType) { + private AbstractInstruction initiateInstruction(TransactionType transactionType) { switch (transactionType) { case MEDICATION_SCHEME: diff --git a/ehconnector/src/main/java/org/imec/ivlab/ehconnector/business/HubHelper.java b/ehconnector/src/main/java/org/imec/ivlab/ehconnector/business/HubHelper.java index 4cd1da5c..275b8764 100644 --- a/ehconnector/src/main/java/org/imec/ivlab/ehconnector/business/HubHelper.java +++ b/ehconnector/src/main/java/org/imec/ivlab/ehconnector/business/HubHelper.java @@ -628,13 +628,14 @@ private TransactionType createTransactionType(String transactionId, String xml) /** * Create a transaction type needed for transaction operations, with a LOCAL id */ + /* private TransactionType createTransactionTypeWithLocalId(String transactionId, String xml) throws Exception { TransactionType transaction = createTransactionType(transactionId, xml); transaction.getIds().add(createIdKmehr("EHBASICSOFT", "1.0", IdGeneratorFactory.getIdGenerator( IdGeneratorFactory.UUID).generateId(), IDKMEHRschemes.LOCAL)); return transaction; - } + }*/ /** diff --git a/ehconnector/src/main/java/org/imec/ivlab/ehconnector/business/sumehr/SumehrServiceImpl.java b/ehconnector/src/main/java/org/imec/ivlab/ehconnector/business/sumehr/SumehrServiceImpl.java index a36120cc..b2a97702 100644 --- a/ehconnector/src/main/java/org/imec/ivlab/ehconnector/business/sumehr/SumehrServiceImpl.java +++ b/ehconnector/src/main/java/org/imec/ivlab/ehconnector/business/sumehr/SumehrServiceImpl.java @@ -15,8 +15,8 @@ import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +//import org.apache.logging.log4j.LogManager; +//import org.apache.logging.log4j.Logger; import org.imec.ivlab.core.exceptions.VitalinkException; import org.imec.ivlab.core.kmehr.model.util.HCPartyUtil; import org.imec.ivlab.core.kmehr.model.util.KmehrMessageUtil; @@ -34,7 +34,7 @@ public class SumehrServiceImpl extends AbstractService implements SumehrService { - private final static Logger LOG = LogManager.getLogger(SumehrServiceImpl.class); + //private final static Logger LOG = LogManager.getLogger(SumehrServiceImpl.class); private static final TransactionType TRANSACTION_TYPE = TransactionType.SUMEHR; private HubFlow hubFlow = new HubFlow(); diff --git a/ehconnector/src/main/java/org/imec/ivlab/ehconnector/hub/session/SessionManager.java b/ehconnector/src/main/java/org/imec/ivlab/ehconnector/hub/session/SessionManager.java index 168f659d..8da8aff9 100644 --- a/ehconnector/src/main/java/org/imec/ivlab/ehconnector/hub/session/SessionManager.java +++ b/ehconnector/src/main/java/org/imec/ivlab/ehconnector/hub/session/SessionManager.java @@ -264,7 +264,7 @@ private static String getCertificatesCommonPath(List paths) throws Inval String[] pathArray = paths.toArray(new String[0]); String commonPath = PathUtils.commonParent(pathArray); if (commonPath == null) { - throw new InvalidConfigurationException("All certificates must be located under the same root. The configuration contains certificate configurations with different roots: " + StringUtils.joinWith(", ", pathArray)); + throw new InvalidConfigurationException("All certificates must be located under the same root. The configuration contains certificate configurations with different roots: " + StringUtils.joinWith(", ", (Object[]) pathArray)); } return commonPath; @@ -325,17 +325,19 @@ public SAMLToken getSamlToken() { return samlToken; } + /* public void setSamlToken(SAMLToken samlToken) { this.samlToken = samlToken; - } + }*/ public String getEncryptionPassword() { return encryptionPassword; } + /* public void setEncryptionPassword(String encryptionPassword) { this.encryptionPassword = encryptionPassword; - } + }*/ } } diff --git a/super/pom.xml b/super/pom.xml index 325bd97a..300231bc 100644 --- a/super/pom.xml +++ b/super/pom.xml @@ -26,14 +26,21 @@ - commons-lang - commons-lang + org.apache.commons + commons-text + 1.10.0 + org.apache.commons commons-lang3 + + commons-lang + commons-lang + + commons-io commons-io diff --git a/validator/src/main/java/org/imec/ivlab/validator/BatchKmehrValidatorFromIde.java b/validator/src/main/java/org/imec/ivlab/validator/BatchKmehrValidatorFromIde.java index 7f3f3ca1..f41acf21 100644 --- a/validator/src/main/java/org/imec/ivlab/validator/BatchKmehrValidatorFromIde.java +++ b/validator/src/main/java/org/imec/ivlab/validator/BatchKmehrValidatorFromIde.java @@ -24,7 +24,7 @@ public static void main(String[] args) throws ValidatorException { arguments.setXsdErrorMessagesToIgnore(xsdErrorsToIgnore); - File report = validator.validate(arguments); + validator.validate(arguments); } diff --git a/validator/src/main/java/org/imec/ivlab/validator/util/RuleReporter.java b/validator/src/main/java/org/imec/ivlab/validator/util/RuleReporter.java index 847300c6..c1dd4d59 100644 --- a/validator/src/main/java/org/imec/ivlab/validator/util/RuleReporter.java +++ b/validator/src/main/java/org/imec/ivlab/validator/util/RuleReporter.java @@ -1,6 +1,6 @@ package org.imec.ivlab.validator.util; -import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.text.StringEscapeUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.imec.ivlab.core.util.ClassesUtil; diff --git a/validator/src/main/java/org/imec/ivlab/validator/validators/business/rules/impl/R1007_TreatmentsuspensionMedicationEqualsMedicationInMedicationTransaction.java b/validator/src/main/java/org/imec/ivlab/validator/validators/business/rules/impl/R1007_TreatmentsuspensionMedicationEqualsMedicationInMedicationTransaction.java index 84f367b3..e911fc6d 100644 --- a/validator/src/main/java/org/imec/ivlab/validator/validators/business/rules/impl/R1007_TreatmentsuspensionMedicationEqualsMedicationInMedicationTransaction.java +++ b/validator/src/main/java/org/imec/ivlab/validator/validators/business/rules/impl/R1007_TreatmentsuspensionMedicationEqualsMedicationInMedicationTransaction.java @@ -75,6 +75,7 @@ private boolean contentTypeListsEqual(List contentTypesA, List toUnparsedContentTables(List parsedItems, String topic) { + public static List toUnparsedContentTables(List> parsedItems, String topic) { if (CollectionsUtil.emptyOrNull(parsedItems)) { return Collections.emptyList(); @@ -50,7 +50,7 @@ public static List toUnparsedContentTables(List PdfPTable contentTable = initializeUnparsedTable(); - for (ParsedItem parsedItem : parsedItems) { + for (ParsedItem parsedItem : parsedItems) { String unparsedAsString = parsedItem.getUnparsedAsString(); if (unparsedAsString == null) { continue; diff --git a/viewer/src/main/java/org/imec/ivlab/viewer/pdf/Translator.java b/viewer/src/main/java/org/imec/ivlab/viewer/pdf/Translator.java index b178f089..9dd48150 100644 --- a/viewer/src/main/java/org/imec/ivlab/viewer/pdf/Translator.java +++ b/viewer/src/main/java/org/imec/ivlab/viewer/pdf/Translator.java @@ -461,9 +461,15 @@ protected static String translateSex(CDSEXvalues cdseXvalues) { } protected static String translateQuantity(BigDecimal x){ - if (x != null && x.compareTo(BigDecimal.valueOf(Integer.MAX_VALUE)) >= 0) { + + if (x == null) { + return ""; + } + + if (x.compareTo(BigDecimal.valueOf(Integer.MAX_VALUE)) >= 0) { return TOO_LARGE_TEXT; } + return translateQuantity(x.doubleValue()); } diff --git a/viewer/src/main/java/org/imec/ivlab/viewer/pdf/Writer.java b/viewer/src/main/java/org/imec/ivlab/viewer/pdf/Writer.java index 44c48b95..9437cf1a 100644 --- a/viewer/src/main/java/org/imec/ivlab/viewer/pdf/Writer.java +++ b/viewer/src/main/java/org/imec/ivlab/viewer/pdf/Writer.java @@ -47,8 +47,8 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +//import org.apache.logging.log4j.LogManager; +//import org.apache.logging.log4j.Logger; import org.imec.ivlab.core.model.internal.parser.ParsedItem; import org.imec.ivlab.core.model.internal.parser.common.Header; import org.imec.ivlab.core.model.internal.parser.common.TransactionCommon; @@ -362,7 +362,7 @@ protected PdfPTable createGeneralInfoTable(String title, Header header) { } - protected List toUnparsedContentTable(T parsedItem, String topic) { + protected > List toUnparsedContentTable(T parsedItem, String topic) { if (parsedItem == null) { return Collections.emptyList(); } else {