diff --git a/wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/EntityFieldReference.java b/wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/EntityFieldReference.java index aab7fc2..31d9680 100644 --- a/wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/EntityFieldReference.java +++ b/wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/EntityFieldReference.java @@ -1,9 +1,6 @@ package org.cobbzilla.wizard.model.entityconfig; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.*; import static org.cobbzilla.util.daemon.ZillaRuntime.empty; @@ -11,7 +8,7 @@ import static org.cobbzilla.util.daemon.ZillaRuntime.empty; * When the EntityFieldType of a field is 'reference', this object is also attached to the field to describe * how to reach the reference. */ -@NoArgsConstructor @EqualsAndHashCode(of={"entity", "field"}) +@NoArgsConstructor @EqualsAndHashCode(of={"entity", "field"}) @ToString(of={"entity", "field"}) public class EntityFieldReference { public EntityFieldReference (String entity, String field) { diff --git a/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/PgRestServerConfiguration.java b/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/PgRestServerConfiguration.java index e9b13e1..394658a 100644 --- a/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/PgRestServerConfiguration.java +++ b/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/PgRestServerConfiguration.java @@ -46,7 +46,7 @@ import static org.cobbzilla.util.system.CommandShell.execScript; import static org.cobbzilla.wizard.model.entityconfig.EntityReferences.getDependencyRefs; import static org.cobbzilla.wizard.model.entityconfig.EntityReferences.getDependentEntities; -@Slf4j +@Slf4j @SuppressWarnings("SpringConfigurationProxyMethods") public class PgRestServerConfiguration extends RestServerConfiguration implements HasDatabaseConfiguration { public static final String ENV_PGPASSWORD = "PGPASSWORD"; @@ -356,9 +356,15 @@ public class PgRestServerConfiguration extends RestServerConfiguration implement return dependencyDAOCache.computeIfAbsent(entityClass, c -> getDependencyRefs(c, getDependencies(c))); } - public void deleteDependencies (Identifiable thing) { + public void deleteDependencies (Identifiable thing) { deleteDependencies(thing, null); } + + public void deleteDependencies (Identifiable thing, Collection> excludes) { dependencyRefs(thing.getClass()).forEach( dep -> { + if (excludes != null && excludes.stream().anyMatch(depClass -> depClass.getName().equals(dep.getEntity()))) { + log.debug("deleteDependencies("+thing+"): excluding: "+dep); + return; + } final DAO dao = getDaoForEntityClass(dep.getEntity()); if (dao instanceof AbstractCRUDDAO) { ((AbstractCRUDDAO) dao).bulkDelete(dep.getField(), thing.getUuid());