svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extDalTransformJoin / src-test / org / gvsig / app / join / dal / feature / JoinTransformTest.java @ 36450
History | View | Annotate | Download (3.38 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 {Iver T.I.} {Task}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.app.join.dal.feature; |
29 |
|
30 |
import java.io.File; |
31 |
import java.net.URL; |
32 |
import java.util.ArrayList; |
33 |
import java.util.Iterator; |
34 |
|
35 |
import org.gvsig.daltransform.BaseFeatureStoreTransform; |
36 |
import org.gvsig.fmap.dal.DataStoreParameters; |
37 |
import org.gvsig.fmap.dal.exception.DataException; |
38 |
import org.gvsig.fmap.dal.exception.InitializeException; |
39 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
40 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
41 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
42 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
43 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
44 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters; |
45 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreProvider; |
46 |
|
47 |
/**
|
48 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
49 |
*/
|
50 |
public class JoinTransformTest extends BaseFeatureStoreTransform { |
51 |
private final File dbf = new File("src-test/org/gvsig/app/join/dal/feature/data/join.dbf"); |
52 |
|
53 |
@Override
|
54 |
public DataStoreParameters getDefaultDataStoreParameters()
|
55 |
throws DataException {
|
56 |
DataStoreParameters dbfParameters = null;
|
57 |
dbfParameters = dataManager.createStoreParameters(DBFStoreProvider.NAME); |
58 |
|
59 |
dbfParameters.setDynValue("dbfFile", dbf);
|
60 |
|
61 |
return dbfParameters;
|
62 |
} |
63 |
|
64 |
@Override
|
65 |
public FeatureStoreTransform getFeatureStoreTransform()
|
66 |
throws DataException, ValidateDataParametersException {
|
67 |
URL url = JoinTransformTest.class.getResource("data/events.dbf"); |
68 |
|
69 |
FeatureStore store = (FeatureStore) dataManager.createStore(this
|
70 |
.getDefaultDataStoreParameters()); |
71 |
|
72 |
FeatureStore store2 = (FeatureStore) dataManager.createStore(this
|
73 |
.getDefaultDataStoreParameters2()); |
74 |
|
75 |
JoinTransform transform = new JoinTransform();
|
76 |
|
77 |
ArrayList names = new ArrayList(); |
78 |
Iterator iter = store2.getDefaultFeatureType().iterator();// <FeatureAttributeDescriptor> |
79 |
while (iter.hasNext()) {
|
80 |
names.add(((FeatureAttributeDescriptor) iter.next()).getName()); |
81 |
} |
82 |
|
83 |
transform.initialize(store, store2, |
84 |
"NOMBRE", "NOMBRE", |
85 |
null, null, |
86 |
(String[]) names.toArray(new String[0])); |
87 |
return transform;
|
88 |
} |
89 |
|
90 |
private DataStoreParameters getDefaultDataStoreParameters2() throws InitializeException, ProviderNotRegisteredException{ |
91 |
DBFStoreParameters dbfParameters = null;
|
92 |
dbfParameters = (DBFStoreParameters) dataManager |
93 |
.createStoreParameters(DBFStoreProvider.NAME); |
94 |
|
95 |
dbfParameters.setFile(dbf); |
96 |
|
97 |
return dbfParameters;
|
98 |
} |
99 |
|
100 |
} |
101 |
|