gvsig-catalog / org.gvsig.catalog / trunk / org.gvsig.catalog / org.gvsig.catalog.lib / src / main / java / org / gvsig / catalog / schemas / Iso19139_119Record.java @ 145
History | View | Annotate | Download (5.45 KB)
1 |
package org.gvsig.catalog.schemas; |
---|---|
2 |
|
3 |
import java.net.URI; |
4 |
|
5 |
import org.gvsig.catalog.metadataxml.XMLNode; |
6 |
import org.gvsig.catalog.metadataxml.XMLTree; |
7 |
import org.gvsig.catalog.querys.Coordinates; |
8 |
/**
|
9 |
* ISO 19139/119 catalog record
|
10 |
* It creates resources(layers) from MD_Distribution and resources(services) from SV_ServiceIdentification
|
11 |
*
|
12 |
* @author jvhigon
|
13 |
*
|
14 |
*/
|
15 |
public class Iso19139_119Record extends Record{ |
16 |
|
17 |
public Iso19139_119Record() {
|
18 |
|
19 |
} |
20 |
|
21 |
/**
|
22 |
* Constructor
|
23 |
* @param node Node with the answer
|
24 |
* @param serverURI Server URL. Necessary to load the image (just Geonetwork)
|
25 |
*/
|
26 |
public Iso19139_119Record(URI uri, XMLNode node) { |
27 |
super(uri,node);
|
28 |
setTitle(node.searchNodeValue( |
29 |
"identificationInfo->SV_ServiceIdentification->citation->CI_Citation->title->CharacterString"));
|
30 |
setAbstract_(node.searchNodeValue("identificationInfo->SV_ServiceIdentification->abstract->gco:CharacterString"));
|
31 |
setPurpose(node.searchNodeValue("dataIdInfo->idPurp"));
|
32 |
setKeyWords(node.searchMultipleNodeValue( |
33 |
"identificationInfo->SV_ServiceIdentification->descriptiveKeywords->MD_Keywords->keyword->gco:CharacterString"));
|
34 |
setResources(getResources("distributionInfo->MD_Distribution->transferOptions->MD_DigitalTransferOptions->onLine->CI_OnlineResource",
|
35 |
"identificationInfo->SV_ServiceIdentification"));
|
36 |
setFileID(node.searchNodeValue("mdFileID"));
|
37 |
setImageURL(node.searchNodeValue("dataIdInfo->graphOver"));
|
38 |
|
39 |
} |
40 |
|
41 |
/**
|
42 |
*
|
43 |
*
|
44 |
*
|
45 |
* @return
|
46 |
* @param label
|
47 |
*/
|
48 |
private Resource[] getResources(String label_layers, String label_services) { |
49 |
//compute onlineresources
|
50 |
XMLNode[] nodes = XMLTree.searchMultipleNode(getNode(), label_layers);
|
51 |
Coordinates coordinates = null;
|
52 |
String srs = null; |
53 |
|
54 |
if (nodes == null) { |
55 |
return null; |
56 |
} |
57 |
//size of resources = all onlineresources + one service
|
58 |
Resource[] resources = new Resource[nodes.length + 1]; |
59 |
if (nodes.length > 0){ |
60 |
srs = XMLTree.searchNodeValue(getNode(),"refSysInfo->MdCoRefSys->refSysID->identCode");
|
61 |
coordinates = new Coordinates(XMLTree.searchNodeValue(getNode(),"dataIdInfo->geoBox->westBL"), |
62 |
XMLTree.searchNodeValue(getNode(),"dataIdInfo->geoBox->northBL"),
|
63 |
XMLTree.searchNodeValue(getNode(),"dataIdInfo->geoBox->eastBL"),
|
64 |
XMLTree.searchNodeValue(getNode(),"dataIdInfo->geoBox->southBL"));
|
65 |
} |
66 |
|
67 |
|
68 |
for (int i = 0; i < resources.length -1; i++){ |
69 |
String linkage=XMLTree.searchNodeValue(nodes[i], "linkage->URL"); |
70 |
String protocol=XMLTree.searchNodeValue(nodes[i], "protocol->gco:CharacterString"); |
71 |
String name=XMLTree.searchNodeValue(nodes[i], "name->gco:CharacterString"); |
72 |
//String description=XMLTree.searchNodeValue(nodes[i], "orDesc");
|
73 |
String description=XMLTree.searchNodeValue(nodes[i], "description->gco:CharacterString"); |
74 |
String function=XMLTree.searchNodeAtribute(nodes[i], "orFunct->OnFunctCd","value"); |
75 |
|
76 |
if (linkage==null){ |
77 |
linkage="";
|
78 |
} |
79 |
if (protocol==null){ |
80 |
protocol="";
|
81 |
} |
82 |
if (name==null){ |
83 |
name="";
|
84 |
} |
85 |
if (description==null){ |
86 |
description="";
|
87 |
} |
88 |
if (function==null){ |
89 |
function="";
|
90 |
} |
91 |
|
92 |
resources[i] = new Resource(linkage,
|
93 |
protocol, |
94 |
name, |
95 |
description, |
96 |
function, |
97 |
srs, |
98 |
coordinates); |
99 |
|
100 |
} |
101 |
//compute service
|
102 |
XMLNode node = XMLTree.searchNode(getNode(), label_services); |
103 |
if (node == null){ |
104 |
return null; |
105 |
} |
106 |
String service_name = XMLTree.searchNodeValue(node, "srv:serviceType->gco:LocalName"); |
107 |
Object operations = XMLTree.searchMultipleNodeValue(node, "srv:containsOperations->srv:SV_OperationMetadata->srv:operationName->gco:CharacterString"); |
108 |
XMLNode[] operations_nodes= XMLTree.searchMultipleNode(node, "srv:containsOperations->srv:SV_OperationMetadata"); |
109 |
String capabilities_url=""; |
110 |
for (int i = 0; i < operations_nodes.length; i++){ |
111 |
String operation_name= XMLTree.searchNodeValue(operations_nodes[i], "srv:operationName->gco:CharacterString"); |
112 |
if (operation_name.toUpperCase().equals("GETCAPABILITIES")){ |
113 |
capabilities_url=XMLTree.searchNodeValue(operations_nodes[i], "srv:connectPoint->gmd:CI_OnlineResource->gmd:linkage->gmd:URL");
|
114 |
break;
|
115 |
} |
116 |
} |
117 |
//service_name = XMLTree.searchNode(node, "serviceType->gco:LocalName").getText();
|
118 |
int last_index = nodes.length;
|
119 |
resources[last_index] = new Resource(capabilities_url, Resource.WMS_SERVICE, null,null,null,null,null); |
120 |
resources[last_index].setType(Resource.WMS_SERVICE); |
121 |
return resources;
|
122 |
} |
123 |
|
124 |
/*
|
125 |
* (non-Javadoc)
|
126 |
* @see es.gva.cit.catalogClient.schemas.discoverer.Record#accept(java.net.URI, es.gva.cit.catalogClient.metadataxml.XMLNode)
|
127 |
*/
|
128 |
public boolean accept(URI uri, XMLNode node) { |
129 |
if (node.getName().endsWith("MD_Metadata")){ |
130 |
if (node.searchNode("identificationInfo->SV_ServiceIdentification->citation->CI_Citation->title")!=null){ |
131 |
return true; |
132 |
} |
133 |
} |
134 |
return false; |
135 |
} |
136 |
|
137 |
} |