Project

General

Profile

« Previous | Next » 

Revision 30791

return ordered metaworkflows

View differences:

modules/dnet-modular-workflows-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/util/ISLookupClient.java
40 40
	private ServiceLocator<ISLookUpService> lookupLocator;
41 41

  
42 42
	private static final Log log = LogFactory.getLog(ISLookupClient.class);
43
	
43

  
44 44
	private static final ApplyXslt metaWorkflowToHTML = new ApplyXslt(new StreamSource(
45 45
			ISLookupClient.class.getResourceAsStream("/eu/dnetlib/functionality/modular/workflows/xslt/metawf_profile2html.xslt")));
46 46

  
47

  
48 47
	public List<String> listSimpleWorflowSections() {
49 48
		final String xquery = "distinct-values(//METAWORKFLOW_SECTION/text())";
50 49
		try {
......
69 68
		return TransformerUtils.toAtomicWorkflow.apply(getProfile(id));
70 69
	}
71 70

  
72
	public List<MetaWorkflowDescriptor> listMetaWorflowsForDatasource(String dsId) {
71
	public List<MetaWorkflowDescriptor> listMetaWorflowsForDatasource(final String dsId) {
73 72
		final String query = queryForMetaWorkflowDescriptor(".//RESOURCE_TYPE/@value='MetaWorkflowDSResourceType' and .//DATAPROVIDER/@id='" + dsId + "'");
74 73

  
75 74
		try {
......
80 79
	}
81 80

  
82 81
	private String queryForMetaWorkflowDescriptor(final String cond) {
83
		return "for $x in /*[" + cond + "]\n" + "return concat(" + "$x//RESOURCE_IDENTIFIER/@value, ' @@@ ', " + "$x//METAWORKFLOW_NAME, ' @@@ ', "
84
				+ "$x//METAWORKFLOW_NAME/@family, ' @@@ ', " + "$x//CONFIGURATION/@status)";
82
		return "for $x in /*[" + cond + "] order by $x//METAWORKFLOW_NAME return concat(" + "$x//RESOURCE_IDENTIFIER/@value, ' @@@ ', "
83
				+ "$x//METAWORKFLOW_NAME, ' @@@ ', " + "$x//METAWORKFLOW_NAME/@family, ' @@@ ', " + "$x//CONFIGURATION/@status)";
85 84
	}
86 85

  
87 86
	public String getProfile(final String id) {
......
118 117
	}
119 118

  
120 119
	public AdvancedMetaWorkflowDescriptor getMetaWorkflow(final String id) {
121
		final String xml = getProfile(id);		
120
		final String xml = getProfile(id);
122 121
		final Set<String> innerWfs = Sets.newHashSet();
123 122
		try {
124 123
			final SAXReader reader = new SAXReader();
......
143 142
					final String start = doc2.valueOf("//CONFIGURATION/@start");
144 143
					final String date = doc2.valueOf("//STATUS/LAST_EXECUTION_DATE");
145 144
					wf.addAttribute("start", start);
146
					
145

  
147 146
					if (!StringUtils.isEmpty(date)) {
148 147
						wf.addAttribute("date", date);
149 148
					}
150
					
149

  
151 150
					if ("disabled".equalsIgnoreCase(start)) {
152 151
						wf.addAttribute("disabled", "true");
153 152
					}
154
					
153

  
155 154
					if (doc2.selectNodes("//PARAM[@required='true' and string-length(normalize-space(.)) = 0]").isEmpty()) {
156 155
						wf.addAttribute("configured", "true");
157 156
					} else {
158 157
						wf.addAttribute("configured", "false");
159 158
					}
160
					
159

  
161 160
				} catch (Exception e) {
162 161
					log.error("Error obtaining wf status", e);
163 162
					wf.addAttribute("status", NodeStatus.NOT_CONFIGURED.toString());
164 163
				}
165 164
			}
166
			
167
			
168
			//TODO delete this
165

  
166
			// TODO delete this
169 167
			ApplyXslt metaWorkflowToHTML = new ApplyXslt(new StreamSource(
170 168
					ISLookupClient.class.getResourceAsStream("/eu/dnetlib/functionality/modular/workflows/xslt/metawf_profile2html.xslt")));
171 169

  
......
232 230
		}
233 231
	}
234 232

  
235
	public String getDatasourceName(String dsId) {
233
	public String getDatasourceName(final String dsId) {
236 234
		final String query = "/*[.//RESOURCE_IDENTIFIER/@value='" + dsId + "']//OFFICIAL_NAME/text()";
237 235

  
238 236
		try {
......
250 248
		try {
251 249
			final SAXReader reader = new SAXReader();
252 250
			final Document doc = reader.read(new StringReader(xml));
253
			
251

  
254 252
			for (Object o : doc.selectNodes("//NODE[.//PARAM/@managedBy='user']")) {
255 253
				final Element node = (Element) o;
256 254
				final String name = node.valueOf("@name");
257 255
				final String desc = node.valueOf("./DESCRIPTION");
258
				
256

  
259 257
				final List<WorkflowParam> params = Lists.newArrayList();
260 258
				for (Object k : node.selectNodes(".//PARAM[@managedBy='user']")) {
261 259
					final Element param = (Element) k;
......
271 269
		} catch (Exception e) {
272 270
			log.error("Error obtaing params of wf: " + wfId, e);
273 271
		}
274
		
272

  
275 273
		return res;
276 274
	}
277 275

  

Also available in: Unified diff