Project

General

Profile

« Previous | Next » 

Revision 29884

use of an extrafield to override the api compliance

View differences:

RepositoriesEntryPointController.java
8 8
import javax.servlet.http.HttpServletRequest;
9 9
import javax.servlet.http.HttpServletResponse;
10 10

  
11
import org.springframework.beans.factory.annotation.Required;
11 12
import org.springframework.ui.ModelMap;
12 13

  
13 14
import com.google.common.base.Splitter;
......
15 16
import com.google.common.collect.Sets;
16 17
import com.google.gson.Gson;
17 18

  
19
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
18 20
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
19 21
import eu.dnetlib.enabling.tools.ServiceLocator;
20 22
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
......
23 25

  
24 26
	@Resource(name = "lookupLocator")
25 27
	private ServiceLocator<ISLookUpService> lookupLocator;
28
	
29
	private String compatibilityLevelsVocabulary;
26 30

  
27 31
	public class RepoHIWorkflow implements Comparable<RepoHIWorkflow> {
28 32

  
......
61 65
		}
62 66

  
63 67
	}
68
	
69
	public class CompatibilityLevel implements Comparable<CompatibilityLevel> {
70
		private String id;
71
		private String name;
72
		
73
		public CompatibilityLevel() {}
74
		
75
		public CompatibilityLevel(String id, String name) {
76
			this.id = id;
77
			this.name = name;
78
		}
64 79

  
65
	@Override
66
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
80
		public String getId() {
81
			return id;
82
		}
83
		public void setId(String id) {
84
			this.id = id;
85
		}
86
		public String getName() {
87
			return name;
88
		}
89
		public void setName(String name) {
90
			this.name = name;
91
		}
92

  
93
		@Override
94
		public int compareTo(CompatibilityLevel o) {
95
			return getName().compareTo(o.getName());
96
		}
97
				
98
	}
99

  
100
	private List<RepoHIWorkflow> listRepoHIWorkflows() throws ISLookUpException {
67 101
		final String xquery = "for $x in collection('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType') " + "where $x//WORKFLOW_TYPE='REPO_HI' "
68 102
				+ "return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x//WORKFLOW_NAME, ' @@@ ', $x//PARAM[@name='expectedInterfaceTypologyPrefixes'], ' @@@ ', $x//PARAM[@name='expectedCompliancePrefixes'])";
69 103

  
......
77 111
			list.add(new RepoHIWorkflow(arr[0].trim(), arr[1].trim(), ifcTypes, compliances));
78 112
		}
79 113
		Collections.sort(list);
114
		
115
		return list;
116
	}
80 117

  
81
		map.addAttribute("availableRepohiWfs", (new Gson()).toJson(list));
118
	
119
	private List<CompatibilityLevel> listCompatibilityLevels() throws ISLookUpException {
120
		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '" + getCompatibilityLevelsVocabulary().trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
121

  
122
		final List<CompatibilityLevel> list = Lists.newArrayList();
123
		for (String s : lookupLocator.getService().quickSearchProfile(xquery)) {
124
			final String[] arr = s.split("@@@");
125
			list.add(new CompatibilityLevel(arr[0].trim(), arr[1].trim()));
126
		}
127
		Collections.sort(list);
128
		
129
		return list;
82 130
	}
131
	
132
	@Override
133
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
134
		map.addAttribute("availableRepohiWfs", (new Gson()).toJson(listRepoHIWorkflows()));
135
		map.addAttribute("compatibilityLevels", (new Gson()).toJson(listCompatibilityLevels()));
136
	}
137

  
138

  
139
	public String getCompatibilityLevelsVocabulary() {
140
		return compatibilityLevelsVocabulary;
141
	}
142

  
143
	@Required
144
	public void setCompatibilityLevelsVocabulary(
145
			String compatibilityLevelsVocabulary) {
146
		this.compatibilityLevelsVocabulary = compatibilityLevelsVocabulary;
147
	}
148

  
83 149
}

Also available in: Unified diff