Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / csw / parsers / CswRecordsParser.java @ 3486

History | View | Annotate | Download (3.46 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*
19
* For more information, contact:
20
*
21
*  Generalitat Valenciana
22
*   Conselleria d'Infraestructures i Transport
23
*   Av. Blasco Ib??ez, 50
24
*   46010 VALENCIA
25
*   SPAIN
26
*
27
*      +34 963862235
28
*   gvsig@gva.es
29
*      www.gvsig.gva.es
30
*
31
*    or
32
*
33
*   IVER T.I. S.A
34
*   Salamanca 50
35
*   46005 Valencia
36
*   Spain
37
*
38
*   +34 963163400
39
*   dac@iver.es
40
*/
41
package es.gva.cit.catalogClient.csw.parsers;
42

    
43
import es.gva.cit.catalogClient.metadataXML.XMLNode;
44
import es.gva.cit.catalogClient.metadataXML.XMLTree;
45
import es.gva.cit.catalogClient.parsers.AbstractTags;
46
import es.gva.cit.catalogClient.parsers.Resource;
47

    
48

    
49
/**
50
 * This class parses the Indicio CSW server answer files.
51
 * 
52
 * @author Jorge Piera Llodra (piera_jor@gva.es)
53
 */
54
public class CswRecordsParser extends AbstractTags {
55
    
56
    public CswRecordsParser(XMLNode node) {
57
        setNode(node);
58
        setTitle(XMLTree.searchNodeValue(node,
59
                "identificationInfo->MD_DataIdentification->citation->title"));
60
        setAbstract_(XMLTree.searchNodeValue(node,
61
                "identificationInfo->MD_DataIdentification->abstract"));
62
        setPurpose(XMLTree.searchNodeValue(node,
63
                "identificationInfo->MD_DataIdentification->purpose"));
64
        setKeyWords(XMLTree.searchMultipleNodeValue(node,
65
                "identificationInfo->MD_DataIdentification->descriptiveKeywords->keyword"));
66
        setResources(getResources("distributionInfo->distributor->distributorTransferOptions->onLine"));
67
        setImage(getImageUrl("identificationInfo->MD_DataIdentification->graphicOverview->fileName"));
68
    }
69
    
70
    /**
71
     * It parses the online resources
72
     * @param label
73
     * Label that contains the resource root
74
     * @return
75
     * Resource
76
     */
77
    private Resource[] getResources(String label) {
78
        XMLNode[] nodes = XMLTree.searchMultipleNode(getNode(), label);
79
       
80
        if (nodes == null) {
81
            return null;
82
        }
83

    
84
        Resource[] resources = new Resource[nodes.length];
85
                
86
        for (int i = 0; i < resources.length; i++){
87
            
88
            String sProtocol = XMLTree.searchNodeValue(nodes[i], "protocol");
89
            String sName = XMLTree.searchNodeValue(nodes[i], "orName");
90
            
91
            if (sProtocol == null){
92
                sProtocol =   Resource.WEBSITE;
93
                sName =  "orName";
94
            }
95
            
96
            resources[i] = new Resource(XMLTree.searchNodeValue(nodes[i],
97
                        "linkage"),
98
                    sProtocol,
99
                    sName,
100
                    "orDesc",
101
                    "",
102
                           "",        
103
                            null);
104
        }
105

    
106
        return resources;
107
    }    
108
      
109
   }