Revision 24017

View differences:

branches/v2_0_0_prep/libraries/libFMap_data/.classpath
5 5
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6 6
	<classpathentry kind="lib" path="lib/log4j-1.2.8.jar"/>
7 7
	<classpathentry kind="lib" path="lib/iver-utiles.jar"/>
8
	<classpathentry kind="lib" path="lib/org.gvsig.tools.jar"/>
9 8
	<classpathentry combineaccessrules="false" kind="src" path="/libMetadata"/>
10 9
	<classpathentry combineaccessrules="false" kind="src" path="/libFMap_geometries"/>
11 10
	<classpathentry kind="lib" path="lib/org.cresques.cts.jar"/>
......
14 13
	<classpathentry kind="lib" path="lib/easymock-1.2_Java1.3.jar"/>
15 14
	<classpathentry kind="lib" path="lib/slf4j-api-1.5.0.jar"/>
16 15
	<classpathentry kind="lib" path="lib/slf4j-log4j12-1.5.0.jar"/>
16
	<classpathentry combineaccessrules="false" kind="src" path="/libTools"/>
17 17
	<classpathentry kind="output" path="bin"/>
18 18
</classpath>
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataExplorer.java
10 10

  
11 11
	public boolean canCreate();
12 12

  
13
	public List list() throws DataException;
13
	public List list() throws DataException; // List of DataStoreParameter
14 14

  
15
	public boolean add(DataStoreParameters ndsp) throws DataException;
15
	public boolean add(DataStoreParameters parameters)
16
			throws DataException;
16 17

  
17
	void remove(DataStoreParameters dsp) throws DataException;
18
	void remove(DataStoreParameters parameters) throws DataException;
18 19

  
20
	public DataStoreParameters getCreationParameters(String storeName);
21

  
19 22
	public void dispose() throws DataException;
20 23

  
21 24
	public DataExplorerParameters getParameters();
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataManager.java
1 1
package org.gvsig.fmap.data;
2 2

  
3
import java.util.List;
4

  
3 5
import org.gvsig.fmap.data.exceptions.InitializeException;
4 6
import org.gvsig.fmap.data.exceptions.ProviderNotRegisteredException;
5
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
6
import org.gvsig.fmap.data.feature.FeatureStore;
7
import org.gvsig.fmap.data.feature.FeatureType;
8
import org.gvsig.fmap.data.feature.spi.index.FeatureIndexProviderServices;
9 7
import org.gvsig.tools.evaluator.Evaluator;
10
import org.gvsig.tools.operations.Operation;
11 8

  
12 9
import com.iver.utiles.XMLEntity;
13 10

  
14 11
public interface DataManager {
15 12

  
13

  
14
	public List getDataStoreProviders();
15

  
16
	public List getDataExplorerProviders();
17

  
16 18
	/**
19
	 * Returns an array of index provider names that are compatible with the
20
	 * given data type.
17 21
	 *
18
	 * @param String
19
	 *            name
20
	 * @param Class
21
	 *            dataStoreClass
22
	 * @param Class
23
	 *            parametersClass
22
	 * @param dataType
23
	 * @return list of strings with the names of compatible index providers
24 24
	 */
25
	public List getDataIndexProviders(int dataType);
25 26

  
26
	public void registerDefaultEvaluator(Class evaluator);
27 27

  
28
	public Evaluator createExpresion(String expresion);
29 28

  
30
	public void registerDataStoreProvider(String name, Class dataStoreProviderClass,
31
			Class parametersClass);
32 29

  
33 30
	/**
34
	 * Levanta una instancia de los parametros solicitados inicializa el nombre
35
	 * en la instancia y la devuelve.
36
	 *
37
	 * @throws InitializeException
38
	 *             TODO
39
	 **/
40
	/**
41 31
	 * Start a instance of the solicited parameters inicialize the instance name
42 32
	 * and returns it.
43 33
	 *
......
55 45
			throws InitializeException, ProviderNotRegisteredException;
56 46

  
57 47
	/**
58
	 * Levanta la instancia del datasource,
59
	 * levanta una instancia del driver que precisa el datasource
60
	 * y por ultimo invoca al metodo init del datasource.
61
	 * @throws InitializeException
62
	 **/
63
	/**
64
	 * Start a instance of datasource, start a instance of driver that
65
	 * datasource needs at ends invoke datasource init method
48
	 * Start a instance of data store, start a instance of provider that data
49
	 * store needs at ends initialize the data store.
66 50
	 *
67 51
	 * @params DataStoreParameters parameters
68 52
	 * @throws InitializeException
......
75 59
			throws InitializeException, ProviderNotRegisteredException;
76 60

  
77 61
	/**
78
	 * Collection of generic properties of a DataStore type which can access
79
	 * without create a DataStore/Driver.
80
	 *
81
	 * For example for "DriverDataSource.shp" could have the size of the data
82
	 * identification.
83
	 *
84
	 * In "DriverDataSource.postgres" could add information about availables
85
	 * tables or things like that. We`ll have to see what GeoDB needs and where
86
	 * it can get.
87
	 *
88
	 * We have to think it good.
89
	 */
90
	/**
91
	 * @param String name
92
	 * @param Class dataSourceClass
93
	 * @param Class parametersClass
94
	 */
95

  
96
	public void registerDataExplorer(String name,
97
			Class dataSourceClass, Class parametersClass);
98

  
99
	/**
100
	 * Levanta una instancia de los parametros solicitados
101
	 * inicializa el nombre en la instancia
102
	 * y la devuelve.
103
	 * @throws InitializeException TODO
104
	 **/
105
	/**
106 62
	 * Start a instance with solicited parameters starts name in the instance
107 63
	 * and returns it.
108 64
	 *
109 65
	 * @param String
110 66
	 *            name
111 67
	 * @throws InitializeException
112
	 *             TODO
113 68
	 * @throws ProviderNotRegisteredException
114 69
	 **/
115 70

  
......
117 72
			String name)
118 73
			throws InitializeException, ProviderNotRegisteredException;
119 74

  
120
	/**
121
	 *
122
	 * @param DataExplorerParameters
123
	 *            parameters
124
	 * @return DataExplorer
125
	 * @throws InitializeException
126
	 * @throws ProviderNotRegisteredException
127
	 */
128

  
129 75
	public DataExplorerParameters createDataExplorerParameters(
130 76
			XMLEntity xmlEntity) throws InitializeException,
131 77
			ProviderNotRegisteredException;
132 78

  
79

  
80

  
133 81
	public DataExplorer createDataExplorer(
134 82
			DataExplorerParameters parameters)
135 83
			throws InitializeException, ProviderNotRegisteredException;
136 84

  
137
	/**
138
	 * 
139
	 * @param String
140
	 *            name
141
	 * @return RegisterInfo
142
	 * @throws ProviderNotRegisteredException
143
	 */
144

  
145 85
	public DataExplorer createDataExplorer(XMLEntity xmlEntity)
146 86
			throws InitializeException, ProviderNotRegisteredException;
147 87

  
148
	/**
149
	 *
150
	 * @param String
151
	 *            storeName
152
	 * @param String
153
	 *            operationName
154
	 * @param DataStoreOperation
155
	 *            operation
156
	 * @return int index
157
	 * @throws IllegalArgumentException
158
	 */
159 88

  
160
	public int registerDataStoreOperation(String storeName,
161
			String operationName, Operation operation);
162

  
163 89
	/**
164
	 *
165
	 * @return String[] TYPE_STORE
166
	 */
167

  
168
	public String[] getRegistersStores();
169

  
170
	/**
171
	 *
172
	 * @return String[] TYPE_EXPLORER
173
	 */
174

  
175
	public String[] getRegistersExplorers();
176
	
177
	/**
178
	 * Returns an array of index provider names that are compatible with
179
	 * the given data type.
180
	 * 
181
	 * @param dataType
182
	 * @return list of strings with the names of compatible index providers
183
	 */
184
	public String[] getDataIndexProviders(int dataType);
185

  
186
	/**
187
	 * Registers a new DataIndexProvider
188
	 * @param name identifier
189
	 * @param description a brief description of the provider
190
	 * @param clazz implementation class
191
	 */
192
	public void registerDataIndexProvider(String name, String description, Class clazz);
193
	
194
	/**
195
	 * Returns a DataIndexProvider compatible with the attribute data type.
196
	 * @param store associated FeatureStore
197
	 * @param type associated FeatureType 
198
	 * @param attr associated FeatureAttributeDescriptor
199
	 * @param providerNames array of strings containing one or more preferred providers
200
	 * @return empty DataIndexProvider, initialized and ready to use
201
	 */
202
	public FeatureIndexProviderServices createDataIndexProvider(FeatureStore store, FeatureType type, 
203
			FeatureAttributeDescriptor attr, String[] providerNames) throws InitializeException, ProviderNotRegisteredException;
204

  
205
	/**
206
	 * Returns the default DataIndexProvider compatible with the attribute data type.
207
	 * @param store associated FeatureStore
208
	 * @param type associated FeatureType 
209
	 * @param attr associated FeatureAttributeDescriptor
210
	 * @return
211
	 */
212
	public FeatureIndexProviderServices createDataIndexProvider(FeatureStore store, FeatureType type,
213
			FeatureAttributeDescriptor attr) throws InitializeException, ProviderNotRegisteredException;
214
	
215
	/**
216 90
	 * Sets the default DataIndexProvider for the given data type.
217 91
	 * @param dataType one of the data types defined in the api package
218 92
	 * @param name Provider's name
219 93
	 */
220 94
    public void setDefaultDataIndexProviderName(int dataType, String name);
221
    
95

  
222 96
    /**
223 97
     * Returns the default DataIndexProvider name, given a data type.
224 98
     * @param dataType
225 99
     * @return
226 100
     */
227 101
    public String getDefaultDataIndexProviderName(int dataType);
228
   
102

  
229 103
    /**
230 104
     * Returns the default DAL's temporary directory
231 105
     * @return Temporary directory name
232 106
     */
233
    public String getTemporaryDirectory();	
107
    public String getTemporaryDirectory();
234 108

  
109

  
110
	public void registerDefaultEvaluator(Class evaluator);
111

  
112
	public Evaluator createExpresion(String expresion);
113

  
114

  
235 115
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/FeatureEvaluator.java
1
package org.gvsig.fmap.data.feature;
2

  
3
import org.gvsig.tools.evaluator.Evaluator;
4

  
5
public interface FeatureEvaluator extends Evaluator {
6

  
7
	/**
8
	 * Devuelve los datos necesarios para aplicar un indice sobre el attributo
9
	 * 'attributeName'.
10
	 *
11
	 * Si el attributo 'attributeName' no es usado por el evaluador retornara
12
	 * null.
13
	 *
14
	 * @param attributeName
15
	 * @return null si no es aplicable indice sobre el attributo indicado para
16
	 *         ese evaluador, y el valor del attributo en el evaluador en caso
17
	 *         de que sea aplicable un indice sobre el.
18
	 */
19
	public Object getIndexData(String attributeName);
20
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/FeatureStoreParameters.java
1
package org.gvsig.fmap.data.feature;
2

  
3
import org.gvsig.fmap.data.DataStoreParameters;
4

  
5
public abstract class FeatureStoreParameters extends DataStoreParameters {
6

  
7
	public void setDefaultFeatureType(FeatureType defaultFeatureType) {
8
		// TODO Auto-generated method stub
9

  
10
	}
11

  
12
}
0 13

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/exceptions/FeatureTypeNotAllowedForThisStoreException.java
1
package org.gvsig.fmap.data.feature.exceptions;
2

  
3
import org.gvsig.fmap.data.exceptions.DataException;
4

  
5
public class FeatureTypeNotAllowedForThisStoreException extends DataException {
6

  
7
	/**
8
	 *
9
	 */
10
	private static final long serialVersionUID = -3151888912258726109L;
11
	private final static String MESSAGE_FORMAT = "Feature type not allowed for the store '%(store)s'.";
12
	private final static String MESSAGE_KEY = "_FeatureTypeNotAllowedForThisStoreException";
13

  
14
	public FeatureTypeNotAllowedForThisStoreException(String store) {
15
		super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID);
16
		setValue("store", store);
17
	}
18
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/exceptions/FeatureNotAllowedForThisStoreException.java
1
package org.gvsig.fmap.data.feature.exceptions;
2

  
3
import org.gvsig.fmap.data.exceptions.DataException;
4

  
5
public class FeatureNotAllowedForThisStoreException extends DataException {
6

  
7
	/**
8
	 *
9
	 */
10
	private static final long serialVersionUID = 1367845204038351116L;
11
	private final static String MESSAGE_FORMAT = "Feature not allowed for the store '%(store)s'.";
12
	private final static String MESSAGE_KEY = "_FeatureNotAllowedForThisStoreException";
13

  
14
	public FeatureNotAllowedForThisStoreException(String store) {
15
		super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID);
16
		setValue("store", store);
17
	}
18
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/exceptions/IllegalFeatureTypeException.java
1
package org.gvsig.fmap.data.feature.exceptions;
2

  
3
import org.gvsig.fmap.data.exceptions.DataException;
4

  
5
public class IllegalFeatureTypeException extends DataException {
6

  
7
	/**
8
	 *
9
	 */
10
	private static final long serialVersionUID = -3151888912258726109L;
11
	private final static String MESSAGE_FORMAT = "Feature type not allowed for the store '%(store)s'.";
12
	private final static String MESSAGE_KEY = "_IllegalFeatureTypeException";
13

  
14
	public IllegalFeatureTypeException(String store) {
15
		super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID);
16
		setValue("store", store);
17
	}
18
}
0 19

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/exceptions/IllegalFeatureException.java
1
package org.gvsig.fmap.data.feature.exceptions;
2

  
3
import org.gvsig.fmap.data.exceptions.DataException;
4

  
5
public class IllegalFeatureException extends DataException {
6

  
7
	/**
8
	 *
9
	 */
10
	private static final long serialVersionUID = 1367845204038351116L;
11
	private final static String MESSAGE_FORMAT = "Feature not allowed for the store '%(store)s'.";
12
	private final static String MESSAGE_KEY = "_IllegalFeatureException";
13

  
14
	public IllegalFeatureException(String store) {
15
		super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID);
16
		setValue("store", store);
17
	}
18
}
0 19

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/FeatureStore.java
182 182

  
183 183
	public void validateFeatures(int mode) throws DataException;
184 184

  
185
	public void export(FeatureExplorer explorer, DataStoreParameters params)
185
	public void export(FeatureExplorer explorer, FeatureStoreParameters params)
186 186
			throws DataException;
187 187

  
188 188
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/FeatureExplorer.java
1 1
package org.gvsig.fmap.data.feature;
2 2

  
3 3
import org.gvsig.fmap.data.DataExplorer;
4
import org.gvsig.fmap.data.DataStoreParameters;
5
import org.gvsig.fmap.data.exceptions.DataException;
6 4

  
7 5
public interface FeatureExplorer extends DataExplorer{
8 6

  
9 7

  
10
	FeatureType[] getFeatureTypes(DataStoreParameters dsp) throws DataException;
11

  
12
	public boolean add(DataStoreParameters params, FeatureType type)
13
			throws DataException;
14

  
15 8
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/DefaultFeatureStore.java
33 33
import org.gvsig.fmap.data.feature.FeatureSet;
34 34
import org.gvsig.fmap.data.feature.FeatureStore;
35 35
import org.gvsig.fmap.data.feature.FeatureStoreNotification;
36
import org.gvsig.fmap.data.feature.FeatureStoreParameters;
36 37
import org.gvsig.fmap.data.feature.FeatureType;
37 38
import org.gvsig.fmap.data.feature.exceptions.AlreadyEditingException;
38 39
import org.gvsig.fmap.data.feature.exceptions.ConcurrentDataModificationException;
39 40
import org.gvsig.fmap.data.feature.exceptions.CreateFeatureException;
40 41
import org.gvsig.fmap.data.feature.exceptions.DataExportException;
41 42
import org.gvsig.fmap.data.feature.exceptions.DataIndexException;
42
import org.gvsig.fmap.data.feature.exceptions.FeatureNotAllowedForThisStoreException;
43
import org.gvsig.fmap.data.feature.exceptions.FeatureTypeNotAllowedForThisStoreException;
43
import org.gvsig.fmap.data.feature.exceptions.IllegalFeatureException;
44
import org.gvsig.fmap.data.feature.exceptions.IllegalFeatureTypeException;
44 45
import org.gvsig.fmap.data.feature.exceptions.FinishEditingException;
45 46
import org.gvsig.fmap.data.feature.exceptions.GetFeatureTypeException;
46 47
import org.gvsig.fmap.data.feature.exceptions.NeedEditingModeException;
......
574 575
	}
575 576

  
576 577
	private void checkIsOwnFeature(Feature feature)
577
			throws FeatureNotAllowedForThisStoreException {
578
			throws IllegalFeatureException {
578 579
		if (((DefaultFeature) feature).getStore() != this) {
579
			throw new FeatureNotAllowedForThisStoreException(this.getName());
580
			throw new IllegalFeatureException(this.getName());
580 581
		}
581 582
		// FIXME: fixFeatureType no vale para el checkIsOwnFeature
582 583
		// fixFeatureType((DefaultFeatureType) feature.getType());
......
789 790
		// notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING);
790 791
	}
791 792

  
792
	public void export(FeatureExplorer explorer, DataStoreParameters params)
793
	public void export(FeatureExplorer explorer, FeatureStoreParameters params)
793 794
			throws DataException {
794 795

  
795 796
		if (this.getFeatureTypes().size() != 1) {
......
798 799
		}
799 800
		try {
800 801
			FeatureType type = this.getDefaultFeatureType();
801
			explorer.add(params, type);
802
			params.setDefaultFeatureType(type);
803
			explorer.add(params);
802 804

  
803 805
			DataManager manager = DALLocator.getDataManager();
804 806
			FeatureStore target = (FeatureStore) manager
......
958 960
			}
959 961

  
960 962
		}
961
		throw new FeatureTypeNotAllowedForThisStoreException(getName());
963
		throw new IllegalFeatureTypeException(getName());
962 964
	}
963 965

  
964 966
	public void validateFeatures(int mode) throws DataException {
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/DefaultFeatureIndexes.java
27 27

  
28 28
package org.gvsig.fmap.data.feature.impl;
29 29

  
30
import java.util.ArrayList;
30 31
import java.util.HashMap;
31 32
import java.util.Iterator;
33
import java.util.List;
32 34
import java.util.Map;
33 35

  
34 36
import org.gvsig.fmap.data.exceptions.DataException;
35 37
import org.gvsig.fmap.data.feature.FeatureIndex;
36 38
import org.gvsig.fmap.data.feature.FeatureIndexes;
37
import org.gvsig.fmap.data.feature.FeatureStore;
38 39
import org.gvsig.fmap.data.feature.FeatureType;
40
import org.gvsig.fmap.data.feature.spi.FeatureSetProvider;
39 41
import org.gvsig.fmap.data.feature.spi.index.FeatureIndexProviderServices;
42
import org.gvsig.tools.evaluator.Evaluator;
43
import org.gvsig.tools.evaluator.EvaluatorFieldValue;
40 44

  
41 45
/**
42 46
 * This class provides access to a FeatureStore local indexes either by
......
47 51

  
48 52
	// Access by FeatureType and attribute name
49 53
	private Map featureTypes = new HashMap();
50
	
54

  
51 55
	// Access by DataIndex name
52 56
	private Map names = new HashMap();
53 57

  
58
	private DefaultFeatureStore store;
59

  
54 60
	/**
55 61
	 * Creates an empty DataIndexes for the given FeatureStore
56
	 * 
62
	 *
57 63
	 * @param store
58 64
	 *            FeatureStore to whom this belongs
59 65
	 * @throws DataException
60 66
	 */
61
	public DefaultFeatureIndexes(FeatureStore store) throws DataException {
67
	public DefaultFeatureIndexes(DefaultFeatureStore store)
68
			throws DataException {
69
		this.store = store;
62 70
		Iterator it = store.getFeatureTypes().iterator();
63 71
		while (it.hasNext()) {
64 72
			FeatureType type = (FeatureType) it.next();
......
66 74
		}
67 75
	}
68 76

  
69
	/* (non-Javadoc)
70
	 * @see org.gvsig.fmap.data.index.DataIndexes#getDataIndex(org.gvsig.fmap.data.feature.FeatureType, java.lang.String)
77
	/**
78
	 * @see org.gvsig.fmap.data.index.DataIndexes#getDataIndex(org.gvsig.fmap.data.feature.FeatureType,
79
	 *      java.lang.String)
80
	 * @deprecated
71 81
	 */
72 82
	public FeatureIndex getFeatureIndex(FeatureType fType, String attrName) {
73 83
		Map indexes = (Map) featureTypes.get(fType);
......
76 86
		}
77 87
		return null;
78 88
	}
79
	
89

  
80 90
	/* (non-Javadoc)
81 91
	 * @see org.gvsig.fmap.data.index.DataIndexes#getDataIndex(java.lang.String)
82 92
	 */
......
96 106
		}
97 107
		// FIXME Taking into account only the first attribute
98 108
		indexes.put(index.getAttributeNames()[0], index);
99
		
109

  
100 110
		// By name
101 111
		names.put(index.getName(), index);
102 112
	}
103 113

  
104
	/* (non-Javadoc)
105
	 * @see org.gvsig.fmap.data.index.DataIndexes#contains(org.gvsig.fmap.data.feature.FeatureType, java.lang.String)
114
	/**
115
	 * @see org.gvsig.fmap.data.index.DataIndexes#contains(org.gvsig.fmap.data.feature.FeatureType,
116
	 *      java.lang.String)
117
	 * @deprecated
106 118
	 */
107 119
	public boolean contains(FeatureType fType, String attrName) {
108 120
		Map map = (Map) featureTypes.get(fType);
109 121
		return map == null ? false : map.containsKey(attrName);
110 122
	}
111
	
123

  
124
	/**
125
	 * @deprecated
126
	 */
112 127
	public boolean contains(String name) {
113 128
		return names.containsKey(name);
114 129
	}
......
116 131
	public Iterator iterator() {
117 132
		return names.values().iterator();
118 133
	}
134

  
135
	/**
136
	 * Obtain a FeatureSetProvider over an index with the attributes used in the
137
	 * evaluator or null if can't apply any index.
138
	 * 
139
	 * @param evaluator
140
	 * @return FeatureSetProvider or null if not has index availables.
141
	 * 
142
	 */
143
	public FeatureSetProvider getFeatureSet(Evaluator evaluator) {
144

  
145
		class ApplyIndex {
146
			DefaultFeatureIndex index;
147
			EvaluatorFieldValue[] data;
148

  
149
			ApplyIndex(DefaultFeatureIndex index, EvaluatorFieldValue[] data) {
150
				this.index = index;
151
				this.data = data;
152
			}
153
		}
154
		try {
155
			List applyIndex = new ArrayList();
156
			Iterator indexes = this.iterator();
157
			while (indexes.hasNext()) {
158
				DefaultFeatureIndex index = (DefaultFeatureIndex) indexes
159
						.next();
160
				String[] attrs = index.getAttributeNames();
161
				for (int i = 0; i < attrs.length; i++) {
162
					String attrname = attrs[i];
163
					EvaluatorFieldValue[] values = evaluator
164
							.getFieldValues(attrname);
165
					if (values != null) {
166
						applyIndex.add(new ApplyIndex(index, values));
167
						break;
168
					}
169
				}
170
			}
171
			switch (applyIndex.size()) {
172
			case 0:
173
				return null;
174

  
175
			default:
176
				// FIXME: hay mas de un indice aplicable, que hacer? de momento
177
				// usa el primero.
178
				this.store
179
						.getLogger()
180
						.info(
181
								"Mas de un indice applica para la consulta. Se escoge arbitrariamente el primero.");
182

  
183
			case 1:
184
				ApplyIndex x = (ApplyIndex) applyIndex.get(0);
185
				switch (x.data[0].getType()) {
186
				case EvaluatorFieldValue.MATCH:
187
					return x.index.getMatchFeatureSet(x.data[0].getValue());
188
				case EvaluatorFieldValue.RANGE:
189
					return x.index.getRangeFeatureSet(x.data[0].getValue1(),
190
							x.data[0].getValue2());
191
				case EvaluatorFieldValue.NEAREST:
192
					if (x.data[0].getTolerance() == -1) {
193
						return x.index.getNearestFeatureSet(x.data[0]
194
								.getCount(), x.data[0].getValue());
195
					} else {
196
						return x.index.getNearestFeatureSet(x.data[0]
197
								.getCount(), x.data[0].getTolerance(),
198
								x.data[0].getValue());
199
					}
200
				}
201
			}
202

  
203
		} catch (Exception e) {
204
			this.store.getLogger().error("Error buscando indice que aplicar.",
205
					e);
206
			return null;
207
		}
208

  
209
		return null;
210
	}
119 211
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/AbstractCommandsRecord.java
6 6

  
7 7
import org.gvsig.fmap.data.feature.Command;
8 8
import org.gvsig.fmap.data.feature.CommandsRecord;
9
import org.gvsig.fmap.data.feature.impl.commands.implementation.AttributeCommand;
10 9
import org.gvsig.fmap.data.feature.impl.commands.implementation.FeatureCommand;
11 10
import org.gvsig.tools.observer.DefaultObservable;
12 11
import org.gvsig.tools.observer.Observer;
......
181 180
		return commands;
182 181
	}
183 182

  
184
	public List getCommandsAttributeDeleted() { // List of Feature
185
		Stack clonedUndos=(Stack)undos.clone();
186

  
187
		ArrayList commands=new ArrayList();
188
		while (!clonedUndos.isEmpty()){
189
			Command command=(Command)clonedUndos.pop();
190
			if (command.getType().equals(Command.DELETE) && command instanceof AttributeCommand) {
191
				commands.add(command);
192
			}
193
		}
194

  
195
		return commands;
196
	}
197

  
198
	public List getCommandsAttributeUpdated() { // List of Feature
199
		Stack clonedUndos=(Stack)undos.clone();
200

  
201
		ArrayList commands=new ArrayList();
202
		while (!clonedUndos.isEmpty()){
203
			Command command=(Command)clonedUndos.pop();
204
			if (command.getType().equals(Command.UPDATE) && command instanceof AttributeCommand) {
205
				commands.add(command);
206
			}
207
		}
208

  
209
		return commands;
210
	}
211
	public List getCommandsAttributeInserted() { // List of Feature
212
		Stack clonedUndos=(Stack)undos.clone();
213

  
214
		ArrayList commands=new ArrayList();
215
		while (!clonedUndos.isEmpty()){
216
			Command command=(Command)clonedUndos.pop();
217
			if (command.getType().equals(Command.INSERT) && command instanceof AttributeCommand) {
218
				commands.add(command);
219
			}
220
		}
221

  
222
		return commands;
223
	}
224

  
225 183
	public void endComplex(String description) {
226 184
		if (collection.isEmpty()) {
227 185
        	complex = false;
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/DeleteFeatureCommand.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
package org.gvsig.fmap.data.feature.impl.commands.implementation;
44

  
45
import org.gvsig.fmap.data.feature.Command;
46
import org.gvsig.fmap.data.feature.Feature;
47
import org.gvsig.fmap.data.feature.impl.FeatureManager;
48
import org.gvsig.fmap.data.feature.impl.SpatialManager;
49

  
50

  
51
/**
52
 * DOCUMENT ME!
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
56
public class DeleteFeatureCommand extends FeatureCommand {
57
    public DeleteFeatureCommand(FeatureManager expansionManager,
58
        SpatialManager spatialManager, Feature feature) {
59
        super(expansionManager, spatialManager, feature);
60

  
61
    }
62

  
63
    public DeleteFeatureCommand(FeatureManager expansionManager,
64
        SpatialManager spatialManager, Feature feature,
65
        String description) {
66
        super(expansionManager, spatialManager, feature, description);
67
    }
68

  
69
    /* (non-Javadoc)
70
     * @see org.gvsig.fmap.data.commands.Command#undo()
71
     */
72
    public void undo() {
73
        expansionManager.restoreFeature(feature.getReference());
74
        spatialManager.insertFeature(feature);
75
    }
76

  
77
    /* (non-Javadoc)
78
     * @see org.gvsig.fmap.data.commands.Command#redo()
79
     */
80
    public void redo() {
81
        execute();
82
    }
83

  
84
    /* (non-Javadoc)
85
     * @see org.gvsig.fmap.data.commands.Command#getType()
86
     */
87
    public String getType() {
88
        return Command.DELETE;
89
    }
90

  
91
    /* (non-Javadoc)
92
     * @see org.gvsig.fmap.data.commands.Command#execute()
93
     */
94
    public void execute() {
95
        expansionManager.deleteFeature(feature.getReference());
96
        spatialManager.deleteFeature(feature);
97
    }
98
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/UpdateFeatureCommand.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
44
 *
45
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
46
 *
47
 * This program is free software; you can redistribute it and/or
48
 * modify it under the terms of the GNU General Public License
49
 * as published by the Free Software Foundation; either version 2
50
 * of the License, or (at your option) any later version.
51
 *
52
 * This program is distributed in the hope that it will be useful,
53
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
54
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
55
 * GNU General Public License for more details.
56
 *
57
 * You should have received a copy of the GNU General Public License
58
 * along with this program; if not, write to the Free Software
59
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
60
 *
61
 * For more information, contact:
62
 *
63
 *  Generalitat Valenciana
64
 *   Conselleria d'Infraestructures i Transport
65
 *   Av. Blasco Ib??ez, 50
66
 *   46010 VALENCIA
67
 *   SPAIN
68
 *
69
 *      +34 963862235
70
 *   gvsig@gva.es
71
 *      www.gvsig.gva.es
72
 *
73
 *    or
74
 *
75
 *   IVER T.I. S.A
76
 *   Salamanca 50
77
 *   46005 Valencia
78
 *   Spain
79
 *
80
 *   +34 963163400
81
 *   dac@iver.es
82
 */
83
package org.gvsig.fmap.data.feature.impl.commands.implementation;
84

  
85
import org.gvsig.fmap.data.feature.Command;
86
import org.gvsig.fmap.data.feature.Feature;
87
import org.gvsig.fmap.data.feature.impl.FeatureManager;
88
import org.gvsig.fmap.data.feature.impl.SpatialManager;
89

  
90

  
91
/**
92
 * DOCUMENT ME!
93
 *
94
 * @author Vicente Caballero Navarro
95
 */
96
public class UpdateFeatureCommand extends FeatureCommand {
97
    private Feature oldFeature;
98

  
99
    public UpdateFeatureCommand(FeatureManager expansionManager,
100
        SpatialManager spatialManager, Feature feature, Feature oldFeature) {
101
        super(expansionManager, spatialManager, feature);
102
        this.oldFeature = oldFeature;
103
    }
104

  
105
    public UpdateFeatureCommand(FeatureManager expansionManager,
106
        SpatialManager spatialManager, Feature feature, Feature oldFeature, String description) {
107
        super(expansionManager, spatialManager, feature, description);
108
        this.oldFeature = oldFeature;
109
    }
110

  
111
    /* (non-Javadoc)
112
    * @see org.gvsig.fmap.data.commands.Command#undo()
113
    */
114
    public void undo() {
115
        if (expansionManager.contains(oldFeature.getReference())) {
116
            expansionManager.deleteLastFeature(feature.getReference());
117
        } else {
118
            expansionManager.deleteFeature(feature.getReference());
119
        }
120

  
121
        expansionManager.restoreFeature(oldFeature.getReference());
122
        spatialManager.updateFeature(oldFeature, feature);
123
    }
124

  
125
    /* (non-Javadoc)
126
     * @see org.gvsig.fmap.data.commands.Command#redo()
127
     */
128
    public void redo() {
129
        execute();
130
    }
131

  
132
    /* (non-Javadoc)
133
    * @see org.gvsig.fmap.data.commands.Command#getType()
134
    */
135
    public String getType() {
136
        return Command.UPDATE;
137
    }
138

  
139
    /* (non-Javadoc)
140
     * @see org.gvsig.fmap.data.commands.Command#execute()
141
     */
142
    public void execute() {
143
        //		 Si la geometr?a no ha sido modificada
144
        if (!expansionManager.contains(oldFeature.getReference())) {
145
            expansionManager.deleteFeature(oldFeature.getReference());
146
            expansionManager.addFeature(feature);
147
        } else {
148
            expansionManager.updateFeature(feature, oldFeature);
149
        }
150

  
151
        spatialManager.updateFeature(feature, oldFeature); //setFullExtentDirty(true);
152
    }
153

  
154
	public Feature getOldFeature() {
155
		return oldFeature;
156
	}
157
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/InsertFeatureCommand.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
package org.gvsig.fmap.data.feature.impl.commands.implementation;
44

  
45
import org.gvsig.fmap.data.feature.Command;
46
import org.gvsig.fmap.data.feature.Feature;
47
import org.gvsig.fmap.data.feature.impl.FeatureManager;
48
import org.gvsig.fmap.data.feature.impl.SpatialManager;
49

  
50

  
51
/**
52
 * DOCUMENT ME!
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
56
public class InsertFeatureCommand extends FeatureCommand {
57
    public InsertFeatureCommand(FeatureManager expansionManager,
58
        SpatialManager spatialManager, Feature feature) {
59
        super(expansionManager, spatialManager, feature);
60
    }
61

  
62
    public InsertFeatureCommand(FeatureManager expansionManager,
63
        SpatialManager spatialManager,Feature feature,
64
        String description) {
65
        super(expansionManager, spatialManager, feature, description);
66
    }
67

  
68
    /* (non-Javadoc)
69
     * @see org.gvsig.fmap.data.commands.Command#undo()
70
     */
71
    public void undo() {
72
        expansionManager.deleteLastFeature(feature.getReference());
73
        spatialManager.deleteFeature(feature);
74
    }
75

  
76
    /* (non-Javadoc)
77
     * @see org.gvsig.fmap.data.commands.Command#redo()
78
     */
79
    public void redo() {
80
        execute();
81
    }
82

  
83
    /* (non-Javadoc)
84
     * @see org.gvsig.fmap.data.commands.Command#getType()
85
     */
86
    public String getType() {
87
        return Command.INSERT;
88
    }
89

  
90
    /* (non-Javadoc)
91
     * @see org.gvsig.fmap.data.commands.Command#execute()
92
     */
93
    public void execute() {
94
        expansionManager.addFeature(feature);
95
        spatialManager.insertFeature(feature);
96
    }
97
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/AttributeCommand.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
package org.gvsig.fmap.data.feature.impl.commands.implementation;
44

  
45
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
46
import org.gvsig.fmap.data.feature.impl.AttributeManager;
47
import org.gvsig.fmap.data.feature.impl.commands.AbstractCommand;
48

  
49

  
50
/**
51
 * DOCUMENT ME!
52
 *
53
 * @author Vicente Caballero Navarro
54
 */
55
public abstract class AttributeCommand extends AbstractCommand {
56
   protected FeatureAttributeDescriptor attributeDescriptor;
57
   protected AttributeManager attributeManager;
58

  
59
    protected AttributeCommand(AttributeManager attributeManager, FeatureAttributeDescriptor attributeDescriptor) {
60
    	this.attributeManager=attributeManager;
61
    	this.attributeDescriptor=attributeDescriptor;
62
    }
63

  
64
    protected AttributeCommand(AttributeManager attributeManager, FeatureAttributeDescriptor attributeDescriptor, String description) {
65
        super(description);
66
        this.attributeManager=attributeManager;
67
        this.attributeDescriptor=attributeDescriptor;
68
    }
69

  
70
	public FeatureAttributeDescriptor getAttributeDescriptor() {
71
		return attributeDescriptor;
72
	}
73

  
74
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/DeleteAttributeCommand.java
1
package org.gvsig.fmap.data.feature.impl.commands.implementation;
2

  
3
import org.gvsig.fmap.data.feature.Command;
4
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
5
import org.gvsig.fmap.data.feature.impl.AttributeManager;
6

  
7
public class DeleteAttributeCommand extends AttributeCommand{
8

  
9

  
10
	public DeleteAttributeCommand(AttributeManager attributeManager, FeatureAttributeDescriptor attributeDescriptor) {
11
		super(attributeManager,attributeDescriptor);
12
	}
13

  
14
	public DeleteAttributeCommand(AttributeManager attributeManager, FeatureAttributeDescriptor attributeDescriptor, String description) {
15
		super(attributeManager,attributeDescriptor, description);
16
	}
17

  
18
	/* (non-Javadoc)
19
	 * @see org.gvsig.fmap.data.commands.Command#undo()
20
	 */
21
	public void undo() {
22
		attributeManager.restoreAttribute(new Integer(attributeDescriptor.ordinal()));
23
	}
24

  
25
	/* (non-Javadoc)
26
	 * @see org.gvsig.fmap.data.commands.Command#redo()
27
	 */
28
	public void redo() {
29
		execute();
30

  
31
	}
32

  
33
	/* (non-Javadoc)
34
	 * @see org.gvsig.fmap.data.commands.Command#getType()
35
	 */
36
	public String getType() {
37
		return Command.DELETE;
38
	}
39

  
40
	/* (non-Javadoc)
41
	 * @see org.gvsig.fmap.data.commands.Command#execute()
42
	 */
43
	public void execute() {
44
		 attributeManager.deleteAttribute(new Integer(attributeDescriptor.ordinal()));
45
	}
46

  
47
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/UpdateAttributeCommand.java
1
package org.gvsig.fmap.data.feature.impl.commands.implementation;
2

  
3
import org.gvsig.fmap.data.feature.Command;
4
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
5
import org.gvsig.fmap.data.feature.impl.AttributeManager;
6

  
7
public class UpdateAttributeCommand extends AttributeCommand{
8
	private FeatureAttributeDescriptor oldAttributeDescriptor;
9

  
10
	public UpdateAttributeCommand(AttributeManager attributeManager, FeatureAttributeDescriptor attributeDescriptor, FeatureAttributeDescriptor oldAttributeDescriptor) {
11
		super(attributeManager,attributeDescriptor);
12
		this.oldAttributeDescriptor=oldAttributeDescriptor;
13
	}
14

  
15
	public UpdateAttributeCommand(AttributeManager attributeManager, FeatureAttributeDescriptor attributeDescriptor,FeatureAttributeDescriptor oldAttributeDescriptor, String description) {
16
		super(attributeManager,attributeDescriptor, description);
17
		this.oldAttributeDescriptor=oldAttributeDescriptor;
18
	}
19

  
20
	public void undo() {
21
		if (attributeManager.contains(new Integer(oldAttributeDescriptor.ordinal()))) {
22
            attributeManager.deleteLastAttribute(new Integer(oldAttributeDescriptor.ordinal()));
23
        } else {
24
            attributeManager.deleteAttribute(new Integer(attributeDescriptor.ordinal()));
25
        }
26

  
27
        attributeManager.restoreAttribute(new Integer(attributeDescriptor.ordinal()));
28
	}
29
	public void redo() {
30
		execute();
31
	}
32

  
33
	public String getType() {
34
		return Command.UPDATE;
35
	}
36

  
37
	public void execute() {
38
		if (!attributeManager.contains(new Integer(oldAttributeDescriptor.ordinal()))) {
39
            attributeManager.deleteAttribute(new Integer(oldAttributeDescriptor.ordinal()));
40
            attributeManager.addAttribute(attributeDescriptor);
41
        } else {
42

  
43
            attributeManager.updateAttribute(attributeDescriptor);
44
        }
45
	}
46
	public FeatureAttributeDescriptor getOldAttributeDescriptor(){
47
		return oldAttributeDescriptor;
48
	}
49

  
50
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/InsertAttributeCommand.java
1
package org.gvsig.fmap.data.feature.impl.commands.implementation;
2

  
3
import org.gvsig.fmap.data.feature.Command;
4
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
5
import org.gvsig.fmap.data.feature.impl.AttributeManager;
6

  
7
public class InsertAttributeCommand extends AttributeCommand{
8

  
9
	public InsertAttributeCommand(AttributeManager attributeManager, FeatureAttributeDescriptor attributeDescriptor) {
10
		super(attributeManager,attributeDescriptor);
11
	}
12

  
13
	public InsertAttributeCommand(AttributeManager attributeManager, FeatureAttributeDescriptor attributeDescriptor, String description) {
14
		super(attributeManager,attributeDescriptor, description);
15
	}
16

  
17
	public void undo() {
18
		 attributeManager.deleteLastAttribute(new Integer(attributeDescriptor.ordinal()));
19
	}
20

  
21
	public void redo() {
22
		execute();
23
	}
24

  
25
	public String getType() {
26
		return Command.INSERT;
27
	}
28

  
29
	public void execute() {
30
		 attributeManager.addAttribute(attributeDescriptor);
31
	}
32

  
33
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/FeatureCommandsRecord.java
1 1
package org.gvsig.fmap.data.feature.impl.commands.implementation;
2 2

  
3 3
import org.gvsig.fmap.data.feature.Feature;
4
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
4
import org.gvsig.fmap.data.feature.FeatureType;
5 5
import org.gvsig.fmap.data.feature.impl.FeatureManager;
6 6
import org.gvsig.fmap.data.feature.impl.FeatureTypeManager;
7 7
import org.gvsig.fmap.data.feature.impl.SpatialManager;
......
31 31
			SpatialManager spatialManager, FeatureTypeManager featureTypeManager) {
32 32
		this.expansionManager=expansionManager;
33 33
		this.spatialManager=spatialManager;
34
		this.attributeManager=attributeManager;
34
		this.featureTypeManager = featureTypeManager;
35 35
	}
36

  
36 37
	public void insert(Object obj) {
37 38
		AbstractCommand command = null;
38 39
		if (obj instanceof Feature){
39 40
			Feature feature=(Feature)obj;
40
			command=new InsertFeatureCommand(expansionManager,spatialManager, feature);
41
		}else if (obj instanceof FeatureAttributeDescriptor){
42
			FeatureAttributeDescriptor attributeDescriptor=(FeatureAttributeDescriptor)obj;
43
			command=new InsertAttributeCommand(attributeManager,attributeDescriptor);
41
			command = new FeatureCommandInsert(expansionManager,
42
					spatialManager, feature);
43
		} else if (obj instanceof FeatureType) {
44
			command = new FeatureTypeCommandInsert(featureTypeManager,
45
					(FeatureType) obj);
44 46
		}else{
45 47
			throw new RuntimeException("Object not supported by any command");
46 48
		}
......
51 53
		AbstractCommand command = null;
52 54
		if (obj instanceof Feature){
53 55
			Feature feature=(Feature)obj;
54
			command=new DeleteFeatureCommand(expansionManager,spatialManager, feature);
55
		}else if (obj instanceof FeatureAttributeDescriptor){
56
			FeatureAttributeDescriptor attributeDescriptor=(FeatureAttributeDescriptor)obj;
57
			command=new DeleteAttributeCommand(attributeManager,attributeDescriptor);
56
			command = new FeatureCommandDelete(expansionManager,
57
					spatialManager, feature);
58
		} else if (obj instanceof FeatureType) {
59
			command = new FeatureTypeCommandDelete(featureTypeManager,
60
					(FeatureType) obj);
58 61
		}else{
59 62
			throw new RuntimeException("Object not supported by any command");
60 63
		}
......
66 69
		if (obj instanceof Feature){
67 70
			Feature feature=(Feature)obj;
68 71
			Feature oldFeature=(Feature)oldObj;
69
			command=new UpdateFeatureCommand(expansionManager,spatialManager, feature, oldFeature);
70
		}else if (obj instanceof FeatureAttributeDescriptor){
71
			FeatureAttributeDescriptor attributeDescriptor=(FeatureAttributeDescriptor)obj;
72
			FeatureAttributeDescriptor oldAttributeDescriptor=(FeatureAttributeDescriptor)oldObj;
73
			command=new UpdateAttributeCommand(attributeManager,attributeDescriptor, oldAttributeDescriptor);
72
			command = new FeatureCommandUpdate(expansionManager,
73
					spatialManager, feature, oldFeature);
74
		} else if (obj instanceof FeatureType) {
75
			command = new FeatureTypeCommandUpdate(featureTypeManager,
76
					(FeatureType) obj, (FeatureType) oldObj);
74 77
		}else{
75 78
			throw new RuntimeException("Object not supported by any command");
76 79
		}
......
81 84
	public void clear() {
82 85
		super.clear();
83 86
		expansionManager.clear();
84
		attributeManager.clear();
87
		featureTypeManager.clear();
85 88
		spatialManager.clear();
86 89
	}
87 90

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/FeatureTypeCommand.java
1
package org.gvsig.fmap.data.feature.impl.commands.implementation;
2

  
3
import org.gvsig.fmap.data.feature.impl.commands.AbstractCommand;
4

  
5
public abstract class FeatureTypeCommand extends AbstractCommand {
6

  
7

  
8
}
0 9

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/FeatureCommandDelete.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff