Skip to content

Commit

Permalink
Made --minor and assuring indexing the default in dataset publishing …
Browse files Browse the repository at this point in the history
…+ simplified publish command line option defintions
  • Loading branch information
janvanmansum committed Nov 4, 2024
1 parent 15c3bc7 commit 237cff1
Showing 1 changed file with 14 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,29 @@ public class DatasetPublish extends AbstractCmd {
@ParentCommand
private DatasetCmd datasetCmd;

static class PublishParams {
@ArgGroup(exclusive = true)
VersionUpdateType versionUpdateType;

static class VersionUpdateType {
@Option(names = "--major", description = "Version update type: major (default)")
boolean major;
@Option(names = "--minor", description = "Version update type: minor")
boolean minor;
}

@Option(names = { "-a", "--assure-indexed" }, paramLabel = "assure-indexed", description = "Set to true to ensure that indexing has already happened before publish.")
private boolean assureIsIndexed = true;
@ArgGroup(exclusive = true)
VersionUpdateType versionUpdateType;

static class VersionUpdateType {
@Option(names = "--major", description = "Version update type: major")
boolean major;
@Option(names = "--minor", description = "Version update type: minor (default)")
boolean minor;
}

@ArgGroup(exclusive = false)
PublishParams publishParams;
@Option(names = {"--skip-assure-indexed" }, paramLabel = "skip-assure-indexed", description = "Do not attempt to assure that the dataset is indexed.")
private boolean skipAssureIsIndexed;

private UpdateType getUpdateType() {
if (publishParams != null && publishParams.versionUpdateType != null) {
if (publishParams.versionUpdateType.minor) {
return UpdateType.minor;
}
}
return UpdateType.major;
}

private boolean isAssureIndexed() {
if (publishParams != null)
return publishParams.assureIsIndexed;

return true;
if (versionUpdateType != null && versionUpdateType.major)
return UpdateType.major;
return UpdateType.minor;
}

@Override
public void doCall() throws IOException, DataverseException {
datasetCmd.batchProcessor(dataset -> dataset
.publish(this.getUpdateType(), this.isAssureIndexed())
.publish(this.getUpdateType(), skipAssureIsIndexed)
.getEnvelopeAsString()
).process();
}
Expand Down

0 comments on commit 237cff1

Please sign in to comment.