Revision 33495
Added by Claudio Atzori almost 10 years ago
modules/dnet-msro-service/trunk/src/main/java/eu/dnetlib/msro/workflows/nodes/objectStore/RetrieveMdStoreId.java | ||
---|---|---|
39 | 39 |
|
40 | 40 |
/* |
41 | 41 |
* (non-Javadoc) |
42 |
*
|
|
42 |
* |
|
43 | 43 |
* @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken) |
44 | 44 |
*/ |
45 | 45 |
@Override |
46 | 46 |
protected String execute(final NodeToken token) throws Exception { |
47 | 47 |
|
48 |
String workflowQuery = "for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType') where($x//DATAPROVIDER/@id='%s') return distinct-values($x//WORKFLOW/@id/string())"; |
|
48 |
String workflowQuery = |
|
49 |
"for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType') where($x//DATAPROVIDER/@id='%s') return distinct-values($x//WORKFLOW/@id/string())"; |
|
49 | 50 |
|
50 | 51 |
List<String> result = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(String.format(workflowQuery, providerId)); |
51 | 52 |
if (result.size() == 0) { throw new RuntimeException("there is no mdStore Associated to the provider " + token.getEnv().getAttribute(getProviderId())); } |
... | ... | |
83 | 84 |
|
84 | 85 |
/** |
85 | 86 |
* Gets the right metadata id whith the format metadataFormat and interpretation interpretation |
86 |
*
|
|
87 |
* |
|
87 | 88 |
* @return the right metadata id |
88 | 89 |
* @throws ISLookUpException |
89 | 90 |
*/ |
90 | 91 |
private Set<String> getRightMetadataId(final Iterable<String> ids) throws ISLookUpException { |
91 |
String query = "concat(//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value=\"%s\"]//METADATA_FORMAT/text(), \"::<<>>::\""
|
|
92 |
+ ",//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value=\"%s\"]//METADATA_FORMAT_INTERPRETATION/text())";
|
|
92 |
String query = |
|
93 |
"let $x:=//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value='%s'] return concat($x//METADATA_FORMAT/text(), '::<<>>::', $x//METADATA_FORMAT_INTERPRETATION/text())";
|
|
93 | 94 |
Set<String> result = Sets.newHashSet(); |
94 | 95 |
|
95 | 96 |
for (String id : ids) { |
96 | 97 |
|
97 |
List<String> results = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(String.format(query, id, id));
|
|
98 |
List<String> results = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(String.format(query, id)); |
|
98 | 99 |
if (results.size() > 0) { |
99 | 100 |
String[] values = results.get(0).split("::<<>>::"); |
100 | 101 |
if (metadataFormat.equals(values[0]) && interpretation.equals(values[1])) { |
... | ... | |
108 | 109 |
|
109 | 110 |
/** |
110 | 111 |
* Gets the interpretation. |
111 |
*
|
|
112 |
* |
|
112 | 113 |
* @return the interpretation |
113 | 114 |
*/ |
114 | 115 |
public String getInterpretation() { |
... | ... | |
117 | 118 |
|
118 | 119 |
/** |
119 | 120 |
* Sets the interpretation. |
120 |
*
|
|
121 |
* |
|
121 | 122 |
* @param interpretation |
122 | 123 |
* the interpretation to set |
123 | 124 |
*/ |
... | ... | |
128 | 129 |
|
129 | 130 |
/** |
130 | 131 |
* Gets the metadata format. |
131 |
*
|
|
132 |
* |
|
132 | 133 |
* @return the metadataFormat |
133 | 134 |
*/ |
134 | 135 |
public String getMetadataFormat() { |
... | ... | |
137 | 138 |
|
138 | 139 |
/** |
139 | 140 |
* Sets the metadata format. |
140 |
*
|
|
141 |
* |
|
141 | 142 |
* @param metadataFormat |
142 | 143 |
* the metadataFormat to set |
143 | 144 |
*/ |
... | ... | |
148 | 149 |
|
149 | 150 |
/** |
150 | 151 |
* Gets the provider id. |
151 |
*
|
|
152 |
* |
|
152 | 153 |
* @return the providerId |
153 | 154 |
*/ |
154 | 155 |
public String getProviderId() { |
... | ... | |
157 | 158 |
|
158 | 159 |
/** |
159 | 160 |
* Sets the provider id. |
160 |
*
|
|
161 |
* |
|
161 | 162 |
* @param providerId |
162 | 163 |
* the providerId to set |
163 | 164 |
*/ |
Also available in: Unified diff
simplified xquery