Revision 45482 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultTransaction.java

View differences:

DefaultTransaction.java
27 27
import java.util.List;
28 28
import java.util.Set;
29 29
import java.util.UUID;
30
import org.gvsig.fmap.dal.DataServerExplorer;
30 31
import org.gvsig.fmap.dal.DataStore;
31 32
import org.gvsig.fmap.dal.DataTransaction;
32 33
import org.gvsig.fmap.dal.exception.DataException;
33 34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import static org.gvsig.fmap.dal.feature.FeatureStore.MODE_QUERY;
34 36
import org.gvsig.tools.dispose.Disposable;
35 37
import org.gvsig.tools.dispose.DisposeUtils;
36 38

  
......
43 45

  
44 46
    private final String code;
45 47
    private Set<DataStore> stores;
48
    private Set<DataServerExplorer> explorers;
46 49
    private boolean inProgress;
47 50
    private List<Disposable> disposables;
48 51

  
49 52
    public DefaultTransaction() {
50 53
        this.code = UUID.randomUUID().toString().replace("-", "");
51 54
        this.stores = new HashSet<>();
55
        this.explorers = new HashSet<>();
52 56
        this.disposables = new ArrayList<>();
53 57
        this.inProgress = false;
54 58
    }
......
71 75
        for (DataStore store : stores) {
72 76
            if( store instanceof FeatureStore ) {
73 77
                FeatureStore fstore = (FeatureStore) store;
74
                if( fstore.isAppending() || fstore.isEditing() ) {
78
                if( fstore.getMode() != MODE_QUERY) {
75 79
                    fstore.finishEditing();
76 80
                }
77 81
            }
......
87 91
        for (DataStore store : stores) {
88 92
            if( store instanceof FeatureStore ) {
89 93
                FeatureStore fstore = (FeatureStore) store;
90
                if( fstore.isAppending() || fstore.isEditing() ) {
94
                if( fstore.getMode() != MODE_QUERY) {
91 95
                    fstore.cancelEditing();
92 96
                }
93 97
            }
......
106 110

  
107 111
    @Override
108 112
    public void add(DataStore store) {
113
        add(store, true);
114
    }
115

  
116
    @Override
117
    public void add(DataStore store, boolean local) {
118
        if(this.stores.contains(store)){
119
            return;
120
        }
109 121
//        if( !store.setTransaction(this) ) {
110 122
//            throw new IllegalStateException("Can't add store to transaction.");
111 123
//        }
112
        DisposeUtils.bind(store);
124
        if(!local){
125
            DisposeUtils.bind(store);
126
        }
113 127
        this.stores.add(store);
114 128
    }
115 129

  
116 130
    @Override
131
    public void add(DataServerExplorer explorer) {
132
        add(explorer, true);
133
    }
134

  
135
    @Override
136
    public void add(DataServerExplorer explorer, boolean local) {
137
        if(this.explorers.contains(explorer)){
138
            return;
139
        }
140
//        if( !explorer.setTransaction(this) ) {
141
//            throw new IllegalStateException("Can't add explorer to transaction.");
142
//        }
143
        if(!local){
144
            DisposeUtils.bind(explorer);
145
        }
146
        this.explorers.add(explorer);
147
    }
148

  
149
    @Override
117 150
    public void add(Disposable resource) throws DataException {
118 151
        this.disposables.add(resource);
119 152
    }
......
143 176
            DisposeUtils.disposeQuietly(store);
144 177
            
145 178
        }
179
        for (DataServerExplorer explorer : explorers) {
180
//            store.setTransaction(null);
181
            DisposeUtils.disposeQuietly(explorer);
182
            
183
        }
146 184
        for (Disposable resource : disposables) {
147 185
//            store.setTransaction(null);
148 186
            DisposeUtils.disposeQuietly(resource);

Also available in: Unified diff