-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11d9763
commit 75cd94d
Showing
10 changed files
with
448 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/main/java/nl/knaw/dans/dvcli/command/CollectionCreateDataset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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 lombok.NonNull; | ||
import nl.knaw.dans.lib.dataverse.DataverseClient; | ||
import nl.knaw.dans.lib.dataverse.DataverseException; | ||
import picocli.CommandLine; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Command(name = "create-dataset", | ||
mixinStandardHelpOptions = true, | ||
description = "Create a dataset in a dataverse collection.") | ||
public class CollectionCreateDataset extends AbstractCmd { | ||
@ParentCommand | ||
private CollectionCmd collectionCmd; | ||
|
||
@CommandLine.Parameters(index = "0", paramLabel = "dataset", description = "A JSON string defining the dataset to create..") | ||
private String dataset; | ||
|
||
@CommandLine.Option(names = { "-m", "--mdkeys" }, paramLabel = "metadataKeys", description = "Maps the names of the metadata blocks to their 'secret' key values") | ||
private Map<String, String> metadataKeys = new HashMap<>(); | ||
|
||
public CollectionCreateDataset(@NonNull DataverseClient dataverseClient) { | ||
super(dataverseClient); | ||
} | ||
|
||
@Override | ||
public void doCall() throws IOException, DataverseException { | ||
var r = dataverseClient.dataverse(collectionCmd.getAlias()).createDataset(dataset, metadataKeys); | ||
System.out.println(r.getEnvelopeAsString()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/nl/knaw/dans/dvcli/command/CollectionDelete.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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 lombok.NonNull; | ||
import nl.knaw.dans.lib.dataverse.DataverseClient; | ||
import nl.knaw.dans.lib.dataverse.DataverseException; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
import java.io.IOException; | ||
|
||
@Command(name = "delete", | ||
mixinStandardHelpOptions = true, | ||
description = "Delete a Dataverse collection.") | ||
public class CollectionDelete extends AbstractCmd { | ||
@ParentCommand | ||
private CollectionCmd collectionCmd; | ||
|
||
public CollectionDelete(@NonNull DataverseClient dataverseClient) { | ||
super(dataverseClient); | ||
} | ||
|
||
@Override | ||
public void doCall() throws IOException, DataverseException { | ||
var r = dataverseClient.dataverse(collectionCmd.getAlias()).delete(); | ||
System.out.println(r.getEnvelopeAsString()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/nl/knaw/dans/dvcli/command/CollectionGetContents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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 lombok.NonNull; | ||
import nl.knaw.dans.lib.dataverse.DataverseClient; | ||
import nl.knaw.dans.lib.dataverse.DataverseException; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
import java.io.IOException; | ||
|
||
@Command(name = "get-contents", | ||
mixinStandardHelpOptions = true, | ||
description = "Show contents of a dataverse collection.") | ||
public class CollectionGetContents extends AbstractCmd { | ||
@ParentCommand | ||
private CollectionCmd collectionCmd; | ||
|
||
public CollectionGetContents(@NonNull DataverseClient dataverseClient) { | ||
super(dataverseClient); | ||
} | ||
|
||
@Override | ||
public void doCall() throws IOException, DataverseException { | ||
var r = dataverseClient.dataverse(collectionCmd.getAlias()).getContents(); | ||
System.out.println(r.getEnvelopeAsString()); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/nl/knaw/dans/dvcli/command/CollectionImportDataset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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 lombok.NonNull; | ||
import nl.knaw.dans.lib.dataverse.DataverseClient; | ||
import nl.knaw.dans.lib.dataverse.DataverseException; | ||
import picocli.CommandLine; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Command(name = "import-dataset", | ||
mixinStandardHelpOptions = true, | ||
description = "Import a JSON dataset into a dataverse collection.") | ||
public class CollectionImportDataset extends AbstractCmd { | ||
@ParentCommand | ||
private CollectionCmd collectionCmd; | ||
|
||
@CommandLine.Parameters(index = "0", paramLabel = "dataset", description = "A JSON string defining the dataset to import..") | ||
private String dataset; | ||
|
||
@CommandLine.Option(names = { "-p", "--persistentId" }, paramLabel = "persistentId", description = "Existing persistent identifier (PID)") | ||
String persistentId = ""; | ||
|
||
@CommandLine.Option(names = { "-a", "--autoPublish" }, paramLabel = "autoPublish", type = Boolean.class, description = "Immediately publish the dataset") | ||
Boolean autoPublish = false; | ||
|
||
@CommandLine.Option(names = { "-m", "--mdkeys" }, paramLabel = "metadataKeys", description = "Maps the names of the metadata blocks to their 'secret' key values") | ||
private Map<String, String> metadataKeys = new HashMap<>(); | ||
|
||
public CollectionImportDataset(@NonNull DataverseClient dataverseClient) { | ||
super(dataverseClient); | ||
} | ||
|
||
@Override | ||
public void doCall() throws IOException, DataverseException { | ||
var r = dataverseClient.dataverse(collectionCmd.getAlias()).importDataset(dataset, persistentId, autoPublish, metadataKeys); | ||
System.out.println(r.getEnvelopeAsString()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/nl/knaw/dans/dvcli/command/CollectionIsMetadataBlocksRoot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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 lombok.NonNull; | ||
import nl.knaw.dans.lib.dataverse.DataverseClient; | ||
import nl.knaw.dans.lib.dataverse.DataverseException; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
import java.io.IOException; | ||
|
||
@Command(name = "is-metadata-blocks-root", | ||
mixinStandardHelpOptions = true, | ||
description = "Determine if a dataverse collection inherits its metadata blocks from its parent.") | ||
public class CollectionIsMetadataBlocksRoot extends AbstractCmd { | ||
@ParentCommand | ||
private CollectionCmd collectionCmd; | ||
|
||
public CollectionIsMetadataBlocksRoot(@NonNull DataverseClient dataverseClient) { | ||
super(dataverseClient); | ||
} | ||
|
||
@Override | ||
public void doCall() throws IOException, DataverseException { | ||
var r = dataverseClient.dataverse(collectionCmd.getAlias()).isMetadataBlocksRoot(); | ||
System.out.println(r.getEnvelopeAsString()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/nl/knaw/dans/dvcli/command/CollectionListMetadataBlocks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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 lombok.NonNull; | ||
import nl.knaw.dans.lib.dataverse.DataverseClient; | ||
import nl.knaw.dans.lib.dataverse.DataverseException; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
import java.io.IOException; | ||
|
||
@Command(name = "list-metadata-blocks", | ||
mixinStandardHelpOptions = true, | ||
description = "Get a list of metadata blocks defined on a dataverse collection.") | ||
public class CollectionListMetadataBlocks extends AbstractCmd { | ||
@ParentCommand | ||
private CollectionCmd collectionCmd; | ||
|
||
public CollectionListMetadataBlocks(@NonNull DataverseClient dataverseClient) { | ||
super(dataverseClient); | ||
} | ||
|
||
@Override | ||
public void doCall() throws IOException, DataverseException { | ||
var r = dataverseClient.dataverse(collectionCmd.getAlias()).listMetadataBlocks(); | ||
System.out.println(r.getEnvelopeAsString()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/nl/knaw/dans/dvcli/command/CollectionListRoles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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 lombok.NonNull; | ||
import nl.knaw.dans.lib.dataverse.DataverseClient; | ||
import nl.knaw.dans.lib.dataverse.DataverseException; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
import java.io.IOException; | ||
|
||
@Command(name = "list-roles", | ||
mixinStandardHelpOptions = true, | ||
description = "Get a list of roles defined in a dataverse collection.") | ||
public class CollectionListRoles extends AbstractCmd { | ||
@ParentCommand | ||
private CollectionCmd collectionCmd; | ||
|
||
public CollectionListRoles(@NonNull DataverseClient dataverseClient) { | ||
super(dataverseClient); | ||
} | ||
|
||
@Override | ||
public void doCall() throws IOException, DataverseException { | ||
var r = dataverseClient.dataverse(collectionCmd.getAlias()).listRoles(); | ||
System.out.println(r.getEnvelopeAsString()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/nl/knaw/dans/dvcli/command/CollectionPublish.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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 lombok.NonNull; | ||
import nl.knaw.dans.lib.dataverse.DataverseClient; | ||
import nl.knaw.dans.lib.dataverse.DataverseException; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
import java.io.IOException; | ||
|
||
@Command(name = "publish", | ||
mixinStandardHelpOptions = true, | ||
description = "Publish a dataverse collection.") | ||
public class CollectionPublish extends AbstractCmd { | ||
@ParentCommand | ||
private CollectionCmd collectionCmd; | ||
|
||
public CollectionPublish(@NonNull DataverseClient dataverseClient) { | ||
super(dataverseClient); | ||
} | ||
|
||
@Override | ||
public void doCall() throws IOException, DataverseException { | ||
var r = dataverseClient.dataverse(collectionCmd.getAlias()).publish(); | ||
System.out.println(r.getEnvelopeAsString()); | ||
} | ||
} |
Oops, something went wrong.