diff --git a/agrest-cayenne/src/main/java/io/agrest/cayenne/processor/delete/stage/CayenneDeleteStartStage.java b/agrest-cayenne/src/main/java/io/agrest/cayenne/processor/delete/stage/CayenneDeleteStartStage.java index 344d31337..541fe919d 100644 --- a/agrest-cayenne/src/main/java/io/agrest/cayenne/processor/delete/stage/CayenneDeleteStartStage.java +++ b/agrest-cayenne/src/main/java/io/agrest/cayenne/processor/delete/stage/CayenneDeleteStartStage.java @@ -1,7 +1,6 @@ package io.agrest.cayenne.processor.delete.stage; import io.agrest.cayenne.persister.ICayennePersister; -import io.agrest.meta.AgSchema; import io.agrest.processor.ProcessingContext; import io.agrest.processor.ProcessorOutcome; import io.agrest.runtime.processor.delete.DeleteContext; @@ -26,8 +25,7 @@ public static ObjectContext cayenneContext(ProcessingContext context) { private final ICayennePersister persister; - public CayenneDeleteStartStage(@Inject AgSchema schema, @Inject ICayennePersister persister) { - super(schema); + public CayenneDeleteStartStage(@Inject ICayennePersister persister) { this.persister = persister; } diff --git a/agrest-engine/src/main/java/io/agrest/runtime/AgRuntime.java b/agrest-engine/src/main/java/io/agrest/runtime/AgRuntime.java index 7d66d5844..a0be30320 100644 --- a/agrest-engine/src/main/java/io/agrest/runtime/AgRuntime.java +++ b/agrest-engine/src/main/java/io/agrest/runtime/AgRuntime.java @@ -180,7 +180,7 @@ public UnrelateBuilder unrelate(Class type) { * @since 5.0 */ public DeleteBuilder delete(Class type) { - DeleteContext context = new DeleteContext<>(type, injector); + DeleteContext context = new DeleteContext<>(type, new RequestSchema(schema), injector); return new DefaultDeleteBuilder<>(context, deleteProcessorFactory); } diff --git a/agrest-engine/src/main/java/io/agrest/runtime/DefaultDeleteBuilder.java b/agrest-engine/src/main/java/io/agrest/runtime/DefaultDeleteBuilder.java index 0e7a7e524..c5376a818 100644 --- a/agrest-engine/src/main/java/io/agrest/runtime/DefaultDeleteBuilder.java +++ b/agrest-engine/src/main/java/io/agrest/runtime/DefaultDeleteBuilder.java @@ -58,7 +58,7 @@ public DeleteBuilder parent(Class parentType, Map parentId @Override public DeleteBuilder entityOverlay(AgEntityOverlay overlay) { - context.addEntityOverlay(overlay); + context.getSchema().addOverlay(overlay); return this; } diff --git a/agrest-engine/src/main/java/io/agrest/runtime/processor/delete/DeleteContext.java b/agrest-engine/src/main/java/io/agrest/runtime/processor/delete/DeleteContext.java index e09d8f5c5..10b61adf8 100644 --- a/agrest-engine/src/main/java/io/agrest/runtime/processor/delete/DeleteContext.java +++ b/agrest-engine/src/main/java/io/agrest/runtime/processor/delete/DeleteContext.java @@ -1,10 +1,10 @@ package io.agrest.runtime.processor.delete; import io.agrest.id.AgObjectId; -import io.agrest.runtime.EntityParent; import io.agrest.meta.AgEntity; -import io.agrest.meta.AgEntityOverlay; import io.agrest.processor.BaseProcessingContext; +import io.agrest.runtime.EntityParent; +import io.agrest.runtime.meta.RequestSchema; import io.agrest.runtime.processor.update.ChangeOperation; import org.apache.cayenne.di.Injector; @@ -18,14 +18,15 @@ */ public class DeleteContext extends BaseProcessingContext { + private final RequestSchema schema; protected AgEntity agEntity; protected Collection ids; protected EntityParent parent; - protected AgEntityOverlay entityOverlay; private List> deleteOperations; - public DeleteContext(Class type, Injector injector) { + public DeleteContext(Class type, RequestSchema schema, Injector injector) { super(type, injector); + this.schema = schema; this.deleteOperations = Collections.emptyList(); } @@ -66,21 +67,6 @@ public AgEntity getAgEntity() { return agEntity; } - /** - * @since 4.8 - */ - public void addEntityOverlay(AgEntityOverlay overlay) { - AgEntityOverlay base = this.entityOverlay != null ? this.entityOverlay : new AgEntityOverlay<>(getType()); - this.entityOverlay = base.merge(overlay); - } - - /** - * @since 4.8 - */ - public AgEntityOverlay getEntityOverlay() { - return entityOverlay; - } - /** * @since 4.8 */ @@ -94,4 +80,11 @@ public List> getDeleteOperations() { public void setDeleteOperations(List> deleteOperations) { this.deleteOperations = deleteOperations; } + + /** + * @since 5.0 + */ + public RequestSchema getSchema() { + return schema; + } } diff --git a/agrest-engine/src/main/java/io/agrest/runtime/processor/delete/stage/DeleteStartStage.java b/agrest-engine/src/main/java/io/agrest/runtime/processor/delete/stage/DeleteStartStage.java index 15ba8ca7a..3352dab5d 100644 --- a/agrest-engine/src/main/java/io/agrest/runtime/processor/delete/stage/DeleteStartStage.java +++ b/agrest-engine/src/main/java/io/agrest/runtime/processor/delete/stage/DeleteStartStage.java @@ -1,24 +1,15 @@ package io.agrest.runtime.processor.delete.stage; -import io.agrest.meta.AgSchema; import io.agrest.meta.AgEntity; -import io.agrest.meta.AgEntityOverlay; import io.agrest.processor.Processor; import io.agrest.processor.ProcessorOutcome; import io.agrest.runtime.processor.delete.DeleteContext; -import org.apache.cayenne.di.Inject; /** * @since 5.0 */ public class DeleteStartStage implements Processor> { - private final AgSchema schema; - - public DeleteStartStage(@Inject AgSchema schema) { - this.schema = schema; - } - @Override public ProcessorOutcome execute(DeleteContext context) { initAgEntity(context); @@ -26,8 +17,7 @@ public ProcessorOutcome execute(DeleteContext context) { } protected void initAgEntity(DeleteContext context) { - AgEntityOverlay overlay = context.getEntityOverlay(); - AgEntity entity = schema.getEntity(context.getType()); - context.setAgEntity(entity.resolveOverlay(schema, overlay)); + AgEntity entity = context.getSchema().getEntity(context.getType()); + context.setAgEntity(entity); } }