From 1e141b73d920f0d4a116d38dd12997032cf685df Mon Sep 17 00:00:00 2001 From: qqmyers Date: Tue, 10 Dec 2024 13:24:29 -0500 Subject: [PATCH] fix case with new terms object --- .../UpdateDatasetVersionMetadataCommand.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetVersionMetadataCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetVersionMetadataCommand.java index 6f760b0a862..577af13eeca 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetVersionMetadataCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetVersionMetadataCommand.java @@ -192,24 +192,18 @@ public Dataset execute(CommandContext ctxt) throws CommandException { // ToDo - only needed if editVersion wasn't persisted if (!dvDifference.getChangedTermsAccess().isEmpty()) { // Update the access terms of the dataset version - logger.info("Terms merged? : " + ctxt.em().contains(editVersion.getTermsOfUseAndAccess())); + if(editVersion.getTermsOfUseAndAccess().getId()==null) { + ctxt.em().persist(editVersion.getTermsOfUseAndAccess()); + editVersion = ctxt.em().merge(editVersion); + editVersion.getTermsOfUseAndAccess().setDatasetVersion(editVersion); + } editVersion.setTermsOfUseAndAccess(ctxt.em().merge(editVersion.getTermsOfUseAndAccess())); } - /* - * if (editVersion.getId() == null || editVersion.getId() == 0L) { - * ctxt.em().flush(); logger.info("Flush new version at: " + - * (System.currentTimeMillis() - startTime)); } - */ /* End editVersion setup */ registerExternalVocabValuesIfAny(ctxt, editVersion, cvocSetting); logger.info("locked and fields validated at: " + (System.currentTimeMillis() - startTime)); - logger.info("Terms merged? " + ctxt.em().contains(editVersion.getTermsOfUseAndAccess())); - logger.info( - "Version merged? " + ctxt.em().contains(editVersion.getTermsOfUseAndAccess().getDatasetVersion())); - -// ctxt.em().flush(); // Create and execute query to update the modification time on the dataset // directly in the database theDataset.setModificationTime(getTimestamp());