Revision 47263
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.app/org.gvsig.xml2db.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
7 | 7 |
_Xml2db_Import_XML_to_database=Importar XML a base de datos |
8 | 8 |
_Xml2db_Copy_xml_to_database=Copiar XML a base de datos |
9 | 9 |
|
10 |
_XML_File=Fichero XML |
|
11 |
_Charset=Juego de caracteres |
|
12 |
_Projection=Proyecci\u00f3n |
|
13 |
_Analize_xml=Analizar XML |
|
14 |
_Tables=Tablas |
|
15 |
_Show_table_structure=Mostrar estructura de la tabla |
|
16 |
_Create_database=Crear base de datos |
|
17 |
_Database=Base de datos |
|
18 |
_Connection_name=Nombre de conexi\u00f3n |
|
10 | 19 |
|
11 | 20 |
|
21 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.app/org.gvsig.xml2db.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
6 | 6 |
_Xml2db_Create_database_and_import_from_xml=Create and import data from XML to a database. |
7 | 7 |
_Xml2db_Import_XML_to_database=Import XML to database |
8 | 8 |
_Xml2db_Copy_xml_to_database=Copy XML to database |
9 |
|
|
10 |
_XML_File=XML file |
|
11 |
_Charset=Charset |
|
12 |
_Projection=Projection |
|
13 |
_Analize_xml=Analize XML |
|
14 |
_Tables=Tables |
|
15 |
_Show_table_structure=Show table structure |
|
16 |
_Create_database=Create database |
|
17 |
_Database=Database |
|
18 |
_Connection_name=Connection name |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/test/java/org/gvsig/xml2db/lib/impl/TestCreateDatabase.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 | 4 |
import java.io.InputStream; |
5 |
import java.util.Map; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 | 5 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
8 | 6 |
import org.gvsig.xml2db.lib.api.Xml2dbManager; |
7 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo; |
|
9 | 8 |
|
10 | 9 |
|
11 | 10 |
public class TestCreateDatabase extends AbstractLibraryAutoInitTestCase { |
... | ... | |
32 | 31 |
Xml2dbManager manager = new DefaultXml2dbManager(); |
33 | 32 |
|
34 | 33 |
InputStream xml = this.getClass().getResourceAsStream("Declaracion4.xml"); |
35 |
Map<String, FeatureType> tables = manager.extractStructure(xml, null, null);
|
|
34 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null);
|
|
36 | 35 |
|
37 | 36 |
File dbfile = utils().getFile(new File("databases/declaracion4")); |
38 |
manager.createDatabase(dbfile, tables);
|
|
37 |
manager.createDatabase(dbfile, xmlinfo);
|
|
39 | 38 |
} |
40 | 39 |
|
41 | 40 |
public void testExtractorR10graf() throws Exception { |
42 | 41 |
Xml2dbManager manager = new DefaultXml2dbManager(); |
43 | 42 |
|
44 | 43 |
InputStream xml = this.getClass().getResourceAsStream("r10graf.xml"); |
45 |
Map<String, FeatureType> tables = manager.extractStructure(xml, null, null);
|
|
44 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null);
|
|
46 | 45 |
|
47 | 46 |
File dbfile = utils().getFile(new File("databases/r10graf")); |
48 |
manager.createDatabase(dbfile, tables);
|
|
47 |
manager.createDatabase(dbfile, xmlinfo);
|
|
49 | 48 |
} |
50 | 49 |
|
51 | 50 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/test/java/org/gvsig/xml2db/lib/impl/TestStructureExtractor.java | ||
---|---|---|
11 | 11 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
12 | 12 |
import org.gvsig.tools.util.ListBuilder; |
13 | 13 |
import org.gvsig.xml2db.lib.api.Xml2dbManager; |
14 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo; |
|
15 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLTableInfo; |
|
14 | 16 |
import org.slf4j.Logger; |
15 | 17 |
import org.slf4j.LoggerFactory; |
16 | 18 |
|
... | ... | |
34 | 36 |
Xml2dbManager manager = new DefaultXml2dbManager(); |
35 | 37 |
|
36 | 38 |
InputStream xml = this.getClass().getResourceAsStream("Declaracion4.xml"); |
37 |
Map<String, FeatureType> tables = manager.extractStructure(xml, null, null);
|
|
39 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null);
|
|
38 | 40 |
|
39 |
List<FeatureType> ftypes = new ArrayList<>(tables.values()); |
|
41 |
List<FeatureType> ftypes = new ArrayList<>(); |
|
42 |
for (XMLTableInfo tableInfo : xmlinfo) { |
|
43 |
ftypes.add(tableInfo.getFeatureType()); |
|
44 |
} |
|
40 | 45 |
ftypes.sort((FeatureType o1, FeatureType o2) -> |
41 | 46 |
o1.getTags().getString("xml2db.tablename","") |
42 | 47 |
.compareTo(o2.getTags().getString("xml2db.tablename",""))); |
... | ... | |
108 | 113 |
Xml2dbManager manager = new DefaultXml2dbManager(); |
109 | 114 |
|
110 | 115 |
InputStream xml = this.getClass().getResourceAsStream("r10graf.xml"); |
111 |
Map<String, FeatureType> tables = manager.extractStructure(xml, null, null);
|
|
116 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null);
|
|
112 | 117 |
|
113 |
List<FeatureType> ftypes = new ArrayList<>(tables.values()); |
|
118 |
List<FeatureType> ftypes = new ArrayList<>(); |
|
119 |
for (XMLTableInfo tableInfo : xmlinfo) { |
|
120 |
ftypes.add(tableInfo.getFeatureType()); |
|
121 |
} |
|
114 | 122 |
ftypes.sort((FeatureType o1, FeatureType o2) -> |
115 | 123 |
o1.getTags().getString("xml2db.tablename","") |
116 | 124 |
.compareTo(o2.getTags().getString("xml2db.tablename",""))); |
... | ... | |
185 | 193 |
Xml2dbManager manager = new DefaultXml2dbManager(); |
186 | 194 |
|
187 | 195 |
InputStream xml = this.getClass().getResourceAsStream("victimas.xml"); |
188 |
Map<String, FeatureType> tables = manager.extractStructure(xml, null, null);
|
|
196 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null);
|
|
189 | 197 |
|
190 | 198 |
} catch(Throwable t) { |
191 | 199 |
LOGGER.warn("Test testExtractorArena2 failed",t); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/test/java/org/gvsig/xml2db/lib/impl/TestCopyXml2db.java | ||
---|---|---|
8 | 8 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
9 | 9 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
10 | 10 |
import org.gvsig.xml2db.lib.api.Xml2dbManager; |
11 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo; |
|
11 | 12 |
import org.slf4j.Logger; |
12 | 13 |
import org.slf4j.LoggerFactory; |
13 | 14 |
|
... | ... | |
39 | 40 |
Xml2dbManager manager = new DefaultXml2dbManager(); |
40 | 41 |
|
41 | 42 |
InputStream xml = this.getClass().getResourceAsStream("Declaracion4.xml"); |
42 |
Map<String, FeatureType> tables = manager.extractStructure(xml, null, null);
|
|
43 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null);
|
|
43 | 44 |
|
44 | 45 |
File dbfile = utils().getFile(new File("databases/declaracion4")); |
45 |
JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, tables);
|
|
46 |
JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, xmlinfo);
|
|
46 | 47 |
|
47 | 48 |
xml = this.getClass().getResourceAsStream("Declaracion4.xml"); |
48 | 49 |
manager.copyXml2Db(xml, null, dbparams); |
... | ... | |
55 | 56 |
try { |
56 | 57 |
Xml2dbManager manager = new DefaultXml2dbManager(); |
57 | 58 |
InputStream xml = this.getClass().getResourceAsStream(xmlfname); |
58 |
Map<String, FeatureType> tables = manager.extractStructure(xml, null, null);
|
|
59 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null);
|
|
59 | 60 |
|
60 | 61 |
File dbfile = utils().getFile(new File("databases/"+FilenameUtils.removeExtension(xmlfname))); |
61 |
JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, tables);
|
|
62 |
JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, xmlinfo);
|
|
62 | 63 |
|
63 | 64 |
xml = this.getClass().getResourceAsStream(xmlfname); |
64 | 65 |
manager.copyXml2Db(xml, null, dbparams); |
... | ... | |
76 | 77 |
Xml2dbManager manager = new DefaultXml2dbManager(); |
77 | 78 |
|
78 | 79 |
InputStream xml = this.getClass().getResourceAsStream("victimas.xml"); |
79 |
Map<String, FeatureType> tables = manager.extractStructure(xml, null, null);
|
|
80 |
XMLInfo xmlinfo = manager.extractStructure(xml, null, null);
|
|
80 | 81 |
|
81 | 82 |
File dbfile = utils().getFile(new File("databases/victimas")); |
82 |
JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, tables);
|
|
83 |
JDBCServerExplorerParameters dbparams = manager.createDatabase(dbfile, xmlinfo);
|
|
83 | 84 |
|
84 | 85 |
xml = this.getClass().getResourceAsStream("victimas.xml"); |
85 | 86 |
// manager.copyXml2Db(xml, null, dbparams); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.xml2db.lib.impl.XML2dbImplLibrary |
|
1 |
org.gvsig.xml2db.lib.impl.Xml2dbImplLibrary |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/xmlinfo/XMLTableInfoImpl.java | ||
---|---|---|
13 | 13 |
import org.apache.commons.io.FilenameUtils; |
14 | 14 |
import org.apache.commons.lang3.StringUtils; |
15 | 15 |
import org.apache.commons.lang3.builder.ToStringBuilder; |
16 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
16 | 18 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLAttributeInfo; |
17 | 19 |
|
18 | 20 |
/** |
... | ... | |
21 | 23 |
*/ |
22 | 24 |
public class XMLTableInfoImpl implements XMLTableInfo { |
23 | 25 |
|
24 |
private String path; |
|
26 |
private final String path; |
|
27 |
private final List<XMLAttributeInfo> attributes; |
|
28 |
private final XMLAttributeInfoImpl tagInfo; |
|
25 | 29 |
private String name; |
26 |
private List<XMLAttributeInfo> attributes; |
|
27 |
private XMLAttributeInfoImpl tagInfo; |
|
30 |
private EditableFeatureType featureType; |
|
28 | 31 |
|
29 | 32 |
public XMLTableInfoImpl(String path, XMLAttributeInfoImpl tagInfo) { |
30 | 33 |
this.tagInfo = tagInfo; |
31 | 34 |
this.name = FilenameUtils.getBaseName(path); |
32 | 35 |
this.path = path; |
33 | 36 |
this.attributes = new ArrayList<>(); |
37 |
this.featureType = null; |
|
34 | 38 |
} |
35 | 39 |
|
36 | 40 |
@Override |
... | ... | |
96 | 100 |
(XMLAttributeInfo o1, XMLAttributeInfo o2) -> o1.getName().compareTo(o2.getName()) |
97 | 101 |
); |
98 | 102 |
} |
99 |
|
|
100 | 103 |
|
104 |
public void setFeatureType(EditableFeatureType featureType) { |
|
105 |
this.featureType = featureType; |
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 |
public EditableFeatureType getFeatureType() { |
|
110 |
return this.featureType; |
|
111 |
} |
|
112 |
|
|
101 | 113 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/StructureExtractorImpl.java | ||
---|---|---|
19 | 19 |
import java.nio.charset.StandardCharsets; |
20 | 20 |
import java.nio.charset.UnsupportedCharsetException; |
21 | 21 |
import java.util.ArrayList; |
22 |
import java.util.Collections; |
|
23 |
import java.util.HashMap; |
|
24 |
import java.util.LinkedHashMap; |
|
25 | 22 |
import java.util.List; |
26 |
import java.util.Map; |
|
27 | 23 |
import javax.xml.parsers.SAXParser; |
28 | 24 |
import javax.xml.parsers.SAXParserFactory; |
29 | 25 |
import org.apache.commons.io.input.BOMInputStream; |
30 | 26 |
import org.apache.commons.lang3.StringUtils; |
31 |
import org.apache.commons.lang3.mutable.MutableObject; |
|
32 | 27 |
import org.cresques.cts.IProjection; |
33 | 28 |
import org.gvsig.fmap.crs.CRSFactory; |
34 | 29 |
import org.gvsig.fmap.dal.DALLocator; |
... | ... | |
38 | 33 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
39 | 34 |
import org.gvsig.fmap.dal.feature.EditableForeingKey; |
40 | 35 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
41 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
42 | 36 |
import org.gvsig.tools.dynobject.DynField_v2; |
43 | 37 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLAttributeInfo; |
38 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo; |
|
44 | 39 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLTableInfo; |
45 | 40 |
import org.gvsig.xml2db.lib.impl.xmlinfo.XMLInfoImpl; |
46 | 41 |
import org.xml.sax.Attributes; |
... | ... | |
55 | 50 |
*/ |
56 | 51 |
public class StructureExtractorImpl { |
57 | 52 |
|
58 |
private Reader openFileReader(File xmlfile) throws FileNotFoundException {
|
|
53 |
private Reader openReader(File xmlfile, Charset encoding) throws FileNotFoundException, IOException {
|
|
59 | 54 |
FileInputStream fis = new FileInputStream(xmlfile); |
60 |
Charset encoding = StandardCharsets.UTF_8; |
|
61 |
InputStreamReader reader = new InputStreamReader(fis, encoding); |
|
55 |
Reader reader = openReader(fis, encoding); |
|
62 | 56 |
return reader; |
63 | 57 |
} |
64 | 58 |
|
59 |
private Reader openReader(InputStream xml, Charset encoding) throws IOException { |
|
60 |
BOMInputStream bis = new BOMInputStream(xml); |
|
61 |
if( encoding == null ) { |
|
62 |
encoding = StandardCharsets.UTF_8; |
|
63 |
if( bis.hasBOM() ) { |
|
64 |
try { |
|
65 |
encoding = Charset.forName(bis.getBOMCharsetName()); |
|
66 |
} catch(IllegalCharsetNameException | UnsupportedCharsetException ex) { |
|
67 |
// FIXME: to log |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
71 |
InputStreamReader reader = new InputStreamReader(bis, encoding); |
|
72 |
return reader; |
|
73 |
} |
|
74 |
|
|
65 | 75 |
@SuppressWarnings("UseSpecificCatch") |
66 | 76 |
private void extractTags(XMLInfoImpl xmlinfo, Reader reader) { |
67 | 77 |
if( reader == null ) { |
... | ... | |
76 | 86 |
InputSource is = new InputSource(reader); |
77 | 87 |
|
78 | 88 |
List<String> path = new ArrayList<>(); |
79 |
// Map<String,AttributeInfo> tags = new LinkedHashMap<>(); |
|
80 | 89 |
|
81 | 90 |
saxParser.parse(is, new DefaultHandler() { |
82 | 91 |
private Locator locator; |
... | ... | |
206 | 215 |
return proj; |
207 | 216 |
} |
208 | 217 |
|
209 |
public Map<String,FeatureType> extractStructure(File xml) throws FileNotFoundException {
|
|
210 |
Reader reader = openFileReader(xml);
|
|
218 |
public XMLInfo extractStructure(File xml, Charset charset) throws FileNotFoundException, IOException {
|
|
219 |
Reader reader = openReader(xml, charset);
|
|
211 | 220 |
return extractStructure(reader); |
212 | 221 |
} |
213 | 222 |
|
214 |
public Map<String,FeatureType> extractStructure(InputStream xml, Charset encoding) throws IOException { |
|
215 |
BOMInputStream bis = new BOMInputStream(xml); |
|
216 |
if( encoding == null ) { |
|
217 |
encoding = StandardCharsets.UTF_8; |
|
218 |
if( bis.hasBOM() ) { |
|
219 |
try { |
|
220 |
encoding = Charset.forName(bis.getBOMCharsetName()); |
|
221 |
} catch(IllegalCharsetNameException | UnsupportedCharsetException ex) { |
|
222 |
// FIXME: to log |
|
223 |
} |
|
224 |
} |
|
225 |
} |
|
226 |
InputStreamReader reader = new InputStreamReader(bis, encoding); |
|
223 |
public XMLInfo extractStructure(InputStream xml, Charset charset) throws IOException { |
|
224 |
Reader reader = openReader(xml, charset); |
|
227 | 225 |
return extractStructure(reader); |
228 | 226 |
} |
229 | 227 |
|
230 |
public Map<String,FeatureType> extractStructure(Reader reader) {
|
|
228 |
public XMLInfo extractStructure(Reader reader) {
|
|
231 | 229 |
|
232 | 230 |
XMLInfoImpl xmlinfo = new XMLInfoImpl(); |
233 | 231 |
|
... | ... | |
239 | 237 |
|
240 | 238 |
createPrimaryKeyAndForeignKeys(xmlinfo); |
241 | 239 |
|
242 |
Map<String,FeatureType>featureTypes = createFeatureTypes(xmlinfo);
|
|
240 |
createFeatureTypes(xmlinfo); |
|
243 | 241 |
|
244 |
return featureTypes;
|
|
242 |
return xmlinfo;
|
|
245 | 243 |
} |
246 | 244 |
|
247 | 245 |
private String plural(String s) { |
... | ... | |
253 | 251 |
return s+"es"; |
254 | 252 |
} |
255 | 253 |
|
256 |
private Map<String,XMLTableInfoImpl> buildTablesFromTags(XMLInfoImpl xmlinfo) { |
|
257 |
Map<String,XMLTableInfoImpl> tables = new LinkedHashMap<>(); |
|
258 |
|
|
254 |
private void buildTablesFromTags(XMLInfoImpl xmlinfo) { |
|
259 | 255 |
for (String tagPath : xmlinfo.getTagsPaths()) { |
260 | 256 |
XMLAttributeInfoImpl tag1Info = xmlinfo.getTagInfo(tagPath); |
261 | 257 |
XMLTableInfoImpl tableInfo = new XMLTableInfoImpl(tagPath, tag1Info); |
... | ... | |
272 | 268 |
} |
273 | 269 |
} |
274 | 270 |
if( !tableInfo.isEmpty() ) { |
275 |
// tables.put(tableInfo.getPath(), tableInfo); |
|
276 | 271 |
xmlinfo.addTable(tableInfo); |
277 | 272 |
} |
278 | 273 |
} |
279 |
return tables; |
|
280 | 274 |
} |
281 | 275 |
|
282 | 276 |
private void removeDuplicateTableNames(XMLInfoImpl xmlinfo) { |
... | ... | |
358 | 352 |
} |
359 | 353 |
} |
360 | 354 |
|
361 |
private Map<String, FeatureType> createFeatureTypes(XMLInfoImpl xmlinfo) {
|
|
355 |
private void createFeatureTypes(XMLInfoImpl xmlinfo) {
|
|
362 | 356 |
DataManager dataManager = DALLocator.getDataManager(); |
363 | 357 |
|
364 |
Map<String,FeatureType>featureTypes = new HashMap<>(); |
|
365 | 358 |
for (XMLTableInfo tableInfo0 : xmlinfo) { |
366 | 359 |
XMLTableInfoImpl tableInfo = (XMLTableInfoImpl) tableInfo0; |
367 | 360 |
EditableFeatureType ft = dataManager.createFeatureType(); |
... | ... | |
417 | 410 |
attrdesc.setRelationType(DynField_v2.RELATION_TYPE_AGGREGATE); |
418 | 411 |
} |
419 | 412 |
} |
420 |
featureTypes.put(tableInfo.getName(), ft);
|
|
413 |
tableInfo.setFeatureType(ft);
|
|
421 | 414 |
} |
422 |
return featureTypes; |
|
423 | 415 |
} |
424 | 416 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/Xml2dbImplLibrary.java | ||
---|---|---|
27 | 27 |
import org.gvsig.tools.library.AbstractLibrary; |
28 | 28 |
import org.gvsig.tools.library.LibraryException; |
29 | 29 |
import org.gvsig.tools.swing.api.ToolsSwingLibrary; |
30 |
import org.gvsig.xml2db.lib.api.Xml2dbLLibrary;
|
|
30 |
import org.gvsig.xml2db.lib.api.Xml2dbLibrary; |
|
31 | 31 |
import org.gvsig.xml2db.lib.api.Xml2dbLocator; |
32 | 32 |
|
33 | 33 |
public class Xml2dbImplLibrary extends AbstractLibrary { |
... | ... | |
35 | 35 |
@Override |
36 | 36 |
public void doRegistration() { |
37 | 37 |
super.doRegistration(); |
38 |
registerAsImplementationOf(Xml2dbLLibrary.class);
|
|
38 |
registerAsImplementationOf(Xml2dbLibrary.class); |
|
39 | 39 |
this.require(ToolsLibrary.class); |
40 | 40 |
this.require(ToolsSwingLibrary.class); |
41 | 41 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/DefaultXml2dbManager.java | ||
---|---|---|
29 | 29 |
import java.io.InputStream; |
30 | 30 |
import java.io.Reader; |
31 | 31 |
import java.nio.charset.Charset; |
32 |
import java.util.Map; |
|
33 | 32 |
import org.cresques.cts.IProjection; |
34 | 33 |
import org.gvsig.fmap.dal.DALLocator; |
35 | 34 |
import org.gvsig.fmap.dal.DataManager; |
... | ... | |
43 | 42 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
44 | 43 |
import org.gvsig.tools.util.HasAFile; |
45 | 44 |
import org.gvsig.xml2db.lib.api.Xml2dbManager; |
45 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo; |
|
46 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLTableInfo; |
|
46 | 47 |
|
47 | 48 |
|
48 | 49 |
@SuppressWarnings("UseSpecificCatch") |
49 | 50 |
public class DefaultXml2dbManager implements Xml2dbManager { |
50 | 51 |
|
52 |
public DefaultXml2dbManager() { |
|
53 |
|
|
54 |
} |
|
51 | 55 |
|
52 | 56 |
@Override |
53 |
public Map<String,FeatureType> extractStructure(File xml, IProjection projection) throws FileNotFoundException {
|
|
57 |
public XMLInfo extractStructure(File xml, Charset encoding, IProjection projection) throws IOException, FileNotFoundException {
|
|
54 | 58 |
StructureExtractorImpl extractor = new StructureExtractorImpl(); |
55 |
Map<String, FeatureType> ftypes = extractor.extractStructure(xml);
|
|
56 |
return ftypes;
|
|
59 |
XMLInfo xmlinfo = extractor.extractStructure(xml, encoding);
|
|
60 |
return xmlinfo;
|
|
57 | 61 |
} |
58 | 62 |
|
59 | 63 |
@Override |
60 |
public Map<String,FeatureType> extractStructure(InputStream xml, Charset encoding, IProjection projection) throws IOException {
|
|
64 |
public XMLInfo extractStructure(InputStream xml, Charset encoding, IProjection projection) throws IOException {
|
|
61 | 65 |
StructureExtractorImpl extractor = new StructureExtractorImpl(); |
62 |
Map<String, FeatureType> ftypes = extractor.extractStructure(xml, encoding);
|
|
63 |
return ftypes;
|
|
66 |
XMLInfo xmlinfo = extractor.extractStructure(xml, encoding);
|
|
67 |
return xmlinfo;
|
|
64 | 68 |
} |
65 | 69 |
|
66 | 70 |
@Override |
67 |
public Map<String,FeatureType> extractStructure(Reader xml, IProjection projection) throws IOException {
|
|
71 |
public XMLInfo extractStructure(Reader xml, IProjection projection) throws IOException {
|
|
68 | 72 |
StructureExtractorImpl extractor = new StructureExtractorImpl(); |
69 |
Map<String, FeatureType> ftypes = extractor.extractStructure(xml);
|
|
70 |
return ftypes;
|
|
73 |
XMLInfo xmlinfo = extractor.extractStructure(xml);
|
|
74 |
return xmlinfo;
|
|
71 | 75 |
} |
72 | 76 |
|
73 | 77 |
@Override |
... | ... | |
83 | 87 |
} |
84 | 88 |
|
85 | 89 |
@Override |
86 |
public JDBCServerExplorerParameters createDatabase(File dbfile, Map<String,FeatureType> tables) {
|
|
90 |
public JDBCServerExplorerParameters createDatabase(File dbfile, XMLInfo xmlinfo) {
|
|
87 | 91 |
try { |
88 | 92 |
DataManager dataManager = DALLocator.getDataManager(); |
89 | 93 |
|
... | ... | |
95 | 99 |
|
96 | 100 |
JDBCServerExplorer server = (JDBCServerExplorer) dbworkspace.getServerExplorer(); |
97 | 101 |
|
98 |
for (Map.Entry<String, FeatureType> entry : tables.entrySet()) {
|
|
99 |
String tablename = entry.getKey();
|
|
100 |
FeatureType ftype = entry.getValue();
|
|
102 |
for (XMLTableInfo tableInfo : xmlinfo) {
|
|
103 |
String tablename = tableInfo.getName();
|
|
104 |
FeatureType ftype = tableInfo.getFeatureType();
|
|
101 | 105 |
JDBCNewStoreParameters tableParams = server.getAddParameters(); |
102 | 106 |
tableParams.setTable(tablename); |
103 | 107 |
tableParams.setDefaultFeatureType(ftype); |
... | ... | |
105 | 109 |
} |
106 | 110 |
for (DataStoreParameters storeParams : server.list()) { |
107 | 111 |
JDBCStoreParameters featureStoreParams = (JDBCStoreParameters)storeParams; |
108 |
if( tables.get(featureStoreParams.getTable())==null ) {
|
|
112 |
if( xmlinfo.get(featureStoreParams.getTable())==null ) {
|
|
109 | 113 |
continue; |
110 | 114 |
} |
111 | 115 |
dbworkspace.writeStoresRepositoryEntry(featureStoreParams.getTable(), featureStoreParams); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.api/src/main/java/org/gvsig/xml2db/lib/api/Xml2dbLLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2023 gvSIG Association |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
package org.gvsig.xml2db.lib.api; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLibrary; |
|
28 |
import org.gvsig.fmap.geom.GeometryLibrary; |
|
29 |
import org.gvsig.tools.library.AbstractLibrary; |
|
30 |
import org.gvsig.tools.library.LibraryException; |
|
31 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
32 |
|
|
33 |
/** |
|
34 |
* Library for API initialization and configuration. |
|
35 |
* |
|
36 |
* @author gvSIG team |
|
37 |
*/ |
|
38 |
public class Xml2dbLLibrary extends AbstractLibrary { |
|
39 |
|
|
40 |
@Override |
|
41 |
public void doRegistration() { |
|
42 |
registerAsAPI(Xml2dbLLibrary.class); |
|
43 |
require(DALLibrary.class); |
|
44 |
require(GeometryLibrary.class); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
protected void doInitialize() throws LibraryException { |
|
49 |
// Do nothing |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
protected void doPostInitialize() throws LibraryException { |
|
54 |
// Validate there is any implementation registered. |
|
55 |
Xml2dbManager manager = Xml2dbLocator.getManager(); |
|
56 |
if (manager == null) { |
|
57 |
throw new ReferenceNotRegisteredException( |
|
58 |
Xml2dbLocator.MANAGER_NAME, Xml2dbLocator.getInstance()); |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.api/src/main/java/org/gvsig/xml2db/lib/api/Xml2dbManager.java | ||
---|---|---|
35 | 35 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
36 | 36 |
import org.gvsig.fmap.dal.feature.FeatureType; |
37 | 37 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
38 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo; |
|
38 | 39 |
|
39 | 40 |
/** |
40 | 41 |
* Main class that defines the available XML services. |
... | ... | |
42 | 43 |
*/ |
43 | 44 |
public interface Xml2dbManager { |
44 | 45 |
|
45 |
public Map<String,FeatureType> extractStructure(File xml, IProjection projection) throws FileNotFoundException;
|
|
46 |
public XMLInfo extractStructure(File xml, Charset encoding, IProjection projection) throws IOException,FileNotFoundException;
|
|
46 | 47 |
|
47 |
public Map<String,FeatureType> extractStructure(InputStream xml, Charset encoding, IProjection projection) throws IOException;
|
|
48 |
public XMLInfo extractStructure(InputStream xml, Charset encoding, IProjection projection) throws IOException;
|
|
48 | 49 |
|
49 |
public Map<String,FeatureType> extractStructure(Reader reader, IProjection projection) throws IOException;
|
|
50 |
public XMLInfo extractStructure(Reader reader, IProjection projection) throws IOException;
|
|
50 | 51 |
|
51 |
public JDBCServerExplorerParameters createDatabase(File dbfile, Map<String,FeatureType> tables);
|
|
52 |
public JDBCServerExplorerParameters createDatabase(File dbfile, XMLInfo tables);
|
|
52 | 53 |
|
53 | 54 |
public void copyXml2Db(File xml, Charset encoding, JDBCServerExplorerParameters dbparams); |
54 | 55 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.api/src/main/java/org/gvsig/xml2db/lib/api/xmlinfo/XMLTableInfo.java | ||
---|---|---|
5 | 5 |
*/ |
6 | 6 |
package org.gvsig.xml2db.lib.api.xmlinfo; |
7 | 7 |
|
8 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
8 | 9 |
import org.gvsig.tools.util.GetItemWithSizeIsEmptyAndIterator; |
9 | 10 |
|
10 | 11 |
/** |
... | ... | |
13 | 14 |
*/ |
14 | 15 |
public interface XMLTableInfo extends GetItemWithSizeIsEmptyAndIterator<XMLAttributeInfo>, Iterable<XMLAttributeInfo> { |
15 | 16 |
|
16 |
String getName(); |
|
17 |
public String getName(); |
|
18 |
|
|
19 |
public EditableFeatureType getFeatureType(); |
|
17 | 20 |
|
18 | 21 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.api/src/main/java/org/gvsig/xml2db/lib/api/Xml2dbLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2023 gvSIG Association |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
package org.gvsig.xml2db.lib.api; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLibrary; |
|
28 |
import org.gvsig.fmap.geom.GeometryLibrary; |
|
29 |
import org.gvsig.tools.library.AbstractLibrary; |
|
30 |
import org.gvsig.tools.library.LibraryException; |
|
31 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
32 |
|
|
33 |
/** |
|
34 |
* Library for API initialization and configuration. |
|
35 |
* |
|
36 |
* @author gvSIG team |
|
37 |
*/ |
|
38 |
public class Xml2dbLibrary extends AbstractLibrary { |
|
39 |
|
|
40 |
@Override |
|
41 |
public void doRegistration() { |
|
42 |
registerAsAPI(Xml2dbLibrary.class); |
|
43 |
require(DALLibrary.class); |
|
44 |
require(GeometryLibrary.class); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
protected void doInitialize() throws LibraryException { |
|
49 |
// Do nothing |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
protected void doPostInitialize() throws LibraryException { |
|
54 |
// Validate there is any implementation registered. |
|
55 |
Xml2dbManager manager = Xml2dbLocator.getManager(); |
|
56 |
if (manager == null) { |
|
57 |
throw new ReferenceNotRegisteredException( |
|
58 |
Xml2dbLocator.MANAGER_NAME, Xml2dbLocator.getInstance()); |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/createdbfromxml/CreatedbFromXmlPanel.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.xml2db.swing.impl.createdbfromxml; |
24 | 24 |
|
25 |
import java.awt.Cursor; |
|
26 |
import java.awt.GridBagConstraints; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
import java.io.File; |
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
import javax.swing.AbstractListModel; |
|
25 | 33 |
import javax.swing.JComponent; |
34 |
import org.cresques.cts.IProjection; |
|
35 |
import java.nio.charset.Charset; |
|
36 |
import java.util.Collections; |
|
37 |
import javax.swing.SwingUtilities; |
|
38 |
import javax.swing.event.ChangeEvent; |
|
39 |
import javax.swing.event.ChangeListener; |
|
26 | 40 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
27 | 41 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
28 | 42 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
29 | 43 |
import org.gvsig.fmap.dal.swing.ProjectionPickerController; |
44 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureTypePanel; |
|
30 | 45 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
31 | 46 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
32 | 47 |
import org.gvsig.tools.swing.api.ToolsSwingUtils; |
... | ... | |
34 | 49 |
import org.gvsig.tools.swing.api.pickercontroller.FilePickerController; |
35 | 50 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
36 | 51 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
52 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
53 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
54 |
import org.gvsig.tools.util.LabeledValue; |
|
55 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
56 |
import org.gvsig.xml2db.lib.api.Xml2dbLocator; |
|
57 |
import org.gvsig.xml2db.lib.api.Xml2dbManager; |
|
58 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo; |
|
59 |
import org.gvsig.xml2db.lib.api.xmlinfo.XMLTableInfo; |
|
37 | 60 |
import org.gvsig.xml2db.swing.Xml2dbPanel; |
38 | 61 |
|
39 | 62 |
/** |
... | ... | |
45 | 68 |
implements Xml2dbPanel |
46 | 69 |
{ |
47 | 70 |
|
71 |
private static class XMLInfoListModel extends AbstractListModel<LabeledValue<XMLTableInfo>> { |
|
72 |
|
|
73 |
private final XMLInfo xmlinfo; |
|
74 |
private final List<LabeledValue<XMLTableInfo>> tables; |
|
75 |
|
|
76 |
|
|
77 |
public XMLInfoListModel() { |
|
78 |
this(null); |
|
79 |
} |
|
80 |
|
|
81 |
public XMLInfoListModel(XMLInfo xmlinfo) { |
|
82 |
this.xmlinfo = xmlinfo; |
|
83 |
if( xmlinfo != null ) { |
|
84 |
this.tables = new ArrayList<>(xmlinfo.size()); |
|
85 |
for (XMLTableInfo tableInfo : xmlinfo) { |
|
86 |
this.tables.add(new LabeledValueImpl<>(tableInfo.getName(),tableInfo)); |
|
87 |
} |
|
88 |
} else { |
|
89 |
this.tables = null; |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public LabeledValue<XMLTableInfo> getElementAt(int index) { |
|
95 |
if( this.tables == null ) { |
|
96 |
return null; |
|
97 |
} |
|
98 |
return tables.get(index); |
|
99 |
} |
|
100 |
|
|
101 |
@Override |
|
102 |
public int getSize() { |
|
103 |
if( this.tables == null ) { |
|
104 |
return 0; |
|
105 |
} |
|
106 |
return this.tables.size(); |
|
107 |
} |
|
108 |
|
|
109 |
|
|
110 |
} |
|
111 |
|
|
112 |
|
|
48 | 113 |
private Dialog dialog; |
49 | 114 |
private FilePickerController pickerXMLFile; |
50 | 115 |
private PickerController<JDBCServerExplorerParameters> pickerConnection; |
51 | 116 |
private ProjectionPickerController pickerProjection; |
52 | 117 |
private CharsetPickerController pickerCharset; |
118 |
private boolean processing; |
|
53 | 119 |
|
54 | 120 |
public CreatedbFromXmlPanel() { |
55 | 121 |
this.createComponents(); |
56 | 122 |
} |
57 | 123 |
|
58 | 124 |
private void createComponents() { |
125 |
this.processing = false; |
|
59 | 126 |
this.initComponents(); |
60 | 127 |
} |
61 | 128 |
|
... | ... | |
66 | 133 |
|
67 | 134 |
this.translate(); |
68 | 135 |
|
136 |
this.lstTables.setModel(new XMLInfoListModel()); |
|
137 |
|
|
69 | 138 |
this.pickerXMLFile = toolsSwingManager.createFilePickerController( |
70 | 139 |
this.txtXMLFile, |
71 | 140 |
this.btnXMLFile |
72 | 141 |
); |
142 |
this.pickerXMLFile.addChangeListener((ChangeEvent e) -> { |
|
143 |
updateEnableComponents(); |
|
144 |
}); |
|
73 | 145 |
|
74 | 146 |
this.pickerCharset = toolsSwingManager.createCharsetPickerController( |
75 | 147 |
null, |
... | ... | |
86 | 158 |
this.btnConnection |
87 | 159 |
); |
88 | 160 |
|
161 |
this.btnAnalizeXML.addActionListener(new ActionListener() { |
|
162 |
@Override |
|
163 |
public void actionPerformed(ActionEvent e) { |
|
164 |
doAnalizeXML(); |
|
165 |
} |
|
166 |
}); |
|
167 |
this.btnAnalizeXML.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
|
89 | 168 |
|
90 |
updateEnableComponents(); |
|
169 |
this.btnViewTableStructure.addActionListener(new ActionListener() { |
|
170 |
@Override |
|
171 |
public void actionPerformed(ActionEvent e) { |
|
172 |
doViewTableStructure(); |
|
173 |
} |
|
174 |
}); |
|
175 |
this.btnViewTableStructure.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
|
176 |
|
|
177 |
this.pickerCharset.set(Charset.defaultCharset()); |
|
178 |
|
|
179 |
SwingUtilities.invokeLater(() -> { updateEnableComponents(); }); |
|
180 |
|
|
91 | 181 |
ToolsSwingUtils.ensureRowsCols(this, 4, 80, 5, 100); |
92 | 182 |
} |
93 |
|
|
183 |
|
|
94 | 184 |
private void translate() { |
185 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
95 | 186 |
|
187 |
toolsSwingManager.translate(this.lblCharset); |
|
188 |
toolsSwingManager.translate(this.lblConnectionName); |
|
189 |
toolsSwingManager.translate(this.lblCreatedb); |
|
190 |
toolsSwingManager.translate(this.lblFileXML); |
|
191 |
toolsSwingManager.translate(this.lblFileXML1); |
|
192 |
toolsSwingManager.translate(this.lblTables); |
|
193 |
toolsSwingManager.translate(this.btnAnalizeXML); |
|
194 |
toolsSwingManager.translate(this.btnViewTableStructure); |
|
96 | 195 |
} |
97 | 196 |
|
197 |
private boolean isProcessing() { |
|
198 |
return this.processing; |
|
199 |
} |
|
200 |
|
|
98 | 201 |
private void updateEnableComponents() { |
99 | 202 |
|
203 |
if( this.isProcessing() ) { |
|
204 |
this.pickerXMLFile.setEnabled(false); |
|
205 |
this.pickerCharset.setEnabled(false); |
|
206 |
this.pickerProjection.setEnabled(false); |
|
207 |
this.btnAnalizeXML.setEnabled(false); |
|
208 |
this.lstTables.setEnabled(false); |
|
209 |
this.btnViewTableStructure.setEnabled(false); |
|
210 |
if( this.dialog!=null ) { |
|
211 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTONS_OK, false); |
|
212 |
} |
|
213 |
} |
|
214 |
this.pickerXMLFile.setEnabled(true); |
|
215 |
this.pickerCharset.setEnabled(true); |
|
216 |
this.pickerProjection.setEnabled(true); |
|
217 |
|
|
218 |
File xmlfile = this.pickerXMLFile.get(); |
|
219 |
if( xmlfile == null || !xmlfile.exists() ) { |
|
220 |
this.btnAnalizeXML.setEnabled(false); |
|
221 |
this.lstTables.setEnabled(false); |
|
222 |
this.btnViewTableStructure.setEnabled(false); |
|
223 |
if( this.dialog!=null ) { |
|
224 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTONS_OK, false); |
|
225 |
} |
|
226 |
return; |
|
227 |
} |
|
228 |
this.btnAnalizeXML.setEnabled(true); |
|
229 |
if( this.lstTables.getModel().getSize()<1 ) { |
|
230 |
this.btnViewTableStructure.setEnabled(false); |
|
231 |
if( this.dialog!=null ) { |
|
232 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTONS_OK, false); |
|
233 |
} |
|
234 |
return; |
|
235 |
} |
|
236 |
this.lstTables.setEnabled(true); |
|
237 |
this.btnViewTableStructure.setEnabled(true); |
|
238 |
JDBCServerExplorerParameters connection = this.pickerConnection.get(); |
|
239 |
if( connection == null ) { |
|
240 |
if( this.dialog!=null ) { |
|
241 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTONS_OK, false); |
|
242 |
} |
|
243 |
return; |
|
244 |
} |
|
245 |
if( this.dialog!=null ) { |
|
246 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTONS_OK, false); |
|
247 |
} |
|
100 | 248 |
} |
101 | 249 |
|
102 | 250 |
@Override |
... | ... | |
114 | 262 |
|
115 | 263 |
} |
116 | 264 |
|
265 |
private void doAnalizeXML() { |
|
266 |
Xml2dbManager manager = Xml2dbLocator.getXml2dbManager(); |
|
267 |
try { |
|
268 |
File xmlfile = this.pickerXMLFile.get(); |
|
269 |
if( xmlfile == null || !xmlfile.exists() ) { |
|
270 |
return; |
|
271 |
} |
|
272 |
IProjection proj = this.pickerProjection.get(); |
|
273 |
Charset charset = this.pickerCharset.get(); |
|
274 |
|
|
275 |
XMLInfo xmlinfo = manager.extractStructure(xmlfile, charset, proj); |
|
276 |
if( xmlinfo != null ) { |
|
277 |
this.lstTables.setModel(new XMLInfoListModel(xmlinfo)); |
|
278 |
} |
|
279 |
} catch(Exception ex) { |
|
280 |
//FIXME: LOGGER |
|
281 |
this.lstTables.setModel(new XMLInfoListModel()); |
|
282 |
} |
|
283 |
this.updateEnableComponents(); |
|
284 |
} |
|
285 |
|
|
286 |
private void doViewTableStructure() { |
|
287 |
LabeledValue<XMLTableInfo> x = (LabeledValue<XMLTableInfo>)this.lstTables.getSelectedValue(); |
|
288 |
if( x == null ) { |
|
289 |
return; |
|
290 |
} |
|
291 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
|
292 |
WindowManager_v2 windowManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
293 |
FeatureTypePanel panel = dataSwingManager.createFeatureTypePanel(); |
|
294 |
panel.put(x.getValue().getFeatureType()); |
|
295 |
Dialog dialog = windowManager.createDialog( |
|
296 |
panel.asJComponent(), |
|
297 |
"tit", |
|
298 |
null, |
|
299 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
300 |
); |
|
301 |
dialog.addActionListener(new ActionListener() { |
|
302 |
@Override |
|
303 |
public void actionPerformed(ActionEvent e) { |
|
304 |
if( dialog.getAction()==WindowManager_v2.BUTTON_OK) { |
|
305 |
panel.fetch(x.getValue().getFeatureType()); |
|
306 |
} |
|
307 |
} |
|
308 |
}); |
|
309 |
dialog.show( |
|
310 |
WindowManager.MODE.WINDOW, |
|
311 |
Collections.singletonMap("align", GridBagConstraints.CENTER) |
|
312 |
); |
|
313 |
} |
|
117 | 314 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/createdbfromxml/CreatedbFromXmlPanelView.xml | ||
---|---|---|
196 | 196 |
</object> |
197 | 197 |
</at> |
198 | 198 |
<at name="name">lblTables</at> |
199 |
<at name="width">1591</at>
|
|
199 |
<at name="width">354</at>
|
|
200 | 200 |
<at name="text">_Tables</at> |
201 | 201 |
<at name="height">17</at> |
202 | 202 |
</object> |
... | ... | |
253 | 253 |
<at name="scrollableTracksViewportHeight">true</at> |
254 | 254 |
<at name="scrollableTracksViewportWidth">true</at> |
255 | 255 |
<at name="name">lstTables</at> |
256 |
<at name="width">1589</at>
|
|
256 |
<at name="width">352</at>
|
|
257 | 257 |
<at name="items"> |
258 | 258 |
<object classname="com.jeta.forms.store.properties.ItemsProperty"> |
259 | 259 |
<at name="name">items</at> |
... | ... | |
286 | 286 |
</at> |
287 | 287 |
</object> |
288 | 288 |
</at> |
289 |
<at name="height">548</at>
|
|
289 |
<at name="height">78</at>
|
|
290 | 290 |
</object> |
291 | 291 |
</at> |
292 | 292 |
</object> |
... | ... | |
345 | 345 |
<at name="actionCommand">...</at> |
346 | 346 |
<at name="opaque">false</at> |
347 | 347 |
<at name="name">btnViewTableStructure</at> |
348 |
<at name="width">118</at>
|
|
348 |
<at name="width">122</at>
|
|
349 | 349 |
<at name="rolloverEnabled">true</at> |
350 |
<at name="text">_View_table_structure</at>
|
|
350 |
<at name="text">_Show_table_structure</at>
|
|
351 | 351 |
<at name="height">20</at> |
352 | 352 |
</object> |
353 | 353 |
</at> |
... | ... | |
401 | 401 |
</object> |
402 | 402 |
</at> |
403 | 403 |
<at name="name">lblCreatedb</at> |
404 |
<at name="width">1591</at>
|
|
404 |
<at name="width">354</at>
|
|
405 | 405 |
<at name="text">_Create_database</at> |
406 | 406 |
<at name="height">17</at> |
407 | 407 |
</object> |
... | ... | |
576 | 576 |
</object> |
577 | 577 |
</at> |
578 | 578 |
<at name="name">txtConnectionName</at> |
579 |
<at name="width">1482</at>
|
|
579 |
<at name="width">245</at>
|
|
580 | 580 |
<at name="height">22</at> |
581 | 581 |
</object> |
582 | 582 |
</at> |
... | ... | |
602 | 602 |
</at> |
603 | 603 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
604 | 604 |
</super> |
605 |
<at name="id">embedded.1362922665</at>
|
|
605 |
<at name="id">embedded.1417135899</at>
|
|
606 | 606 |
<at name="rowspecs">CENTER:DEFAULT:NONE</at> |
607 | 607 |
<at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at> |
608 | 608 |
<at name="components"> |
... | ... | |
652 | 652 |
</object> |
653 | 653 |
</at> |
654 | 654 |
<at name="name">txtXMLFile</at> |
655 |
<at name="width">1454</at>
|
|
655 |
<at name="width">217</at>
|
|
656 | 656 |
<at name="height">22</at> |
657 | 657 |
</object> |
658 | 658 |
</at> |
... | ... | |
740 | 740 |
</at> |
741 | 741 |
</object> |
742 | 742 |
</at> |
743 |
<at name="name"></at>
|
|
743 |
<at name="name"/>
|
|
744 | 744 |
<at name="fill"> |
745 | 745 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
746 | 746 |
<at name="name">fill</at> |
... | ... | |
822 | 822 |
</at> |
823 | 823 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
824 | 824 |
</super> |
825 |
<at name="id">embedded.726323618</at>
|
|
825 |
<at name="id">embedded.406248529</at>
|
|
826 | 826 |
<at name="rowspecs">CENTER:DEFAULT:NONE</at> |
827 | 827 |
<at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at> |
828 | 828 |
<at name="components"> |
... | ... | |
934 | 934 |
</object> |
935 | 935 |
</at> |
936 | 936 |
<at name="name">cboConnection</at> |
937 |
<at name="width">1454</at>
|
|
937 |
<at name="width">217</at>
|
|
938 | 938 |
<at name="items"> |
939 | 939 |
<object classname="com.jeta.forms.store.properties.ItemsProperty"> |
940 | 940 |
<at name="name">items</at> |
... | ... | |
965 | 965 |
</at> |
966 | 966 |
</object> |
967 | 967 |
</at> |
968 |
<at name="name"></at>
|
|
968 |
<at name="name"/>
|
|
969 | 969 |
<at name="fill"> |
970 | 970 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
971 | 971 |
<at name="name">fill</at> |
... | ... | |
1107 | 1107 |
</at> |
1108 | 1108 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
1109 | 1109 |
</super> |
1110 |
<at name="id">embedded.1044303207</at>
|
|
1110 |
<at name="id">embedded.395478776</at>
|
|
1111 | 1111 |
<at name="rowspecs">CENTER:DEFAULT:NONE</at> |
1112 | 1112 |
<at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at> |
1113 | 1113 |
<at name="components"> |
... | ... | |
1157 | 1157 |
</object> |
1158 | 1158 |
</at> |
1159 | 1159 |
<at name="name">txtProjection</at> |
1160 |
<at name="width">1454</at>
|
|
1160 |
<at name="width">217</at>
|
|
1161 | 1161 |
<at name="height">22</at> |
1162 | 1162 |
</object> |
1163 | 1163 |
</at> |
... | ... | |
1245 | 1245 |
</at> |
1246 | 1246 |
</object> |
1247 | 1247 |
</at> |
1248 |
<at name="name"></at>
|
|
1248 |
<at name="name"/>
|
|
1249 | 1249 |
<at name="fill"> |
1250 | 1250 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
1251 | 1251 |
<at name="name">fill</at> |
... | ... | |
1415 | 1415 |
</object> |
1416 | 1416 |
</at> |
1417 | 1417 |
<at name="name">cboCharset</at> |
1418 |
<at name="width">1482</at>
|
|
1418 |
<at name="width">245</at>
|
|
1419 | 1419 |
<at name="items"> |
1420 | 1420 |
<object classname="com.jeta.forms.store.properties.ItemsProperty"> |
1421 | 1421 |
<at name="name">items</at> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/createdbfromxml/CreatedbFromXmlPanelView.java | ||
---|---|---|
163 | 163 |
btnViewTableStructure.setName("btnViewTableStructure"); |
164 | 164 |
btnViewTableStructure.setOpaque(false); |
165 | 165 |
btnViewTableStructure.setRolloverEnabled(true); |
166 |
btnViewTableStructure.setText("_View_table_structure");
|
|
166 |
btnViewTableStructure.setText("_Show_table_structure");
|
|
167 | 167 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
168 | 168 |
btnViewTableStructure.setBorder(emptyborder2); |
169 | 169 |
jpanel1.add(btnViewTableStructure,new CellConstraints(4,14,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
Also available in: Unified diff