gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.lib / org.gvsig.vcsgis.lib.impl / src / main / java / org / gvsig / vcsgis / lib / workspace / tables / TopologyplanTable.java @ 3309
History | View | Annotate | Download (2.63 KB)
1 |
package org.gvsig.vcsgis.lib.workspace.tables; |
---|---|
2 |
|
3 |
import org.gvsig.vcsgis.lib.repository.localdb.tables.*; |
4 |
import org.gvsig.fmap.dal.DALLocator; |
5 |
import org.gvsig.fmap.dal.DataManager; |
6 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
7 |
import org.gvsig.fmap.dal.feature.Feature; |
8 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
10 |
import org.gvsig.tools.dataTypes.DataTypes; |
11 |
import org.gvsig.tools.dispose.DisposeUtils; |
12 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
13 |
|
14 |
/**
|
15 |
*
|
16 |
* @author gvSIG Team
|
17 |
*/
|
18 |
@SuppressWarnings("UseSpecificCatch") |
19 |
public class TopologyplanTable extends AbstractRepoTable { |
20 |
|
21 |
public static final String TABLE_NAME = "VCSGIS_TOPOLOGYPLANS"; |
22 |
|
23 |
private static final String COD_TOPOLOGYPLAN = "COD_TOPOLOGYPLAN"; |
24 |
private static final String TOPPLAN_NAME = "TOPP_NAME"; |
25 |
private static final String TOPPLAN_DESCRIPTION = "TOPP_DESCRIPTION"; |
26 |
private static final String TOPPLAN_DATA = "TOPP_DATA"; |
27 |
|
28 |
public static final FeatureType featureType() { |
29 |
DataManager dataManager = DALLocator.getDataManager(); |
30 |
EditableFeatureType ft = dataManager.createFeatureType(); |
31 |
ft.setLabel("VCSGIS TopologyPlans");
|
32 |
ft.getTags().set("ID", TABLE_NAME);
|
33 |
ft.add(COD_TOPOLOGYPLAN, DataTypes.STRING) |
34 |
.setSize(40)
|
35 |
.setIsPrimaryKey(true)
|
36 |
.setLabel("Code")
|
37 |
.setReadOnly(true);
|
38 |
ft.add(TOPPLAN_NAME, DataTypes.STRING) |
39 |
.setIsIndexed(true)
|
40 |
.setAllowIndexDuplicateds(true)
|
41 |
.setSize(50)
|
42 |
.setLabel("Name");
|
43 |
ft.add(TOPPLAN_DESCRIPTION, DataTypes.STRING) |
44 |
.setSize(10240)
|
45 |
.setLabel("Description");
|
46 |
ft.add(TOPPLAN_DATA, DataTypes.STRING) |
47 |
.setSize(10240)
|
48 |
.setLabel("Serialized topology plan in json.");
|
49 |
|
50 |
return ft.getNotEditableCopy();
|
51 |
} |
52 |
|
53 |
public TopologyplanTable() {
|
54 |
super(TABLE_NAME, featureType());
|
55 |
} |
56 |
|
57 |
public String getByCode(VCSGisWorkspace workspace, String topologyPlanCode) { |
58 |
FeatureStore store = null;
|
59 |
try {
|
60 |
store = workspace.getFeatureStore(TABLE_NAME); |
61 |
Feature f = store.findFirst("\""+COD_TOPOLOGYPLAN+"\"='"+topologyPlanCode+"'"); |
62 |
if( f==null ) { |
63 |
return null; |
64 |
} |
65 |
return f.getString(TOPPLAN_DATA);
|
66 |
} catch (Exception ex) { |
67 |
throw new RuntimeException("Can't retrieve topology plan '"+topologyPlanCode+"'.", ex); |
68 |
} finally {
|
69 |
DisposeUtils.disposeQuietly(store); |
70 |
} |
71 |
} |
72 |
|
73 |
} |