Sfoglia il codice sorgente

allow deleting dependencies with exclusions

tags/2.0.1
Jonathan Cobb 4 anni fa
parent
commit
1310753e0e
2 ha cambiato i file con 10 aggiunte e 7 eliminazioni
  1. +2
    -5
      wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/EntityFieldReference.java
  2. +8
    -2
      wizard-server/src/main/java/org/cobbzilla/wizard/server/config/PgRestServerConfiguration.java

+ 2
- 5
wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/EntityFieldReference.java Vedi File

@@ -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) {


+ 8
- 2
wizard-server/src/main/java/org/cobbzilla/wizard/server/config/PgRestServerConfiguration.java Vedi File

@@ -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<Class<? extends Identifiable>> 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());


Caricamento…
Annulla
Salva