Revision 46346
Added by Alessia Bardi over 7 years ago
modules/dnet-modular-uis/branches/saxonHE/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/branches/saxonHE/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/branches/saxonHE/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/branches/saxonHE/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/branches/saxonHE/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 |
@Autowired |
|
66 |
TransformerFactory saxonTransformerFactory; |
|
67 |
|
|
68 |
@Value("${dnet.modular.ui.index.gmf.xslt}") |
|
69 |
private String gmf2documentXslt; |
|
70 |
|
|
71 |
/** |
|
72 |
* Index metadata formats. |
|
73 |
* |
|
74 |
* @param map the map |
|
75 |
* @return the list< md format info> |
|
76 |
* @throws Exception the exception |
|
77 |
*/ |
|
78 |
@RequestMapping(value = "/ui/index/indexMetadataFormats.do") |
|
79 |
@ResponseBody |
|
80 |
public List<MdFormatInfo> indexMetadataFormats(final ModelMap map) throws Exception { |
|
81 |
final String xquery = |
|
82 |
"for $x in //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='MDFormatDSResourceType'] " |
|
83 |
+ "let $format:= $x//CONFIGURATION/NAME/string() for $y in $x//LAYOUTS/LAYOUT let $layout:= $y/@name/string() " |
|
84 |
+ "let $interpretation:= $x//CONFIGURATION/INTERPRETATION/text() let $id:=$x//RESOURCE_IDENTIFIER/@value/string() " |
|
85 |
+ " return concat($format,'-',$layout,'-',$interpretation,'::', $id) "; |
|
86 |
log.debug("Executing lookup query " + xquery); |
|
87 |
|
|
88 |
return Lists.transform(quickSearchProfile(xquery), input -> MdFormatInfo.initFromXqueryResult(input)); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Index datastructures. |
|
93 |
* |
|
94 |
* @param backend the backend |
|
95 |
* @return the list< index info> |
|
96 |
* @throws Exception the exception |
|
97 |
*/ |
|
98 |
@RequestMapping(value = "/ui/index/indexDatastructures.do") |
|
99 |
@ResponseBody |
|
100 |
public List<IndexInfo> indexDatastructures(@RequestParam(value = "backend", required = true) final String backend) throws Exception { |
|
101 |
final String xquery = |
|
102 |
"for $x in //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='IndexDSResourceType' and .//BACKEND/@ID='%s'] let $format := $x//METADATA_FORMAT " |
|
103 |
+ "let $layout := $x//METADATA_FORMAT_LAYOUT let $interpretation :=$x//METADATA_FORMAT_INTERPRETATION " |
|
104 |
+ "let $id :=$x//RESOURCE_IDENTIFIER/@value let $backendid := $x//BACKEND/@ID let $size := $x//INDEX_SIZE " |
|
105 |
+ "return concat($format, ':-:',$layout,':-:',$interpretation,':-:',$id,':-:',$backendid,':-:',$size)"; |
|
106 |
log.debug("Executing lookup query " + String.format(xquery, backend)); |
|
107 |
|
|
108 |
Function<String, IndexInfo> function = input -> IndexInfo.newInstanceFromString(input); |
|
109 |
return Lists.transform(quickSearchProfile(String.format(xquery, backend)), function); |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* Md format info. |
|
114 |
* |
|
115 |
* @param id the id |
|
116 |
* @param layout the layout |
|
117 |
* @return the list< string> |
|
118 |
* @throws Exception the exception |
|
119 |
*/ |
|
120 |
@RequestMapping(value = "/ui/index/mdFormatInfo.do") |
|
121 |
@ResponseBody |
|
122 |
public List<String> mdFormatInfo(@RequestParam(value = "id", required = true) final String id, |
|
123 |
@RequestParam(value = "layout", required = true) final String layout) throws Exception { |
|
124 |
|
|
125 |
String xqueryTemplate = |
|
126 |
"//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value='%s']" + "//LAYOUT[./@name/string()='%s'] " |
|
127 |
+ "//FIELD[./@tokenizable/string()='false' or ./@type = 'int' or ./@type = 'date']/@name/string()"; |
|
128 |
log.debug("executing query: " + String.format(xqueryTemplate, id, layout)); |
|
129 |
return quickSearchProfile(String.format(xqueryTemplate, id, layout)); |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* Gets the backend available. |
|
134 |
* |
|
135 |
* @return the ids of the available backends |
|
136 |
* @throws Exception the exception |
|
137 |
*/ |
|
138 |
@RequestMapping(value = "/ui/index/backend.do") |
|
139 |
@ResponseBody |
|
140 |
public Set<String> getBackendAvailable() throws Exception { |
|
141 |
|
|
142 |
String xquery = "for $x in //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='IndexDSResourceType'] return distinct-values($x//BACKEND/@ID/string())"; |
|
143 |
log.debug("executing query: " + xquery); |
|
144 |
return Sets.newHashSet(quickSearchProfile(xquery)); |
|
145 |
|
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Browse. |
|
150 |
* |
|
151 |
* @param map the map |
|
152 |
* @param backend the backend |
|
153 |
* @param format the format |
|
154 |
* @param layout the layout |
|
155 |
* @param interpretation the interpretation |
|
156 |
* @return the list< string> |
|
157 |
* @throws IndexClientException the index client exception |
|
158 |
*/ |
|
159 |
@RequestMapping(value = "/ui/index/browse.do", method = RequestMethod.POST) |
|
160 |
@ResponseBody |
|
161 |
public List<BrowseEntry> browse(final ModelMap map, |
|
162 |
@RequestParam(value = "backend", required = true) final String backend, |
|
163 |
@RequestParam(value = "format", required = true) final String format, |
|
164 |
@RequestParam(value = "layout", required = true) final String layout, |
|
165 |
@RequestParam(value = "interpretation", required = true) final String interpretation, |
|
166 |
@RequestParam(value = "fields", required = true) final String fields, |
|
167 |
@RequestParam(value = "query", required = true) final String query) throws IndexClientException { |
|
168 |
|
|
169 |
List<String> browseFields = new Gson().fromJson(fields, new TypeToken<List<String>>() { |
|
170 |
}.getType()); |
|
171 |
|
|
172 |
if (browseFields != null) { |
|
173 |
for (String s : browseFields) { |
|
174 |
log.debug("Browse field " + s); |
|
175 |
} |
|
176 |
} |
|
177 |
|
|
178 |
String indexClientKeys = backend + "-" + format + "-" + layout + "-" + interpretation; |
|
179 |
|
|
180 |
IndexClient client = null; |
|
181 |
if (clientMap.getMap().containsKey(indexClientKeys)) { |
|
182 |
client = clientMap.getMap().get(indexClientKeys); |
|
183 |
} else { |
|
184 |
client = indexClientFactory.getClient(format, layout, interpretation, backend); |
|
185 |
clientMap.getMap().put(indexClientKeys, client); |
|
186 |
} |
|
187 |
|
|
188 |
// LookupResponse result = client.lookup("*=*", null, 0, 10); |
|
189 |
|
|
190 |
List<BrowseEntry> result = client.browse(query, browseFields, 99); |
|
191 |
return result; |
|
192 |
} |
|
193 |
|
|
194 |
@RequestMapping(value = "/ui/index/delete.do", method = RequestMethod.POST) |
|
195 |
@ResponseBody |
|
196 |
public long delete(final ModelMap map, |
|
197 |
@RequestParam(value = "backend", required = true) final String backend, |
|
198 |
@RequestParam(value = "format", required = true) final String format, |
|
199 |
@RequestParam(value = "layout", required = true) final String layout, |
|
200 |
@RequestParam(value = "interpretation", required = true) final String interpretation, |
|
201 |
@RequestParam(value = "query", required = true) final String query, |
|
202 |
@RequestParam(value = "indexidentifier", required = false) final String indexId) throws IndexServiceException { |
|
203 |
|
|
204 |
String indexClientKeys = backend + "-" + format + "-" + layout + "-" + interpretation; |
|
205 |
|
|
206 |
IndexClient client = null; |
|
207 |
if (clientMap.getMap().containsKey(indexClientKeys)) { |
|
208 |
client = clientMap.getMap().get(indexClientKeys); |
|
209 |
} else { |
|
210 |
client = indexClientFactory.getClient(format, layout, interpretation, backend); |
|
211 |
clientMap.getMap().put(indexClientKeys, client); |
|
212 |
} |
|
213 |
String mquery = query; |
|
214 |
|
|
215 |
if (!StringUtils.isEmpty(indexId)) { |
|
216 |
mquery = query + " and __dsid exact \"" + indexId + "\""; |
|
217 |
} |
|
218 |
|
|
219 |
return client.delete(mquery); |
|
220 |
} |
|
221 |
|
|
222 |
@RequestMapping(value = "/ui/index/search.do", method = RequestMethod.POST) |
|
223 |
@ResponseBody |
|
224 |
public LookupResponse search(final ModelMap map, |
|
225 |
@RequestParam(value = "backend", required = true) final String backend, |
|
226 |
@RequestParam(value = "format", required = true) final String format, |
|
227 |
@RequestParam(value = "layout", required = true) final String layout, |
|
228 |
@RequestParam(value = "interpretation", required = true) final String interpretation, |
|
229 |
@RequestParam(value = "query", required = true) final String query, |
|
230 |
@RequestParam(value = "from", required = true) final int from, |
|
231 |
@RequestParam(value = "number", required = true) final int number, |
|
232 |
@RequestParam(value = "indexidentifier", required = false) final String indexId |
|
233 |
|
|
234 |
) throws IndexClientException { |
|
235 |
|
|
236 |
String indexClientKeys = backend + "-" + format + "-" + layout + "-" + interpretation; |
|
237 |
|
|
238 |
log.debug(indexClientKeys); |
|
239 |
|
|
240 |
IndexClient client = null; |
|
241 |
|
|
242 |
if (!clientMap.getMap().containsKey(indexClientKeys)) { |
|
243 |
clientMap.getMap().put(indexClientKeys, indexClientFactory.getClient(format, layout, interpretation, backend)); |
|
244 |
} |
|
245 |
client = clientMap.getMap().get(indexClientKeys); |
|
246 |
|
|
247 |
List<String> filterId = null; |
|
248 |
if (indexId != null && !indexId.isEmpty()) { |
|
249 |
filterId = Lists.newArrayList("__dsid:\"" + indexId + "\""); |
|
250 |
} |
|
251 |
|
|
252 |
log.debug(String.format("query: '%s', filter: '%s', from: '%d', number: '%d'", query, filterId, from, number)); |
|
253 |
|
|
254 |
LookupResponse result = client.lookup(query, filterId, from, number); |
|
255 |
|
|
256 |
ClassPathResource cpr = new ClassPathResource(gmf2documentXslt); |
|
257 |
ApplyXslt xslt = new ApplyXslt(cpr, saxonTransformerFactory); |
|
258 |
List<String> convertedList = Lists.newArrayList(); |
|
259 |
|
|
260 |
for (String s : result.getRecords()) { |
|
261 |
log.debug("response record: \n" + s); |
|
262 |
convertedList.add(xslt.apply(s)); |
|
263 |
} |
|
264 |
result.setRecords(convertedList); |
|
265 |
return result; |
|
266 |
} |
|
267 |
|
|
268 |
/** |
|
269 |
* Quick search profile. |
|
270 |
* |
|
271 |
* @param xquery the xquery |
|
272 |
* @return the list< string> |
|
273 |
* @throws Exception the exception |
|
274 |
*/ |
|
275 |
private List<String> quickSearchProfile(final String xquery) throws Exception { |
|
276 |
try { |
|
277 |
return serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery); |
|
278 |
} catch (ISLookUpException e) { |
|
279 |
throw new Exception(e); |
|
280 |
} |
|
281 |
} |
|
282 |
} |
modules/dnet-modular-uis/branches/saxonHE/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/branches/saxonHE/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/branches/saxonHE/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/branches/saxonHE/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/branches/saxonHE/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/branches/saxonHE/src/main/resources/eu/dnetlib/web/resources/html/index/indexManage.html | ||
---|---|---|
1 |
<h1>IT WORKSSS!</h1> |
modules/dnet-modular-uis/branches/saxonHE/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/branches/saxonHE/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/branches/saxonHE/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/branches/saxonHE/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 |
|
|
256 |
if (($scope.selectedMdref == null) || ($scope.selectedbackend == null)) { |
|
257 |
alert("You must select a metadata format and a backend identifier") |
|
258 |
return; |
|
259 |
} |
|
260 |
if ($scope.addedBrowseFields.length == 0) { |
|
261 |
alert("You must select at least one browse field") |
|
262 |
return; |
|
263 |
} |
|
264 |
$scope.showSpinner(); |
|
265 |
$scope.error = null; |
|
266 |
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8"; |
|
267 |
$http.post('index/browse.do', $.param({ |
|
268 |
|
|
269 |
'backend': $scope.selectedbackend, |
|
270 |
'format': $scope.selectedMdref.metadataReference.format, |
|
271 |
'layout': $scope.selectedMdref.metadataReference.layout, |
|
272 |
'interpretation': $scope.selectedMdref.metadataReference.interpretation, |
|
273 |
'fields': JSON.stringify($scope.addedBrowseFields), |
|
274 |
'query': $scope.query |
|
275 |
})) |
|
276 |
.success(function (data) { |
|
277 |
$scope.hideSpinner(); |
|
278 |
$scope.browseResult = data |
|
279 |
}).error(function (error) { |
|
280 |
$scope.error = error; |
|
281 |
$scope.hideSpinner(); |
|
282 |
}); |
|
283 |
} |
|
284 |
|
|
285 |
|
|
286 |
$scope.deleteBrowseField = function (item) { |
|
287 |
var i = 0 |
|
288 |
|
|
289 |
for (; i < $scope.addedBrowseFields.length; i++) { |
|
290 |
if ($scope.addedBrowseFields[i] == item) |
|
291 |
break; |
|
292 |
} |
|
293 |
$scope.addedBrowseFields.splice(i, 1) |
|
294 |
$scope.browseFields = $scope.browseFields.concat(item) |
|
295 |
$scope.browseFields.sort(); |
|
296 |
|
|
297 |
} |
|
298 |
|
|
299 |
$scope.browseFieldAdded = function () { |
|
300 |
for (i = 0; i < $scope.browseFields.length; i++) { |
|
301 |
if ($scope.browseFields[i] == $scope.selectedBrowser) { |
|
302 |
var data = $scope.browseFields[i]; |
|
303 |
$scope.addedBrowseFields = $scope.addedBrowseFields.concat(data) |
|
304 |
$scope.browseFields.splice(i, 1) |
|
305 |
return; |
|
306 |
} |
|
307 |
} |
|
308 |
} |
|
309 |
|
|
310 |
|
|
311 |
}]); |
|
312 |
|
|
313 |
function replaceText(str) { |
|
314 |
var str1 = String(str); |
|
315 |
|
|
316 |
return str1.replace(/\n/g, "<br/>"); |
|
317 |
} |
|
318 |
|
|
319 |
|
|
320 |
function constructMDREFfromString(input) { |
|
321 |
if (input == null || input.length == 0) |
|
322 |
return null; |
|
323 |
var mdrefArr = input.split('-'); |
|
324 |
if (3 == mdrefArr.length) { |
|
325 |
var x = []; |
|
326 |
x['format'] = mdrefArr[0]; |
|
327 |
x['layout'] = mdrefArr[1]; |
|
328 |
x['interpretation'] = mdrefArr[2]; |
|
329 |
return x; |
|
330 |
} |
|
331 |
} |
|
332 |
|
|
333 |
|
|
334 |
function counstructStringMDREF(item) { |
|
335 |
if (item != null && item.hasOwnProperty('format') && item.hasOwnProperty('layout') && item.hasOwnProperty('interpretation')) |
|
336 |
return item.format + '-' + item.layout + '-' + item.interpretation; |
|
337 |
|
|
338 |
return null; |
|
339 |
} |
|
340 |
|
|
341 |
|
|
342 |
indexInspectorControllers.controller('indexQueryController', [ |
|
343 |
'$scope', '$http', '$sce', '$location', '$routeParams', |
|
344 |
function ($scope, $http, $sce, $location, $routeParams) { |
|
345 |
common_init($scope, $http, $sce, $location); |
|
346 |
|
|
347 |
$scope.mdFormats = [] |
|
348 |
$scope.backends = [] |
|
349 |
$scope.indices = [] |
|
350 |
$scope.query = '*=*' |
|
351 |
$scope.from = 0 |
|
352 |
$scope.size = 10 |
Also available in: Unified diff
Added index inspector