fix #495: add schema preflight and DDL details
This commit is contained in:
@@ -4,6 +4,11 @@ public record SchemaActionResult(
|
||||
String objectName,
|
||||
String action,
|
||||
String status,
|
||||
String message
|
||||
String message,
|
||||
String sqlText
|
||||
) {
|
||||
|
||||
public SchemaActionResult(String objectName, String action, String status, String message) {
|
||||
this(objectName, action, status, message, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.cloudhandson.vpdbackoffice.domain.schema;
|
||||
|
||||
public record SchemaPreflightCheck(
|
||||
String layer,
|
||||
String itemName,
|
||||
String objectType,
|
||||
String status,
|
||||
String detail,
|
||||
String nextAction,
|
||||
boolean sqlclRequired
|
||||
) {
|
||||
|
||||
public boolean ok() {
|
||||
return "OK".equalsIgnoreCase(status);
|
||||
}
|
||||
|
||||
public boolean warning() {
|
||||
return "WARN".equalsIgnoreCase(status);
|
||||
}
|
||||
|
||||
public boolean missing() {
|
||||
return "MISSING".equalsIgnoreCase(status);
|
||||
}
|
||||
|
||||
public boolean error() {
|
||||
return "ERROR".equalsIgnoreCase(status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.cloudhandson.vpdbackoffice.domain.schema;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record SchemaPreflightView(
|
||||
String currentUser,
|
||||
String recommendedOrdsSchema,
|
||||
List<SchemaPreflightCheck> checks,
|
||||
String appDdlPreview,
|
||||
String sqlclScript
|
||||
) {
|
||||
|
||||
public long okCount() {
|
||||
return count("OK");
|
||||
}
|
||||
|
||||
public long warnCount() {
|
||||
return count("WARN");
|
||||
}
|
||||
|
||||
public long missingCount() {
|
||||
return count("MISSING");
|
||||
}
|
||||
|
||||
public long errorCount() {
|
||||
return count("ERROR");
|
||||
}
|
||||
|
||||
public boolean hasActionNeeded() {
|
||||
return warnCount() + missingCount() + errorCount() > 0;
|
||||
}
|
||||
|
||||
private long count(String status) {
|
||||
return checks.stream()
|
||||
.filter(check -> status.equalsIgnoreCase(check.status()))
|
||||
.count();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user