Revision 55892
Added by Claudio Atzori almost 5 years ago
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/deploy.info | ||
---|---|---|
1 |
{"type_source": "SVN", "goal": "package -U source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-modular-lightui-ui/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-modular-lightui-ui"} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/clients/ISLookupClient.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.clients; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import org.apache.commons.logging.Log; |
|
9 |
import org.apache.commons.logging.LogFactory; |
|
10 |
|
|
11 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException; |
|
12 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
13 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
14 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
15 |
import eu.dnetlib.functionality.modular.ui.lightui.menu.LightUiMenuEntry; |
|
16 |
|
|
17 |
public class ISLookupClient { |
|
18 |
|
|
19 |
@Resource |
|
20 |
private UniqueServiceLocator serviceLocator; |
|
21 |
|
|
22 |
private static final Log log = LogFactory.getLog(ISLookupClient.class); |
|
23 |
|
|
24 |
public List<LightUiMenuEntry> listMenuEntries() { |
|
25 |
final String xQuery = "for $x in collection('/db/DRIVER/LightUiDSResources/LightUiDSResourceType') order by $x//UI_NAME " |
|
26 |
+ "return concat ($x//UI_NAME/@id, '§§§', $x//UI_NAME, '§§§', $x//UI_DESCRIPTION)"; |
|
27 |
List<LightUiMenuEntry> result = new ArrayList<LightUiMenuEntry>(); |
|
28 |
try { |
|
29 |
List<String> uiProfiles = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xQuery); |
|
30 |
int i = 1; |
|
31 |
for (String profile : uiProfiles) { |
|
32 |
String[] tokens = profile.split("§§§"); |
|
33 |
result.add(new LightUiMenuEntry(tokens[0].trim(), tokens[1].trim(), tokens[1].trim(), tokens[2].trim(), i++)); |
|
34 |
} |
|
35 |
return result; |
|
36 |
} catch (ISLookUpException e) { |
|
37 |
log.error("Error calculating lightui menu entries", e); |
|
38 |
return result; |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
public String getLightUiProfile(final String lightuiId) throws ISLookUpDocumentNotFoundException, ISLookUpException { |
|
43 |
String xQuery = "for $x in collection('/db/DRIVER/LightUiDSResources/LightUiDSResourceType') where $x//UI_NAME/@id = '{id}' return $x"; |
|
44 |
return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xQuery.replace("{id}", lightuiId)); |
|
45 |
} |
|
46 |
|
|
47 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/clients/IndexLightUIClient.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.clients; |
|
2 |
|
|
3 |
import java.io.StringWriter; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import eu.dnetlib.functionality.index.client.IndexClientFactory; |
|
10 |
import org.apache.commons.logging.Log; |
|
11 |
import org.apache.commons.logging.LogFactory; |
|
12 |
import org.dom4j.Document; |
|
13 |
import org.dom4j.DocumentException; |
|
14 |
import org.dom4j.DocumentHelper; |
|
15 |
import org.dom4j.Element; |
|
16 |
import org.springframework.beans.factory.annotation.Autowired; |
|
17 |
import org.springframework.core.io.Resource; |
|
18 |
|
|
19 |
import com.google.common.collect.Lists; |
|
20 |
|
|
21 |
import eu.dnetlib.data.provision.index.rmi.IndexServiceException; |
|
22 |
import eu.dnetlib.enabling.resultset.rmi.ResultSetException; |
|
23 |
import eu.dnetlib.functionality.index.client.IndexClient; |
|
24 |
import eu.dnetlib.functionality.index.client.IndexClientException; |
|
25 |
import eu.dnetlib.functionality.index.client.response.BrowseEntry; |
|
26 |
import eu.dnetlib.functionality.index.client.response.BrowseValueEntry; |
|
27 |
import eu.dnetlib.functionality.index.client.response.LookupResponse; |
|
28 |
import eu.dnetlib.functionality.modular.ui.lightui.objects.IndexConfiguration; |
|
29 |
import eu.dnetlib.functionality.modular.ui.lightui.objects.SearchResult; |
|
30 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
31 |
|
|
32 |
public class IndexLightUIClient { |
|
33 |
|
|
34 |
@Autowired |
|
35 |
private IndexClientFactory indexClientFactory; |
|
36 |
|
|
37 |
private Map<String, IndexClient> indexClientMap; |
|
38 |
|
|
39 |
private static final Log log = LogFactory.getLog(IndexLightUIClient.class); |
|
40 |
|
|
41 |
/** |
|
42 |
* Fixes the labels of the index response according to the specification of the given map. |
|
43 |
* <p> |
|
44 |
* If a browse entry has label = x and field=xForBrowsing, and the map contains (x, xForUI), the returned BrowseEntry will contain label |
|
45 |
* = xForUI, field=xForBrowsing. |
|
46 |
* </p> |
|
47 |
* |
|
48 |
* @param browseResult |
|
49 |
* List of BrowseEntry |
|
50 |
* @param fieldLabels |
|
51 |
* @return |
|
52 |
*/ |
|
53 |
private List<BrowseEntry> fixBrowseEntryLabels(final List<BrowseEntry> browseResult, final Map<String, String> fieldLabels) { |
|
54 |
List<BrowseEntry> fixedBrowseLabels = Lists.newArrayListWithExpectedSize(browseResult.size()); |
|
55 |
for (BrowseEntry be : browseResult) { |
|
56 |
String fieldName = be.getLabel(); |
|
57 |
String browsableFieldName = be.getField(); |
|
58 |
if (fieldLabels.containsKey(fieldName)) { |
|
59 |
fixedBrowseLabels.add(new BrowseEntry(browsableFieldName, fieldLabels.get(fieldName), be.getValues())); |
|
60 |
} else { |
|
61 |
fixedBrowseLabels.add(be); |
|
62 |
} |
|
63 |
} |
|
64 |
return fixedBrowseLabels; |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* |
|
69 |
* @param query |
|
70 |
* @param idx |
|
71 |
* @param browseFieldLabels |
|
72 |
* map with key = field name to browse for, value = label to use in the UI |
|
73 |
* @param max |
|
74 |
* @return |
|
75 |
* @throws IndexServiceException |
|
76 |
* @throws DocumentException |
|
77 |
* @throws ResultSetException |
|
78 |
*/ |
|
79 |
public List<BrowseEntry> browse(final String query, final IndexConfiguration idx, final Map<String, String> browseFieldLabels, final int max) |
|
80 |
throws IndexServiceException, DocumentException, ResultSetException { |
|
81 |
|
|
82 |
final List<String> browseFields = new ArrayList<String>(browseFieldLabels.keySet()); |
|
83 |
|
|
84 |
IndexClient indexClient = getIndexClient(idx); |
|
85 |
List<BrowseEntry> browseResult = indexClient.browse(query, browseFields, max); |
|
86 |
|
|
87 |
return fixBrowseEntryLabels(browseResult, browseFieldLabels); |
|
88 |
|
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* |
|
93 |
* @param query |
|
94 |
* @param idx |
|
95 |
* @param browseFieldLabels |
|
96 |
* map with key = field name to browse for, value = label to use in the UI |
|
97 |
* @param max |
|
98 |
* @param xslt |
|
99 |
* @return |
|
100 |
* @throws IndexServiceException |
|
101 |
* @throws DocumentException |
|
102 |
* @throws ResultSetException |
|
103 |
*/ |
|
104 |
public String browse(final String query, final IndexConfiguration idx, final Map<String, String> browseFieldLabels, final int max, final Resource xslt) |
|
105 |
throws IndexServiceException, DocumentException, ResultSetException { |
|
106 |
List<BrowseEntry> myResults = browse(query, idx, browseFieldLabels, max); |
|
107 |
int total = myResults.size(); |
|
108 |
|
|
109 |
if (total > 0) { |
|
110 |
|
|
111 |
final Element docRoot = DocumentHelper.createElement("browse"); |
|
112 |
final Document docRes = DocumentHelper.createDocument(docRoot); |
|
113 |
|
|
114 |
for (BrowseEntry myEntry : myResults) { |
|
115 |
|
|
116 |
String xpath = "./field[@name='" + myEntry.getField() + "']"; |
|
117 |
|
|
118 |
Element f = (Element) docRoot.selectSingleNode(xpath); |
|
119 |
if (f == null) { |
|
120 |
f = docRoot.addElement("field"); |
|
121 |
f.addAttribute("name", myEntry.getField()); |
|
122 |
f.addAttribute("label", myEntry.getLabel()); |
|
123 |
} |
|
124 |
|
|
125 |
for (BrowseValueEntry valueEntry : myEntry.getValues()) { |
|
126 |
final Element v = f.addElement("value"); |
|
127 |
v.addAttribute("name", valueEntry.getValue().replaceAll("\"", "%22").replaceAll("'", "%27")); |
|
128 |
v.addAttribute("size", "" + valueEntry.getSize()); |
|
129 |
} |
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
return new ApplyXslt(xslt).evaluate(docRes.asXML()); |
|
134 |
} |
|
135 |
|
|
136 |
return ""; |
|
137 |
} |
|
138 |
|
|
139 |
public SearchResult search(final String query, final IndexConfiguration idx, final int page, final int pageSize, final Resource xslt) |
|
140 |
throws IndexServiceException, DocumentException, ResultSetException { |
|
141 |
|
|
142 |
log.info("executing query: " + query); |
|
143 |
IndexClient indexClient = getIndexClient(idx); |
|
144 |
int prod = page * pageSize; |
|
145 |
final int from = prod - pageSize; |
|
146 |
final int to = (from + pageSize) - 1; |
|
147 |
LookupResponse lookupResponse = indexClient.lookup(query, null, from, to); |
|
148 |
|
|
149 |
final long total = lookupResponse.getTotal(); |
|
150 |
final StringWriter html = new StringWriter(); |
|
151 |
|
|
152 |
ApplyXslt f = new ApplyXslt(xslt); |
|
153 |
int totalPages = 0; |
|
154 |
if (lookupResponse.getRecords() != null) { |
|
155 |
for (String s : lookupResponse.getRecords()) { |
|
156 |
html.append(f.evaluate(s)); |
|
157 |
} |
|
158 |
totalPages = ((int) lookupResponse.getTotal() / pageSize) + 1; |
|
159 |
} |
|
160 |
|
|
161 |
return new SearchResult(page, totalPages, total, html.toString()); |
|
162 |
} |
|
163 |
|
|
164 |
public String getDocument(final IndexConfiguration idx, final String field, final String id, final Resource xslt) throws IndexServiceException, |
|
165 |
ResultSetException { |
|
166 |
|
|
167 |
final String query = field + " exact \"" + id.trim() + "\""; |
|
168 |
IndexClient indexClient = getIndexClient(idx); |
|
169 |
LookupResponse lookupResponse = indexClient.lookup(query, null, 0, 1); |
|
170 |
|
|
171 |
final int total = (int) lookupResponse.getTotal(); |
|
172 |
if (total != 1) { |
|
173 |
log.error("Invalid number of results (" + total + ") for query: " + query); |
|
174 |
throw new IllegalArgumentException("Invalid number of results (" + total + ") for query: " + query); |
|
175 |
} |
|
176 |
|
|
177 |
final String record = lookupResponse.getRecords().get(0); |
|
178 |
|
|
179 |
return new ApplyXslt(xslt).evaluate(record); |
|
180 |
} |
|
181 |
|
|
182 |
private IndexClient getIndexClient(final IndexConfiguration configuration) throws IndexClientException { |
|
183 |
if (indexClientMap == null) { |
|
184 |
indexClientMap = new HashMap<String, IndexClient>(); |
|
185 |
} |
|
186 |
if (indexClientMap.containsKey(configuration.getBackendId())) return indexClientMap.get(configuration.getBackendId()); |
|
187 |
|
|
188 |
final IndexClient index = indexClientFactory.getClient(configuration.getFormat(), configuration.getLayout(), configuration.getInterpretation()); |
|
189 |
indexClientMap.put(configuration.getBackendId(), index); |
|
190 |
|
|
191 |
return index; |
|
192 |
} |
|
193 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/menu/LightUiMenuGroup.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.menu; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Set; |
|
5 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import org.springframework.beans.factory.annotation.Required; |
|
9 |
|
|
10 |
import com.google.common.collect.Sets; |
|
11 |
|
|
12 |
import eu.dnetlib.functionality.modular.ui.AbstractMenu; |
|
13 |
import eu.dnetlib.functionality.modular.ui.MenuEntry; |
|
14 |
import eu.dnetlib.functionality.modular.ui.lightui.clients.ISLookupClient; |
|
15 |
import eu.dnetlib.functionality.modular.ui.users.AccessLimited; |
|
16 |
import eu.dnetlib.functionality.modular.ui.users.PermissionLevel; |
|
17 |
|
|
18 |
public class LightUiMenuGroup extends AbstractMenu implements AccessLimited { |
|
19 |
|
|
20 |
private int order; |
|
21 |
|
|
22 |
@Resource |
|
23 |
private ISLookupClient isLookupClient; |
|
24 |
|
|
25 |
@Override |
|
26 |
public Set<PermissionLevel> getPermissionLevels() { |
|
27 |
return Sets.newHashSet(PermissionLevel.USER); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public List<? extends MenuEntry> getEntries() { |
|
32 |
return isLookupClient.listMenuEntries(); |
|
33 |
} |
|
34 |
|
|
35 |
@Required |
|
36 |
public void setOrder(final int order) { |
|
37 |
this.order = order; |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public int getOrder() { |
|
42 |
return order; |
|
43 |
} |
|
44 |
|
|
45 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/menu/LightUiMenuEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.menu; |
|
2 |
|
|
3 |
import java.io.UnsupportedEncodingException; |
|
4 |
import java.net.URLEncoder; |
|
5 |
|
|
6 |
import eu.dnetlib.functionality.modular.ui.MenuEntry; |
|
7 |
|
|
8 |
public class LightUiMenuEntry extends MenuEntry { |
|
9 |
|
|
10 |
private String id; |
|
11 |
|
|
12 |
public LightUiMenuEntry(final String id, final String title, final String menu, final String desc, final int order) { |
|
13 |
setId(id); |
|
14 |
setTitle(title); |
|
15 |
setMenu(menu); |
|
16 |
setDescription(desc); |
|
17 |
setOrder(order); |
|
18 |
} |
|
19 |
|
|
20 |
@Override |
|
21 |
public String getRelativeUrl() { |
|
22 |
try { |
|
23 |
return "/ui/lightui.do?ui=" + URLEncoder.encode(getId(), "UTF-8"); |
|
24 |
} catch (UnsupportedEncodingException e) { |
|
25 |
return "javascript:void(0)"; |
|
26 |
} |
|
27 |
} |
|
28 |
|
|
29 |
public String getId() { |
|
30 |
return id; |
|
31 |
} |
|
32 |
|
|
33 |
public void setId(String id) { |
|
34 |
this.id = id; |
|
35 |
} |
|
36 |
|
|
37 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/LightUiEntryPointController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import javax.servlet.http.HttpServletRequest; |
|
6 |
import javax.servlet.http.HttpServletResponse; |
|
7 |
|
|
8 |
import org.springframework.beans.factory.annotation.Required; |
|
9 |
import org.springframework.ui.ModelMap; |
|
10 |
|
|
11 |
import com.google.gson.Gson; |
|
12 |
|
|
13 |
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint; |
|
14 |
import eu.dnetlib.functionality.modular.ui.lightui.objects.SearchField; |
|
15 |
import eu.dnetlib.functionality.modular.ui.lightui.objects.SearchFieldGrouper; |
|
16 |
|
|
17 |
public class LightUiEntryPointController extends ModuleEntryPoint { |
|
18 |
|
|
19 |
private SearchFieldGrouper searchFieldGrouper; |
|
20 |
|
|
21 |
@Override |
|
22 |
protected void initialize(final ModelMap map, final HttpServletRequest request, |
|
23 |
final HttpServletResponse response) throws Exception { |
|
24 |
|
|
25 |
if (request.getParameterMap().containsKey("ui")) { |
|
26 |
final String uiId = request.getParameter("ui"); |
|
27 |
final List<SearchField> searchFields = searchFieldGrouper.getAllFields(uiId); |
|
28 |
map.addAttribute("fields", searchFields); |
|
29 |
map.addAttribute("fieldsJson", (new Gson()).toJson(searchFields)); |
|
30 |
map.addAttribute("uiId", uiId); |
|
31 |
} else { |
|
32 |
response.sendError(500, "Field 'ui' is missing"); |
|
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
public SearchFieldGrouper getSearchFieldGrouper() { |
|
37 |
return searchFieldGrouper; |
|
38 |
} |
|
39 |
|
|
40 |
@Required |
|
41 |
public void setSearchFieldGrouper(SearchFieldGrouper searchFieldGrouper) { |
|
42 |
this.searchFieldGrouper = searchFieldGrouper; |
|
43 |
} |
|
44 |
|
|
45 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/LightUIUtils.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.dom4j.DocumentException; |
|
7 |
import org.dom4j.Element; |
|
8 |
import org.dom4j.Node; |
|
9 |
|
|
10 |
import com.google.common.collect.Maps; |
|
11 |
|
|
12 |
import eu.dnetlib.functionality.modular.ui.lightui.objects.IndexConfiguration; |
|
13 |
|
|
14 |
public class LightUIUtils { |
|
15 |
|
|
16 |
public Map<String, String> getBrowseFields(final Node browseNode) { |
|
17 |
|
|
18 |
final Map<String, String> browseFields = Maps.newLinkedHashMap(); |
|
19 |
for (Object o : browseNode.selectNodes(".//BROWSE_FIELD")) { |
|
20 |
final String id = ((Element) o).valueOf("@id"); |
|
21 |
final String label = ((Element) o).valueOf("@label"); |
|
22 |
browseFields.put(id, label); |
|
23 |
} |
|
24 |
return browseFields; |
|
25 |
} |
|
26 |
|
|
27 |
public IndexConfiguration calculateIndexConfiguration(final String lightuiId, final Node node) throws DocumentException, IOException { |
|
28 |
final String id = node.valueOf("./INDEX/@id"); |
|
29 |
final String format = node.valueOf("./INDEX/@format"); |
|
30 |
final String layout = node.valueOf("./INDEX/@layout"); |
|
31 |
final String interpretation = node.valueOf("./INDEX/@interpretation"); |
|
32 |
final String backendId = node.valueOf("./INDEX/@backendId"); |
|
33 |
|
|
34 |
return new IndexConfiguration(id, format, layout, interpretation, backendId); |
|
35 |
} |
|
36 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/LightUiInternalController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.apache.commons.lang.math.NumberUtils; |
|
7 |
import org.dom4j.Document; |
|
8 |
import org.dom4j.Node; |
|
9 |
import org.dom4j.io.SAXReader; |
|
10 |
import org.springframework.core.io.ClassPathResource; |
|
11 |
import org.springframework.core.io.Resource; |
|
12 |
import org.springframework.stereotype.Controller; |
|
13 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
14 |
import org.springframework.web.bind.annotation.RequestParam; |
|
15 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
16 |
|
|
17 |
import com.google.common.collect.Maps; |
|
18 |
|
|
19 |
import eu.dnetlib.functionality.modular.ui.lightui.clients.ISLookupClient; |
|
20 |
import eu.dnetlib.functionality.modular.ui.lightui.clients.IndexLightUIClient; |
|
21 |
import eu.dnetlib.functionality.modular.ui.lightui.objects.SearchResult; |
|
22 |
|
|
23 |
@Controller |
|
24 |
public class LightUiInternalController { |
|
25 |
|
|
26 |
private static final int DEFAULT_MAX_BROWSE_VALUES = 20; |
|
27 |
private static final int DEFAULT_MAX_SINGLE_BROWSE_FIELD_VALUES = 20; |
|
28 |
private static final int DEFAULT_PAGESIZE = 10; |
|
29 |
|
|
30 |
@javax.annotation.Resource |
|
31 |
private IndexLightUIClient indexClient; |
|
32 |
|
|
33 |
@javax.annotation.Resource |
|
34 |
private ISLookupClient isLookupClient; |
|
35 |
|
|
36 |
@javax.annotation.Resource |
|
37 |
private LightUIUtils lightUIUtils; |
|
38 |
|
|
39 |
@RequestMapping("/ui/lightui_browse") |
|
40 |
public @ResponseBody String browse(@RequestParam(value = "ui", required = true) final String lightuiId, |
|
41 |
@RequestParam(value = "query", required = true) final String query) |
|
42 |
throws Exception { |
|
43 |
final Node browseNode = getConfigurationNode(lightuiId, "//BROWSE"); |
|
44 |
final int max = NumberUtils.toInt(browseNode.valueOf("@max"), DEFAULT_MAX_BROWSE_VALUES); |
|
45 |
final Resource xslt = new ClassPathResource(browseNode.valueOf("./FORMATTER/@xslt")); |
|
46 |
|
|
47 |
final Map<String, String> browseFields = lightUIUtils.getBrowseFields(browseNode); |
|
48 |
|
|
49 |
return indexClient.browse(query, lightUIUtils.calculateIndexConfiguration(lightuiId, browseNode), browseFields, max, xslt); |
|
50 |
} |
|
51 |
|
|
52 |
@RequestMapping("/ui/lightui_browse_one") |
|
53 |
public @ResponseBody String browseOne(@RequestParam(value = "ui", required = true) final String lightuiId, |
|
54 |
@RequestParam(value = "query", required = true) final String query, |
|
55 |
@RequestParam(value = "field", required = true) final String field, |
|
56 |
@RequestParam(value = "label", required = true) final String label) throws Exception { |
|
57 |
|
|
58 |
final Node browseNode = getConfigurationNode(lightuiId, "//BROWSE_SINGLE_FIELD"); |
|
59 |
final int max = NumberUtils.toInt(browseNode.valueOf("@max"), DEFAULT_MAX_SINGLE_BROWSE_FIELD_VALUES); |
|
60 |
|
|
61 |
final Resource xslt = new ClassPathResource(browseNode.valueOf("./FORMATTER/@xslt")); |
|
62 |
final Map<String, String> browseFields = Maps.newHashMap(); |
|
63 |
browseFields.put(field, label); |
|
64 |
|
|
65 |
return indexClient.browse(query, lightUIUtils.calculateIndexConfiguration(lightuiId, browseNode), browseFields, max, xslt); |
|
66 |
} |
|
67 |
|
|
68 |
@RequestMapping("/ui/lightui_search") |
|
69 |
public @ResponseBody SearchResult search(@RequestParam(value = "ui", required = true) final String lightuiId, |
|
70 |
@RequestParam(value = "query", required = true) final String query, |
|
71 |
@RequestParam(value = "page", required = true) final int page) throws Exception { |
|
72 |
|
|
73 |
final Node searchNode = getConfigurationNode(lightuiId, "//SEARCH"); |
|
74 |
final Resource xslt = new ClassPathResource(searchNode.valueOf("./FORMATTER/@xslt")); |
|
75 |
final int pageSize = NumberUtils.toInt(searchNode.valueOf("@pageSize"), DEFAULT_PAGESIZE); |
|
76 |
|
|
77 |
return indexClient.search(query, lightUIUtils.calculateIndexConfiguration(lightuiId, searchNode), page, pageSize, xslt); |
|
78 |
} |
|
79 |
|
|
80 |
@RequestMapping("/ui/lightui_findone") |
|
81 |
public @ResponseBody String getDocument(@RequestParam(value = "ui", required = true) final String lightuiId, |
|
82 |
@RequestParam(value = "field", required = true) final String field, |
|
83 |
@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
84 |
final Node searchNode = getConfigurationNode(lightuiId, "//DOCUMENT"); |
|
85 |
final Resource xslt = new ClassPathResource(searchNode.valueOf("./FORMATTER/@xslt")); |
|
86 |
|
|
87 |
return indexClient.getDocument(lightUIUtils.calculateIndexConfiguration(lightuiId, searchNode), field, id, xslt); |
|
88 |
} |
|
89 |
|
|
90 |
private Node getConfigurationNode(final String lightuiId, final String xpath) throws Exception { |
|
91 |
final SAXReader reader = new SAXReader(); |
|
92 |
final Document doc = reader.read(new StringReader(isLookupClient.getLightUiProfile(lightuiId))); |
|
93 |
return doc.selectSingleNode(xpath); |
|
94 |
} |
|
95 |
|
|
96 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/objects/IndexConfiguration.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.objects; |
|
2 |
|
|
3 |
public class IndexConfiguration { |
|
4 |
|
|
5 |
private String id; |
|
6 |
private String format; |
|
7 |
private String layout; |
|
8 |
private String interpretation; |
|
9 |
private String backendId; |
|
10 |
|
|
11 |
public IndexConfiguration() {} |
|
12 |
|
|
13 |
public IndexConfiguration(final String id, final String format, final String layout, final String interpretation, final String backendId) { |
|
14 |
this.id = id; |
|
15 |
this.format = format; |
|
16 |
this.layout = layout; |
|
17 |
this.interpretation = interpretation; |
|
18 |
this.backendId = backendId; |
|
19 |
} |
|
20 |
|
|
21 |
public String getId() { |
|
22 |
return id; |
|
23 |
} |
|
24 |
|
|
25 |
public void setId(final String id) { |
|
26 |
this.id = id; |
|
27 |
} |
|
28 |
|
|
29 |
public String getFormat() { |
|
30 |
return format; |
|
31 |
} |
|
32 |
|
|
33 |
public void setFormat(final String format) { |
|
34 |
this.format = format; |
|
35 |
} |
|
36 |
|
|
37 |
public String getLayout() { |
|
38 |
return layout; |
|
39 |
} |
|
40 |
|
|
41 |
public void setLayout(final String layout) { |
|
42 |
this.layout = layout; |
|
43 |
} |
|
44 |
|
|
45 |
public String getInterpretation() { |
|
46 |
return interpretation; |
|
47 |
} |
|
48 |
|
|
49 |
public void setInterpretation(final String interpretation) { |
|
50 |
this.interpretation = interpretation; |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @return the backendId |
|
55 |
*/ |
|
56 |
public String getBackendId() { |
|
57 |
return backendId; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* @param backendId |
|
62 |
* the backendId to set |
|
63 |
*/ |
|
64 |
public void setBackendId(final String backendId) { |
|
65 |
this.backendId = backendId; |
|
66 |
} |
|
67 |
|
|
68 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/objects/BrowseFieldResult.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.objects; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.google.common.collect.Lists; |
|
6 |
|
|
7 |
public class BrowseFieldResult { |
|
8 |
private String field; |
|
9 |
private String label; |
|
10 |
private List<BrowseValue> values = Lists.newArrayList(); |
|
11 |
|
|
12 |
public BrowseFieldResult() {} |
|
13 |
|
|
14 |
public BrowseFieldResult(final String field, final String label, final List<BrowseValue> values) { |
|
15 |
this.field = field; |
|
16 |
this.setLabel(label); |
|
17 |
this.values = values; |
|
18 |
} |
|
19 |
|
|
20 |
public String getField() { |
|
21 |
return field; |
|
22 |
} |
|
23 |
|
|
24 |
public void setField(final String field) { |
|
25 |
this.field = field; |
|
26 |
} |
|
27 |
|
|
28 |
public String getLabel() { |
|
29 |
return label; |
|
30 |
} |
|
31 |
|
|
32 |
public void setLabel(final String label) { |
|
33 |
this.label = label; |
|
34 |
} |
|
35 |
|
|
36 |
public List<BrowseValue> getValues() { |
|
37 |
return values; |
|
38 |
} |
|
39 |
|
|
40 |
public void setValues(final List<BrowseValue> values) { |
|
41 |
this.values = values; |
|
42 |
} |
|
43 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/objects/SearchResult.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.objects; |
|
2 |
|
|
3 |
public class SearchResult { |
|
4 |
private int currPage; |
|
5 |
private int totalPages; |
|
6 |
private long total; |
|
7 |
|
|
8 |
private String html; |
|
9 |
|
|
10 |
public SearchResult() {} |
|
11 |
|
|
12 |
public SearchResult(int currPage, int totalPages, long total, String html) { |
|
13 |
super(); |
|
14 |
this.currPage = currPage; |
|
15 |
this.totalPages = totalPages; |
|
16 |
this.total = total; |
|
17 |
this.html = html; |
|
18 |
} |
|
19 |
|
|
20 |
public int getCurrPage() { |
|
21 |
return currPage; |
|
22 |
} |
|
23 |
public void setCurrPage(int currPage) { |
|
24 |
this.currPage = currPage; |
|
25 |
} |
|
26 |
public int getTotalPages() { |
|
27 |
return totalPages; |
|
28 |
} |
|
29 |
public void setTotalPages(int totalPages) { |
|
30 |
this.totalPages = totalPages; |
|
31 |
} |
|
32 |
public String getHtml() { |
|
33 |
return html; |
|
34 |
} |
|
35 |
public void setHtml(String html) { |
|
36 |
this.html = html; |
|
37 |
} |
|
38 |
|
|
39 |
public long getTotal() { |
|
40 |
return total; |
|
41 |
} |
|
42 |
|
|
43 |
public void setTotal(long total) { |
|
44 |
this.total = total; |
|
45 |
} |
|
46 |
|
|
47 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/objects/ValueWithLabel.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.objects; |
|
2 |
|
|
3 |
/** |
|
4 |
* The Class ValueWithLabel. |
|
5 |
*/ |
|
6 |
public class ValueWithLabel { |
|
7 |
|
|
8 |
/** The label. */ |
|
9 |
private String label; |
|
10 |
|
|
11 |
/** The value. */ |
|
12 |
private String value; |
|
13 |
|
|
14 |
/** |
|
15 |
* The Constructor. |
|
16 |
*/ |
|
17 |
public ValueWithLabel() {} |
|
18 |
|
|
19 |
/** |
|
20 |
* The Constructor. |
|
21 |
* |
|
22 |
* @param label |
|
23 |
* the label |
|
24 |
* @param value |
|
25 |
* the value |
|
26 |
*/ |
|
27 |
public ValueWithLabel(final String label, final String value) { |
|
28 |
this.label = label; |
|
29 |
this.value = value; |
|
30 |
} |
|
31 |
|
|
32 |
/** |
|
33 |
* Gets the label. |
|
34 |
* |
|
35 |
* @return the label |
|
36 |
*/ |
|
37 |
public String getLabel() { |
|
38 |
return label; |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* Sets the label. |
|
43 |
* |
|
44 |
* @param label |
|
45 |
* the label |
|
46 |
*/ |
|
47 |
public void setLabel(final String label) { |
|
48 |
this.label = label; |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Gets the value. |
|
53 |
* |
|
54 |
* @return the value |
|
55 |
*/ |
|
56 |
public String getValue() { |
|
57 |
return value; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Sets the value. |
|
62 |
* |
|
63 |
* @param value |
|
64 |
* the value |
|
65 |
*/ |
|
66 |
public void setValue(final String value) { |
|
67 |
this.value = value; |
|
68 |
} |
|
69 |
|
|
70 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/objects/SearchField.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.objects; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
public class SearchField { |
|
6 |
private String field; |
|
7 |
private String label; |
|
8 |
private String operator; |
|
9 |
private List<ValueWithLabel> predefinedValues = null; |
|
10 |
|
|
11 |
public SearchField() {} |
|
12 |
|
|
13 |
public SearchField(final String field, final String label, final String operator) { |
|
14 |
this(field, label, operator, null); |
|
15 |
} |
|
16 |
|
|
17 |
public SearchField(final String field, final String label, final String operator, final List<ValueWithLabel> predefinedValues) { |
|
18 |
super(); |
|
19 |
this.field = field; |
|
20 |
this.label = label; |
|
21 |
this.operator = operator; |
|
22 |
this.predefinedValues = predefinedValues; |
|
23 |
} |
|
24 |
|
|
25 |
public String getOperator() { |
|
26 |
return operator; |
|
27 |
} |
|
28 |
|
|
29 |
public void setOperator(final String operator) { |
|
30 |
this.operator = operator; |
|
31 |
} |
|
32 |
|
|
33 |
public String getField() { |
|
34 |
return field; |
|
35 |
} |
|
36 |
|
|
37 |
public void setField(final String field) { |
|
38 |
this.field = field; |
|
39 |
} |
|
40 |
|
|
41 |
public String getLabel() { |
|
42 |
return label; |
|
43 |
} |
|
44 |
|
|
45 |
public void setLabel(final String label) { |
|
46 |
this.label = label; |
|
47 |
} |
|
48 |
|
|
49 |
public List<ValueWithLabel> getPredefinedValues() { |
|
50 |
return predefinedValues; |
|
51 |
} |
|
52 |
|
|
53 |
public void setPredefinedValues(final List<ValueWithLabel> predefinedValues) { |
|
54 |
this.predefinedValues = predefinedValues; |
|
55 |
} |
|
56 |
|
|
57 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/objects/SearchFieldGrouper.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.objects; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import org.apache.commons.logging.Log; |
|
9 |
import org.apache.commons.logging.LogFactory; |
|
10 |
import org.dom4j.Document; |
|
11 |
import org.dom4j.Element; |
|
12 |
import org.dom4j.Node; |
|
13 |
import org.dom4j.io.SAXReader; |
|
14 |
|
|
15 |
import com.google.common.base.Function; |
|
16 |
import com.google.common.collect.Lists; |
|
17 |
|
|
18 |
import eu.dnetlib.functionality.index.client.response.BrowseEntry; |
|
19 |
import eu.dnetlib.functionality.index.client.response.BrowseValueEntry; |
|
20 |
import eu.dnetlib.functionality.modular.ui.lightui.LightUIUtils; |
|
21 |
import eu.dnetlib.functionality.modular.ui.lightui.clients.ISLookupClient; |
|
22 |
import eu.dnetlib.functionality.modular.ui.lightui.clients.IndexLightUIClient; |
|
23 |
|
|
24 |
public class SearchFieldGrouper { |
|
25 |
|
|
26 |
private static final int maxBrowseValues = 100; |
|
27 |
|
|
28 |
@Resource |
|
29 |
private IndexLightUIClient indexClient; |
|
30 |
|
|
31 |
@Resource |
|
32 |
private ISLookupClient isLookupClient; |
|
33 |
|
|
34 |
@Resource |
|
35 |
private LightUIUtils lightUiUtils; |
|
36 |
|
|
37 |
private static final Log log = LogFactory.getLog(SearchFieldGrouper.class); |
|
38 |
|
|
39 |
public List<SearchField> getAllFields(final String lightuiId) { |
|
40 |
final List<SearchField> res = Lists.newArrayList(); |
|
41 |
final SAXReader reader = new SAXReader(); |
|
42 |
try { |
|
43 |
final Document doc = reader.read(new StringReader(isLookupClient.getLightUiProfile(lightuiId))); |
|
44 |
final Node searchNode = doc.selectSingleNode("//CONFIGURATION/SEARCH"); |
|
45 |
final IndexConfiguration idx = getIndexConfiguration(searchNode); |
|
46 |
res.addAll(getPredefinedFields(searchNode)); |
|
47 |
res.addAll(calculateBrowseFields(idx, searchNode)); |
|
48 |
} catch (Exception e) { |
|
49 |
log.error("Error obtaining search fields", e); |
|
50 |
} |
|
51 |
return res; |
|
52 |
} |
|
53 |
|
|
54 |
private IndexConfiguration getIndexConfiguration(final Node searchNode) { |
|
55 |
final String id = searchNode.valueOf("./INDEX/@id"); |
|
56 |
final String format = searchNode.valueOf("./INDEX/@format"); |
|
57 |
final String layout = searchNode.valueOf("./INDEX/@layout"); |
|
58 |
final String interpretation = searchNode.valueOf("./INDEX/@interpretation"); |
|
59 |
final String backendId = searchNode.valueOf("./INDEX/@backendId"); |
|
60 |
|
|
61 |
return new IndexConfiguration(id, format, layout, interpretation, backendId); |
|
62 |
} |
|
63 |
|
|
64 |
private List<SearchField> calculateBrowseFields(final IndexConfiguration idx, final Node node) { |
|
65 |
try { |
|
66 |
return Lists.transform(indexClient.browse("*=*", idx, lightUiUtils.getBrowseFields(node), maxBrowseValues), |
|
67 |
new Function<BrowseEntry, SearchField>() { |
|
68 |
|
|
69 |
@Override |
|
70 |
public SearchField apply(final BrowseEntry r) { |
|
71 |
final SearchField sf = new SearchField(); |
|
72 |
sf.setField(r.getField()); |
|
73 |
sf.setLabel(r.getLabel()); |
|
74 |
sf.setOperator("exact"); |
|
75 |
sf.setPredefinedValues(Lists.transform(r.getValues(), new Function<BrowseValueEntry, ValueWithLabel>() { |
|
76 |
|
|
77 |
@Override |
|
78 |
public ValueWithLabel apply(final BrowseValueEntry bv) { |
|
79 |
return new ValueWithLabel(bv.getValue() + " (" + bv.getSize() + ")", bv.getValue()); |
|
80 |
} |
|
81 |
})); |
|
82 |
return sf; |
|
83 |
} |
|
84 |
}); |
|
85 |
} catch (Exception e) { |
|
86 |
log.warn("Error executing default browse query", e); |
|
87 |
return Lists.newArrayList(); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
private List<SearchField> getPredefinedFields(final Node node) { |
|
92 |
final List<SearchField> list = Lists.newArrayList(); |
|
93 |
|
|
94 |
for (Object o : node.selectNodes(".//TEXT_FIELD")) { |
|
95 |
final String id = ((Element) o).valueOf("@id"); |
|
96 |
final String label = ((Element) o).valueOf("@label"); |
|
97 |
final String operator = ((Element) o).valueOf("@operator"); |
|
98 |
list.add(new SearchField(id, label, operator)); |
|
99 |
} |
|
100 |
|
|
101 |
for (Object o : node.selectNodes(".//SELECT_FIELD")) { |
|
102 |
final String id = ((Element) o).valueOf("@id"); |
|
103 |
final String label = ((Element) o).valueOf("@label"); |
|
104 |
final String operator = ((Element) o).valueOf("@operator"); |
|
105 |
|
|
106 |
final List<ValueWithLabel> values = Lists.newArrayList(); |
|
107 |
for (Object v : ((Element) o).selectNodes("./VALUE")) { |
|
108 |
final String v_id = ((Element) v).valueOf("@id"); |
|
109 |
final String v_label = ((Element) v).valueOf("@label"); |
|
110 |
values.add(new ValueWithLabel(v_label, v_id)); |
|
111 |
} |
|
112 |
list.add(new SearchField(id, label, operator, values)); |
|
113 |
} |
|
114 |
|
|
115 |
return list; |
|
116 |
} |
|
117 |
|
|
118 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/java/eu/dnetlib/functionality/modular/ui/lightui/objects/BrowseValue.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.lightui.objects; |
|
2 |
|
|
3 |
public class BrowseValue { |
|
4 |
private String value; |
|
5 |
private int size; |
|
6 |
|
|
7 |
public BrowseValue() {} |
|
8 |
|
|
9 |
public BrowseValue(final String value, final int size) { |
|
10 |
this.value = value; |
|
11 |
this.size = size; |
|
12 |
} |
|
13 |
|
|
14 |
public String getValue() { |
|
15 |
return value; |
|
16 |
} |
|
17 |
|
|
18 |
public void setValue(final String value) { |
|
19 |
this.value = value; |
|
20 |
} |
|
21 |
|
|
22 |
public int getSize() { |
|
23 |
return size; |
|
24 |
} |
|
25 |
|
|
26 |
public void setSize(final int size) { |
|
27 |
this.size = size; |
|
28 |
} |
|
29 |
|
|
30 |
} |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/resources/eu/dnetlib/test/schemas/lightui/LightUiDSResourceType.xsd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> |
|
3 |
<xs:element name="RESOURCE_PROFILE"> |
|
4 |
<xs:complexType> |
|
5 |
<xs:sequence> |
|
6 |
<xs:element ref="HEADER"/> |
|
7 |
<xs:element ref="BODY"/> |
|
8 |
</xs:sequence> |
|
9 |
</xs:complexType> |
|
10 |
</xs:element> |
|
11 |
<xs:element name="HEADER"> |
|
12 |
<xs:complexType> |
|
13 |
<xs:sequence> |
|
14 |
<xs:element ref="RESOURCE_IDENTIFIER"/> |
|
15 |
<xs:element ref="RESOURCE_TYPE"/> |
|
16 |
<xs:element ref="RESOURCE_KIND"/> |
|
17 |
<xs:element ref="RESOURCE_URI"/> |
|
18 |
<xs:element ref="DATE_OF_CREATION"/> |
|
19 |
</xs:sequence> |
|
20 |
</xs:complexType> |
|
21 |
</xs:element> |
|
22 |
<xs:element name="RESOURCE_IDENTIFIER"> |
|
23 |
<xs:complexType> |
|
24 |
<xs:attribute name="value" use="required"/> |
|
25 |
</xs:complexType> |
|
26 |
</xs:element> |
|
27 |
<xs:element name="RESOURCE_TYPE"> |
|
28 |
<xs:complexType> |
|
29 |
<xs:attribute name="value" use="required" type="xs:NCName"/> |
|
30 |
</xs:complexType> |
|
31 |
</xs:element> |
|
32 |
<xs:element name="RESOURCE_KIND"> |
|
33 |
<xs:complexType> |
|
34 |
<xs:attribute name="value" use="required" type="xs:NCName"/> |
|
35 |
</xs:complexType> |
|
36 |
</xs:element> |
|
37 |
<xs:element name="RESOURCE_URI"> |
|
38 |
<xs:complexType> |
|
39 |
<xs:attribute name="value" use="required"/> |
|
40 |
</xs:complexType> |
|
41 |
</xs:element> |
|
42 |
<xs:element name="DATE_OF_CREATION"> |
|
43 |
<xs:complexType> |
|
44 |
<xs:attribute name="value" use="required" type="xs:dateTime"/> |
|
45 |
</xs:complexType> |
|
46 |
</xs:element> |
|
47 |
<xs:element name="BODY"> |
|
48 |
<xs:complexType> |
|
49 |
<xs:sequence> |
|
50 |
<xs:element ref="CONFIGURATION"/> |
|
51 |
<xs:element ref="STATUS"/> |
|
52 |
<xs:element ref="SECURITY_PARAMETERS"/> |
|
53 |
</xs:sequence> |
|
54 |
</xs:complexType> |
|
55 |
</xs:element> |
|
56 |
<xs:element name="CONFIGURATION"> |
|
57 |
<xs:complexType> |
|
58 |
<xs:sequence> |
|
59 |
<xs:element ref="UI_NAME"/> |
|
60 |
<xs:element ref="UI_DESCRIPTION"/> |
|
61 |
<xs:element ref="SEARCH"/> |
|
62 |
<xs:element ref="BROWSE"/> |
|
63 |
<xs:element ref="BROWSE_SINGLE_FIELD"/> |
|
64 |
<xs:element ref="DOCUMENT"/> |
|
65 |
</xs:sequence> |
|
66 |
</xs:complexType> |
|
67 |
</xs:element> |
|
68 |
<xs:element name="UI_NAME"> |
|
69 |
<xs:complexType mixed="true"> |
|
70 |
<xs:attribute name="id" use="required" type="xs:NCName"/> |
|
71 |
</xs:complexType> |
|
72 |
</xs:element> |
|
73 |
<xs:element name="UI_DESCRIPTION" type="xs:string"/> |
|
74 |
<xs:element name="SEARCH"> |
|
75 |
<xs:complexType> |
|
76 |
<xs:sequence> |
|
77 |
<xs:element ref="INDEX"/> |
|
78 |
<xs:element ref="FIELDS"/> |
|
79 |
<xs:element ref="FORMATTER"/> |
|
80 |
</xs:sequence> |
|
81 |
<xs:attribute name="pageSize" use="required" type="xs:integer"/> |
|
82 |
</xs:complexType> |
|
83 |
</xs:element> |
|
84 |
<xs:element name="BROWSE"> |
|
85 |
<xs:complexType> |
|
86 |
<xs:sequence> |
|
87 |
<xs:element ref="INDEX"/> |
|
88 |
<xs:element ref="FIELDS"/> |
|
89 |
<xs:element ref="FORMATTER"/> |
|
90 |
</xs:sequence> |
|
91 |
<xs:attribute name="max" use="required" type="xs:integer"/> |
|
92 |
</xs:complexType> |
|
93 |
</xs:element> |
|
94 |
<xs:element name="BROWSE_SINGLE_FIELD"> |
|
95 |
<xs:complexType> |
|
96 |
<xs:sequence> |
|
97 |
<xs:element ref="INDEX"/> |
|
98 |
<xs:element ref="FORMATTER"/> |
|
99 |
</xs:sequence> |
|
100 |
<xs:attribute name="max" use="required" type="xs:integer"/> |
|
101 |
</xs:complexType> |
|
102 |
</xs:element> |
|
103 |
<xs:element name="DOCUMENT"> |
|
104 |
<xs:complexType> |
|
105 |
<xs:sequence> |
|
106 |
<xs:element ref="INDEX"/> |
|
107 |
<xs:element ref="FORMATTER"/> |
|
108 |
</xs:sequence> |
|
109 |
</xs:complexType> |
|
110 |
</xs:element> |
|
111 |
<xs:element name="STATUS"> |
|
112 |
<xs:complexType> |
|
113 |
<xs:sequence> |
|
114 |
<xs:element ref="LAST_UPDATE" minOccurs="0" maxOccurs="1"/> |
|
115 |
</xs:sequence> |
|
116 |
</xs:complexType> |
|
117 |
</xs:element> |
|
118 |
<xs:element name="LAST_UPDATE"> |
|
119 |
<xs:complexType> |
|
120 |
<xs:attribute name="value" use="required" type="xs:dateTime"/> |
|
121 |
</xs:complexType> |
|
122 |
</xs:element> |
|
123 |
<xs:element name="SECURITY_PARAMETERS" type="xs:NCName"/> |
|
124 |
<xs:element name="INDEX"> |
|
125 |
<xs:complexType> |
|
126 |
<xs:attribute name="backendId" use="required" type="xs:NCName"/> |
|
127 |
<xs:attribute name="format" use="required" type="xs:NCName"/> |
|
128 |
<xs:attribute name="id" use="required" type="xs:NCName"/> |
|
129 |
<xs:attribute name="interpretation" use="required" type="xs:NCName"/> |
|
130 |
<xs:attribute name="layout" use="required" type="xs:NCName"/> |
|
131 |
</xs:complexType> |
|
132 |
</xs:element> |
|
133 |
<xs:element name="FIELDS"> |
|
134 |
<xs:complexType> |
|
135 |
<xs:sequence> |
|
136 |
<xs:element minOccurs="0" maxOccurs="unbounded" ref="TEXT_FIELD"/> |
|
137 |
<xs:element maxOccurs="unbounded" ref="BROWSE_FIELD"/> |
|
138 |
<xs:element minOccurs="0" ref="SELECT_FIELD"/> |
|
139 |
</xs:sequence> |
|
140 |
</xs:complexType> |
|
141 |
</xs:element> |
|
142 |
<xs:element name="TEXT_FIELD"> |
|
143 |
<xs:complexType> |
|
144 |
<xs:attribute name="id" use="required" type="xs:NCName"/> |
|
145 |
<xs:attribute name="label" use="required"/> |
|
146 |
<xs:attribute name="operator" use="required" type="xs:NCName"/> |
|
147 |
</xs:complexType> |
|
148 |
</xs:element> |
|
149 |
<xs:element name="BROWSE_FIELD"> |
|
150 |
<xs:complexType> |
|
151 |
<xs:attribute name="id" use="required" type="xs:NCName"/> |
|
152 |
<xs:attribute name="label" use="required"/> |
|
153 |
</xs:complexType> |
|
154 |
</xs:element> |
|
155 |
<xs:element name="SELECT_FIELD"> |
|
156 |
<xs:complexType> |
|
157 |
<xs:sequence> |
|
158 |
<xs:element maxOccurs="unbounded" ref="VALUE"/> |
|
159 |
</xs:sequence> |
|
160 |
<xs:attribute name="id" use="required" type="xs:NCName"/> |
|
161 |
<xs:attribute name="label" use="required"/> |
|
162 |
<xs:attribute name="operator" use="required" type="xs:NCName"/> |
|
163 |
</xs:complexType> |
|
164 |
</xs:element> |
|
165 |
<xs:element name="VALUE"> |
|
166 |
<xs:complexType> |
|
167 |
<xs:attribute name="id" use="required" type="xs:integer"/> |
|
168 |
<xs:attribute name="label" use="required" type="xs:integer"/> |
|
169 |
</xs:complexType> |
|
170 |
</xs:element> |
|
171 |
<xs:element name="FORMATTER"> |
|
172 |
<xs:complexType> |
|
173 |
<xs:attribute name="xslt" use="required"/> |
|
174 |
</xs:complexType> |
|
175 |
</xs:element> |
|
176 |
</xs:schema> |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/resources/eu/dnetlib/functionality/modular/ui/lightui/webContext-dnet-modular-lightui-ui.xml | ||
---|---|---|
1 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
2 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" |
|
3 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> |
|
4 |
|
|
5 |
<bean name="/ui/lightui.do" |
|
6 |
class="eu.dnetlib.functionality.modular.ui.lightui.LightUiEntryPointController" |
|
7 |
p:menu="MD inspector" p:title="Metadata Record Inspector" |
|
8 |
p:description="Inspector for metadata records" p:group="MD inspector" |
|
9 |
p:order="1" |
|
10 |
p:groupOrder="50" |
|
11 |
p:searchFieldGrouper-ref="lightUIsearchFieldGrouper" |
|
12 |
p:validMenuEntry="false"> |
|
13 |
<property name="permissionLevels"> |
|
14 |
<set> |
|
15 |
<value>USER</value> |
|
16 |
</set> |
|
17 |
</property> |
|
18 |
</bean> |
|
19 |
|
|
20 |
<bean name="lightUiMenuGroup" |
|
21 |
class="eu.dnetlib.functionality.modular.ui.lightui.menu.LightUiMenuGroup" |
|
22 |
p:title="MD inspectors" |
|
23 |
p:order="70"/> |
|
24 |
|
|
25 |
</beans> |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/resources/eu/dnetlib/functionality/modular/ui/lightui/applicationContext-dnet-modular-lightui-ui.properties | ||
---|---|---|
1 |
|
|
2 |
lightui.index.endpoint = http://127.0.1.1:8280/app/services/IndexService |
|
3 |
|
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/resources/eu/dnetlib/functionality/modular/ui/lightui/applicationContext-dnet-modular-lightui-ui.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://cxf.apache.org/configuration/security" |
|
4 |
xmlns:wsa="http://cxf.apache.org/ws/addressing" xmlns:p="http://www.springframework.org/schema/p" |
|
5 |
xmlns:http="http://cxf.apache.org/transports/http/configuration" |
|
6 |
xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
7 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
|
8 |
http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd |
|
9 |
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd |
|
10 |
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd |
|
11 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> |
|
12 |
|
|
13 |
|
|
14 |
<bean id="lightUiIndexClient" |
|
15 |
class="eu.dnetlib.functionality.modular.ui.lightui.clients.IndexLightUIClient" /> |
|
16 |
|
|
17 |
<bean id="lightUiIsLookupClient" |
|
18 |
class="eu.dnetlib.functionality.modular.ui.lightui.clients.ISLookupClient" /> |
|
19 |
|
|
20 |
<bean id="lightUIsearchFieldGrouper" |
|
21 |
class="eu.dnetlib.functionality.modular.ui.lightui.objects.SearchFieldGrouper" /> |
|
22 |
|
|
23 |
<bean id="lightUIUtils" |
|
24 |
class="eu.dnetlib.functionality.modular.ui.lightui.LightUIUtils" /> |
|
25 |
|
|
26 |
|
|
27 |
</beans> |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/resources/eu/dnetlib/functionality/modular/ui/xslt/default_browse_single_field.xslt | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<xsl:stylesheet version="2.0" |
|
4 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
5 |
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> |
|
6 |
|
|
7 |
<xsl:output method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/> |
|
8 |
|
|
9 |
<xsl:template match="/"> |
|
10 |
<xsl:for-each select="//field"> |
|
11 |
<xsl:variable name="field" select="@name"></xsl:variable> |
|
12 |
<xsl:variable name="label" select="@label"></xsl:variable> |
|
13 |
<table class="table table-striped" ng-hide="browse_{$field}_showAll"> |
|
14 |
<xsl:for-each select="./value"> |
|
15 |
<tr ng-hide="browse_{$field}_showAll"> |
|
16 |
<th><a href="javascript:void(0)" data-dismiss="modal" ng-click="updateQueryWithValue('{$field}', '{@name}', 1500)"><xsl:value-of select="@name" /></a></th> |
|
17 |
<td class="text-right"><xsl:value-of select="@size" /></td> |
|
18 |
</tr> |
|
19 |
</xsl:for-each> |
|
20 |
</table> |
|
21 |
</xsl:for-each> |
|
22 |
</xsl:template> |
|
23 |
</xsl:stylesheet> |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/resources/eu/dnetlib/functionality/modular/ui/xslt/dc_2_row.xslt | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<xsl:stylesheet version="2.0" |
|
3 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
4 |
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> |
|
5 |
|
|
6 |
<xsl:output method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/> |
|
7 |
|
|
8 |
<xsl:template match="/"> |
|
9 |
<xsl:variable name="id" select="//*[local-name() = 'objIdentifier']" /> |
|
10 |
|
|
11 |
<div class="well"> |
|
12 |
<table> |
|
13 |
<tr> |
|
14 |
<td style="width: 120px"> |
|
15 |
<img src="../resources/img/record.png" width="80" height="80" /> |
|
16 |
</td> |
|
17 |
<td> |
|
18 |
<strong>Author: </strong><xsl:value-of select="//*[local-name()='creator']" /><br/> |
|
19 |
<strong>Title: </strong><xsl:value-of select="//*[local-name()='title']" /><br/> |
|
20 |
<strong>Description: </strong><i><xsl:value-of select="//*[local-name()='description']" /></i><br/> |
|
21 |
<br /> |
|
22 |
<button class="btn btn-primary btn-sm" ng-click="getDocument('objidentifier', '{$id}')">show record</button> |
|
23 |
</td> |
|
24 |
</tr> |
|
25 |
</table> |
|
26 |
</div> |
|
27 |
</xsl:template> |
|
28 |
|
|
29 |
</xsl:stylesheet> |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/resources/eu/dnetlib/functionality/modular/ui/xslt/accordion_browse.xslt | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<xsl:stylesheet version="2.0" |
|
4 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" |
|
5 |
xmlns:fn="http://www.w3.org/2005/xpath-functions"> |
|
6 |
|
|
7 |
<xsl:output method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" /> |
|
8 |
|
|
9 |
<xsl:template match="/"> |
|
10 |
<xsl:for-each select="//field"> |
|
11 |
<xsl:variable name="field" select="@name" /> |
|
12 |
<xsl:variable name="label" select="@label" /> |
|
13 |
<div class="panel-group" id="accordion_{$field}"> |
|
14 |
<div class="panel panel-default"> |
|
15 |
<div class="panel-heading"> |
|
16 |
<h4 class="panel-title"> |
|
17 |
<a href="javascript:void(0)" ng-click="browse_one('{$field}', '{$label}')" data-toggle="modal" data-target="#browseOneModal"><xsl:value-of select="$label" /></a> |
|
18 |
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion_{$field}" data-target="#collapse_{$field}" /> |
|
19 |
</h4> |
|
20 |
</div> |
|
21 |
<div id="collapse_{$field}" class="panel-collapse collapse in"> |
|
22 |
<table class="table" ng-hide="browse_{$field}_showAll"> |
|
23 |
<xsl:for-each select="./value"> |
|
24 |
<tr> |
|
25 |
<td> |
|
26 |
<a href="javascript:void(0)" ng-click="updateQueryWithValue('{$field}', '{@name}', 0)"> |
|
27 |
<xsl:value-of select="@name" /> |
|
28 |
</a> |
|
29 |
</td> |
|
30 |
<td class="text-right"> |
|
31 |
<xsl:value-of select="@size" /> |
|
32 |
</td> |
|
33 |
</tr> |
|
34 |
</xsl:for-each> |
|
35 |
</table> |
|
36 |
</div> |
|
37 |
</div> |
|
38 |
</div> |
|
39 |
</xsl:for-each> |
|
40 |
|
|
41 |
</xsl:template> |
|
42 |
</xsl:stylesheet> |
modules/dnet-modular-lightui-ui/tags/dnet-modular-lightui-ui-2.1.4/src/main/resources/eu/dnetlib/functionality/modular/ui/xslt/dc_2_document.xslt | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<xsl:stylesheet version="2.0" |
|
4 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
5 |
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> |
|
6 |
|
|
7 |
<xsl:output method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/> |
|
8 |
|
|
9 |
<xsl:template match="/"> |
|
10 |
<div class="row"> |
|
11 |
<div class="col-xs-2"> |
|
12 |
<img src="../resources/img/record.png" width="80" height="80" /> |
|
13 |
</div> |
|
14 |
<div class="col-xs-10"> |
|
15 |
<xsl:if test="//*[local-name()='title']"> |
|
16 |
<h1 id="overview" ><xsl:value-of select="//*[local-name()='title']" /></h1> |
|
17 |
</xsl:if> |
|
18 |
</div> |
|
19 |
</div> |
|
20 |
|
|
21 |
<div class="row"> |
|
22 |
<div class="col-xs-12"> |
|
23 |
<h6><span class="glyphicon glyphicon-align-left" /> GENERAL INFORMATION</h6> |
|
24 |
<table class="table"> |
|
25 |
<tbody> |
|
26 |
<tr> |
|
27 |
<td class="col-xs-3"><strong>Author</strong></td> |
|
28 |
<td> |
|
29 |
<xsl:for-each select="//*[local-name()='creator']"> |
|
30 |
<xsl:value-of select="." /><br /> |
|
31 |
</xsl:for-each> |
|
32 |
</td> |
|
33 |
</tr> |
|
34 |
<tr> |
|
35 |
<td class="col-xs-3"><strong>Title</strong></td> |
|
36 |
<td> |
|
37 |
<xsl:for-each select="//*[local-name()='title']"> |
|
38 |
<xsl:value-of select="." /><br /> |
|
39 |
</xsl:for-each> |
|
40 |
</td> |
|
41 |
</tr> |
|
42 |
<tr> |
|
43 |
<td class="col-xs-3"><strong>Description</strong></td> |
|
44 |
<td> |
|
45 |
<xsl:for-each select="//*[local-name()='description']"> |
|
46 |
<xsl:value-of select="." /><br /> |
|
47 |
</xsl:for-each> |
|
48 |
</td> |
|
49 |
</tr> |
|
50 |
<tr> |
|
51 |
<td class="col-xs-3"><strong>Identifier</strong></td> |
|
52 |
<td> |
|
53 |
<xsl:for-each select="//*[local-name()='identifier']"> |
|
54 |
<xsl:value-of select="." /><br /> |
|
55 |
</xsl:for-each> |
|
56 |
</td> |
|
57 |
</tr> |
|
58 |
<tr> |
|
59 |
<td class="col-xs-3"><strong>Type</strong></td> |
|
60 |
<td> |
|
61 |
<xsl:for-each select="//*[local-name()='type']"> |
|
62 |
<xsl:value-of select="." /><br /> |
|
63 |
</xsl:for-each> |
|
64 |
</td> |
|
65 |
</tr> |
|
66 |
</tbody> |
|
67 |
</table> |
|
68 |
</div> |
|
69 |
</div> |
|
70 |
|
|
71 |
<xsl:for-each select="//*[local-name()='record']"> |
|
72 |
<h6><span class="glyphicon glyphicon-wrench" /> RECORD XML</h6> |
|
73 |
<xsl:call-template name="xmlItem"> |
|
74 |
<xsl:with-param name="indent" select="string('')" /> |
|
75 |
</xsl:call-template> |
|
76 |
</xsl:for-each> |
|
77 |
</xsl:template> |
|
78 |
|
|
79 |
<xsl:template name="xmlItem"> |
|
80 |
<xsl:param name="indent" /> |
|
81 |
|
|
82 |
<xsl:variable name="tag" select="local-name()" /> |
|
83 |
|
|
84 |
<xsl:variable name="newindent"> |
|
85 |
<xsl:value-of select="$indent" /> |
|
86 |
     |
|
87 |
</xsl:variable> |
|
88 |
|
|
89 |
<xsl:variable name="attribs"> |
|
90 |
<xsl:for-each select="@*"> |
|
91 |
<xsl:value-of select="concat(' ', local-name(), '="', ., '"')" /> |
|
92 |
</xsl:for-each> |
|
93 |
</xsl:variable> |
|
94 |
<xsl:value-of select="$indent" /> |
|
95 |
|
|
96 |
<b> |
|
97 |
<xsl:value-of select="concat('<',$tag)" /> |
|
98 |
</b> |
|
99 |
<i> |
|
100 |
<xsl:value-of select="$attribs" /> |
|
101 |
</i> |
|
102 |
<b>></b> |
|
103 |
|
|
104 |
<xsl:value-of select="text()" /> |
|
105 |
|
|
106 |
<xsl:choose> |
|
107 |
<xsl:when test="count(child::*) > 0"> |
|
108 |
<br /> |
|
109 |
<xsl:for-each select="child::*"> |
|
110 |
<xsl:call-template name="xmlItem"> |
|
111 |
<xsl:with-param name="indent" select="$newindent" /> |
|
112 |
</xsl:call-template> |
|
113 |
<br /> |
|
114 |
</xsl:for-each> |
|
115 |
<xsl:value-of select="$indent" /> |
|
116 |
</xsl:when> |
|
117 |
<xsl:otherwise> |
|
118 |
|
|
119 |
</xsl:otherwise> |
|
120 |
</xsl:choose> |
|
121 |
|
|
122 |
<b> |
|
123 |
<xsl:value-of select="concat('</',$tag,'>')" /> |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-modular-lightui-ui-2.1.4