-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Application Version's Performance Indicator (list & get)
- Loading branch information
Showing
8 changed files
with
234 additions
and
0 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
26 changes: 26 additions & 0 deletions
26
...sc/appversion_performanceindicator/cli/cmd/SSCAppVersionPerformanceIndicatorCommands.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,26 @@ | ||
/******************************************************************************* | ||
* Copyright 2021, 2023 Open Text. | ||
* | ||
* The only warranties for products and services of Open Text | ||
* and its affiliates and licensors ("Open Text") are as may | ||
* be set forth in the express warranty statements accompanying | ||
* such products and services. Nothing herein should be construed | ||
* as constituting an additional warranty. Open Text shall not be | ||
* liable for technical or editorial errors or omissions contained | ||
* herein. The information contained herein is subject to change | ||
* without notice. | ||
*******************************************************************************/ | ||
package com.fortify.cli.ssc.appversion_performanceindicator.cli.cmd; | ||
|
||
import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; | ||
import picocli.CommandLine.Command; | ||
|
||
@Command( | ||
name = "appversion-performanceindicator", | ||
subcommands = { | ||
SSCAppVersionPerformanceIndicatorGetCommand.class, | ||
SSCAppVersionPerformanceIndicatorListCommand.class | ||
} | ||
) | ||
public class SSCAppVersionPerformanceIndicatorCommands extends AbstractContainerCommand { | ||
} |
40 changes: 40 additions & 0 deletions
40
.../appversion_performanceindicator/cli/cmd/SSCAppVersionPerformanceIndicatorGetCommand.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,40 @@ | ||
/******************************************************************************* | ||
* Copyright 2021, 2023 Open Text. | ||
* | ||
* The only warranties for products and services of Open Text | ||
* and its affiliates and licensors ("Open Text") are as may | ||
* be set forth in the express warranty statements accompanying | ||
* such products and services. Nothing herein should be construed | ||
* as constituting an additional warranty. Open Text shall not be | ||
* liable for technical or editorial errors or omissions contained | ||
* herein. The information contained herein is subject to change | ||
* without notice. | ||
*******************************************************************************/ | ||
package com.fortify.cli.ssc.appversion_performanceindicator.cli.cmd; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; | ||
import com.fortify.cli.ssc._common.output.cli.cmd.AbstractSSCJsonNodeOutputCommand; | ||
import com.fortify.cli.ssc.appversion.cli.mixin.SSCAppVersionResolverMixin; | ||
import com.fortify.cli.ssc.appversion_performanceindicator.cli.mixin.SSCAppVersionPerformanceIndicatorResolverMixin; | ||
import kong.unirest.UnirestInstance; | ||
import lombok.Getter; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.Mixin; | ||
|
||
@Command(name = OutputHelperMixins.Get.CMD_NAME) | ||
public class SSCAppVersionPerformanceIndicatorGetCommand extends AbstractSSCJsonNodeOutputCommand { | ||
@Getter @Mixin private OutputHelperMixins.Get outputHelper; | ||
@Mixin SSCAppVersionPerformanceIndicatorResolverMixin.PositionalParameterSingle performanceIndicatorResolver; | ||
@Mixin private SSCAppVersionResolverMixin.RequiredOption parentResolver; | ||
|
||
@Override | ||
public JsonNode getJsonNode(UnirestInstance unirest) { | ||
return performanceIndicatorResolver.getPerformanceIndicatorDescriptor(unirest, parentResolver.getAppVersionId(unirest)).asJsonNode(); | ||
} | ||
|
||
@Override | ||
public boolean isSingular() { | ||
return true; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...appversion_performanceindicator/cli/cmd/SSCAppVersionPerformanceIndicatorListCommand.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,39 @@ | ||
/******************************************************************************* | ||
* Copyright 2021, 2023 Open Text. | ||
* | ||
* The only warranties for products and services of Open Text | ||
* and its affiliates and licensors ("Open Text") are as may | ||
* be set forth in the express warranty statements accompanying | ||
* such products and services. Nothing herein should be construed | ||
* as constituting an additional warranty. Open Text shall not be | ||
* liable for technical or editorial errors or omissions contained | ||
* herein. The information contained herein is subject to change | ||
* without notice. | ||
*******************************************************************************/ | ||
package com.fortify.cli.ssc.appversion_performanceindicator.cli.cmd; | ||
|
||
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; | ||
import com.fortify.cli.ssc._common.output.cli.cmd.AbstractSSCBaseRequestOutputCommand; | ||
import com.fortify.cli.ssc._common.rest.SSCUrls; | ||
import com.fortify.cli.ssc.appversion.cli.mixin.SSCAppVersionResolverMixin; | ||
import kong.unirest.HttpRequest; | ||
import kong.unirest.UnirestInstance; | ||
import lombok.Getter; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.Mixin; | ||
|
||
@Command(name = OutputHelperMixins.List.CMD_NAME) | ||
public class SSCAppVersionPerformanceIndicatorListCommand extends AbstractSSCBaseRequestOutputCommand { | ||
@Getter @Mixin private OutputHelperMixins.List outputHelper; | ||
@Mixin private SSCAppVersionResolverMixin.RequiredOption parentResolver; | ||
|
||
@Override | ||
public HttpRequest<?> getBaseRequest(UnirestInstance unirest) { | ||
return unirest.get(SSCUrls.PROJECT_VERSION_PERFORMANCE_INDICATOR_HISTORIES(parentResolver.getAppVersionId(unirest))); | ||
} | ||
|
||
@Override | ||
public boolean isSingular() { | ||
return false; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ersion_performanceindicator/cli/mixin/SSCAppVersionPerformanceIndicatorResolverMixin.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,40 @@ | ||
/******************************************************************************* | ||
* Copyright 2021, 2023 Open Text. | ||
* | ||
* The only warranties for products and services of Open Text | ||
* and its affiliates and licensors ("Open Text") are as may | ||
* be set forth in the express warranty statements accompanying | ||
* such products and services. Nothing herein should be construed | ||
* as constituting an additional warranty. Open Text shall not be | ||
* liable for technical or editorial errors or omissions contained | ||
* herein. The information contained herein is subject to change | ||
* without notice. | ||
*******************************************************************************/ | ||
package com.fortify.cli.ssc.appversion_performanceindicator.cli.mixin; | ||
|
||
import com.fortify.cli.ssc.appversion_performanceindicator.helper.SSCAppVersionPerformanceIndicatorDescriptor; | ||
import com.fortify.cli.ssc.appversion_performanceindicator.helper.SSCAppVersionPerformanceIndicatorHelper; | ||
import kong.unirest.UnirestInstance; | ||
import lombok.Getter; | ||
import picocli.CommandLine.Option; | ||
import picocli.CommandLine.Parameters; | ||
|
||
public class SSCAppVersionPerformanceIndicatorResolverMixin { | ||
private static abstract class AbstractSSCPerformanceIndicatorResolverMixin { | ||
public abstract String getPerformanceIndicatorId(); | ||
|
||
public SSCAppVersionPerformanceIndicatorDescriptor getPerformanceIndicatorDescriptor(UnirestInstance unirest, String appVersionId) { | ||
return new SSCAppVersionPerformanceIndicatorHelper(unirest, appVersionId).getDescriptorById(getPerformanceIndicatorId(), true); | ||
} | ||
} | ||
|
||
public static class PerformanceIndicatorOption extends AbstractSSCPerformanceIndicatorResolverMixin { | ||
@Option(names="--performanceindicator", descriptionKey = "fcli.ssc.appversion-performance-indicator.resolver.id") | ||
@Getter private String performanceIndicatorId; | ||
} | ||
|
||
public static class PositionalParameterSingle extends AbstractSSCPerformanceIndicatorResolverMixin { | ||
@Parameters(index = "0", arity = "1", descriptionKey = "fcli.ssc.appversion-performance-indicator.resolver.id") | ||
@Getter private String performanceIndicatorId; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...c/appversion_performanceindicator/helper/SSCAppVersionPerformanceIndicatorDescriptor.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,26 @@ | ||
/******************************************************************************* | ||
* Copyright 2021, 2023 Open Text. | ||
* | ||
* The only warranties for products and services of Open Text | ||
* and its affiliates and licensors ("Open Text") are as may | ||
* be set forth in the express warranty statements accompanying | ||
* such products and services. Nothing herein should be construed | ||
* as constituting an additional warranty. Open Text shall not be | ||
* liable for technical or editorial errors or omissions contained | ||
* herein. The information contained herein is subject to change | ||
* without notice. | ||
*******************************************************************************/ | ||
package com.fortify.cli.ssc.appversion_performanceindicator.helper; | ||
|
||
import com.formkiq.graalvm.annotations.Reflectable; | ||
import com.fortify.cli.common.json.JsonNodeHolder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Reflectable @NoArgsConstructor | ||
@Data @EqualsAndHashCode(callSuper=true) | ||
public class SSCAppVersionPerformanceIndicatorDescriptor extends JsonNodeHolder { | ||
private String id; | ||
private boolean defaultPerformanceIndicator; | ||
} |
55 changes: 55 additions & 0 deletions
55
...i/ssc/appversion_performanceindicator/helper/SSCAppVersionPerformanceIndicatorHelper.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,55 @@ | ||
/******************************************************************************* | ||
* Copyright 2021, 2023 Open Text. | ||
* | ||
* The only warranties for products and services of Open Text | ||
* and its affiliates and licensors ("Open Text") are as may | ||
* be set forth in the express warranty statements accompanying | ||
* such products and services. Nothing herein should be construed | ||
* as constituting an additional warranty. Open Text shall not be | ||
* liable for technical or editorial errors or omissions contained | ||
* herein. The information contained herein is subject to change | ||
* without notice. | ||
*******************************************************************************/ | ||
package com.fortify.cli.ssc.appversion_performanceindicator.helper; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fortify.cli.common.json.JsonHelper; | ||
import com.fortify.cli.ssc._common.rest.SSCUrls; | ||
import kong.unirest.UnirestInstance; | ||
import lombok.Getter; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public final class SSCAppVersionPerformanceIndicatorHelper { | ||
private final Map<String, SSCAppVersionPerformanceIndicatorDescriptor> descriptorsById = new HashMap<>(); | ||
@Getter private SSCAppVersionPerformanceIndicatorDescriptor defaultPerformanceIndicatorDescriptor; | ||
|
||
/** | ||
* This constructor calls the SSC projectVersion filterSets endpoint to retrieve filter set data, | ||
* then calls the {@link #processPerformanceIndicator(JsonNode)} method for each filter set to collect the | ||
* relevant data. | ||
* @param unirest | ||
*/ | ||
public SSCAppVersionPerformanceIndicatorHelper(UnirestInstance unirest, String applicationVersionId) { | ||
JsonNode body = unirest.get(SSCUrls.PROJECT_VERSION_PERFORMANCE_INDICATOR_HISTORIES(applicationVersionId)).queryString("limit","-1").asObject(JsonNode.class).getBody(); | ||
body.get("data").forEach(this::processPerformanceIndicator); | ||
} | ||
|
||
private void processPerformanceIndicator(JsonNode issueTemplate) { | ||
SSCAppVersionPerformanceIndicatorDescriptor descriptor = JsonHelper.treeToValue(issueTemplate, SSCAppVersionPerformanceIndicatorDescriptor.class); | ||
descriptorsById.put(descriptor.getId(), descriptor); | ||
if ( descriptor.isDefaultPerformanceIndicator() ) { | ||
this.defaultPerformanceIndicatorDescriptor = descriptor; | ||
} | ||
} | ||
|
||
public SSCAppVersionPerformanceIndicatorDescriptor getDescriptorById(String performanceIndicatorId, boolean failIfNotFound) { | ||
if ( performanceIndicatorId==null ) { return defaultPerformanceIndicatorDescriptor; } | ||
SSCAppVersionPerformanceIndicatorDescriptor descriptor = descriptorsById.get(performanceIndicatorId); | ||
if ( failIfNotFound && descriptor==null ) { | ||
throw new IllegalArgumentException("No Performance Indicator found with id "+performanceIndicatorId); | ||
} | ||
return descriptor; | ||
} | ||
} |
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