root / trunk / extensions / extPublish / src / com / iver / cit / gvsig / publish / gui / comboServer / ServerDataPersistence.java @ 6958
History | View | Annotate | Download (3.7 KB)
1 | 6956 | jorpiell | package com.iver.cit.gvsig.publish.gui.comboServer; |
---|---|---|---|
2 | |||
3 | import java.util.Date; |
||
4 | |||
5 | import com.iver.utiles.DateTime; |
||
6 | import com.iver.utiles.XMLEntity; |
||
7 | |||
8 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
9 | *
|
||
10 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
11 | *
|
||
12 | * This program is free software; you can redistribute it and/or
|
||
13 | * modify it under the terms of the GNU General Public License
|
||
14 | * as published by the Free Software Foundation; either version 2
|
||
15 | * of the License, or (at your option) any later version.
|
||
16 | *
|
||
17 | * This program is distributed in the hope that it will be useful,
|
||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
20 | * GNU General Public License for more details.
|
||
21 | *
|
||
22 | * You should have received a copy of the GNU General Public License
|
||
23 | * along with this program; if not, write to the Free Software
|
||
24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
25 | *
|
||
26 | * For more information, contact:
|
||
27 | *
|
||
28 | * Generalitat Valenciana
|
||
29 | * Conselleria d'Infraestructures i Transport
|
||
30 | * Av. Blasco Ib??ez, 50
|
||
31 | * 46010 VALENCIA
|
||
32 | * SPAIN
|
||
33 | *
|
||
34 | * +34 963862235
|
||
35 | * gvsig@gva.es
|
||
36 | * www.gvsig.gva.es
|
||
37 | *
|
||
38 | * or
|
||
39 | *
|
||
40 | * IVER T.I. S.A
|
||
41 | * Salamanca 50
|
||
42 | * 46005 Valencia
|
||
43 | * Spain
|
||
44 | *
|
||
45 | * +34 963163400
|
||
46 | * dac@iver.es
|
||
47 | */
|
||
48 | /* CVS MESSAGES:
|
||
49 | *
|
||
50 | * $Id$
|
||
51 | * $Log$
|
||
52 | 6958 | luisw2 | * Revision 1.2 2006-09-01 02:26:49 luisw2
|
53 | * xml por getXml()
|
||
54 | 6956 | jorpiell | *
|
55 | *
|
||
56 | 6958 | luisw2 | * Revision 1.1 2006/08/31 19:19:04 jorpiell
|
57 | * *** empty log message ***
|
||
58 | 6956 | jorpiell | */
|
59 | /**
|
||
60 | * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
||
61 | */
|
||
62 | public class ServerDataPersistence extends com.iver.andami.persistence.serverData.ServerDataPersistence{ |
||
63 | |||
64 | public ServerDataPersistence(Object pluginClassInstance, String serviceType) { |
||
65 | super(pluginClassInstance, serviceType);
|
||
66 | } |
||
67 | |||
68 | /**
|
||
69 | * This method creates and returns a new XMLEntity.
|
||
70 | * @param server
|
||
71 | * ServerData with all the server information
|
||
72 | * @return
|
||
73 | * XMLEntity
|
||
74 | */
|
||
75 | public XMLEntity serverDataToXml_(ServerData server){
|
||
76 | String dFormat="Y-m-d H:i:s.Z"; |
||
77 | |||
78 | XMLEntity xmlEnt = new XMLEntity();
|
||
79 | xmlEnt.putProperty("serverURL",server.getServerAddress());
|
||
80 | xmlEnt.putProperty("added",DateTime.dateToString(server.getAdded(),dFormat));
|
||
81 | xmlEnt.putProperty("lastAccess",DateTime.dateToString(server.getLastAccess(),dFormat));
|
||
82 | xmlEnt.putProperty("type",server.getServiceType());
|
||
83 | xmlEnt.putProperty("subType",server.getServiceSubType());
|
||
84 | xmlEnt.putProperty("name",server.getServerName());
|
||
85 | |||
86 | return xmlEnt;
|
||
87 | } |
||
88 | |||
89 | /**
|
||
90 | * This method returns an array of ServerData objects that
|
||
91 | * have been saved using the Andami persistence model.
|
||
92 | * @return
|
||
93 | * String[]
|
||
94 | */
|
||
95 | public ServerData[] getArrayOfServerData_(){ |
||
96 | 6958 | luisw2 | ServerData[] servers = new ServerData[getXml().getChildrenCount()]; |
97 | for (int i=0 ; i<getXml().getChildrenCount() ; i++){ |
||
98 | servers[i] = xmlToServerData_(getXml().getChild(i)); |
||
99 | 6956 | jorpiell | } |
100 | return servers;
|
||
101 | } |
||
102 | |||
103 | /**
|
||
104 | * This method creates a new serverData from a XMLEntity
|
||
105 | * @param xmlEnt
|
||
106 | * XMLRntity that contains the server information
|
||
107 | * @return
|
||
108 | * ServerData
|
||
109 | */
|
||
110 | public ServerData xmlToServerData_(XMLEntity xmlEnt){
|
||
111 | String serverAddress;
|
||
112 | Date added;
|
||
113 | Date lastAccess;
|
||
114 | String serviceType = ""; |
||
115 | String serviceSubType = ""; |
||
116 | String name = ""; |
||
117 | |||
118 | serverAddress = xmlEnt.getStringProperty("serverURL");
|
||
119 | added = DateTime.stringToDate(xmlEnt.getStringProperty("added"));
|
||
120 | lastAccess = DateTime.stringToDate(xmlEnt.getStringProperty("lastAccess"));
|
||
121 | serviceType = xmlEnt.getStringProperty("type").toUpperCase();
|
||
122 | serviceSubType = xmlEnt.getStringProperty("subType").toUpperCase();
|
||
123 | name = xmlEnt.getStringProperty("name");
|
||
124 | return new ServerData(serverAddress,added,lastAccess,serviceType,serviceSubType,name); |
||
125 | } |
||
126 | |||
127 | } |