-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
7 changed files
with
108 additions
and
19 deletions.
There are no files selected for viewing
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
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
59 changes: 59 additions & 0 deletions
59
src/main/java/org/nasdanika/launcher/demo/GitLabDemoRetrospectCommand.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,59 @@ | ||
package org.nasdanika.launcher.demo; | ||
|
||
import java.io.IOException; | ||
import java.util.Date; | ||
|
||
import org.eclipse.emf.common.util.URI; | ||
import org.eclipse.emf.ecore.resource.Resource; | ||
import org.eclipse.emf.ecore.resource.ResourceSet; | ||
import org.nasdanika.capability.CapabilityLoader; | ||
import org.nasdanika.capability.ServiceCapabilityFactory; | ||
import org.nasdanika.capability.ServiceCapabilityFactory.Requirement; | ||
import org.nasdanika.capability.emf.ResourceSetRequirement; | ||
import org.nasdanika.cli.CommandBase; | ||
import org.nasdanika.cli.ParentCommands; | ||
import org.nasdanika.common.PrintStreamProgressMonitor; | ||
import org.nasdanika.common.ProgressMonitor; | ||
import org.nasdanika.models.gitlab.Project; | ||
import org.nasdanika.models.gitlab.cli.GitLabContributorCommand.Result; | ||
import org.nasdanika.models.gitlab.cli.GitLabRetrospectCommand; | ||
import org.nasdanika.models.gitlab.util.GitLabURIHandler; | ||
|
||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
@Command( | ||
description = "Demo retrospect command", | ||
name = "demo", | ||
mixinStandardHelpOptions = true) | ||
@ParentCommands(GitLabRetrospectCommand.class) | ||
public class GitLabDemoRetrospectCommand extends CommandBase { | ||
|
||
public GitLabDemoRetrospectCommand(CapabilityLoader capabilityLoader) { | ||
super(capabilityLoader); | ||
} | ||
|
||
@ParentCommand | ||
private GitLabRetrospectCommand parent; | ||
|
||
protected String apply(GitLabURIHandler gitLabURIHandler, Date since, Date until, Project project) throws IOException { | ||
ProgressMonitor progressMonitor = new PrintStreamProgressMonitor(); | ||
Requirement<ResourceSetRequirement, ResourceSet> requirement = ServiceCapabilityFactory.createRequirement(ResourceSet.class); | ||
ResourceSet resourceSet = capabilityLoader.loadOne(requirement, progressMonitor); | ||
resourceSet.getURIConverter().getURIHandlers().add(0, gitLabURIHandler); | ||
URI modelURI = URI.createURI(GitLabURIHandler.GITLAB_URI_SCHEME + "://bank/main/retrospect-" + Long.toString(System.currentTimeMillis(), Character.MAX_RADIX) + ".xml"); | ||
Resource model = resourceSet.createResource(modelURI); | ||
model.getContents().add(project); | ||
model.save(null); | ||
return "Hello"; | ||
} | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
Result<String> result = parent.apply(this::apply); | ||
System.out.println(result); | ||
return 0; | ||
} | ||
|
||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/nasdanika/launcher/demo/GitLabDemoRetrospectCommandFactory.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,28 @@ | ||
package org.nasdanika.launcher.demo; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionStage; | ||
|
||
import org.nasdanika.capability.CapabilityFactory; | ||
import org.nasdanika.cli.SubCommandCapabilityFactory; | ||
import org.nasdanika.common.ProgressMonitor; | ||
|
||
import picocli.CommandLine; | ||
|
||
public class GitLabDemoRetrospectCommandFactory extends SubCommandCapabilityFactory<GitLabDemoRetrospectCommand> { | ||
|
||
@Override | ||
protected Class<GitLabDemoRetrospectCommand> getCommandType() { | ||
return GitLabDemoRetrospectCommand.class; | ||
} | ||
|
||
@Override | ||
protected CompletionStage<GitLabDemoRetrospectCommand> doCreateCommand( | ||
List<CommandLine> parentPath, | ||
CapabilityFactory.Loader loader, | ||
ProgressMonitor progressMonitor) { | ||
return CompletableFuture.completedStage(new GitLabDemoRetrospectCommand(loader.getCapabilityLoader())); | ||
} | ||
|
||
} |
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
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
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