Revision 37496

View differences:

branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/FeatureStoreTransform.java
30 30
import java.util.List;
31 31

  
32 32
import org.gvsig.fmap.dal.exception.DataException;
33
import org.gvsig.tools.dynobject.DynObject;
34
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
33 35
import org.gvsig.tools.persistence.Persistent;
34 36

  
35 37
/**
......
110 112
	public String getName();
111 113
	
112 114
	public String getDescription();
115

  
116
	/**
117
	 * Sets the original metadata for this transform
118
	 * 
119
	 * @param metadata
120
	 */
121
	public void setSourceMetadata(DynObject metadata);
113 122
	
123
    public void setDynValue(String name, Object value)
124
            throws DynFieldNotFoundException;
125
    
126
    public boolean hasDynValue(String name);
127
    
128
    public Object getDynValue(String name) throws DynFieldNotFoundException;
129
	
114 130
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
180 180

  
181 181
    private DefaultFeatureStoreTransforms transforms;
182 182

  
183
    private DelegatedDynObject metadata;
183
    DelegatedDynObject metadata;
184
    
184 185
    private Set metadataChildren;
185 186

  
186 187
    private Long featureCount = null;
......
1786 1787
        return this.metadata.getDynClass();
1787 1788
    }
1788 1789

  
1789
    public Object getDynValue(String name) throws DynFieldNotFoundException {
1790
        if (this.metadata.hasDynValue(name)) {
1791
            return this.metadata.getDynValue(name);
1792
        }
1793
        if (METADATA_PROVIDER.equalsIgnoreCase(name)) {
1794
            return this.provider.getProviderName();
1795
        } else
1796
            if (METADATA_CONTAINERNAME.equalsIgnoreCase(name)) {
1797
                return this.provider.getSourceId();
1798
            } else
1799
                if (METADATA_FEATURETYPE.equalsIgnoreCase(name)) {
1800
                    try {
1801
                        return this.getDefaultFeatureType();
1802
                    } catch (DataException e) {
1803
                        return null;
1804
                    }
1805
                }
1806
        return this.metadata.getDynValue(name);
1807
    }
1790
	public Object getDynValue(String name) throws DynFieldNotFoundException {
1791
		if( this.transforms.hasDynValue(name) ) {
1792
			return this.transforms.getDynValue(name);
1793
		}
1794
		if (this.metadata.hasDynValue(name)) {
1795
			return this.metadata.getDynValue(name);
1796
		}
1797
		if (METADATA_PROVIDER.equalsIgnoreCase(name)) {
1798
			return this.provider.getProviderName();
1799
		} else if (METADATA_CONTAINERNAME.equalsIgnoreCase(name)) {
1800
			return this.provider.getSourceId();
1801
		} else if (METADATA_FEATURETYPE.equalsIgnoreCase(name)) {
1802
			try {
1803
				return this.getDefaultFeatureType();
1804
			} catch (DataException e) {
1805
				return null;
1806
			}
1807
		}
1808
		return this.metadata.getDynValue(name);
1809
	}
1808 1810

  
1809 1811
    public boolean hasDynValue(String name) {
1812
		if( this.transforms.hasDynValue(name) ) {
1813
			return true;
1814
		}
1810 1815
        return this.metadata.hasDynValue(name);
1811 1816
    }
1812 1817

  
......
1826 1831

  
1827 1832
    public void setDynValue(String name, Object value)
1828 1833
        throws DynFieldNotFoundException {
1834
		if( this.transforms.hasDynValue(name) ) {
1835
			this.transforms.setDynValue(name, value);
1836
			return;
1837
		}
1829 1838
        this.metadata.setDynValue(name, value);
1830 1839

  
1831 1840
    }
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/FeatureTypeManager.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2 2
 *
3 3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4 4
 *
......
20 20
 *
21 21
 *  Generalitat Valenciana
22 22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
23
 *   Av. Blasco Ib��ez, 50
24 24
 *   46010 VALENCIA
25 25
 *   SPAIN
26 26
 *
......
49 49
import java.util.List;
50 50

  
51 51
import org.gvsig.fmap.dal.exception.DataException;
52
import org.gvsig.fmap.dal.feature.AbstractFeatureStoreTransform;
52 53
import org.gvsig.fmap.dal.feature.EditableFeature;
53 54
import org.gvsig.fmap.dal.feature.EditableFeatureType;
54 55
import org.gvsig.fmap.dal.feature.Feature;
......
190 191
		return oldNum;
191 192
	}
192 193

  
193
	private class UpdateFeatureTypeTransform implements FeatureStoreTransform {
194
	private class UpdateFeatureTypeTransform extends AbstractFeatureStoreTransform {
194 195
		private FeatureType ftSource;
195 196
		private FeatureType ftTarget;
196 197
		private WeakReference wkRefStore;
......
205 206
			this.initializeAttributesToUse();
206 207
		}
207 208

  
208
		public String getDescription() {
209
		//TODO
210
		    return "";
211
		}
212
		
213
		public String getName() {
214
		//TODO
215
		    return "";
216
		}
217
		
218 209
		private void initializeAttributesToUse() {
219 210
			attrToUse = new ArrayList(ftTarget.size());
220 211
			Iterator iter = ftTarget.iterator();
......
286 277
			this.wkRefStore = new WeakReference(featureStore);
287 278
		}
288 279

  
289
		public PersistentState getState() throws PersistenceException {
290
			// FIXME
291
			throw new UnsupportedOperationException();
292
		}
293

  
294
		public void saveToState(PersistentState state)
295
				throws PersistenceException {
296
			// FIXME
297
			throw new UnsupportedOperationException();
298
		}
299

  
300
		public void loadFromState(PersistentState state) throws PersistenceException {
301
			// FIXME
302
			throw new UnsupportedOperationException();
303
		}
304

  
305 280
		public boolean isTransformsOriginalValues() {
306 281
			return false;
307 282
		}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStoreTransforms.java
17 17
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
18 18
import org.gvsig.tools.ToolsLocator;
19 19
import org.gvsig.tools.dynobject.DynStruct;
20
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
20 21
import org.gvsig.tools.persistence.Persistent;
21 22
import org.gvsig.tools.persistence.PersistentState;
22 23
import org.gvsig.tools.persistence.exception.PersistenceException;
......
55 56
		checkEditingMode();
56 57
		if (transform.getDefaultFeatureType()!=null){
57 58
			if( ! transform.getFeatureTypes().contains(transform.getDefaultFeatureType())) {
58
				throw new IllegalArgumentException(); // FIXME: A?adir tipo especifico.
59
				throw new IllegalArgumentException(); // FIXME: Aadir tipo especifico.
59 60
			}
60 61
			this.transforms.add(transform);
62
			transform.setSourceMetadata(this.store.metadata);
61 63
			this.notifyChangeToStore();
62 64
			if (this.isTramsformValues == null
63 65
					|| (!this.isTramsformValues.booleanValue())) {
......
121 123
	}
122 124

  
123 125
	private class TransformTemporalList extends ArrayList {
126
		/**
127
		 * 
128
		 */
129
		private static final long serialVersionUID = 1677014259279944000L;
124 130
		private FeatureType targetFType;
125 131

  
126 132
		public boolean add(Object arg0) {
......
221 227

  
222 228
	public void setFeatureStore(FeatureStore featureStore) {
223 229
		if (this.store != null) {
224
			throw new IllegalStateException();// FIXME: A?adir tipo especifico.
230
			throw new IllegalStateException();// FIXME: Aadir tipo especifico.
225 231
		}
226 232
		this.store = (DefaultFeatureStore) featureStore;
227 233
	}
......
293 299

  
294 300
	}
295 301

  
302
	public Object getDynValue(String name) throws DynFieldNotFoundException {
303
		if( ! this.transforms.isEmpty() ) {
304
			FeatureStoreTransform transform = (FeatureStoreTransform) transforms.get(this.transforms.size()-1);
305
			if( transform.hasDynValue(name) ) {
306
				return transform.getDynValue(name);
307
			}
308
		}
309
		throw new DynFieldNotFoundException(name, "transforms");
310
	}
311

  
312
	public void setDynValue(String name, Object value) throws DynFieldNotFoundException {
313
		if( ! this.transforms.isEmpty() ) {
314
			FeatureStoreTransform transform = (FeatureStoreTransform) transforms.get(this.transforms.size()-1);
315
			transform.setDynValue(name, value);
316
		}
317
	}
318

  
319
	public boolean hasDynValue(String name) {
320
		if( ! this.transforms.isEmpty() ) {
321
			FeatureStoreTransform transform = (FeatureStoreTransform) transforms.get(this.transforms.size()-1);
322
			if( transform.hasDynValue(name) ) {
323
				return true;
324
			}
325
		}
326
		return false;
327
	}
328

  
296 329
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/AbstractFeatureStoreTransform.java
5 5

  
6 6
import org.gvsig.fmap.dal.exception.DataException;
7 7
import org.gvsig.tools.ToolsLocator;
8
import org.gvsig.tools.dynobject.DynObject;
8 9
import org.gvsig.tools.dynobject.DynStruct;
10
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
9 11
import org.gvsig.tools.persistence.PersistenceManager;
10 12
import org.gvsig.tools.persistence.PersistentState;
11 13
import org.gvsig.tools.persistence.exception.PersistenceException;
......
24 26
 */
25 27
public abstract class AbstractFeatureStoreTransform implements
26 28
FeatureStoreTransform {
29
    public static final String METADATA_DEFINITION_NAME = "FeatureStoreTransform";
27 30
	public static final String ABSTRACT_FEATURESTORE_DYNCLASS_NAME = "AbstractFeatureStoreTransform";
28 31

  
29 32
	private FeatureStore store;
......
35 38

  
36 39
    protected String descripcion;
37 40

  
38
	
41
    private DynObject originalMetadata = null;
42

  
39 43
    
40 44
    public AbstractFeatureStoreTransform() {
41
        this("", "");
45
        this(null, "");
42 46
    }
43 47

  
44 48
    public AbstractFeatureStoreTransform(String name, String description) {
......
48 52
            this.name = name;
49 53
        }
50 54
        this.descripcion = description;
55

  
51 56
    }
52 57
    
53 58
	public String getDescription() {
......
106 111
	public void saveToState(PersistentState state) throws PersistenceException {
107 112
		state.set("store", store);	
108 113
	}
114

  
115
	
116
	public final void setSourceMetadata(DynObject metadata) {
117
		this.originalMetadata = metadata;
118
	}
119
	
120
	protected DynObject getSourceMetadata() {
121
		return this.originalMetadata;
122
	}
123
	
124
	/**
125
	 * Get the metadata value for the name <code>name</code>.
126
	 * 
127
	 * Overwrite this method to support that this transform overwrite the values
128
	 * of the statore's metadata.
129
	 * 
130
	 * @see {#Metadata.getDynValue}
131
	 */
132
	public Object getDynValue(String name) throws DynFieldNotFoundException {
133
		throw new DynFieldNotFoundException(name, "transform");
134
	}
135

  
136
	/**
137
	 * Return true is the value <code>name</name> has a value in the metadata
138
	 * 
139
	 * Overwrite this method to support that this transform overwrite the values
140
	 * of the statore's metadata.
141
	 * 
142
	 * @see {#Metadata.hasDynValue}
143
	 */
144
	public boolean hasDynValue(String name) {
145
		return false;
146
	}
147

  
148
	/**
149
	 * Set the value of a metadata.
150
	 * 
151
	 * Overwrite this method to support that this transform overwrite the values
152
	 * of the statore's metadata.
153
	 * 
154
	 * @see {#Metadata.getDynValue}
155
	 */
156
	public void setDynValue(String name, Object value)
157
			throws DynFieldNotFoundException {
158
		throw new DynFieldNotFoundException(name, "transform");
159
	}
160

  
109 161
}
branches/v2_0_0_prep/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/feature/BaseTestFeatureStore.java
59 59
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo;
60 60
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
61 61
import org.gvsig.tools.persistence.PersistentState;
62
import org.gvsig.tools.persistence.exception.PersistenceException;
63 62
import org.slf4j.Logger;
64 63
import org.slf4j.LoggerFactory;
65 64

  
......
1487 1486
		store1.dispose();
1488 1487
	}
1489 1488

  
1490
	abstract class myTransform implements FeatureStoreTransform {
1489
	abstract class myTransform extends AbstractFeatureStoreTransform {
1491 1490
		protected FeatureStore store;
1492 1491
		protected FeatureType orgDefaultFType;
1493 1492
		protected List orgFTypes;
......
1509 1508
			target.set(attrTarget.getIndex(), source.get(attrTarget.getName()));
1510 1509
		}
1511 1510

  
1512
		public void saveToState(PersistentState state)
1513
		throws PersistenceException {
1514
			// TODO Auto-generated method stub
1515

  
1516
		}
1517

  
1518
		public void loadFromState(PersistentState state) throws PersistenceException {
1519
			// TODO Auto-generated method stub
1520

  
1521
		}
1522

  
1523 1511
		public FeatureType getDefaultFeatureType() throws DataException {
1524 1512
			return orgDefaultFType;
1525 1513
		}
......
1544 1532

  
1545 1533
		}
1546 1534

  
1547
		public PersistentState getState() throws PersistenceException {
1548
			// TODO Auto-generated method stub
1549
			return null;
1550
		}
1551

  
1552 1535
		public FeatureType getSourceFeatureTypeFrom(
1553 1536
				FeatureType targetFeatureType) {
1554 1537

  
......
1556 1539
		}
1557 1540
		
1558 1541
        public String getName() {
1559
            System.out
1560
                .println("\nmyFeatureStore.getname(): " + store.getName());
1542
//            System.out
1543
//                .println("\nmyFeatureStore.getname(): " + store.getName());
1561 1544
            return store.getName();
1562 1545
        }
1563 1546

  
1564 1547
        public String getDescription() {
1565
            System.out.println("\nmyFeatureStore.getDescription(getfullname): "
1566
                + store.getFullName());
1548
//            System.out.println("\nmyFeatureStore.getDescription(getfullname): "
1549
//                + store.getFullName());
1567 1550
            return store.getFullName();
1568 1551
        }
1569 1552

  

Also available in: Unified diff