From c83e29c17333c8bb069c9188ea139ec27e5b7972 Mon Sep 17 00:00:00 2001 From: Ali Sheikhi Date: Thu, 5 Sep 2024 13:03:32 +0200 Subject: [PATCH] DD-1605 Implement several dd-dataverse-cli dataset commands - VI - changes for PR reviewers --- .../nl/knaw/dans/dvcli/DdDataverseCli.java | 2 - .../dvcli/command/AbstractAssignmentRole.java | 3 -- .../command/CollectionCreateDataset.java | 12 +---- .../dans/dvcli/command/CollectionDelete.java | 10 +--- .../dvcli/command/CollectionGetContents.java | 10 +--- .../command/CollectionGetStorageSize.java | 10 +--- .../command/CollectionImportDataset.java | 12 +---- .../CollectionIsMetadataBlocksRoot.java | 10 +--- .../command/CollectionListMetadataBlocks.java | 10 +--- .../CollectionListRoleAssignments.java | 10 +--- .../dvcli/command/CollectionListRoles.java | 10 +--- .../dans/dvcli/command/CollectionPublish.java | 10 +--- .../CollectionSetMetadataBlocksRoot.java | 10 +--- .../dans/dvcli/command/CollectionView.java | 10 +--- .../dvcli/command/DatasetDeleteDraft.java | 14 +---- .../dans/dvcli/command/DatasetDeleteRole.java | 53 ------------------- .../dans/dvcli/command/DatasetGetFiles.java | 10 +--- .../command/DatasetGetLatestVersion.java | 10 +--- .../dans/dvcli/command/DatasetGetVersion.java | 11 ++-- .../command/DatasetListRoleAssignments.java | 10 +--- .../dans/dvcli/command/DatasetPublish.java | 19 ++----- 21 files changed, 26 insertions(+), 230 deletions(-) delete mode 100644 src/main/java/nl/knaw/dans/dvcli/command/DatasetDeleteRole.java diff --git a/src/main/java/nl/knaw/dans/dvcli/DdDataverseCli.java b/src/main/java/nl/knaw/dans/dvcli/DdDataverseCli.java index fb64939..7832990 100644 --- a/src/main/java/nl/knaw/dans/dvcli/DdDataverseCli.java +++ b/src/main/java/nl/knaw/dans/dvcli/DdDataverseCli.java @@ -34,7 +34,6 @@ import nl.knaw.dans.dvcli.command.DatasetAssignRole; import nl.knaw.dans.dvcli.command.DatasetCmd; import nl.knaw.dans.dvcli.command.DatasetDeleteDraft; -import nl.knaw.dans.dvcli.command.DatasetDeleteRole; import nl.knaw.dans.dvcli.command.DatasetGetFiles; import nl.knaw.dans.dvcli.command.DatasetGetLatestVersion; import nl.knaw.dans.dvcli.command.DatasetGetVersion; @@ -81,7 +80,6 @@ public void configureCommandLine(CommandLine commandLine, DdDataverseCliConfig c .addSubcommand(new CommandLine(new DatasetCmd(dataverseClient)) .addSubcommand(new DatasetAssignRole()) .addSubcommand(new DatasetDeleteDraft()) - .addSubcommand(new DatasetDeleteRole()) .addSubcommand(new DatasetGetFiles()) .addSubcommand(new DatasetGetLatestVersion()) .addSubcommand(new DatasetGetVersion()) diff --git a/src/main/java/nl/knaw/dans/dvcli/command/AbstractAssignmentRole.java b/src/main/java/nl/knaw/dans/dvcli/command/AbstractAssignmentRole.java index 8facf93..1ae68e8 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/AbstractAssignmentRole.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/AbstractAssignmentRole.java @@ -103,8 +103,5 @@ else if (commandParameter.assignment != null) { protected record RoleAssignmentParams(DatasetApi pid, Optional roleAssignment) { } - @Override - public void doCall() throws IOException, DataverseException { - } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionCreateDataset.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionCreateDataset.java index 0890cb5..83ee78b 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionCreateDataset.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionCreateDataset.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.Option; @@ -43,14 +42,7 @@ public class CollectionCreateDataset extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var json = Files.readString(Path.of(dataset)); - var r = d.createDataset(json, metadataKeys); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> + c.createDataset(Files.readString(Path.of(dataset)), metadataKeys).getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionDelete.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionDelete.java index f7eba89..15d70ed 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionDelete.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionDelete.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,13 +30,6 @@ public class CollectionDelete extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.delete(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.delete().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionGetContents.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionGetContents.java index e8743ff..4ac1a07 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionGetContents.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionGetContents.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,13 +30,6 @@ public class CollectionGetContents extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.getContents(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.getContents().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionGetStorageSize.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionGetStorageSize.java index a616f69..828d0a5 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionGetStorageSize.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionGetStorageSize.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,13 +30,6 @@ public class CollectionGetStorageSize extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.getStorageSize(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.getStorageSize().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionImportDataset.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionImportDataset.java index 3faefe8..34c5d02 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionImportDataset.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionImportDataset.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.Option; @@ -49,14 +48,7 @@ public class CollectionImportDataset extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var json = Files.readString(Path.of(dataset)); - var r = d.importDataset(json, persistentId, autoPublish, metadataKeys); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> + c.importDataset(Files.readString(Path.of(dataset)), persistentId, autoPublish, metadataKeys).getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionIsMetadataBlocksRoot.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionIsMetadataBlocksRoot.java index d010237..3337b56 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionIsMetadataBlocksRoot.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionIsMetadataBlocksRoot.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,13 +30,6 @@ public class CollectionIsMetadataBlocksRoot extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.isMetadataBlocksRoot(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.isMetadataBlocksRoot().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionListMetadataBlocks.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionListMetadataBlocks.java index b2a3462..1534681 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionListMetadataBlocks.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionListMetadataBlocks.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,13 +30,6 @@ public class CollectionListMetadataBlocks extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.listMetadataBlocks(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.listMetadataBlocks().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionListRoleAssignments.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionListRoleAssignments.java index a7e9971..2310fa1 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionListRoleAssignments.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionListRoleAssignments.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,13 +30,6 @@ public class CollectionListRoleAssignments extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.listRoleAssignments(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.listRoleAssignments().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionListRoles.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionListRoles.java index 160c7c6..d0391f2 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionListRoles.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionListRoles.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,13 +30,6 @@ public class CollectionListRoles extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.listRoles(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.listRoles().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionPublish.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionPublish.java index 9ff7048..b444595 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionPublish.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionPublish.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,13 +30,6 @@ public class CollectionPublish extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.publish(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.publish().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionSetMetadataBlocksRoot.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionSetMetadataBlocksRoot.java index e983b6a..b36f975 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionSetMetadataBlocksRoot.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionSetMetadataBlocksRoot.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.Parameters; @@ -35,13 +34,6 @@ public class CollectionSetMetadataBlocksRoot extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.setMetadataBlocksRoot(isRoot); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.setMetadataBlocksRoot(isRoot).getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/CollectionView.java b/src/main/java/nl/knaw/dans/dvcli/command/CollectionView.java index 4c78208..63622e4 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/CollectionView.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/CollectionView.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,13 +30,6 @@ public class CollectionView extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - collectionCmd.batchProcessorBuilder() - .action(d -> { - var r = d.view(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + collectionCmd.batchProcessor(c -> c.view().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/DatasetDeleteDraft.java b/src/main/java/nl/knaw/dans/dvcli/command/DatasetDeleteDraft.java index 3cbd7e6..bfed14b 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/DatasetDeleteDraft.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/DatasetDeleteDraft.java @@ -15,9 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.BatchProcessor; -import nl.knaw.dans.dvcli.action.ConsoleReport; -import nl.knaw.dans.lib.dataverse.DatasetApi; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -33,15 +30,6 @@ public class DatasetDeleteDraft extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - BatchProcessor. builder() - .labeledItems(datasetCmd.getItems()) - .action(d -> { - var r = d.deleteDraft(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .delay(1000L) - .build() - .process(); + datasetCmd.batchProcessor(d -> d.deleteDraft().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/DatasetDeleteRole.java b/src/main/java/nl/knaw/dans/dvcli/command/DatasetDeleteRole.java deleted file mode 100644 index 90efe90..0000000 --- a/src/main/java/nl/knaw/dans/dvcli/command/DatasetDeleteRole.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package nl.knaw.dans.dvcli.command; - -import nl.knaw.dans.dvcli.action.ConsoleReport; -import nl.knaw.dans.dvcli.action.ThrowingFunction; -import nl.knaw.dans.lib.dataverse.DataverseException; -import picocli.CommandLine.Command; -import picocli.CommandLine.ParentCommand; - -import java.io.IOException; - -@Command(name = "remove-role", mixinStandardHelpOptions = true, description = "remove role assignment from specified dataset(s)") -public class DatasetDeleteRole extends AbstractAssignmentRole { - @ParentCommand - private DatasetCmd datasetCmd; - - private static class RoleAssignmentAction implements ThrowingFunction { - @Override - public String apply(RoleAssignmentParams roleAssignmentParams) throws IOException, DataverseException { - if (roleAssignmentParams.roleAssignment().isPresent()) { - // TODO var r = roleAssignmentParams.pid().deleteRole(roleAssignmentParams.roleAssignment.get()); - // TODO return r.getEnvelopeAsString(); - // TODO in DatasetApi: https://guides.dataverse.org/en/latest/api/native-api.html#delete-role-assignment-from-a-dataset - return "Couldn't process 'Remove Role Assignment'"; - } - return "Nothing to Do"; - } - } - - @Override - public void doCall() throws IOException, DataverseException { - datasetCmd. paramsBatchProcessorBuilder() - .labeledItems(getRoleAssignmentParams(datasetCmd)) - .action(new RoleAssignmentAction()) - .report(new ConsoleReport<>()) - .build() - .process(); - } -} \ No newline at end of file diff --git a/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetFiles.java b/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetFiles.java index 88836d4..7487824 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetFiles.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetFiles.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.Parameters; @@ -35,13 +34,6 @@ public class DatasetGetFiles extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - datasetCmd.batchProcessorBuilder() - .action(d -> { - var r = d.getFiles(version); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + datasetCmd.batchProcessor(d -> d.getFiles(version).getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetLatestVersion.java b/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetLatestVersion.java index 2671d2a..5b5f051 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetLatestVersion.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetLatestVersion.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -31,14 +30,7 @@ public class DatasetGetLatestVersion extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - datasetCmd.batchProcessorBuilder() - .action(d -> { - var r = d.getLatestVersion(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + datasetCmd.batchProcessor(d -> d.getLatestVersion().getEnvelopeAsString()).process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetVersion.java b/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetVersion.java index b0b5139..b957758 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetVersion.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/DatasetGetVersion.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.ArgGroup; import picocli.CommandLine.Command; @@ -44,13 +43,9 @@ static class VersionInfo { @Override public void doCall() throws IOException, DataverseException { - datasetCmd.batchProcessorBuilder() - .action(d -> { - var r = versionInfo.allVersions ? d.getAllVersions() : d.getVersion(versionInfo.version); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() + datasetCmd.batchProcessor(d -> + versionInfo.allVersions ? d.getAllVersions().getEnvelopeAsString() : d.getVersion(versionInfo.version).getEnvelopeAsString() + ) .process(); } } diff --git a/src/main/java/nl/knaw/dans/dvcli/command/DatasetListRoleAssignments.java b/src/main/java/nl/knaw/dans/dvcli/command/DatasetListRoleAssignments.java index 68cd18d..2d37b57 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/DatasetListRoleAssignments.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/DatasetListRoleAssignments.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.ConsoleReport; import nl.knaw.dans.lib.dataverse.DataverseException; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -29,13 +28,6 @@ public class DatasetListRoleAssignments extends AbstractCmd { @Override public void doCall() throws IOException, DataverseException { - datasetCmd.batchProcessorBuilder() - .action(d -> { - var r = d.listRoleAssignments(); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .build() - .process(); + datasetCmd.batchProcessor(d -> d.listRoleAssignments().getEnvelopeAsString()).process(); } } \ No newline at end of file diff --git a/src/main/java/nl/knaw/dans/dvcli/command/DatasetPublish.java b/src/main/java/nl/knaw/dans/dvcli/command/DatasetPublish.java index f2874d2..61d8421 100644 --- a/src/main/java/nl/knaw/dans/dvcli/command/DatasetPublish.java +++ b/src/main/java/nl/knaw/dans/dvcli/command/DatasetPublish.java @@ -15,9 +15,6 @@ */ package nl.knaw.dans.dvcli.command; -import nl.knaw.dans.dvcli.action.BatchProcessor; -import nl.knaw.dans.dvcli.action.ConsoleReport; -import nl.knaw.dans.lib.dataverse.DatasetApi; import nl.knaw.dans.lib.dataverse.DataverseException; import nl.knaw.dans.lib.dataverse.model.dataset.UpdateType; import picocli.CommandLine.ArgGroup; @@ -52,7 +49,7 @@ static class VersionUpdateType { @ArgGroup(exclusive = false) PublishParams publishParams; - private UpdateType getUpdateType() { + private UpdateType getUpdateType() { if (publishParams != null && publishParams.versionUpdateType != null) { if (publishParams.versionUpdateType.minor) { return UpdateType.minor; @@ -70,16 +67,10 @@ private boolean isAssureIndexed() { @Override public void doCall() throws IOException, DataverseException { - BatchProcessor. builder() - .labeledItems(datasetCmd.getItems()) - .action(d -> { - var r = d.publish(this.getUpdateType(), this.isAssureIndexed()); - return r.getEnvelopeAsString(); - }) - .report(new ConsoleReport<>()) - .delay(1000L) - .build() - .process(); + datasetCmd.batchProcessor(dataset -> dataset + .publish(this.getUpdateType(), this.isAssureIndexed()) + .getEnvelopeAsString() + ).process(); } }