01: /**********************************************************************
02: Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15: Contributors:
16: ...
17: **********************************************************************/package org.jpox.sco.queued;
18:
19: import org.jpox.StateManager;
20: import org.jpox.store.scostore.CollectionStore;
21: import org.jpox.store.scostore.MapStore;
22: import org.jpox.store.scostore.Store;
23:
24: /**
25: * Remove operation for a collection or map.
26: *
27: * @version $Revision: 1.4 $
28: */
29: public class RemoveOperation implements QueuedOperation {
30: /** The value to remove. */
31: Object value;
32:
33: /** Whether to allow cascade-delete checks. */
34: boolean allowCascadeDelete = true;
35:
36: /**
37: * Constructor.
38: * @param value The value to remove
39: */
40: public RemoveOperation(Object value) {
41: this .value = value;
42: }
43:
44: /**
45: * Constructor, specifying whether cascade delete should be allowed.
46: * @param value The value to remove
47: * @param allowCascadeDelete Whether to allow cascade delete
48: */
49: public RemoveOperation(Object value, boolean allowCascadeDelete) {
50: this (value);
51: this .allowCascadeDelete = allowCascadeDelete;
52: }
53:
54: /**
55: * Perform the remove(Object) operation on the specified container.
56: * @param store The backing store to perform it on
57: * @param sm StateManager for the owner of the container
58: */
59: public void perform(Store store, StateManager sm) {
60: if (store instanceof CollectionStore) {
61: ((CollectionStore) store).remove(sm, value, -1,
62: allowCascadeDelete);
63: } else if (store instanceof MapStore) {
64: ((MapStore) store).remove(sm, value);
65: }
66: }
67: }
|