packer (WIP)

This commit is contained in:
bQUARKz 2026-03-20 05:45:35 +00:00
parent 5b6ed046fc
commit fac421e2ca
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
8 changed files with 127 additions and 67 deletions

View File

@ -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");
}
}
}

View File

@ -1,22 +1,16 @@
package p.packer.dtos; package p.packer.dtos;
import java.util.List;
import java.util.Objects; import java.util.Objects;
public record PackerPackSummaryDTO( public record PackerPackSummaryDTO(
int includedRegisteredAssetCount, int totalIncludedAssetCount,
int outsideBuildSetAssetCount, List<PackerPackSummaryAssetDTO> assets) {
String canonicalArtifactName) {
public PackerPackSummaryDTO { public PackerPackSummaryDTO {
if (includedRegisteredAssetCount < 0) { if (totalIncludedAssetCount < 0) {
throw new IllegalArgumentException("includedRegisteredAssetCount must not be negative"); throw new IllegalArgumentException("totalIncludedAssetCount 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");
} }
assets = List.copyOf(Objects.requireNonNull(assets, "assets"));
} }
} }

View File

@ -1,18 +1,35 @@
package p.packer.dtos; package p.packer.dtos;
import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
public record PackerPackValidationAssetDTO( public record PackerPackValidationAssetDTO(
PackerAssetSummaryDTO asset, int assetId,
boolean blocked, String assetName,
Path assetPath,
long lastModified,
List<PackerDiagnosticDTO> diagnostics) { List<PackerDiagnosticDTO> diagnostics) {
public PackerPackValidationAssetDTO { 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")); diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
if (blocked && diagnostics.stream().noneMatch(PackerDiagnosticDTO::blocking)) { if (assetName.isBlank()) {
throw new IllegalArgumentException("blocked validation asset must include at least one blocking diagnostic"); 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();
}
} }

View File

@ -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");
}
}
}

View File

@ -1,7 +1,6 @@
package p.packer.messages; package p.packer.messages;
import p.packer.dtos.PackerPackValidationAssetDTO; import p.packer.dtos.PackerPackValidationAssetDTO;
import p.packer.dtos.PackerPackValidationSummaryDTO;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -9,16 +8,18 @@ import java.util.Objects;
public record ValidatePackWorkspaceResult( public record ValidatePackWorkspaceResult(
PackerOperationStatus status, PackerOperationStatus status,
String summary, String summary,
PackerPackValidationSummaryDTO validation,
List<PackerPackValidationAssetDTO> assets) { List<PackerPackValidationAssetDTO> assets) {
public ValidatePackWorkspaceResult { public ValidatePackWorkspaceResult {
Objects.requireNonNull(status, "status"); Objects.requireNonNull(status, "status");
summary = Objects.requireNonNull(summary, "summary").trim(); summary = Objects.requireNonNull(summary, "summary").trim();
Objects.requireNonNull(validation, "validation");
assets = List.copyOf(Objects.requireNonNull(assets, "assets")); assets = List.copyOf(Objects.requireNonNull(assets, "assets"));
if (summary.isBlank()) { if (summary.isBlank()) {
throw new IllegalArgumentException("summary must not be blank"); throw new IllegalArgumentException("summary must not be blank");
} }
} }
public boolean canPack() {
return assets.isEmpty();
}
} }

View File

@ -275,6 +275,9 @@ public enum I18n {
ASSETS_PACK_WIZARD_LABEL_PACKED_ASSETS("assets.packWizard.label.packedAssets"), ASSETS_PACK_WIZARD_LABEL_PACKED_ASSETS("assets.packWizard.label.packedAssets"),
ASSETS_PACK_WIZARD_LABEL_ELAPSED("assets.packWizard.label.elapsed"), ASSETS_PACK_WIZARD_LABEL_ELAPSED("assets.packWizard.label.elapsed"),
ASSETS_PACK_WIZARD_LABEL_EMITTED_ARTIFACTS("assets.packWizard.label.emittedArtifacts"), 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_READY("assets.packWizard.status.ready"),
ASSETS_PACK_WIZARD_STATUS_BLOCKED("assets.packWizard.status.blocked"), ASSETS_PACK_WIZARD_STATUS_BLOCKED("assets.packWizard.status.blocked"),
ASSETS_PACK_WIZARD_STATUS_RUNNING("assets.packWizard.status.running"), ASSETS_PACK_WIZARD_STATUS_RUNNING("assets.packWizard.status.running"),

View File

@ -3,6 +3,7 @@ package p.studio.workspaces.assets.wizards;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
@ -12,6 +13,7 @@ import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.Window; import javafx.stage.Window;
import p.packer.dtos.PackerEmittedArtifactDTO; import p.packer.dtos.PackerEmittedArtifactDTO;
import p.packer.dtos.PackerPackSummaryAssetDTO;
import p.packer.dtos.PackerPackValidationAssetDTO; import p.packer.dtos.PackerPackValidationAssetDTO;
import p.packer.messages.PackWorkspaceRequest; import p.packer.messages.PackWorkspaceRequest;
import p.packer.messages.PackWorkspaceResult; import p.packer.messages.PackWorkspaceResult;
@ -127,7 +129,7 @@ public final class PackWorkspaceWizard {
packButton.setVisible(phase == Phase.VALIDATION); packButton.setVisible(phase == Phase.VALIDATION);
packButton.setManaged(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.setVisible(phase == Phase.RESULT);
copyFailuresButton.setManaged(phase == Phase.RESULT); copyFailuresButton.setManaged(phase == Phase.RESULT);
@ -156,18 +158,52 @@ public final class PackWorkspaceWizard {
} }
stepBody.getChildren().setAll( stepBody.getChildren().setAll(
AssetDetailsUiSupport.createKeyValueRow(
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_CANONICAL_ARTIFACT),
summaryResult.packSummary().canonicalArtifactName()),
AssetDetailsUiSupport.createKeyValueRow( AssetDetailsUiSupport.createKeyValueRow(
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_INCLUDED_ASSETS), Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_INCLUDED_ASSETS),
Integer.toString(summaryResult.packSummary().includedRegisteredAssetCount())), Integer.toString(summaryResult.packSummary().totalIncludedAssetCount())),
AssetDetailsUiSupport.createKeyValueRow( createSummaryAssetsSection(),
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_OUTSIDE_BUILD_SET),
Integer.toString(summaryResult.packSummary().outsideBuildSetAssetCount())),
AssetDetailsUiSupport.createSectionMessage(summaryResult.summary())); 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() { private void renderValidationPhase() {
stepTitle.textProperty().unbind(); stepTitle.textProperty().unbind();
stepDescription.textProperty().unbind(); stepDescription.textProperty().unbind();
@ -185,18 +221,12 @@ public final class PackWorkspaceWizard {
final VBox content = new VBox(12); final VBox content = new VBox(12);
content.getChildren().addAll( 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( AssetDetailsUiSupport.createKeyValueRow(
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_BLOCKED_ASSETS), Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_BLOCKED_ASSETS),
Integer.toString(validationResult.validation().blockedAssetCount())), Integer.toString(validationResult.assets().size())),
AssetDetailsUiSupport.createKeyValueRow( AssetDetailsUiSupport.createKeyValueRow(
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_STATUS), 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_READY)
: Container.i18n().text(I18n.ASSETS_PACK_WIZARD_STATUS_BLOCKED)), : Container.i18n().text(I18n.ASSETS_PACK_WIZARD_STATUS_BLOCKED)),
AssetDetailsUiSupport.createSectionMessage(validationResult.summary())); AssetDetailsUiSupport.createSectionMessage(validationResult.summary()));
@ -220,10 +250,13 @@ public final class PackWorkspaceWizard {
content.getChildren().addAll( content.getChildren().addAll(
AssetDetailsUiSupport.createKeyValueRow( AssetDetailsUiSupport.createKeyValueRow(
Container.i18n().text(I18n.ASSETS_LABEL_NAME), Container.i18n().text(I18n.ASSETS_LABEL_NAME),
asset.asset().identity().assetName()), asset.assetName()),
AssetDetailsUiSupport.createKeyValueRow( AssetDetailsUiSupport.createKeyValueRow(
Container.i18n().text(I18n.ASSETS_LABEL_LOCATION), 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( AssetDetailsUiSupport.createKeyValueRow(
Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_STATUS), Container.i18n().text(I18n.ASSETS_PACK_WIZARD_LABEL_STATUS),
asset.blocked() asset.blocked()
@ -241,7 +274,7 @@ public final class PackWorkspaceWizard {
diagnostic.severity().name() + ": " + diagnostic.message()))); 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); final TitledPane pane = new TitledPane(title, content);
pane.setExpanded(false); pane.setExpanded(false);
return pane; return pane;
@ -372,7 +405,7 @@ public final class PackWorkspaceWizard {
private void applyValidationResult(ValidatePackWorkspaceResult result) { private void applyValidationResult(ValidatePackWorkspaceResult result) {
loadingValidation = false; loadingValidation = false;
validationResult = result; validationResult = result;
if (!result.validation().canPack()) { if (!result.canPack()) {
feedbackLabel.setText(result.summary()); feedbackLabel.setText(result.summary());
} else { } else {
feedbackLabel.setText(""); feedbackLabel.setText("");
@ -387,7 +420,7 @@ public final class PackWorkspaceWizard {
} }
private void startPack() { private void startPack() {
if (validationResult == null || !validationResult.validation().canPack() || packing) { if (validationResult == null || !validationResult.canPack() || packing) {
return; return;
} }
phase = Phase.PACKING; phase = Phase.PACKING;

View File

@ -266,6 +266,9 @@ assets.packWizard.label.status=Status
assets.packWizard.label.packedAssets=Packed Assets assets.packWizard.label.packedAssets=Packed Assets
assets.packWizard.label.elapsed=Elapsed assets.packWizard.label.elapsed=Elapsed
assets.packWizard.label.emittedArtifacts=Emitted Artifacts 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.ready=Ready to pack
assets.packWizard.status.blocked=Validation blocked assets.packWizard.status.blocked=Validation blocked
assets.packWizard.status.running=Packing in progress assets.packWizard.status.running=Packing in progress