Revision 25587
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/spi/AbstractFeatureStoreProvider.java | ||
---|---|---|
5 | 5 |
import org.gvsig.fmap.dal.DALLocator; |
6 | 6 |
import org.gvsig.fmap.dal.DataServerExplorer; |
7 | 7 |
import org.gvsig.fmap.dal.exception.*; |
8 |
import org.gvsig.fmap.dal.feature.FeatureLocks; |
|
8 | 9 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
9 | 10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
10 | 11 |
import org.gvsig.fmap.dal.feature.exception.PerformEditingException; |
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java | ||
---|---|---|
146 | 146 |
this.parameters = parameters; |
147 | 147 |
this.transforms = new DefaultFeatureStoreTransforms(this); |
148 | 148 |
this.provider.initialize(this); |
149 |
try { |
|
150 |
indexes=new DefaultFeatureIndexes(this); |
|
151 |
} catch (DataException e) { |
|
152 |
throw new InitializeException(e); |
|
153 |
} |
|
149 | 154 |
} |
150 | 155 |
|
151 | 156 |
public Logger getLogger() { |
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureIndex.java | ||
---|---|---|
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
// FIXME Esto debe ir al provider |
83 |
if (featureStore.getProvider().getFeatureReferenceOIDType() != DataTypes.INT) { |
|
83 |
if (featureStore.getProvider().getFeatureReferenceOIDType() != DataTypes.INT && |
|
84 |
featureStore.getProvider().getFeatureReferenceOIDType() != DataTypes.LONG) { |
|
84 | 85 |
throw new IllegalArgumentException(); |
85 | 86 |
} |
86 | 87 |
|
branches/v2_0_0_prep/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/feature/impl/MyTransform.java | ||
---|---|---|
14 | 14 |
import org.gvsig.tools.persistence.PersistentState; |
15 | 15 |
|
16 | 16 |
/** |
17 |
*
|
|
17 |
* |
|
18 | 18 |
* This transform adds a new attribute of type Geometry to the |
19 |
* original store's default FeatureType. When applying the transform
|
|
20 |
* to a single feature this new attribute is assigned the value of a
|
|
19 |
* original store's default FeatureType. When applying the transform |
|
20 |
* to a single feature this new attribute is assigned the value of a |
|
21 | 21 |
* point whose coordinates proceed from two numeric attributes from the |
22 | 22 |
* store, called xname, yname. |
23 | 23 |
* |
... | ... | |
26 | 26 |
|
27 | 27 |
private FeatureStore store; |
28 | 28 |
private String geomName; |
29 |
private String xname;
|
|
29 |
private String xname; |
|
30 | 30 |
private String yname; |
31 |
|
|
31 |
|
|
32 | 32 |
/** |
33 | 33 |
* Empty default constructor |
34 | 34 |
*/ |
35 | 35 |
public MyTransform() { |
36 | 36 |
} |
37 |
|
|
37 |
|
|
38 | 38 |
/** |
39 | 39 |
* Initializes the transform by assigning the source store and the names of the necessary attributes. |
40 | 40 |
* |
41 | 41 |
* @param store |
42 | 42 |
* source store. |
43 |
*
|
|
43 |
* |
|
44 | 44 |
* @param geomName |
45 | 45 |
* name of the geometry attribute in the default feature type from the source store. |
46 |
*
|
|
46 |
* |
|
47 | 47 |
* @param xname |
48 | 48 |
* name of the attribute containing the X coordinates |
49 |
*
|
|
49 |
* |
|
50 | 50 |
* @param yname |
51 | 51 |
* name of the attribute containing the Y coordinates |
52 |
*
|
|
52 |
* |
|
53 | 53 |
* @throws DataException |
54 | 54 |
*/ |
55 | 55 |
public void initialize(FeatureStore store, String geomName, String xname, String yname) throws DataException { |
56 |
|
|
56 |
|
|
57 | 57 |
// Initialize some data |
58 | 58 |
this.store = store; |
59 | 59 |
this.geomName = geomName; |
60 | 60 |
this.xname = xname; |
61 | 61 |
this.yname = yname; |
62 |
|
|
62 |
|
|
63 | 63 |
// obtain the feature type, add the new attribute and keep a reference to the resulting feature type |
64 | 64 |
EditableFeatureType type = store.getDefaultFeatureType().getEditable(); |
65 | 65 |
type.add(geomName, DataTypes.GEOMETRY); |
66 |
this.defaultFeatureType = type.getNotEditableCopy();
|
|
66 |
setDefaultFeatureType(type.getNotEditableCopy());
|
|
67 | 67 |
} |
68 |
|
|
68 |
|
|
69 | 69 |
/** |
70 |
* Applies this transform to a target editable feature, using data from the
|
|
70 |
* Applies this transform to a target editable feature, using data from the |
|
71 | 71 |
* source feature. |
72 | 72 |
*/ |
73 | 73 |
public void applyTransform(Feature source, EditableFeature target) |
74 | 74 |
throws DataException { |
75 |
|
|
75 |
|
|
76 | 76 |
// copy source feature data over target feature |
77 | 77 |
target.copyFrom(source); |
78 |
|
|
78 |
|
|
79 | 79 |
// calculate and assign new attribute's value |
80 | 80 |
GeometryFactory geomFactory = GeometryManager.getInstance().getGeometryFactory(); |
81 | 81 |
Geometry geom = geomFactory.createPoint2D( |
82 |
source.getDouble(xname),
|
|
82 |
source.getDouble(xname), |
|
83 | 83 |
source.getDouble(yname) |
84 | 84 |
); |
85 | 85 |
target.setGeometry(this.geomName, geom); |
... | ... | |
95 | 95 |
|
96 | 96 |
public void setState(PersistentState state) throws PersistenceException { |
97 | 97 |
} |
98 |
|
|
98 |
|
|
99 | 99 |
} |
branches/v2_0_0_prep/libraries/libFMap_dal/src-test/org/gvsig/fmap/dal/feature/impl/JoinTransform.java | ||
---|---|---|
63 | 63 |
|
64 | 64 |
/** |
65 | 65 |
* Initializes all the necessary data for this transform |
66 |
*
|
|
66 |
* |
|
67 | 67 |
* @param store1 |
68 | 68 |
* store whose default feature type is the target of this |
69 | 69 |
* transform |
70 |
*
|
|
70 |
* |
|
71 | 71 |
* @param store2 |
72 | 72 |
* store whose default feature type will provide the new |
73 | 73 |
* attributes to join |
74 |
*
|
|
74 |
* |
|
75 | 75 |
* @param keyAttr1 |
76 | 76 |
* key attribute in store1 that matches keyAttr2 in store2 |
77 | 77 |
* (foreign key), used for joining both stores. |
78 |
*
|
|
78 |
* |
|
79 | 79 |
* @param keyAttr2 |
80 | 80 |
* key attribute in store2 that matches keyAttr1 in store2 |
81 | 81 |
* (foreign key), used for joining both stores. |
82 |
*
|
|
82 |
* |
|
83 | 83 |
* @param attrs |
84 | 84 |
* names of the attributes in store2 that will be joined to |
85 | 85 |
* store1. |
... | ... | |
118 | 118 |
} |
119 | 119 |
|
120 | 120 |
// assign calculated feature type as this transform's feature type |
121 |
this.defaultFeatureType = type.getNotEditableCopy();
|
|
121 |
setDefaultFeatureType(type.getNotEditableCopy());
|
|
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
/** |
125 |
*
|
|
126 |
*
|
|
125 |
* |
|
126 |
* |
|
127 | 127 |
* @param source |
128 |
*
|
|
128 |
* |
|
129 | 129 |
* @param target |
130 |
*
|
|
130 |
* |
|
131 | 131 |
* @throws DataException |
132 | 132 |
*/ |
133 | 133 |
public void applyTransform(Feature source, EditableFeature target) |
Also available in: Unified diff