packer (WIP)
This commit is contained in:
parent
5b6ed046fc
commit
fac421e2ca
@ -0,0 +1,35 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import p.packer.messages.assets.AssetFamilyCatalog;
|
||||
|
||||
public record PackerPackSummaryAssetDTO(
|
||||
int assetId,
|
||||
String assetName,
|
||||
AssetFamilyCatalog assetFamily,
|
||||
int minArtifactCount,
|
||||
int maxArtifactCount,
|
||||
long lastModified) {
|
||||
|
||||
public PackerPackSummaryAssetDTO {
|
||||
if (assetId < 0) {
|
||||
throw new IllegalArgumentException("assetId must not be negative");
|
||||
}
|
||||
assetName = java.util.Objects.requireNonNull(assetName, "assetName").trim();
|
||||
assetFamily = java.util.Objects.requireNonNullElse(assetFamily, AssetFamilyCatalog.UNKNOWN);
|
||||
if (assetName.isBlank()) {
|
||||
throw new IllegalArgumentException("assetName must not be blank");
|
||||
}
|
||||
if (minArtifactCount < 0) {
|
||||
throw new IllegalArgumentException("minArtifactCount must not be negative");
|
||||
}
|
||||
if (maxArtifactCount < 0) {
|
||||
throw new IllegalArgumentException("maxArtifactCount must not be negative");
|
||||
}
|
||||
if (minArtifactCount > maxArtifactCount) {
|
||||
throw new IllegalArgumentException("minArtifactCount must not be greater than maxArtifactCount");
|
||||
}
|
||||
if (lastModified < 0L) {
|
||||
throw new IllegalArgumentException("lastModified must not be negative");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,22 +1,16 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerPackSummaryDTO(
|
||||
int includedRegisteredAssetCount,
|
||||
int outsideBuildSetAssetCount,
|
||||
String canonicalArtifactName) {
|
||||
int totalIncludedAssetCount,
|
||||
List<PackerPackSummaryAssetDTO> assets) {
|
||||
|
||||
public PackerPackSummaryDTO {
|
||||
if (includedRegisteredAssetCount < 0) {
|
||||
throw new IllegalArgumentException("includedRegisteredAssetCount must not be negative");
|
||||
}
|
||||
if (outsideBuildSetAssetCount < 0) {
|
||||
throw new IllegalArgumentException("outsideBuildSetAssetCount must not be negative");
|
||||
}
|
||||
canonicalArtifactName = Objects.requireNonNull(canonicalArtifactName, "canonicalArtifactName").trim();
|
||||
if (canonicalArtifactName.isBlank()) {
|
||||
throw new IllegalArgumentException("canonicalArtifactName must not be blank");
|
||||
if (totalIncludedAssetCount < 0) {
|
||||
throw new IllegalArgumentException("totalIncludedAssetCount must not be negative");
|
||||
}
|
||||
assets = List.copyOf(Objects.requireNonNull(assets, "assets"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +1,35 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerPackValidationAssetDTO(
|
||||
PackerAssetSummaryDTO asset,
|
||||
boolean blocked,
|
||||
int assetId,
|
||||
String assetName,
|
||||
Path assetPath,
|
||||
long lastModified,
|
||||
List<PackerDiagnosticDTO> diagnostics) {
|
||||
|
||||
public PackerPackValidationAssetDTO {
|
||||
Objects.requireNonNull(asset, "asset");
|
||||
if (assetId < 0) {
|
||||
throw new IllegalArgumentException("assetId must not be negative");
|
||||
}
|
||||
assetName = Objects.requireNonNull(assetName, "assetName").trim();
|
||||
assetPath = Objects.requireNonNull(assetPath, "assetPath").toAbsolutePath().normalize();
|
||||
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
|
||||
if (blocked && diagnostics.stream().noneMatch(PackerDiagnosticDTO::blocking)) {
|
||||
throw new IllegalArgumentException("blocked validation asset must include at least one blocking diagnostic");
|
||||
if (assetName.isBlank()) {
|
||||
throw new IllegalArgumentException("assetName must not be blank");
|
||||
}
|
||||
if (lastModified < 0L) {
|
||||
throw new IllegalArgumentException("lastModified must not be negative");
|
||||
}
|
||||
if (diagnostics.stream().anyMatch(diagnostic -> !diagnostic.blocking())) {
|
||||
throw new IllegalArgumentException("validation diagnostics must be blocking in the first wave");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean blocked() {
|
||||
return !diagnostics.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
public record PackerPackValidationSummaryDTO(
|
||||
int totalAssetsInScope,
|
||||
int validAssetCount,
|
||||
int blockedAssetCount,
|
||||
boolean canPack) {
|
||||
|
||||
public PackerPackValidationSummaryDTO {
|
||||
if (totalAssetsInScope < 0) {
|
||||
throw new IllegalArgumentException("totalAssetsInScope must not be negative");
|
||||
}
|
||||
if (validAssetCount < 0) {
|
||||
throw new IllegalArgumentException("validAssetCount must not be negative");
|
||||
}
|
||||
if (blockedAssetCount < 0) {
|
||||
throw new IllegalArgumentException("blockedAssetCount must not be negative");
|
||||
}
|
||||
if (validAssetCount + blockedAssetCount > totalAssetsInScope) {
|
||||
throw new IllegalArgumentException("validAssetCount + blockedAssetCount must not exceed totalAssetsInScope");
|
||||
}
|
||||
if (canPack && blockedAssetCount > 0) {
|
||||
throw new IllegalArgumentException("canPack must be false when blockedAssetCount is greater than zero");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.dtos.PackerPackValidationAssetDTO;
|
||||
import p.packer.dtos.PackerPackValidationSummaryDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -9,16 +8,18 @@ import java.util.Objects;
|
||||
public record ValidatePackWorkspaceResult(
|
||||
PackerOperationStatus status,
|
||||
String summary,
|
||||
PackerPackValidationSummaryDTO validation,
|
||||
List<PackerPackValidationAssetDTO> assets) {
|
||||
|
||||
public ValidatePackWorkspaceResult {
|
||||
Objects.requireNonNull(status, "status");
|
||||
summary = Objects.requireNonNull(summary, "summary").trim();
|
||||
Objects.requireNonNull(validation, "validation");
|
||||
assets = List.copyOf(Objects.requireNonNull(assets, "assets"));
|
||||
if (summary.isBlank()) {
|
||||
throw new IllegalArgumentException("summary must not be blank");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPack() {
|
||||
return assets.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,6 +275,9 @@ public enum I18n {
|
||||
ASSETS_PACK_WIZARD_LABEL_PACKED_ASSETS("assets.packWizard.label.packedAssets"),
|
||||
ASSETS_PACK_WIZARD_LABEL_ELAPSED("assets.packWizard.label.elapsed"),
|
||||
ASSETS_PACK_WIZARD_LABEL_EMITTED_ARTIFACTS("assets.packWizard.label.emittedArtifacts"),
|
||||
ASSETS_PACK_WIZARD_LABEL_MIN_ARTIFACTS("assets.packWizard.label.minArtifacts"),
|
||||
ASSETS_PACK_WIZARD_LABEL_MAX_ARTIFACTS("assets.packWizard.label.maxArtifacts"),
|
||||
ASSETS_PACK_WIZARD_LABEL_LAST_MODIFIED("assets.packWizard.label.lastModified"),
|
||||
ASSETS_PACK_WIZARD_STATUS_READY("assets.packWizard.status.ready"),
|
||||
ASSETS_PACK_WIZARD_STATUS_BLOCKED("assets.packWizard.status.blocked"),
|
||||
ASSETS_PACK_WIZARD_STATUS_RUNNING("assets.packWizard.status.running"),
|
||||
|
||||
@ -3,6 +3,7 @@ package p.studio.workspaces.assets.wizards;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.HBox;
|
||||
@ -12,6 +13,7 @@ import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import p.packer.dtos.PackerEmittedArtifactDTO;
|
||||
import p.packer.dtos.PackerPackSummaryAssetDTO;
|
||||
import p.packer.dtos.PackerPackValidationAssetDTO;
|
||||
import p.packer.messages.PackWorkspaceRequest;
|
||||
import p.packer.messages.PackWorkspaceResult;
|
||||
@ -127,7 +129,7 @@ public final class PackWorkspaceWizard {
|
||||
|
||||
packButton.setVisible(phase == Phase.VALIDATION);
|
||||
packButton.setManaged(phase == Phase.VALIDATION);
|
||||
packButton.setDisable(busy || validationResult == null || !validationResult.validation().canPack());
|
||||
packButton.setDisable(busy || validationResult == null || !validationResult.canPack());
|
||||
|
||||
copyFailuresButton.setVisible(phase == Phase.RESULT);
|
||||
copyFailuresButton.setManaged(phase == Phase.RESULT);
|
||||
@ -156,18 +158,52 @@ public final class PackWorkspaceWizard {
|
||||
}
|
||||
|
||||
stepBody.getChildren().setAll(
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_CANONICAL_ARTIFACT),
|
||||
summaryResult.packSummary().canonicalArtifactName()),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_INCLUDED_ASSETS),
|
||||
Integer.toString(summaryResult.packSummary().includedRegisteredAssetCount())),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_OUTSIDE_BUILD_SET),
|
||||
Integer.toString(summaryResult.packSummary().outsideBuildSetAssetCount())),
|
||||
Integer.toString(summaryResult.packSummary().totalIncludedAssetCount())),
|
||||
createSummaryAssetsSection(),
|
||||
AssetDetailsUiSupport.createSectionMessage(summaryResult.summary()));
|
||||
}
|
||||
|
||||
private Node createSummaryAssetsSection() {
|
||||
if (summaryResult.packSummary().assets().isEmpty()) {
|
||||
return AssetDetailsUiSupport.createSectionMessage(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_VALIDATION_EMPTY));
|
||||
}
|
||||
final Accordion accordion = new Accordion();
|
||||
for (PackerPackSummaryAssetDTO asset : summaryResult.packSummary().assets()) {
|
||||
accordion.getPanes().add(createSummaryPane(asset));
|
||||
}
|
||||
VBox.setVgrow(accordion, Priority.ALWAYS);
|
||||
return accordion;
|
||||
}
|
||||
|
||||
private TitledPane createSummaryPane(PackerPackSummaryAssetDTO asset) {
|
||||
final VBox content = new VBox(8);
|
||||
content.getChildren().addAll(
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_LABEL_ASSET_ID),
|
||||
Integer.toString(asset.assetId())),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_LABEL_NAME),
|
||||
asset.assetName()),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_LABEL_TYPE),
|
||||
AssetDetailsUiSupport.typeLabel(asset.assetFamily())),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_MIN_ARTIFACTS),
|
||||
Integer.toString(asset.minArtifactCount())),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_MAX_ARTIFACTS),
|
||||
Integer.toString(asset.maxArtifactCount())),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_LAST_MODIFIED),
|
||||
Long.toString(asset.lastModified())));
|
||||
final TitledPane pane = new TitledPane(asset.assetName(), content);
|
||||
pane.setExpanded(false);
|
||||
return pane;
|
||||
}
|
||||
|
||||
private void renderValidationPhase() {
|
||||
stepTitle.textProperty().unbind();
|
||||
stepDescription.textProperty().unbind();
|
||||
@ -185,18 +221,12 @@ public final class PackWorkspaceWizard {
|
||||
|
||||
final VBox content = new VBox(12);
|
||||
content.getChildren().addAll(
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_TOTAL_IN_SCOPE),
|
||||
Integer.toString(validationResult.validation().totalAssetsInScope())),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_VALID_ASSETS),
|
||||
Integer.toString(validationResult.validation().validAssetCount())),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_BLOCKED_ASSETS),
|
||||
Integer.toString(validationResult.validation().blockedAssetCount())),
|
||||
Integer.toString(validationResult.assets().size())),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_STATUS),
|
||||
validationResult.validation().canPack()
|
||||
validationResult.canPack()
|
||||
? Container.i18n().text(I18n.ASSETS_PACK_WIZARD_STATUS_READY)
|
||||
: Container.i18n().text(I18n.ASSETS_PACK_WIZARD_STATUS_BLOCKED)),
|
||||
AssetDetailsUiSupport.createSectionMessage(validationResult.summary()));
|
||||
@ -220,10 +250,13 @@ public final class PackWorkspaceWizard {
|
||||
content.getChildren().addAll(
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_LABEL_NAME),
|
||||
asset.asset().identity().assetName()),
|
||||
asset.assetName()),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_LABEL_LOCATION),
|
||||
asset.asset().identity().assetRoot().toString()),
|
||||
asset.assetPath().toString()),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_LAST_MODIFIED),
|
||||
Long.toString(asset.lastModified())),
|
||||
AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_STATUS),
|
||||
asset.blocked()
|
||||
@ -241,7 +274,7 @@ public final class PackWorkspaceWizard {
|
||||
diagnostic.severity().name() + ": " + diagnostic.message())));
|
||||
}
|
||||
|
||||
final String title = asset.asset().identity().assetName() + (asset.blocked() ? " (blocked)" : " (ready)");
|
||||
final String title = asset.assetName() + (asset.blocked() ? " (blocked)" : " (ready)");
|
||||
final TitledPane pane = new TitledPane(title, content);
|
||||
pane.setExpanded(false);
|
||||
return pane;
|
||||
@ -372,7 +405,7 @@ public final class PackWorkspaceWizard {
|
||||
private void applyValidationResult(ValidatePackWorkspaceResult result) {
|
||||
loadingValidation = false;
|
||||
validationResult = result;
|
||||
if (!result.validation().canPack()) {
|
||||
if (!result.canPack()) {
|
||||
feedbackLabel.setText(result.summary());
|
||||
} else {
|
||||
feedbackLabel.setText("");
|
||||
@ -387,7 +420,7 @@ public final class PackWorkspaceWizard {
|
||||
}
|
||||
|
||||
private void startPack() {
|
||||
if (validationResult == null || !validationResult.validation().canPack() || packing) {
|
||||
if (validationResult == null || !validationResult.canPack() || packing) {
|
||||
return;
|
||||
}
|
||||
phase = Phase.PACKING;
|
||||
|
||||
@ -266,6 +266,9 @@ assets.packWizard.label.status=Status
|
||||
assets.packWizard.label.packedAssets=Packed Assets
|
||||
assets.packWizard.label.elapsed=Elapsed
|
||||
assets.packWizard.label.emittedArtifacts=Emitted Artifacts
|
||||
assets.packWizard.label.minArtifacts=Min Artifacts
|
||||
assets.packWizard.label.maxArtifacts=Max Artifacts
|
||||
assets.packWizard.label.lastModified=Last Modified
|
||||
assets.packWizard.status.ready=Ready to pack
|
||||
assets.packWizard.status.blocked=Validation blocked
|
||||
assets.packWizard.status.running=Packing in progress
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user