Revision 46343
Added by Alessia Bardi about 7 years ago
modules/dnet-modular-uis/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/index/models/IndexInfo.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.index.models; |
|
2 |
|
|
3 |
/** |
|
4 |
* The Class IndexInfo. |
|
5 |
*/ |
|
6 |
public class IndexInfo { |
|
7 |
|
|
8 |
/** The Constant SEPARATOR. */ |
|
9 |
private static final String SEPARATOR = ":-:"; |
|
10 |
|
|
11 |
/** The id. */ |
|
12 |
private String id; |
|
13 |
|
|
14 |
/** The forma. */ |
|
15 |
private String format; |
|
16 |
|
|
17 |
/** The layout. */ |
|
18 |
private String layout; |
|
19 |
|
|
20 |
/** The interpretation. */ |
|
21 |
private String interpretation; |
|
22 |
|
|
23 |
/** The backend id. */ |
|
24 |
private String backendId; |
|
25 |
|
|
26 |
private int size; |
|
27 |
|
|
28 |
/** |
|
29 |
* The Constructor. |
|
30 |
*/ |
|
31 |
public IndexInfo() { |
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
/** |
|
36 |
* The Constructor. |
|
37 |
* |
|
38 |
* @param id |
|
39 |
* the id |
|
40 |
* @param forma |
|
41 |
* the forma |
|
42 |
* @param layout |
|
43 |
* the layout |
|
44 |
* @param interpretation |
|
45 |
* the interpretation |
|
46 |
* @param backendId |
|
47 |
* the backend id |
|
48 |
*/ |
|
49 |
public IndexInfo(final String id, final String forma, final String layout, final String interpretation, final String backendId) { |
|
50 |
super(); |
|
51 |
this.id = id; |
|
52 |
this.format = forma; |
|
53 |
this.layout = layout; |
|
54 |
this.interpretation = interpretation; |
|
55 |
this.backendId = backendId; |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Gets the id. |
|
60 |
* |
|
61 |
* @return the id |
|
62 |
*/ |
|
63 |
public String getId() { |
|
64 |
return id; |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Sets the id. |
|
69 |
* |
|
70 |
* @param id |
|
71 |
* the id |
|
72 |
*/ |
|
73 |
public void setId(final String id) { |
|
74 |
this.id = id; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Gets the forma. |
|
79 |
* |
|
80 |
* @return the forma |
|
81 |
*/ |
|
82 |
public String getFormat() { |
|
83 |
return format; |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Sets the forma. |
|
88 |
* |
|
89 |
* @param forma |
|
90 |
* the forma |
|
91 |
*/ |
|
92 |
public void setFormat(final String format) { |
|
93 |
this.format = format; |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* Gets the layout. |
|
98 |
* |
|
99 |
* @return the layout |
|
100 |
*/ |
|
101 |
public String getLayout() { |
|
102 |
return layout; |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* Sets the layout. |
|
107 |
* |
|
108 |
* @param layout |
|
109 |
* the layout |
|
110 |
*/ |
|
111 |
public void setLayout(final String layout) { |
|
112 |
this.layout = layout; |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Gets the interpretation. |
|
117 |
* |
|
118 |
* @return the interpretation |
|
119 |
*/ |
|
120 |
public String getInterpretation() { |
|
121 |
return interpretation; |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* Sets the interpretation. |
|
126 |
* |
|
127 |
* @param interpretation |
|
128 |
* the interpretation |
|
129 |
*/ |
|
130 |
public void setInterpretation(final String interpretation) { |
|
131 |
this.interpretation = interpretation; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Gets the backend id. |
|
136 |
* |
|
137 |
* @return the backend id |
|
138 |
*/ |
|
139 |
public String getBackendId() { |
|
140 |
return backendId; |
|
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* Sets the backend id. |
|
145 |
* |
|
146 |
* @param backendId |
|
147 |
* the backend id |
|
148 |
*/ |
|
149 |
public void setBackendId(final String backendId) { |
|
150 |
this.backendId = backendId; |
|
151 |
} |
|
152 |
|
|
153 |
public int getSize() { |
|
154 |
return size; |
|
155 |
} |
|
156 |
|
|
157 |
public void setSize(final int size) { |
|
158 |
this.size = size; |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* New instance from string. the string must have the form format:-:layout:-:interpretation:-:id:-:backendid:-:size |
|
163 |
* |
|
164 |
* @param serialized |
|
165 |
* the serialized |
|
166 |
* @return the index info |
|
167 |
*/ |
|
168 |
public static IndexInfo newInstanceFromString(final String serialized) { |
|
169 |
String[] values = serialized.split(SEPARATOR); |
|
170 |
if ((values == null) || (values.length != 6)) return null; |
|
171 |
IndexInfo tmp = new IndexInfo(); |
|
172 |
tmp.format = values[0]; |
|
173 |
tmp.layout = values[1]; |
|
174 |
tmp.interpretation = values[2]; |
|
175 |
tmp.id = values[3]; |
|
176 |
tmp.backendId = values[4]; |
|
177 |
tmp.size = Integer.parseInt(values[5]); |
|
178 |
return tmp; |
|
179 |
|
|
180 |
} |
|
181 |
} |
modules/dnet-modular-uis/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/index/models/MdFormatInfo.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.index.models; |
|
2 |
|
|
3 |
import eu.dnetlib.utils.MetadataReference; |
|
4 |
|
|
5 |
/** |
|
6 |
* The Class MdFormatInfo. |
|
7 |
*/ |
|
8 |
public class MdFormatInfo { |
|
9 |
|
|
10 |
/** The Constant SplitCharachters. */ |
|
11 |
private static final String SplitCharachters = "::"; |
|
12 |
|
|
13 |
/** The id. */ |
|
14 |
private String id; |
|
15 |
|
|
16 |
private MetadataReference metadataReference; |
|
17 |
|
|
18 |
/** |
|
19 |
* The Constructor. |
|
20 |
*/ |
|
21 |
public MdFormatInfo() { |
|
22 |
|
|
23 |
} |
|
24 |
|
|
25 |
/** |
|
26 |
* The Constructor. |
|
27 |
* |
|
28 |
* @param id |
|
29 |
* the id |
|
30 |
* @param format |
|
31 |
* the format |
|
32 |
* @param layout |
|
33 |
* the layout |
|
34 |
* @param interpretation |
|
35 |
* the interpretation |
|
36 |
*/ |
|
37 |
public MdFormatInfo(final String id, final String format, final String layout, final String interpretation) { |
|
38 |
super(); |
|
39 |
this.id = id; |
|
40 |
this.metadataReference = new MetadataReference(format, layout, interpretation); |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* Gets the id. |
|
45 |
* |
|
46 |
* @return the id |
|
47 |
*/ |
|
48 |
public String getId() { |
|
49 |
return id; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Sets the id. |
|
54 |
* |
|
55 |
* @param id |
|
56 |
* the id |
|
57 |
*/ |
|
58 |
public void setId(final String id) { |
|
59 |
this.id = id; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Gets the format. |
|
64 |
* |
|
65 |
* @return the format |
|
66 |
*/ |
|
67 |
public String getFormat() { |
|
68 |
return this.metadataReference.getFormat(); |
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
/** |
|
73 |
* Gets the layout. |
|
74 |
* |
|
75 |
* @return the layout |
|
76 |
*/ |
|
77 |
public String getLayout() { |
|
78 |
return this.metadataReference.getLayout(); |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
/** |
|
83 |
* Gets the interpretation. |
|
84 |
* |
|
85 |
* @return the interpretation |
|
86 |
*/ |
|
87 |
public String getInterpretation() { |
|
88 |
return this.metadataReference.getInterpretation(); |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
/** |
|
93 |
* Create a new MdFormatInfo starting from the xquery result the string MUST be in this forma $format-$layout-$interpretation::$id |
|
94 |
* |
|
95 |
* @param result |
|
96 |
* the result |
|
97 |
* @return the md format info |
|
98 |
*/ |
|
99 |
public static MdFormatInfo initFromXqueryResult(final String result) { |
|
100 |
String[] values = result.split(SplitCharachters); |
|
101 |
if ((values == null) || (values.length != 2)) return null; |
|
102 |
|
|
103 |
String[] mdref = values[0].split("-"); |
|
104 |
if ((mdref == null) || (mdref.length != 3)) return null; |
|
105 |
|
|
106 |
return new MdFormatInfo(values[1], mdref[0], mdref[1], mdref[2]); |
|
107 |
|
|
108 |
} |
|
109 |
|
|
110 |
} |
modules/dnet-modular-uis/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/index/IndexClientMap.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.index; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import com.google.common.collect.Maps; |
|
6 |
import eu.dnetlib.clients.index.client.IndexClient; |
|
7 |
import eu.dnetlib.clients.index.client.IndexClientException; |
|
8 |
import org.apache.commons.logging.Log; |
|
9 |
import org.apache.commons.logging.LogFactory; |
|
10 |
|
|
11 |
|
|
12 |
public class IndexClientMap { |
|
13 |
|
|
14 |
private static final Log log = LogFactory.getLog(IndexClientMap.class); |
|
15 |
|
|
16 |
private Map<String, IndexClient> map = Maps.newHashMap(); |
|
17 |
|
|
18 |
public void shutdown() throws IndexClientException { |
|
19 |
log.debug("shutdown index clients"); |
|
20 |
for (IndexClient client : map.values()) { |
|
21 |
client.stop(); |
|
22 |
} |
|
23 |
} |
|
24 |
|
|
25 |
public Map<String, IndexClient> getMap() { |
|
26 |
return map; |
|
27 |
} |
|
28 |
|
|
29 |
public void setMap(final Map<String, IndexClient> map) { |
|
30 |
this.map = map; |
|
31 |
} |
|
32 |
|
|
33 |
} |
modules/dnet-modular-uis/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/index/IndexServiceEntryPointController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.index; |
|
2 |
|
|
3 |
import javax.annotation.Resource; |
|
4 |
import javax.servlet.http.HttpServletRequest; |
|
5 |
import javax.servlet.http.HttpServletResponse; |
|
6 |
|
|
7 |
import org.springframework.ui.ModelMap; |
|
8 |
|
|
9 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
10 |
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint; |
|
11 |
|
|
12 |
public class IndexServiceEntryPointController extends ModuleEntryPoint { |
|
13 |
|
|
14 |
@Resource |
|
15 |
private UniqueServiceLocator serviceLocator; |
|
16 |
|
|
17 |
@Override |
|
18 |
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception { |
|
19 |
|
|
20 |
} |
|
21 |
|
|
22 |
} |
modules/dnet-modular-uis/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/index/IndexServiceInternalController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.index; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Set; |
|
5 |
import javax.annotation.Resource; |
|
6 |
import javax.xml.transform.TransformerFactory; |
|
7 |
|
|
8 |
import com.google.common.base.Function; |
|
9 |
import com.google.common.collect.Lists; |
|
10 |
import com.google.common.collect.Sets; |
|
11 |
import com.google.gson.Gson; |
|
12 |
import com.google.gson.reflect.TypeToken; |
|
13 |
import eu.dnetlib.clients.index.client.IndexClient; |
|
14 |
import eu.dnetlib.clients.index.client.IndexClientException; |
|
15 |
import eu.dnetlib.clients.index.client.ResolvingIndexClientFactory; |
|
16 |
import eu.dnetlib.clients.index.client.response.BrowseEntry; |
|
17 |
import eu.dnetlib.clients.index.client.response.LookupResponse; |
|
18 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
19 |
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController; |
|
20 |
import eu.dnetlib.functionality.modular.ui.index.models.IndexInfo; |
|
21 |
import eu.dnetlib.functionality.modular.ui.index.models.MdFormatInfo; |
|
22 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
23 |
import eu.dnetlib.rmi.enabling.ISLookUpException; |
|
24 |
import eu.dnetlib.rmi.enabling.ISLookUpService; |
|
25 |
import eu.dnetlib.rmi.provision.IndexServiceException; |
|
26 |
import org.apache.commons.lang3.StringUtils; |
|
27 |
import org.apache.commons.logging.Log; |
|
28 |
import org.apache.commons.logging.LogFactory; |
|
29 |
import org.springframework.beans.factory.annotation.Autowired; |
|
30 |
import org.springframework.beans.factory.annotation.Value; |
|
31 |
import org.springframework.core.io.ClassPathResource; |
|
32 |
import org.springframework.stereotype.Controller; |
|
33 |
import org.springframework.ui.ModelMap; |
|
34 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
35 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
36 |
import org.springframework.web.bind.annotation.RequestParam; |
|
37 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
38 |
|
|
39 |
/** |
|
40 |
* The Class IndexServiceInternalController. |
|
41 |
*/ |
|
42 |
@Controller |
|
43 |
public class IndexServiceInternalController extends AbstractAjaxController { |
|
44 |
|
|
45 |
/** |
|
46 |
* The Constant log. |
|
47 |
*/ |
|
48 |
private static final Log log = LogFactory.getLog(IndexServiceInternalController.class); |
|
49 |
|
|
50 |
/** |
|
51 |
* The lookup locator. |
|
52 |
*/ |
|
53 |
@Resource |
|
54 |
private UniqueServiceLocator serviceLocator; |
|
55 |
|
|
56 |
/** |
|
57 |
* The index client factory. |
|
58 |
*/ |
|
59 |
@Autowired |
|
60 |
private ResolvingIndexClientFactory indexClientFactory; |
|
61 |
|
|
62 |
@Autowired |
|
63 |
private IndexClientMap clientMap; |
|
64 |
|
|
65 |
@Value("${dnet.modular.ui.index.gmf.xslt}") |
|
66 |
private String gmf2documentXslt; |
|
67 |
|
|
68 |
/** |
|
69 |
* Index metadata formats. |
|
70 |
* |
|
71 |
* @param map the map |
|
72 |
* @return the list< md format info> |
|
73 |
* @throws Exception the exception |
|
74 |
*/ |
|
75 |
@RequestMapping(value = "/ui/index/indexMetadataFormats.do") |
|
76 |
@ResponseBody |
|
77 |
public List<MdFormatInfo> indexMetadataFormats(final ModelMap map) throws Exception { |
|
78 |
final String xquery = |
|
79 |
"for $x in //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='MDFormatDSResourceType'] " |
|
80 |
+ "let $format:= $x//CONFIGURATION/NAME/string() for $y in $x//LAYOUTS/LAYOUT let $layout:= $y/@name/string() " |
|
81 |
+ "let $interpretation:= $x//CONFIGURATION/INTERPRETATION/text() let $id:=$x//RESOURCE_IDENTIFIER/@value/string() " |
|
82 |
+ " return concat($format,'-',$layout,'-',$interpretation,'::', $id) "; |
|
83 |
log.debug("Executing lookup query " + xquery); |
|
84 |
|
|
85 |
return Lists.transform(quickSearchProfile(xquery), input -> MdFormatInfo.initFromXqueryResult(input)); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Index datastructures. |
|
90 |
* |
|
91 |
* @param backend the backend |
|
92 |
* @return the list< index info> |
|
93 |
* @throws Exception the exception |
|
94 |
*/ |
|
95 |
@RequestMapping(value = "/ui/index/indexDatastructures.do") |
|
96 |
@ResponseBody |
|
97 |
public List<IndexInfo> indexDatastructures(@RequestParam(value = "backend", required = true) final String backend) throws Exception { |
|
98 |
final String xquery = |
|
99 |
"for $x in //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='IndexDSResourceType' and .//BACKEND/@ID='%s'] let $format := $x//METADATA_FORMAT " |
|
100 |
+ "let $layout := $x//METADATA_FORMAT_LAYOUT let $interpretation :=$x//METADATA_FORMAT_INTERPRETATION " |
|
101 |
+ "let $id :=$x//RESOURCE_IDENTIFIER/@value let $backendid := $x//BACKEND/@ID let $size := $x//INDEX_SIZE " |
|
102 |
+ "return concat($format, ':-:',$layout,':-:',$interpretation,':-:',$id,':-:',$backendid,':-:',$size)"; |
|
103 |
log.debug("Executing lookup query " + String.format(xquery, backend)); |
|
104 |
|
|
105 |
Function<String, IndexInfo> function = input -> IndexInfo.newInstanceFromString(input); |
|
106 |
return Lists.transform(quickSearchProfile(String.format(xquery, backend)), function); |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Md format info. |
|
111 |
* |
|
112 |
* @param id the id |
|
113 |
* @param layout the layout |
|
114 |
* @return the list< string> |
|
115 |
* @throws Exception the exception |
|
116 |
*/ |
|
117 |
@RequestMapping(value = "/ui/index/mdFormatInfo.do") |
|
118 |
@ResponseBody |
|
119 |
public List<String> mdFormatInfo(@RequestParam(value = "id", required = true) final String id, |
|
120 |
@RequestParam(value = "layout", required = true) final String layout) throws Exception { |
|
121 |
|
|
122 |
String xqueryTemplate = |
|
123 |
"//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value='%s']" + "//LAYOUT[./@name/string()='%s'] " |
|
124 |
+ "//FIELD[./@tokenizable/string()='false' or ./@type = 'int' or ./@type = 'date']/@name/string()"; |
|
125 |
log.debug("executing query: " + String.format(xqueryTemplate, id, layout)); |
|
126 |
return quickSearchProfile(String.format(xqueryTemplate, id, layout)); |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* Gets the backend available. |
|
131 |
* |
|
132 |
* @return the ids of the available backends |
|
133 |
* @throws Exception the exception |
|
134 |
*/ |
|
135 |
@RequestMapping(value = "/ui/index/backend.do") |
|
136 |
@ResponseBody |
|
137 |
public Set<String> getBackendAvailable() throws Exception { |
|
138 |
|
|
139 |
String xquery = "for $x in //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='IndexDSResourceType'] return distinct-values($x//BACKEND/@ID/string())"; |
|
140 |
log.debug("executing query: " + xquery); |
|
141 |
return Sets.newHashSet(quickSearchProfile(xquery)); |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* Browse. |
|
147 |
* |
|
148 |
* @param map the map |
|
149 |
* @param backend the backend |
|
150 |
* @param format the format |
|
151 |
* @param layout the layout |
|
152 |
* @param interpretation the interpretation |
|
153 |
* @return the list< string> |
|
154 |
* @throws IndexClientException the index client exception |
|
155 |
*/ |
|
156 |
@RequestMapping(value = "/ui/index/browse.do", method = RequestMethod.POST) |
|
157 |
@ResponseBody |
|
158 |
public List<BrowseEntry> browse(final ModelMap map, |
|
159 |
@RequestParam(value = "backend", required = true) final String backend, |
|
160 |
@RequestParam(value = "format", required = true) final String format, |
|
161 |
@RequestParam(value = "layout", required = true) final String layout, |
|
162 |
@RequestParam(value = "interpretation", required = true) final String interpretation, |
|
163 |
@RequestParam(value = "fields", required = true) final String fields, |
|
164 |
@RequestParam(value = "query", required = true) final String query) throws IndexClientException { |
|
165 |
|
|
166 |
List<String> browseFields = new Gson().fromJson(fields, new TypeToken<List<String>>() { |
|
167 |
}.getType()); |
|
168 |
|
|
169 |
if (browseFields != null) { |
|
170 |
for (String s : browseFields) { |
|
171 |
log.debug("Browse field " + s); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
String indexClientKeys = backend + "-" + format + "-" + layout + "-" + interpretation; |
|
176 |
|
|
177 |
IndexClient client = null; |
|
178 |
if (clientMap.getMap().containsKey(indexClientKeys)) { |
|
179 |
client = clientMap.getMap().get(indexClientKeys); |
|
180 |
} else { |
|
181 |
client = indexClientFactory.getClient(format, layout, interpretation, backend); |
|
182 |
clientMap.getMap().put(indexClientKeys, client); |
|
183 |
} |
|
184 |
|
|
185 |
// LookupResponse result = client.lookup("*=*", null, 0, 10); |
|
186 |
|
|
187 |
List<BrowseEntry> result = client.browse(query, browseFields, 99); |
|
188 |
return result; |
|
189 |
} |
|
190 |
|
|
191 |
@RequestMapping(value = "/ui/index/delete.do", method = RequestMethod.POST) |
|
192 |
@ResponseBody |
|
193 |
public long delete(final ModelMap map, |
|
194 |
@RequestParam(value = "backend", required = true) final String backend, |
|
195 |
@RequestParam(value = "format", required = true) final String format, |
|
196 |
@RequestParam(value = "layout", required = true) final String layout, |
|
197 |
@RequestParam(value = "interpretation", required = true) final String interpretation, |
|
198 |
@RequestParam(value = "query", required = true) final String query, |
|
199 |
@RequestParam(value = "indexidentifier", required = false) final String indexId) throws IndexServiceException { |
|
200 |
|
|
201 |
String indexClientKeys = backend + "-" + format + "-" + layout + "-" + interpretation; |
|
202 |
|
|
203 |
IndexClient client = null; |
|
204 |
if (clientMap.getMap().containsKey(indexClientKeys)) { |
|
205 |
client = clientMap.getMap().get(indexClientKeys); |
|
206 |
} else { |
|
207 |
client = indexClientFactory.getClient(format, layout, interpretation, backend); |
|
208 |
clientMap.getMap().put(indexClientKeys, client); |
|
209 |
} |
|
210 |
String mquery = query; |
|
211 |
|
|
212 |
if (!StringUtils.isEmpty(indexId)) { |
|
213 |
mquery = query + " and __dsid exact \"" + indexId + "\""; |
|
214 |
} |
|
215 |
|
|
216 |
return client.delete(mquery); |
|
217 |
} |
|
218 |
|
|
219 |
@RequestMapping(value = "/ui/index/search.do", method = RequestMethod.POST) |
|
220 |
@ResponseBody |
|
221 |
public LookupResponse search(final ModelMap map, |
|
222 |
@RequestParam(value = "backend", required = true) final String backend, |
|
223 |
@RequestParam(value = "format", required = true) final String format, |
|
224 |
@RequestParam(value = "layout", required = true) final String layout, |
|
225 |
@RequestParam(value = "interpretation", required = true) final String interpretation, |
|
226 |
@RequestParam(value = "query", required = true) final String query, |
|
227 |
@RequestParam(value = "from", required = true) final int from, |
|
228 |
@RequestParam(value = "number", required = true) final int number, |
|
229 |
@RequestParam(value = "indexidentifier", required = false) final String indexId |
|
230 |
|
|
231 |
) throws IndexClientException { |
|
232 |
|
|
233 |
String indexClientKeys = backend + "-" + format + "-" + layout + "-" + interpretation; |
|
234 |
|
|
235 |
log.debug(indexClientKeys); |
|
236 |
|
|
237 |
IndexClient client = null; |
|
238 |
|
|
239 |
if (!clientMap.getMap().containsKey(indexClientKeys)) { |
|
240 |
clientMap.getMap().put(indexClientKeys, indexClientFactory.getClient(format, layout, interpretation, backend)); |
|
241 |
} |
|
242 |
client = clientMap.getMap().get(indexClientKeys); |
|
243 |
|
|
244 |
List<String> filterId = null; |
|
245 |
if (indexId != null && !indexId.isEmpty()) { |
|
246 |
filterId = Lists.newArrayList("__dsid:\"" + indexId + "\""); |
|
247 |
} |
|
248 |
|
|
249 |
log.debug(String.format("query: '%s', filter: '%s', from: '%d', number: '%d'", query, filterId, from, number)); |
|
250 |
|
|
251 |
LookupResponse result = client.lookup(query, filterId, from, number); |
|
252 |
|
|
253 |
ClassPathResource cpr = new ClassPathResource(gmf2documentXslt); |
|
254 |
ApplyXslt xslt = new ApplyXslt(cpr); |
|
255 |
List<String> convertedList = Lists.newArrayList(); |
|
256 |
|
|
257 |
for (String s : result.getRecords()) { |
|
258 |
log.debug("response record: \n" + s); |
|
259 |
convertedList.add(xslt.apply(s)); |
|
260 |
} |
|
261 |
result.setRecords(convertedList); |
|
262 |
return result; |
|
263 |
} |
|
264 |
|
|
265 |
/** |
|
266 |
* Quick search profile. |
|
267 |
* |
|
268 |
* @param xquery the xquery |
|
269 |
* @return the list< string> |
|
270 |
* @throws Exception the exception |
|
271 |
*/ |
|
272 |
private List<String> quickSearchProfile(final String xquery) throws Exception { |
|
273 |
try { |
|
274 |
return serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery); |
|
275 |
} catch (ISLookUpException e) { |
|
276 |
throw new Exception(e); |
|
277 |
} |
|
278 |
} |
|
279 |
} |
modules/dnet-modular-uis/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/oai/OAIInternalController.java | ||
---|---|---|
21 | 21 |
import eu.dnetlib.oai.info.SetInfo; |
22 | 22 |
import eu.dnetlib.rmi.enabling.ISLookUpException; |
23 | 23 |
import eu.dnetlib.rmi.provision.MDFInfo; |
24 |
import eu.dnetlib.utils.MetadataReference; |
|
24 | 25 |
import org.apache.commons.io.IOUtils; |
25 | 26 |
import org.apache.commons.logging.Log; |
26 | 27 |
import org.apache.commons.logging.LogFactory; |
... | ... | |
51 | 52 |
@RequestMapping(value = "/ui/getSourceMDFs.do") |
52 | 53 |
public |
53 | 54 |
@ResponseBody |
54 |
List<MDFInfo> getSourceMDFs(final HttpServletResponse response) throws Exception {
|
|
55 |
List<MetadataReference> getSourceMDFs(final HttpServletResponse response) throws Exception {
|
|
55 | 56 |
|
56 | 57 |
return configuration.getMetadataFormatInfo().stream() |
57 |
.map(mdf -> { |
|
58 |
MDFInfo srcOnly = new MDFInfo(); |
|
59 |
srcOnly.setSourceFormatName(mdf.getSourceFormatName()); |
|
60 |
srcOnly.setSourceFormatLayout(mdf.getSourceFormatLayout()); |
|
61 |
srcOnly.setSourceFormatInterpretation(mdf.getSourceFormatInterpretation()); |
|
62 |
return srcOnly; |
|
63 |
}) |
|
58 |
.map(mdf -> mdf.getSourceMetadataReference()) |
|
64 | 59 |
.distinct() |
65 | 60 |
.collect(Collectors.toList()); |
66 | 61 |
|
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/oaiConfig.st | ||
---|---|---|
18 | 18 |
|
19 | 19 |
<label>Source Metadata Formats</label> |
20 | 20 |
<ul class="nav nav-pills nav-stacked"> |
21 |
<li ng-repeat="mdformat in srcFormats"
|
|
22 |
ng-click="showSrcMetadataFormat(mdformat)"><a href="#">{{mdformat.sourceFormatName}}
|
|
23 |
- {{mdformat.sourceFormatLayout}} -
|
|
24 |
{{mdformat.sourceFormatInterpretation}} <span
|
|
21 |
<li ng-repeat="srcFormat in srcFormats"
|
|
22 |
ng-click="showSrcMetadataFormat(srcFormat)"><a href="#">{{srcFormat.format}}
|
|
23 |
- {{srcFormat.layout}} -
|
|
24 |
{{srcFormat.interpretation}} <span
|
|
25 | 25 |
class="glyphicon glyphicon-chevron-right pull-right"></span> |
26 | 26 |
</a></li> |
27 | 27 |
</ul> |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/indexInspector.st | ||
---|---|---|
1 |
$common/master( header={ |
|
2 |
|
|
3 |
<script type="text/javascript" src="../resources/js/angular-1.4.8.min.js"></script> |
|
4 |
<script type="text/javascript" src="../resources/js/angular-route.min.js"></script> |
|
5 |
<script type="text/javascript" src="../resources/js/angular-local-storage.min.js"></script> |
|
6 |
|
|
7 |
<script type="text/javascript" src="../resources/js/index/index_inspector_controllers.js"></script> |
|
8 |
<script type="text/javascript" src="../resources/js/index/index_inspector.js"></script> |
|
9 |
}, body={ |
|
10 |
<div ng-app="indexInspector" class="row"> |
|
11 |
<div class="col-sm-3 col-lg-2" ng-controller="moduleMenuCtrl"> |
|
12 |
<ul class="nav nav-pills nav-stacked"> |
|
13 |
<li ng-class="{active : isActive('^\/q')}"><a href="#/query">Query</a></li> |
|
14 |
<li ng-class="{active : isActive('^\/(schemas|schema)')}"><a href="#/deletebyquery">Delete By Query</a></li> |
|
15 |
<li ng-class="{active : isActive('^\/browse')}"><a href="#/browse">Browse</a></li> |
|
16 |
<li ng-class="{active : isActive('^\/register')}"><a href="#/manage">Manage Index DS</a></li> |
|
17 |
</ul> |
|
18 |
</div> |
|
19 |
<div ng-view class="col-sm-9 col-lg-10"></div> |
|
20 |
<script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script> |
|
21 |
<script> |
|
22 |
function reload(){ |
|
23 |
alert("prima"); |
|
24 |
prettyPrint(); |
|
25 |
alert("dopo"); |
|
26 |
} |
|
27 |
|
|
28 |
</script> |
|
29 |
</div> |
|
30 |
} )$ |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/index/webContext-modular-ui-index.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration" |
|
4 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
|
5 |
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd"> |
|
6 |
|
|
7 |
|
|
8 |
<bean name="/ui/indexInspector.do" |
|
9 |
class="eu.dnetlib.functionality.modular.ui.index.IndexServiceEntryPointController" |
|
10 |
p:menu="Index Service Inspector" |
|
11 |
p:title="Index Service Inspector" |
|
12 |
p:description="Index Service Inspector" |
|
13 |
p:order="3" |
|
14 |
p:group="Tools"> |
|
15 |
<property name="permissionLevels"> |
|
16 |
<set> |
|
17 |
<value>IS_ADMIN</value> |
|
18 |
</set> |
|
19 |
</property> |
|
20 |
</bean> |
|
21 |
|
|
22 |
<bean id="indexClientMap" class="eu.dnetlib.functionality.modular.ui.index.IndexClientMap" |
|
23 |
destroy-method="shutdown"/> |
|
24 |
|
|
25 |
</beans> |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/index/applicationContext-modular-ui-index.properties | ||
---|---|---|
1 |
dnet.modular.ui.index.gmf.xslt=/eu/dnetlib/functionality/modular/ui/index/xslt/gmf2document.xslt |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/index/xslt/gmf2document.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="//*[local-name()='record']"> |
|
11 |
<div |
|
12 |
style="color:black; font-family:'Courier New', Courier, monospace; font-size:small"> |
|
13 |
<xsl:call-template name="xmlItem"> |
|
14 |
<xsl:with-param name="indent" select="string('')" /> |
|
15 |
</xsl:call-template> |
|
16 |
</div> |
|
17 |
</xsl:for-each> |
|
18 |
</xsl:template> |
|
19 |
|
|
20 |
<xsl:template name="xmlAttr"> |
|
21 |
<span style='color:red'><xsl:value-of select="concat(' ', local-name())"/></span> |
|
22 |
<xsl:value-of select="concat('="', ., '"')"/> |
|
23 |
</xsl:template> |
|
24 |
|
|
25 |
<xsl:template name="xmlItem"> |
|
26 |
<xsl:param name="indent" /> |
|
27 |
<xsl:variable name="tag" select="local-name()" /> |
|
28 |
<xsl:variable name="newindent"><xsl:value-of select="$indent" />    </xsl:variable> |
|
29 |
|
|
30 |
<xsl:if test="string-length($tag)"> |
|
31 |
<br/><xsl:value-of select="$indent" /><span style='color:blue'><xsl:value-of select="concat('<',$tag)" /></span> |
|
32 |
<xsl:for-each select="@*"> |
|
33 |
<xsl:call-template name="xmlAttr"/> |
|
34 |
</xsl:for-each> |
|
35 |
|
|
36 |
<xsl:choose> |
|
37 |
<xsl:when test="count(child::*) = 0 and count(child::text()) = 1"> |
|
38 |
<span style='color:blue'>></span> |
|
39 |
<xsl:value-of select="normalize-space(.)" /> |
|
40 |
<span style='color:blue'><xsl:value-of select="concat('</',$tag,'>')" /></span> |
|
41 |
</xsl:when> |
|
42 |
<xsl:when test="count(child::* | child::text()) > 0"> |
|
43 |
<span style='color:blue'>></span> |
|
44 |
<xsl:for-each select="child::* | child::text()"> |
|
45 |
<xsl:choose> |
|
46 |
<xsl:when test="self::text() and string-length(normalize-space(.)) > 0"> |
|
47 |
<xsl:value-of select="normalize-space(.)" /> |
|
48 |
</xsl:when> |
|
49 |
<xsl:otherwise> |
|
50 |
<xsl:call-template name="xmlItem"> |
|
51 |
<xsl:with-param name="indent" select="$newindent" /> |
|
52 |
</xsl:call-template> |
|
53 |
</xsl:otherwise> |
|
54 |
</xsl:choose> |
|
55 |
</xsl:for-each> |
|
56 |
<br /><xsl:value-of select="$indent" /><span style='color:blue'><xsl:value-of select="concat('</',$tag,'>')" /></span> |
|
57 |
</xsl:when> |
|
58 |
<xsl:otherwise> |
|
59 |
<span style='color:blue'> /></span> |
|
60 |
</xsl:otherwise> |
|
61 |
</xsl:choose> |
|
62 |
</xsl:if> |
|
63 |
</xsl:template> |
|
64 |
|
|
65 |
</xsl:stylesheet> |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/web/resources/html/index/indexQuery.html | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
<div class="row"> |
|
4 |
<div class="col-md-12"> |
|
5 |
<label for="xqueryInput" class="control-label">Cql Query</label> |
|
6 |
</div> |
|
7 |
</div> |
|
8 |
<div class="row"> |
|
9 |
<div class="col-md-12"> |
|
10 |
<textarea class="form-control" id="xqueryInput" ng-model="query"></textarea> |
|
11 |
</div> |
|
12 |
</div> |
|
13 |
<div class="row"> |
|
14 |
<div class="col-md-3"> |
|
15 |
<label for="xqueryInput" class="control-label">Metadata |
|
16 |
Format</label> |
|
17 |
</div> |
|
18 |
<div class="col-md-3"> |
|
19 |
<label for="xqueryInput" class="control-label">Backend</label> |
|
20 |
</div> |
|
21 |
<div class="col-md-3"> |
|
22 |
<label for="xqueryInput" class="control-label">Index</label> |
|
23 |
</div> |
|
24 |
</div> |
|
25 |
<div class="row"> |
|
26 |
|
|
27 |
<div class="col-md-3"> |
|
28 |
<select class="form-control" ng-model="selectedMdref" |
|
29 |
ng-change="metadataFormatSelected({{item.metadataReference.layout}})" |
|
30 |
ng-options="(item.metadataReference.format +'-' + item.metadataReference.layout + '-' + item.metadataReference.interpretation) for item in mdFormats"> |
|
31 |
<option value="" selected="selected">--Select Metadata |
|
32 |
Format--</option> |
|
33 |
</select> |
|
34 |
|
|
35 |
|
|
36 |
</div> |
|
37 |
<div class="col-md-3"> |
|
38 |
<select class="form-control" ng-model="selectedbackend" |
|
39 |
ng-change="backendSelected()" ng-options="item for item in backends"> |
|
40 |
<option value="" selected="selected">--Select Backend--</option> |
|
41 |
</select> |
|
42 |
</div> |
|
43 |
<div class="col-md-3"> |
|
44 |
<select class="form-control" ng-model="selectedIndex" |
|
45 |
ng-options="item.id for item in indices"> |
|
46 |
<option value="" selected="selected">--ALL --</option> |
|
47 |
</select> |
|
48 |
</div> |
|
49 |
</div> |
|
50 |
|
|
51 |
<div class="row" style="padding-top: 10px"> |
|
52 |
<div class="col-md-4"> |
|
53 |
<button class="btn btn-info" ng-click="startSearch()">Search</button> |
|
54 |
</div> |
|
55 |
|
|
56 |
<div class="col-md-6"> |
|
57 |
<button class="btn btn-info" ng-click="share()">Share</button> |
|
58 |
</div> |
|
59 |
</div> |
|
60 |
|
|
61 |
<div class="container-fluid" style="padding-top: 10px"> |
|
62 |
|
|
63 |
<div class="row" ng-show="error"> |
|
64 |
<div class="panel panel-default" > |
|
65 |
<div class="panel-heading"> |
|
66 |
<a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_error"><b>Error:</b> <i>{{error.message}}</i></a> |
|
67 |
</div> |
|
68 |
<div id="collapse_error" class="panel-collapse collapse in"> |
|
69 |
<div class="panel-body"> |
|
70 |
<pre>{{error.stacktrace}}</pre> |
|
71 |
</div> |
|
72 |
</div> |
|
73 |
</div> |
|
74 |
</div> |
|
75 |
|
|
76 |
<div class="row" ng-show="searchResult"> |
|
77 |
<div class="col-md-12 "> |
|
78 |
<h3>Number of results: {{searchResult.total}}</h3> |
|
79 |
</div> |
|
80 |
<div class="col-md-12 text-center"> |
|
81 |
<ul class="pagination"> |
|
82 |
<li><a href="" ng-click="prevPage()">«</a></li> |
|
83 |
<li><a href="" ng-click="nextPage()">»</a></li> |
|
84 |
</ul> |
|
85 |
</div> |
|
86 |
</div> |
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
<div class="row" ng-repeat="item in searchResult.records"> |
|
91 |
<div class="col-md-12"> |
|
92 |
<div class="panel panel-default"> |
|
93 |
<div class="panel-heading"> |
|
94 |
<a class="accordion-toggle" data-toggle="collapse" |
|
95 |
data-target="#collapse_{{$index}}"><b>{{$index+1 + from}}</b></a> |
|
96 |
</div> |
|
97 |
<div id="collapse_{{$index}}" class="panel-collapse collapse in"> |
|
98 |
<div class="panel-body"> |
|
99 |
<div ng-bind-html="to_trusted(item)" compile-template></div> |
|
100 |
</div> |
|
101 |
|
|
102 |
|
|
103 |
</div> |
|
104 |
</div> |
|
105 |
</div> |
|
106 |
</div> |
|
107 |
</div> |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/web/resources/html/index/indexManage.html | ||
---|---|---|
1 |
<h1>IT WORKSSS!</h1> |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/web/resources/html/index/browse.html | ||
---|---|---|
1 |
<form> |
|
2 |
<div class="container-fluid"> |
|
3 |
<div class="row"> |
|
4 |
<div class="col-md-12"><label for="xqueryInput" class="control-label">CQL Query</label></div> |
|
5 |
</div> |
|
6 |
<div class="row"> |
|
7 |
<div class="col-md-12"> |
|
8 |
<textarea class="form-control" id="xqueryInput" ng-model="query"></textarea> |
|
9 |
</div> |
|
10 |
</div> |
|
11 |
<div class="row"> |
|
12 |
<div class="col-md-4"><label for="xqueryInput" class="control-label">Metadata Format:</label></div> |
|
13 |
<div class="col-md-4"><label for="xqueryInput" class="control-label">Backend:</label></div> |
|
14 |
<div class="col-md-4"><label for="xqueryInput" class="control-label">Index::</label></div> |
|
15 |
</div> |
|
16 |
<div class="row"> |
|
17 |
|
|
18 |
<div class="col-md-4"> |
|
19 |
<select class="form-control" ng-model="selectedMdref" |
|
20 |
ng-change="metadataFormatSelected({{item.metadataReference.layout}})" |
|
21 |
ng-options="(item.metadataReference.format +'-' + item.metadataReference.layout + '-' + item.metadataReference.interpretation) for item in mdFormats"> |
|
22 |
<option value="" selected="selected">--Select Metadata |
|
23 |
Format--</option> |
|
24 |
</select> |
|
25 |
</div> |
|
26 |
<div class="col-md-4"> |
|
27 |
<select class="form-control" ng-model="selectedbackend" ng-change="backendSelected()" ng-options="item for item in backends"> |
|
28 |
<option value="" selected="selected">--Select Backend--</option> |
|
29 |
</select> |
|
30 |
</div> |
|
31 |
<div class="col-md-4"> |
|
32 |
<select class="form-control" ng-model="selectedIndex" ng-options="item.id for item in indices" > |
|
33 |
<option value="" selected="selected" >--ALL --</option> |
|
34 |
</select> |
|
35 |
</div> |
|
36 |
</div> |
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
<div class="row" style="padding-top: 10px"> |
|
41 |
<div class ="col-md-6"> |
|
42 |
<table class="table table-striped table-bordered"> |
|
43 |
<thead> |
|
44 |
<tr> |
|
45 |
<th width="80%">Browse Field</th> |
|
46 |
<th width="20%">delete</th> |
|
47 |
</tr> |
|
48 |
</thead> |
|
49 |
<tbody> |
|
50 |
<tr ng-repeat="item in addedBrowseFields"> |
|
51 |
<td>{{item}}</td> |
|
52 |
<td><a href="" ng-click="deleteBrowseField(item)" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span></a></td> |
|
53 |
</tr> |
|
54 |
</tbody> |
|
55 |
|
|
56 |
|
|
57 |
</table> |
|
58 |
</div> |
|
59 |
</div> |
|
60 |
|
|
61 |
<div class="row" style="padding-top: 10px"> |
|
62 |
<div class="col-md-4"> |
|
63 |
<select class="form-control" ng-model="selectedBrowser" ng-options="item for item in browseFields"> |
|
64 |
<option value="" selected="selected">--- Add Field --</option> |
|
65 |
</select> </td> |
|
66 |
</div> |
|
67 |
<div class="col-md-1"> |
|
68 |
<a href="" ng-click="browseFieldAdded()" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span></a> |
|
69 |
</div> |
|
70 |
|
|
71 |
</div> |
|
72 |
|
|
73 |
|
|
74 |
<div class="row" style="padding-top: 10px"> |
|
75 |
<div class="col-md-4"> |
|
76 |
<input type="submit" class="btn btn-info" ng-click="startBrowse()" value="Browse" > |
|
77 |
</div> |
|
78 |
</div> |
|
79 |
</div> |
|
80 |
</form> |
|
81 |
|
|
82 |
|
|
83 |
<div class="container-fluid" style="padding-top: 10px"> |
|
84 |
|
|
85 |
<div class="row" ng-show="error"> |
|
86 |
<div class="panel panel-default" > |
|
87 |
<div class="panel-heading"> |
|
88 |
<a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_error"><b>Error:</b> <i>{{error.message}}</i></a> |
|
89 |
</div> |
|
90 |
<div id="collapse_error" class="panel-collapse collapse in"> |
|
91 |
<div class="panel-body"> |
|
92 |
<pre>{{error.stacktrace}}</pre> |
|
93 |
</div> |
|
94 |
</div> |
|
95 |
</div> |
|
96 |
</div> |
|
97 |
|
|
98 |
<div class="row" ng-repeat="item in browseResult"> |
|
99 |
<div class ="col-md-6"> |
|
100 |
<div class="panel panel-default" > |
|
101 |
<div class="panel-heading"> |
|
102 |
<a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_{{$index}}"><b>{{item.label}} :</b></a> |
|
103 |
</div> |
|
104 |
<div id="collapse_{{$index}}" class="panel-collapse collapse in"> |
|
105 |
<table class="table"> |
|
106 |
<tbody> |
|
107 |
<tr ng-repeat="value in item.values"> |
|
108 |
<td>{{value.value}}</td> |
|
109 |
<td class="text-right">{{value.size}}</td> |
|
110 |
</tr> |
|
111 |
</tbody> |
|
112 |
</table> |
|
113 |
</div> |
|
114 |
</div> |
|
115 |
</div> |
|
116 |
</div> |
|
117 |
</div> |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/web/resources/html/index/deletebyquery.html | ||
---|---|---|
1 |
<h3>Delete By Query</h3> |
|
2 |
|
|
3 |
|
|
4 |
<div class="row"> |
|
5 |
<div class="col-md-12"> |
|
6 |
<label for="xqueryInput" class="control-label">Cql Query</label> |
|
7 |
</div> |
|
8 |
</div> |
|
9 |
<div class="row"> |
|
10 |
<div class="col-md-12"> |
|
11 |
<textarea class="form-control" id="xqueryInput" ng-model="query"></textarea> |
|
12 |
</div> |
|
13 |
</div> |
|
14 |
<div class="row"> |
|
15 |
<div class="col-md-3"> |
|
16 |
<label for="xqueryInput" class="control-label">Metadata |
|
17 |
Format</label> |
|
18 |
</div> |
|
19 |
<div class="col-md-3"> |
|
20 |
<label for="xqueryInput" class="control-label">Backend</label> |
|
21 |
</div> |
|
22 |
<div class="col-md-3"> |
|
23 |
<label for="xqueryInput" class="control-label">Index</label> |
|
24 |
</div> |
|
25 |
</div> |
|
26 |
<div class="row"> |
|
27 |
|
|
28 |
<div class="col-md-3"> |
|
29 |
<select class="form-control" ng-model="selectedMdref" |
|
30 |
ng-change="metadataFormatSelected({{item.metadataReference.layout}})" |
|
31 |
ng-options="(item.metadataReference.format +'-' + item.metadataReference.layout + '-' + item.metadataReference.interpretation) for item in mdFormats"> |
|
32 |
<option value="" selected="selected">--Select Metadata |
|
33 |
Format--</option> |
|
34 |
</select> |
|
35 |
|
|
36 |
</div> |
|
37 |
<div class="col-md-3"> |
|
38 |
<select class="form-control" ng-model="selectedbackend" |
|
39 |
ng-change="backendSelected()" ng-options="item for item in backends"> |
|
40 |
<option value="" selected="selected">--Select Backend--</option> |
|
41 |
</select> |
|
42 |
</div> |
|
43 |
<div class="col-md-3"> |
|
44 |
<select class="form-control" ng-model="selectedIndex" |
|
45 |
ng-options="item.id for item in indices"> |
|
46 |
<option value="" selected="selected">--ALL --</option> |
|
47 |
</select> |
|
48 |
</div> |
|
49 |
</div> |
|
50 |
|
|
51 |
<div class="row" style="padding-top: 10px"> |
|
52 |
<div class="col-md-4"> |
|
53 |
<button class="btn btn-danger" ng-click="startDelete()">Delete</button> |
|
54 |
</div> |
|
55 |
</div> |
|
56 |
|
|
57 |
|
|
58 |
<div class="row" ng-show="searchResult"> |
|
59 |
<div class="col-md-12 "> |
|
60 |
<h3>Number of record deleted : {{searchResult}}</h3> |
|
61 |
</div> |
|
62 |
</div> |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/web/resources/js/oai/oai.js | ||
---|---|---|
13 | 13 |
) |
14 | 14 |
.error( |
15 | 15 |
function () { |
16 |
show_notification('error', 'Cannot load info about trasnformation rules');
|
|
16 |
show_notification('error', 'Cannot load info about transformation rules');
|
|
17 | 17 |
} |
18 | 18 |
); |
19 | 19 |
} |
... | ... | |
58 | 58 |
.success( |
59 | 59 |
function (data) { |
60 | 60 |
if (data) { |
61 |
var newSourceMdf = { |
|
62 |
"sourceFormatName": mdf.sourceFormatName, |
|
63 |
"sourceFormatLayout": mdf.sourceFormatLayout, |
|
64 |
"sourceFormatInterpretation": mdf.sourceFormatInterpretation |
|
65 |
}; |
|
61 |
var newSourceMdf = mdf.sourceMetadataReference; |
|
66 | 62 |
if (isNew) { |
67 | 63 |
$scope.exportFormats.push(mdf); |
68 | 64 |
if (!contains($scope.srcFormats, newSourceMdf)) $scope.srcFormats.push(newSourceMdf); |
... | ... | |
119 | 115 |
showSpinner(); |
120 | 116 |
$scope.show = 'source'; |
121 | 117 |
$scope.currentMdf = mdFormat |
122 |
$scope.currentPrefix = mdFormat.sourceFormatName
|
|
123 |
$scope.showStoreIndexes($scope.currentMdf.sourceFormatName, $scope.currentMdf.sourceFormatLayout, $scope.currentMdf.sourceFormatInterpretation);
|
|
118 |
$scope.currentPrefix = mdFormat.format
|
|
119 |
$scope.showStoreIndexes($scope.currentMdf.format, $scope.currentMdf.layout, $scope.currentMdf.interpretation);
|
|
124 | 120 |
hideSpinner(); |
125 | 121 |
} |
126 | 122 |
|
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/web/resources/js/oai/oaiCommon.js | ||
---|---|---|
16 | 16 |
} |
17 | 17 |
); |
18 | 18 |
|
19 |
//load source metadata formats |
|
19 |
//load source metadata formats (MetadataReference instances)
|
|
20 | 20 |
$http.get('getSourceMDFs.do') |
21 | 21 |
.success( |
22 | 22 |
function (data) { |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/web/resources/js/index/index_inspector.js | ||
---|---|---|
1 |
var module = angular.module('indexInspector', ['ngRoute', 'indexInspectorControllers']); |
|
2 |
|
|
3 |
module.config([ |
|
4 |
'$routeProvider', |
|
5 |
function($routeProvider) { |
|
6 |
$routeProvider |
|
7 |
.when('/query', { templateUrl: '../resources/html/index/indexQuery.html', controller: 'indexQueryController' }) |
|
8 |
.when('/query/:mdformat/:backend/:index/:start/:query', { templateUrl: '../resources/html/index/indexQuery.html', controller: 'indexQueryController' }) |
|
9 |
.when('/browse', { templateUrl: '../resources/html/index/browse.html', controller: 'indexBrowseController' }) |
|
10 |
.when('/manage', { templateUrl: '../resources/html/index/indexManage.html', controller: 'indexmanageController' }) |
|
11 |
.when('/deletebyquery', { templateUrl: '../resources/html/index/deletebyquery.html', controller: 'indexdbqController' }) |
|
12 |
.otherwise({ redirectTo: '/query' }); |
|
13 |
} |
|
14 |
]); |
|
15 |
|
|
16 |
|
|
17 |
module.controller('moduleMenuCtrl', [ '$scope', '$location', |
|
18 |
function ($scope, $location) { |
|
19 |
$scope.isActive = function(regex) { |
|
20 |
var re = new RegExp(regex); |
|
21 |
return re.test($location.path()); |
|
22 |
} |
|
23 |
} |
|
24 |
]); |
|
25 |
|
|
26 |
module.filter('encodeURIComponent', function() { |
|
27 |
return window.encodeURIComponent; |
|
28 |
}); |
modules/dnet-modular-uis/trunk/src/main/resources/eu/dnetlib/web/resources/js/index/index_inspector_controllers.js | ||
---|---|---|
1 |
var indexInspectorControllers = angular.module('indexInspectorControllers', ['LocalStorageModule']); |
|
2 |
|
|
3 |
function common_init($scope, $http, $sce, $location) { |
|
4 |
initSpinner(); |
|
5 |
$scope.showError = function (error) { |
|
6 |
show_notification("error", error); |
|
7 |
} |
|
8 |
$scope.showNotification = function (message) { |
|
9 |
show_notification("info", message); |
|
10 |
} |
|
11 |
$scope.showSpinner = function () { |
|
12 |
showSpinner(); |
|
13 |
} |
|
14 |
$scope.hideSpinner = function () { |
|
15 |
hideSpinner(); |
|
16 |
} |
|
17 |
$scope.to_trusted = function (html) { |
|
18 |
return $sce.trustAsHtml(html); |
|
19 |
} |
|
20 |
$scope.go = function (path) { |
|
21 |
$location.path(path); |
|
22 |
} |
|
23 |
$scope.encodeValue = function (val) { |
|
24 |
return val; |
|
25 |
} |
|
26 |
} |
|
27 |
|
|
28 |
indexInspectorControllers.directive('compileTemplate', function ($compile, $parse) { |
|
29 |
return { |
|
30 |
link: function (scope, element, attr) { |
|
31 |
var parsed = $parse(attr.ngBindHtml); |
|
32 |
|
|
33 |
function getStringValue() { |
|
34 |
return (parsed(scope) || '').toString(); |
|
35 |
} |
|
36 |
|
|
37 |
//Recompile if the template changes |
|
38 |
scope.$watch(getStringValue, function () { |
|
39 |
$compile(element, null, -9999)(scope); //The -9999 makes it skip directives so that we do not recompile ourselves |
|
40 |
}); |
|
41 |
} |
|
42 |
} |
|
43 |
}); |
|
44 |
|
|
45 |
|
|
46 |
indexInspectorControllers.controller('indexmanageController', [ |
|
47 |
'$scope', '$http', '$sce', '$location', |
|
48 |
function ($scope, $http, $sce, $location) { |
|
49 |
common_init($scope, $http, $sce, $location); |
|
50 |
|
|
51 |
|
|
52 |
}]); |
|
53 |
|
|
54 |
indexInspectorControllers.controller('indexdbqController', ['$scope', |
|
55 |
'$http', '$sce', '$location', function ($scope, $http, $sce, $location) { |
|
56 |
common_init($scope, $http, $sce, $location); |
|
57 |
$scope.mdFormats = [] |
|
58 |
$scope.backends = [] |
|
59 |
$scope.indices = [] |
|
60 |
$scope.query = '*=*' |
|
61 |
$scope.from = 0 |
|
62 |
$scope.size = 10 |
|
63 |
$scope.error = null; |
|
64 |
|
|
65 |
$scope.showSpinner(); |
|
66 |
|
|
67 |
$scope.to_trusted = function (html_code) { |
|
68 |
return $sce.trustAsHtml(html_code); |
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
$http.get('index/indexMetadataFormats.do').success(function (data) { |
|
73 |
$scope.hideSpinner(); |
|
74 |
$scope.mdFormats = data; |
|
75 |
}).error(function () { |
|
76 |
$scope.showError('Error listing xmldb collections'); |
|
77 |
$scope.hideSpinner(); |
|
78 |
}); |
|
79 |
|
|
80 |
$http.get('index/backend.do').success(function (data) { |
|
81 |
$scope.hideSpinner(); |
|
82 |
$scope.backends = data; |
|
83 |
}).error(function (error) { |
|
84 |
$scope.showError(error.message); |
|
85 |
$scope.hideSpinner(); |
|
86 |
}); |
|
87 |
|
|
88 |
$scope.backendSelected = function (index) { |
|
89 |
|
|
90 |
if ($scope.selectedbackend != null) { |
|
91 |
$http.get('index/indexDatastructures.do', { |
|
92 |
params: { |
|
93 |
backend: $scope.selectedbackend |
|
94 |
} |
|
95 |
}).success(function (data) { |
|
96 |
$scope.hideSpinner(); |
|
97 |
$scope.indices = data |
|
98 |
|
|
99 |
}).error(function () { |
|
100 |
$scope.showError('Error listing xmldb collections'); |
|
101 |
$scope.hideSpinner(); |
|
102 |
}); |
|
103 |
} |
|
104 |
|
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
|
|
109 |
$scope.hideSpinner(); |
|
110 |
|
|
111 |
$scope.startDelete = function () { |
|
112 |
$scope.from = 0; |
|
113 |
$scope.size = 10 |
|
114 |
$scope.deleteByQuery() |
|
115 |
} |
|
116 |
|
|
117 |
|
|
118 |
$scope.deleteByQuery = function () { |
|
119 |
|
|
120 |
if (($scope.selectedMdref == null) || ($scope.selectedbackend == null)) { |
|
121 |
alert("You must select a metadata format and a backend identifier") |
|
122 |
return; |
|
123 |
} |
|
124 |
|
|
125 |
$scope.showSpinner(); |
|
126 |
$scope.error = null; |
|
127 |
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8"; |
|
128 |
var selectedId = null; |
|
129 |
if ($scope.selectedIndex != null) |
|
130 |
selectedId = $scope.selectedIndex.id |
|
131 |
$http.post('index/delete.do', $.param({ |
|
132 |
|
|
133 |
'backend': $scope.selectedbackend, |
|
134 |
'format': $scope.selectedMdref.metadataReference.format, |
|
135 |
'layout': $scope.selectedMdref.metadataReference.layout, |
|
136 |
'interpretation': $scope.selectedMdref.metadataReference.interpretation, |
|
137 |
'query': $scope.query, |
|
138 |
'indexidentifier': selectedId |
|
139 |
|
|
140 |
})) |
|
141 |
.success(function (data) { |
|
142 |
$scope.hideSpinner(); |
|
143 |
$scope.searchResult = data |
|
144 |
console.log(data) |
|
145 |
}).error(function (error) { |
|
146 |
$scope.error = error; |
|
147 |
$scope.hideSpinner(); |
|
148 |
}); |
|
149 |
} |
|
150 |
|
|
151 |
$scope.nextPage = function () { |
|
152 |
if ($scope.searchResult == null) |
|
153 |
return; |
|
154 |
if ($scope.from > $scope.searchResult.total) |
|
155 |
return; |
|
156 |
$scope.from += 10; |
|
157 |
$scope.size = $scope.from + 10 |
|
158 |
$scope.search() |
|
159 |
} |
|
160 |
|
|
161 |
$scope.prevPage = function () { |
|
162 |
if ($scope.from <= 0) { |
|
163 |
return; |
|
164 |
} |
|
165 |
|
|
166 |
$scope.from -= 10; |
|
167 |
$scope.size -= 10 |
|
168 |
$scope.search() |
|
169 |
} |
|
170 |
|
|
171 |
$scope.range = function (n) { |
|
172 |
return new Array(n); |
|
173 |
}; |
|
174 |
|
|
175 |
|
|
176 |
}]); |
|
177 |
|
|
178 |
|
|
179 |
indexInspectorControllers.controller('indexBrowseController', [ |
|
180 |
'$scope', '$http', '$sce', '$location', |
|
181 |
function ($scope, $http, $sce, $location) { |
|
182 |
common_init($scope, $http, $sce, $location); |
|
183 |
$scope.showSpinner(); |
|
184 |
$scope.mdFormats = [] |
|
185 |
$scope.backends = [] |
|
186 |
$scope.indices = [] |
|
187 |
$scope.query = '*=*' |
|
188 |
$scope.error = null; |
|
189 |
|
|
190 |
$scope.browseFields = []; |
|
191 |
$scope.addedBrowseFields = []; |
|
192 |
$scope.selectedMdref = ""; |
|
193 |
|
|
194 |
$http.get('index/indexMetadataFormats.do').success(function (data) { |
|
195 |
$scope.hideSpinner(); |
|
196 |
$scope.mdFormats = data; |
|
197 |
}).error(function () { |
|
198 |
$scope.showError('Error listing xmldb collections'); |
|
199 |
$scope.hideSpinner(); |
|
200 |
}); |
|
201 |
|
|
202 |
$http.get('index/backend.do').success(function (data) { |
|
203 |
$scope.hideSpinner(); |
|
204 |
$scope.backends = data; |
|
205 |
}).error(function (error) { |
|
206 |
$scope.showError(error.message); |
|
207 |
$scope.hideSpinner(); |
|
208 |
}); |
|
209 |
|
|
210 |
$scope.backendSelected = function (index) { |
|
211 |
|
|
212 |
if ($scope.selectedbackend != null) { |
|
213 |
$http.get('index/indexDatastructures.do', { |
|
214 |
params: { |
|
215 |
backend: $scope.selectedbackend |
|
216 |
} |
|
217 |
}).success(function (data) { |
|
218 |
$scope.hideSpinner(); |
|
219 |
$scope.indices = data |
|
220 |
|
|
221 |
}).error(function () { |
|
222 |
$scope.showError('Error listing xmldb collections'); |
|
223 |
$scope.hideSpinner(); |
|
224 |
}); |
|
225 |
} |
|
226 |
|
|
227 |
|
|
228 |
} |
|
229 |
|
|
230 |
$scope.metadataFormatSelected = function (index) { |
|
231 |
if ($scope.selectedMdref == null) { |
|
232 |
$scope.addedBrowseFields = []; |
|
233 |
$scope.browseFields = [] |
|
234 |
return; |
|
235 |
} |
|
236 |
|
|
237 |
$http.get('index/mdFormatInfo.do', { |
|
238 |
params: { |
|
239 |
id: $scope.selectedMdref.id, |
|
240 |
layout: $scope.selectedMdref.metadataReference.layout |
|
241 |
} |
|
242 |
}).success(function (data) { |
|
243 |
$scope.hideSpinner(); |
|
244 |
$scope.browseFields = data; |
|
245 |
$scope.browseFields.sort() |
|
246 |
$scope.addedBrowseFields = []; |
|
247 |
$scope.selectedBrowser = '--- Add Field --' |
|
248 |
}).error(function () { |
|
249 |
$scope.showError('Error listing xmldb collections'); |
|
250 |
$scope.hideSpinner(); |
|
251 |
}); |
|
252 |
}; |
|
253 |
|
|
254 |
$scope.startBrowse = function () { |
|
255 |
|
Also available in: Unified diff
Added index inspector