Project

General

Profile

« Previous | Next » 

Revision 50737

[maven-release-plugin] copy for tag dnet-modular-mdstore-ui-1.0.0

View differences:

modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/dnet-modular-mdstore-ui.iml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
4
    <output url="file://$MODULE_DIR$/target/classes" />
5
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
6
    <content url="file://$MODULE_DIR$">
7
      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8
      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
9
      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
10
      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
11
      <excludeFolder url="file://$MODULE_DIR$/target" />
12
    </content>
13
    <orderEntry type="inheritedJdk" />
14
    <orderEntry type="sourceFolder" forTests="false" />
15
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-resultset-client:2.1.2-SNAPSHOT" level="project" />
16
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-resultset-service:2.0.3-SNAPSHOT" level="project" />
17
    <orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
18
    <orderEntry type="library" name="Maven: cglib:cglib-nodep:2.2" level="project" />
19
    <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.2.5.RELEASE" level="project" />
20
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-spring-utils:1.0.1-SNAPSHOT" level="project" />
21
    <orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
22
    <orderEntry type="library" name="Maven: jparsec:jparsec:2.0" level="project" />
23
    <orderEntry type="library" name="Maven: runcc:runcc:0.7" level="project" />
24
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-transports-http:3.1.5" level="project" />
25
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-core:3.1.5" level="project" />
26
    <orderEntry type="library" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.4.1" level="project" />
27
    <orderEntry type="library" name="Maven: org.codehaus.woodstox:stax2-api:3.1.4" level="project" />
28
    <orderEntry type="library" name="Maven: org.apache.ws.xmlschema:xmlschema-core:2.2.1" level="project" />
29
    <orderEntry type="library" name="Maven: eu.dnetlib:dnet-modular-ui:3.0.14-SNAPSHOT" level="project" />
30
    <orderEntry type="library" name="Maven: org.springframework:spring-web:4.2.5.RELEASE" level="project" />
31
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.2.5.RELEASE" level="project" />
32
    <orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
33
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.2.5.RELEASE" level="project" />
34
    <orderEntry type="library" name="Maven: org.springframework:spring-context:4.2.5.RELEASE" level="project" />
35
    <orderEntry type="library" name="Maven: org.springframework:spring-core:4.2.5.RELEASE" level="project" />
36
    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
37
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.2.5.RELEASE" level="project" />
38
    <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.2.5.RELEASE" level="project" />
39
    <orderEntry type="library" name="Maven: eu.dnetlib:dnet-runtime:1.0.1-SNAPSHOT" level="project" />
40
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-soap:3.1.5" level="project" />
41
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-wsdl:3.1.5" level="project" />
42
    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.3" level="project" />
43
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-databinding-jaxb:3.1.5" level="project" />
44
    <orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.2.11" level="project" />
45
    <orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.2.11" level="project" />
46
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-jaxws:3.1.5" level="project" />
47
    <orderEntry type="library" name="Maven: xml-resolver:xml-resolver:1.2" level="project" />
48
    <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
49
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-xml:3.1.5" level="project" />
50
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-simple:3.1.5" level="project" />
51
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-addr:3.1.5" level="project" />
52
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-policy:3.1.5" level="project" />
53
    <orderEntry type="library" name="Maven: org.apache.neethi:neethi:3.0.3" level="project" />
54
    <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
55
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-service-common:2.1.6-SNAPSHOT" level="project" />
56
    <orderEntry type="library" name="Maven: org.antlr:stringtemplate:3.2" level="project" />
57
    <orderEntry type="library" name="Maven: org.antlr:antlr:2.7.7" level="project" />
58
    <orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.2.2" level="project" />
59
    <orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.1" level="project" />
60
    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
61
    <orderEntry type="library" name="Maven: org.springframework:spring-tx:4.2.5.RELEASE" level="project" />
62
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-service-utils:1.0.2-SNAPSHOT" level="project" />
63
    <orderEntry type="library" name="Maven: apache:oro:2.0.8" level="project" />
64
    <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.2" level="project" />
65
    <orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.2.2" level="project" />
66
    <orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.9.13" level="project" />
67
    <orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-core-asl:1.9.13" level="project" />
68
    <orderEntry type="library" name="Maven: org.apache.maven:maven-model:3.2.3" level="project" />
69
    <orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-utils:3.0.17" level="project" />
70
    <orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
71
    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.9" level="project" />
72
    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
73
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-modular-mdstore-service:6.0.1-SNAPSHOT" level="project" />
74
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-rmi-api:2.6.1-SNAPSHOT" level="project" />
75
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-blackboard-common:2.2.1-SNAPSHOT" level="project" />
76
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-notifications-common:2.1.1-SNAPSHOT" level="project" />
77
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-misc-utils:1.0.4-SNAPSHOT" level="project" />
78
    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
79
    <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
80
    <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
81
    <orderEntry type="library" name="Maven: jaxen:jaxen:1.1.6" level="project" />
82
    <orderEntry type="library" name="Maven: saxonica:saxon:9.1.0.8" level="project" />
83
    <orderEntry type="library" name="Maven: saxonica:saxon-dom:9.1.0.8" level="project" />
84
    <orderEntry type="library" name="Maven: jgrapht:jgrapht:0.7.2" level="project" />
85
    <orderEntry type="library" name="Maven: net.sf.ehcache:ehcache:2.8.0" level="project" />
86
    <orderEntry type="library" name="Maven: org.springframework:spring-test:4.2.5.RELEASE" level="project" />
87
    <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
88
  </component>
89
</module>
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-modular-mdstore-ui/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-modular-mdstore-ui"}
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/test/java/eu/dnetlib/modular/modstore/ui/MDStoreInfoTest.java
1
package eu.dnetlib.modular.modstore.ui;
2

  
3
import junit.framework.Assert;
4

  
5
import org.junit.Before;
6
import org.junit.Ignore;
7
import org.junit.Test;
8

  
9
import com.google.gson.Gson;
10
import com.google.gson.GsonBuilder;
11

  
12
import eu.dnetlib.functionality.modular.ui.mdstore.model.MDStoreInfo;
13

  
14
public class MDStoreInfoTest {
15

  
16
	@Before
17
	public void setUp() throws Exception {}
18

  
19
	@Test
20
	@Ignore
21
	public void test() {
22
		String values[] = {
23
				"http://127.0.1.1:8280/app/services/mdStore?wsdl@::@da2cd5a7-c7b5-44e8-93db-3a9493a8fac6_TURTdG9yZURTUmVzb3VyY2VzL01EU3RvcmVEU1Jlc291cmNlVHlwZQ==@::@oai_dc-store-native@::@2014-10-01T15:01:58+02:00@::@11104",
24
				"http://127.0.1.1:8280/app/services/mdStore?wsdl@::@ce8c5bbe-ac2a-4d04-af73-59cb7ee6d8cd_TURTdG9yZURTUmVzb3VyY2VzL01EU3RvcmVEU1Jlc291cmNlVHlwZQ==@::@OAF-store-cleaned@::@2014-10-01T15:02:49+02:00@::@11104",
25
				"http://127.0.1.1:8280/app/services/mdStore?wsdl@::@0f9d29ef-687b-4902-8bd3-ee9927790d71_TURTdG9yZURTUmVzb3VyY2VzL01EU3RvcmVEU1Jlc291cmNlVHlwZQ==@::@oai_dc-store-native@::@@::@0",
26
		"http://127.0.1.1:8280/app/services/mdStore?wsdl@::@f034020b-75f5-44b5-acc8-a9dbe9a68773_TURTdG9yZURTUmVzb3VyY2VzL01EU3RvcmVEU1Jlc291cmNlVHlwZQ==@::@OAF-store-cleaned@::@@::@0" };
27

  
28
		for (String v : values) {
29
			Gson g = new GsonBuilder().disableHtmlEscaping().create();
30
			System.out.println(g.toJson(MDStoreInfo.fromXqueryResult(v)));
31
			Assert.assertNotNull(MDStoreInfo.fromXqueryResult(v));
32
		}
33
	}
34

  
35
}
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/mdstore/MDStoreServiceInternalController.java
1
package eu.dnetlib.functionality.modular.ui.mdstore;
2

  
3
import com.google.common.base.Function;
4
import com.google.common.collect.Lists;
5
import com.google.common.collect.Maps;
6
import eu.dnetlib.data.mdstore.DocumentNotFoundException;
7
import eu.dnetlib.data.mdstore.MDStoreService;
8
import eu.dnetlib.data.mdstore.modular.MDFormatDescription;
9
import eu.dnetlib.data.mdstore.modular.MDStoreUtils;
10
import eu.dnetlib.data.mdstore.modular.ModularMDStoreService;
11
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
12
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
13
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
14
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
15
import eu.dnetlib.functionality.modular.ui.mdstore.model.MDStoreInfo;
16
import eu.dnetlib.functionality.modular.ui.mdstore.model.MDStoreResult;
17
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
18
import org.apache.commons.logging.Log;
19
import org.apache.commons.logging.LogFactory;
20
import org.springframework.beans.factory.annotation.Autowired;
21
import org.springframework.core.io.ClassPathResource;
22
import org.springframework.stereotype.Controller;
23
import org.springframework.ui.ModelMap;
24
import org.springframework.web.bind.annotation.*;
25

  
26
import javax.annotation.Resource;
27
import javax.xml.ws.wsaddressing.W3CEndpointReference;
28
import java.util.ArrayList;
29
import java.util.Iterator;
30
import java.util.List;
31
import java.util.Map;
32

  
33
/**
34
 * The Class MDStoreServiceInternalController.
35
 */
36
@Controller
37
public class MDStoreServiceInternalController {
38

  
39
    /**
40
     * The Constant log.
41
     */
42
    private static final Log log = LogFactory.getLog(MDStoreServiceInternalController.class);
43

  
44
    /**
45
     * The lookup locator.
46
     */
47
    @Resource
48
    private UniqueServiceLocator serviceLocator;
49

  
50
    @Autowired
51
    private MDStoreUtils mdStoreUtils;
52

  
53
    @Resource
54
    private ResultSetClientFactory resultSetClientFactory;
55

  
56
    @Autowired
57
    private ModularMDStoreService mdStoreService;
58

  
59

  
60
    private Map<String, Info> datasourceCache;
61

  
62
    /**
63
     * List md stores.
64
     *
65
     * @param map the map
66
     * @return the list
67
     * @throws Exception the exception
68
     */
69
    @RequestMapping(value = "/ui/mdstore/listMDStores.do")
70
    @ResponseBody
71

  
72
    public List<MDStoreInfo> listMDStores(final ModelMap map) throws Exception {
73
        if (datasourceCache == null) {
74
            datasourceCache = datasourceFromMdStore();
75
        }
76

  
77

  
78
        final String xquery = "for $x in  collection('/db/DRIVER/MDStoreDSResources/MDStoreDSResourceType')  let $format := $x//METADATA_FORMAT  "
79
                + "let $layout := $x//METADATA_FORMAT_LAYOUT  let $interpretation :=$x//METADATA_FORMAT_INTERPRETATION "
80
                + "let $uri := $x//RESOURCE_URI/@value/string()  let $id := $x//RESOURCE_IDENTIFIER/@value/string() "
81
                + "let $lastDate := $x//LAST_STORAGE_DATE  let $size :=$x//NUMBER_OF_RECORDS "
82
                + "return concat($uri,'@::@',$id,'@::@',$format,'(-)',$layout, '(-)',$interpretation,'@::@',$lastDate,'@::@',$size) ";
83

  
84
        log.debug("Executing lookup query" + xquery);
85
        return Lists.transform(serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery), new Function<String, MDStoreInfo>() {
86

  
87
            @Override
88
            public MDStoreInfo apply(final String input) {
89
                MDStoreInfo mdStoreInfo = MDStoreInfo.fromXqueryResult(input);
90
                Info currentInfo = datasourceCache.get(mdStoreInfo.getId());
91
                if (currentInfo != null) {
92
                    Map<String, String> datasourcesInvolved = mdStoreInfo.getDatasourcesInvolved();
93
                    if (datasourcesInvolved == null) {
94
                        datasourcesInvolved = Maps.newHashMap();
95
                        mdStoreInfo.setDatasourcesInvolved(datasourcesInvolved);
96
                    }
97
                    datasourcesInvolved.put("datasourceId", currentInfo.getDatasourceId());
98
                    datasourcesInvolved.put("datasourceName", currentInfo.getDatasourceName());
99

  
100
                }
101
                return mdStoreInfo;
102
            }
103
        });
104
    }
105

  
106
    @RequestMapping(value = "/ui/mdstore/reloadInfo")
107
    @ResponseBody
108
    public List<MDStoreInfo> reloadInfo(final ModelMap map) throws Exception {
109
        datasourceCache = null;
110
        return listMDStores(map);
111
    }
112

  
113
    @RequestMapping(value = "/ui/mdstore/getMdStoreInfo.do")
114
    @ResponseBody
115
    public MDStoreInfo getMdStoreInfo(final ModelMap map, @RequestParam(value = "id", required = true) final String profileId) throws Exception {
116

  
117
        final MDStoreInfo mdStoreInfo = retrieveMDStoreInfo(profileId);
118
        List<MDFormatDescription> indexFields = mdStoreUtils.getField(mdStoreInfo.getFormat(), mdStoreInfo.getLayout());
119
        List<String> idFields;
120
        if (indexFields != null) {
121
            idFields = Lists.transform(indexFields, new Function<MDFormatDescription, String>() {
122
                @Override
123
                public String apply(MDFormatDescription input) {
124
                    return input.getName();
125
                }
126
            });
127
            mdStoreInfo.setIndexFields(idFields);
128
        }
129
        return mdStoreInfo;
130
    }
131

  
132

  
133
    @RequestMapping(value = "/ui/mdstore/findRecords", method = RequestMethod.POST)
134
    @ResponseBody
135
    public MDStoreResult findRecords(final ModelMap map,
136
                                     @RequestBody final Map<String, String> queryParam) throws Exception {
137

  
138
        if (!queryParam.containsKey("mdId")) throw new MDStoreUIException("mdId parameters expected");
139

  
140
        final String mdId = queryParam.get("mdId");
141

  
142
        int offset = 0;
143

  
144
        if (queryParam.containsKey("page")) {
145
            try {
146
                offset = Integer.parseInt(queryParam.get("page"));
147
                queryParam.remove("page");
148
            } catch (Exception e) {
149
                log.error("Error on parsing page " + queryParam.get("page"));
150
            }
151
        }
152
        queryParam.remove("mdId");
153

  
154
        final ClassPathResource cpr = new ClassPathResource("/eu/dnetlib/functionality/modular/ui/xslt/gmf2document.xslt");
155
        final ApplyXslt xslt = new ApplyXslt(cpr);
156

  
157
        final MDStoreResult res = new MDStoreResult();
158
        res.setResult(Lists.transform(mdStoreService.getMDStoreRecords(mdId, 10, offset, queryParam), new Function<String, String>() {
159
            @Override
160
            public String apply(String it) {
161
                return xslt.evaluate(it);
162
            }
163
        }));
164

  
165

  
166
        //TERRIBLE HACK SHAME SANDRO SHAME!
167
        int count = 0;
168
        try {
169
            count = Integer.parseInt(queryParam.get("count"));
170
        } catch (Exception e) {
171
            log.error(e);
172
        }
173

  
174
        res.setCount(count);
175

  
176
        return res;
177
    }
178

  
179
    @RequestMapping(value = "/ui/mdstore/mdStoreResults")
180
    @ResponseBody
181
    public MDStoreResult getMDStoreResults(final ModelMap map,
182
                                           @RequestParam(value = "mdId", required = true) final String mdId,
183
                                           @RequestParam(value = "from", required = true) final int from,
184
                                           @RequestParam(value = "id_query", required = false) final String idToQuery,
185
                                           @RequestParam(value = "free_query", required = false) final String freeQuery) throws Exception {
186

  
187
        MDStoreService mdService = serviceLocator.getService(MDStoreService.class, mdId);
188
        ClassPathResource cpr = new ClassPathResource("/eu/dnetlib/functionality/modular/ui/xslt/gmf2document.xslt");
189
        ApplyXslt xslt = new ApplyXslt(cpr);
190
        MDStoreResult resultValues = new MDStoreResult();
191
        resultValues.setCount(getMdStoreInfo(map, mdId).getSize());
192

  
193
        if (idToQuery != null && !idToQuery.isEmpty()) {
194
            try {
195
                String record = mdService.deliverRecord(mdId, idToQuery);
196
                resultValues.setResult(Lists.newArrayList(xslt.evaluate(record)));
197
                return resultValues;
198
            } catch (DocumentNotFoundException e) {
199
                return null;
200
            }
201
        }
202

  
203

  
204
        W3CEndpointReference epr = mdService.deliverMDRecords(mdId, null, null, null);
205
        Iterable<String> result = resultSetClientFactory.getClient(epr);
206
        List<String> convertedList = new ArrayList<String>();
207
        Iterator<String> it = result.iterator();
208
        int currentCounter = 0;
209
        while (currentCounter < from) {
210
            if (it.hasNext()) {
211
                it.next();
212
                currentCounter++;
213
            } else {
214
                resultValues.setResult(convertedList);
215
                return resultValues;
216
            }
217
        }
218

  
219
        for (int i = 0; i < 10; i++) {
220
            if (it.hasNext()) {
221
                convertedList.add(xslt.evaluate(it.next()));
222
            } else {
223
                break;
224
            }
225
        }
226
        resultValues.setResult(convertedList);
227
        return resultValues;
228
    }
229

  
230

  
231
    private Map<String, Info> datasourceFromMdStore() {
232
        final String query = "for $x in collection('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType') where $x[.//PARAM/@category/string()='MDSTORE_ID'] " +
233
                "return concat($x//PARAM[./@name='providerId'][1]/string(), '<::>',$x//PARAM[./@name='providerName'][1]/string(), '<::>', " +
234
                "string-join($x//PARAM[./@category/string()='MDSTORE_ID']/string(), '--'))";
235
        final ISLookUpService lookupService = serviceLocator.getService(ISLookUpService.class);
236
        try {
237
            Map<String, Info> result = Maps.newHashMap();
238
            List<String> results = lookupService.quickSearchProfile(query);
239
            for (String item : results) {
240
                String[] splitted = item.split("<::>");
241
                if (splitted != null && splitted.length == 3) {
242
                    final Info currentInfo = new Info();
243
                    currentInfo.setDatasourceId(splitted[0]);
244
                    currentInfo.setDatasourceName(splitted[1]);
245
                    final String[] mdstores = splitted[2].split("--");
246
                    if (mdstores != null) {
247
                        for (String mdstore : mdstores) {
248
                            result.put(mdstore, currentInfo);
249
                        }
250
                    }
251
                }
252
            }
253
            return result;
254
        } catch (ISLookUpException e) {
255
            log.error(e);
256
            return null;
257
        }
258
    }
259

  
260
    private MDStoreInfo retrieveMDStoreInfo(final String identifier) {
261

  
262
        MDStoreInfo result = null;
263
        try {
264
            result = null;
265
            final String xquery = " for $x in collection('/db/DRIVER/MDStoreDSResources/MDStoreDSResourceType') "
266
                    + " where $x//RESOURCE_IDENTIFIER/@value/string()=\"%s\"   return concat($x//RESOURCE_URI/@value/string() "
267
                    + ", '@::@',$x//RESOURCE_IDENTIFIER/@value/string() ,'@::@',$x//METADATA_FORMAT,'(-)',$x//METADATA_FORMAT_LAYOUT,  "
268
                    + " '(-)', $x//METADATA_FORMAT_INTERPRETATION ,'@::@',$x//LAST_STORAGE_DATE,'@::@',$x//NUMBER_OF_RECORDS)";
269

  
270
            List<String> results = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(String.format(xquery, identifier));
271
            if (results != null && !results.isEmpty()) {
272
                result = MDStoreInfo.fromXqueryResult(results.get(0));
273
            }
274
        } catch (ISLookUpException e) {
275
            log.error(String.format("Error on getting information for mdstore with identifier: %s", identifier), e);
276
        }
277

  
278
        return result;
279
    }
280

  
281

  
282
    private Map<String, String> findDatasourceNameAssociatedToMdStore(final String mdStoreId) throws ISLookUpException {
283
        final String baseQuery = "for $x in collection('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType') where $x[.//PARAM/string()='%s'] return concat($x//PARAM[./@name='providerId'][1]/string(), '<::>',$x//PARAM[./@name='providerName'][1]/string())";
284
        final ISLookUpService lookupService = serviceLocator.getService(ISLookUpService.class);
285
        List<String> result = lookupService.quickSearchProfile(String.format(baseQuery, mdStoreId));
286
        Map<String, String> datasources = Maps.newHashMap();
287
        for (String item : result) {
288
            String[] splitted = item.split("<::>");
289
            if (splitted != null && splitted.length == 2) {
290
                datasources.put(splitted[0], splitted[1]);
291
            }
292
        }
293
        return datasources;
294
    }
295

  
296

  
297
    class Info {
298
        private String datasourceId;
299
        private String datasourceName;
300
        private String mdStoreId;
301

  
302

  
303
        public String getDatasourceName() {
304
            return datasourceName;
305
        }
306

  
307
        public void setDatasourceName(String datasourceName) {
308
            this.datasourceName = datasourceName;
309
        }
310

  
311
        public String getDatasourceId() {
312
            return datasourceId;
313
        }
314

  
315
        public void setDatasourceId(String datasourceId) {
316
            this.datasourceId = datasourceId;
317
        }
318

  
319
        public String getMdStoreId() {
320
            return mdStoreId;
321
        }
322

  
323
        public void setMdStoreId(String mdStoreId) {
324
            this.mdStoreId = mdStoreId;
325
        }
326
    }
327
}
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/mdstore/model/MDStoreInfo.java
1
package eu.dnetlib.functionality.modular.ui.mdstore.model;
2

  
3
import java.util.List;
4
import java.util.Map;
5

  
6
/**
7
 * The Class MDStoreInfo.
8
 */
9
public class MDStoreInfo {
10

  
11
    private static String DEFAULT_XQUERY_DELIMITER = "@::@";
12

  
13
    /**
14
     * The id.
15
     */
16
    private String id;
17

  
18
    /**
19
     * The service uri.
20
     */
21
    private String serviceURI;
22

  
23
    /**
24
     * The format.
25
     */
26
    private String format;
27

  
28
    /**
29
     * The layout.
30
     */
31
    private String layout;
32

  
33
    /**
34
     * The interpretation.
35
     */
36
    private String interpretation;
37

  
38
    /**
39
     * The last storage data.
40
     */
41
    private String lastStorageDate;
42

  
43
    private Map<String, String> datasourcesInvolved;
44

  
45
    private List<String> indexFields;
46

  
47
    /**
48
     * The size.
49
     */
50
    private int size;
51

  
52
    public static MDStoreInfo fromXqueryResult(final String result) {
53
        MDStoreInfo info = new MDStoreInfo();
54
        String values[] = result.split(DEFAULT_XQUERY_DELIMITER);
55
        if (values == null || values.length != 5) {
56
            return null;
57
        }
58
        info.setServiceURI(values[0]);
59
        info.setId(values[1]);
60
        String mdFormat[] = values[2].split("\\(-\\)");
61
        if (mdFormat == null || mdFormat.length != 3) {
62
            return null;
63
        }
64
        info.setFormat(mdFormat[0]);
65
        info.setLayout(mdFormat[1]);
66
        info.setInterpretation(mdFormat[2]);
67
        info.setLastStorageDate(values[3]);
68
        info.setSize(new Integer(values[4]));
69
        return info;
70
    }
71

  
72
    /**
73
     * Gets the id.
74
     *
75
     * @return the id
76
     */
77
    public String getId() {
78
        return id;
79
    }
80

  
81
    /**
82
     * Sets the id.
83
     *
84
     * @param id the new id
85
     */
86
    public void setId(final String id) {
87
        this.id = id;
88
    }
89

  
90
    /**
91
     * Gets the service uri.
92
     *
93
     * @return the service uri
94
     */
95
    public String getServiceURI() {
96
        return serviceURI;
97
    }
98

  
99
    /**
100
     * Sets the service uri.
101
     *
102
     * @param serviceURI the new service uri
103
     */
104
    public void setServiceURI(final String serviceURI) {
105
        this.serviceURI = serviceURI;
106
    }
107

  
108
    /**
109
     * Gets the format.
110
     *
111
     * @return the format
112
     */
113
    public String getFormat() {
114
        return format;
115
    }
116

  
117
    /**
118
     * Sets the format.
119
     *
120
     * @param format the new format
121
     */
122
    public void setFormat(final String format) {
123
        this.format = format;
124
    }
125

  
126
    /**
127
     * Gets the layout.
128
     *
129
     * @return the layout
130
     */
131
    public String getLayout() {
132
        return layout;
133
    }
134

  
135
    /**
136
     * Sets the layout.
137
     *
138
     * @param layout the new layout
139
     */
140
    public void setLayout(final String layout) {
141
        this.layout = layout;
142
    }
143

  
144
    /**
145
     * Gets the interpretation.
146
     *
147
     * @return the interpretation
148
     */
149
    public String getInterpretation() {
150
        return interpretation;
151
    }
152

  
153
    /**
154
     * Sets the interpretation.
155
     *
156
     * @param interpretation the new interpretation
157
     */
158
    public void setInterpretation(final String interpretation) {
159
        this.interpretation = interpretation;
160
    }
161

  
162
    /**
163
     * Gets the last storage data.
164
     *
165
     * @return the last storage data
166
     */
167
    public String getLastStorageDate() {
168
        return lastStorageDate;
169
    }
170

  
171
    /**
172
     * Sets the last storage data.
173
     *
174
     * @param lastStorageData the new last storage data
175
     */
176
    public void setLastStorageDate(final String lastStorageDate) {
177
        this.lastStorageDate = lastStorageDate;
178
    }
179

  
180
    /**
181
     * Gets the size.
182
     *
183
     * @return the size
184
     */
185
    public int getSize() {
186
        return size;
187
    }
188

  
189
    /**
190
     * Sets the size.
191
     *
192
     * @param size the new size
193
     */
194
    public void setSize(final int size) {
195
        this.size = size;
196
    }
197

  
198
    public Map<String, String> getDatasourcesInvolved() {
199
        return datasourcesInvolved;
200
    }
201

  
202
    public void setDatasourcesInvolved(Map<String, String> datasourcesInvolved) {
203
        this.datasourcesInvolved = datasourcesInvolved;
204
    }
205

  
206
    public List<String> getIndexFields() {
207
        return indexFields;
208
    }
209

  
210
    public void setIndexFields(List<String> indexFields) {
211
        this.indexFields = indexFields;
212
    }
213
}
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/mdstore/model/MDStoreResult.java
1
package eu.dnetlib.functionality.modular.ui.mdstore.model;
2

  
3
import java.util.List;
4

  
5
/**
6
 * Created by sandro on 12/2/16.
7
 */
8
public class MDStoreResult {
9

  
10
    private int count;
11

  
12
    private List<String> result;
13

  
14
    public MDStoreResult() {
15

  
16
    }
17

  
18
    public MDStoreResult(int count, List<String> result) {
19
        this.count = count;
20
        this.result = result;
21
    }
22

  
23
    public int getCount() {
24
        return count;
25
    }
26

  
27
    public void setCount(int count) {
28
        this.count = count;
29
    }
30

  
31
    public List<String> getResult() {
32
        return result;
33
    }
34

  
35
    public void setResult(List<String> result) {
36
        this.result = result;
37
    }
38
}
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/mdstore/MDStoreUIException.java
1
package eu.dnetlib.functionality.modular.ui.mdstore;
2

  
3
/**
4
 * Created by sandro on 12/1/16.
5
 */
6
public class MDStoreUIException extends Exception {
7

  
8
    public MDStoreUIException() {
9

  
10
    }
11

  
12
    public MDStoreUIException(String message) {
13
        super(message);
14
    }
15

  
16
    public MDStoreUIException(Throwable e) {
17
        super(e);
18
    }
19

  
20
}
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/mdstore/MDStoreServiceEntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.mdstore;
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 MDStoreServiceEntryPointController extends ModuleEntryPoint {
13

  
14
	/** The lookup locator. */
15
	@Resource
16
	private UniqueServiceLocator serviceLocator;
17

  
18
	@Override
19
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
20

  
21
	}
22

  
23
}
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-mdstore.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
4
	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
5
	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
6
	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
7
	xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
8
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
9
						http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
10
						http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
11
						http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
12
						http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
13
						http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd
14
						http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
15
						http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
16

  
17

  
18
	<bean name="/ui/mdstoreInspector.do"
19
		class="eu.dnetlib.functionality.modular.ui.mdstore.MDStoreServiceEntryPointController"
20
		p:menu="MDStore Service Inspector" 
21
		p:title="MDStore Service Inspector"
22
		p:description="MDStore Service Inspector"
23
		p:order="4" 
24
		p:group="Tools">
25
		<property name="permissionLevels">
26
			<set>
27
				<value>IS_ADMIN</value>
28
			</set>
29
		</property>
30
	</bean>
31

  
32
</beans>
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/resources/eu/dnetlib/functionality/modular/ui/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" xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
	xmlns:fn="http://www.w3.org/2005/xpath-functions">
6

  
7
	<xsl:output method="html" encoding="UTF-8" indent="yes"
8
		omit-xml-declaration="yes" />
9

  
10
	<xsl:template match="/">
11
		<p
12
			style="color:black; font-family:'Courier New', Courier, monospace; font-size:small">
13
			<xsl:call-template name="xmlItem">
14

  
15
				<xsl:with-param name="indent" select="string('')" />
16
			</xsl:call-template>
17
		</p>
18
	</xsl:template>
19

  
20

  
21
	<xsl:template name="xmlAttr">
22
		<span style='color:blue'>
23
			<xsl:value-of select="concat(' ', local-name())" />
24
		</span>
25
		<span style='color:red'>
26
		<xsl:value-of select="concat('=&quot;', ., '&quot;')" />
27
		</span>
28

  
29
	</xsl:template>
30

  
31
	<xsl:template name="xmlItem">
32
		<xsl:param name="indent" />
33

  
34
		<xsl:variable name="tag" select="local-name()" />
35

  
36
		<xsl:variable name="newindent">
37
			<xsl:value-of select="$indent" />
38
			&#160;
39
		</xsl:variable>
40

  
41
		<xsl:value-of select="$indent" />
42

  
43
		<xsl:choose>
44
			<xsl:when test="string-length($tag) &gt; 0">
45
				<span style='color:darkblue'>
46
					<xsl:value-of select="concat('&lt;',$tag)" />
47
					<xsl:for-each select="@*">
48
						<xsl:call-template name="xmlAttr" />
49
					</xsl:for-each>
50

  
51
					<span style='color:blue'>&gt;</span>
52
				</span>
53
			</xsl:when>
54
		</xsl:choose>
55

  
56

  
57
		<!-- <xsl:value-of select="$attribs" /> -->
58

  
59

  
60
		<xsl:value-of select="text()" />
61

  
62
		<xsl:choose>
63
			<xsl:when test="count(child::*) &gt; 0">
64
				<br />
65
				<xsl:for-each select="child::*">
66
					<xsl:call-template name="xmlItem">
67
						<xsl:with-param name="indent" select="$newindent" />
68
					</xsl:call-template>
69
					<br />
70
				</xsl:for-each>
71
				<xsl:value-of select="$indent" />
72
			</xsl:when>
73
			<xsl:otherwise>
74

  
75
			</xsl:otherwise>
76
		</xsl:choose>
77

  
78
		<xsl:choose>
79
			<xsl:when test="string-length($tag) &gt; 0">
80
				<span style='color:blue'>
81
					<xsl:value-of select="concat('&lt;/',$tag,'&gt;')" />
82
				</span>
83
			</xsl:when>
84
		</xsl:choose>
85

  
86

  
87

  
88
	</xsl:template>
89

  
90
</xsl:stylesheet>
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/mdstoreInspector.st
1
$common/master( header={
2
	<script type="text/javascript" src="../resources/js/angular.min.js" ></script>
3
	<script type="text/javascript" src="../resources/js/angular-route.min.js"></script>
4
	<script type="text/javascript" src="../resources/js/angular-local-storage.min.js"></script>
5
	<script type="text/javascript" src="../resources/js/ng-grid-2.0.7.min.js"></script>
6
	<script type="text/javascript" src="../resources/js/mdstore_inspector_controllers.js"></script>
7
	<script type="text/javascript" src="../resources/js/mdstore_inspector.js"></script>
8
	<link rel="stylesheet" type="text/css" href="../resources/css/ng-grid.min.css" />
9
}, body={
10
	<div ng-app="indexInspector" class="row">
11
	<!--
12
		<div class="col-sm-3 col-lg-2" ng-controller="moduleMenuCtrl">
13
			<ul class="nav nav-pills nav-stacked">
14
				<li ng-class="{active : isActive('^\/q')}"><a href="#/list">MdStores</a></li>
15
				<li ng-class="{active : isActive('^\/q')}"><a href="#/list">MdStores</a></li>								
16
			</ul>
17
		</div>
18
	--> 
19
		<div ng-view class="col-xs-9"></div>
20
	</div>
21
} )$
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/resources/eu/dnetlib/web/resources/html/mdstore/inspect.html
1
<div class="container">
2
    <div class="row">
3
        <div class="col-md-12">
4
            <h2>Inspect MdStore <a href="#/list" class="btn btn-primary btn-sm"><span
5
                    class="glyphicon glyphicon-step-backward"></span>
6
                Back</a></h2>
7

  
8

  
9
            <div class="panel panel-default">
10
                <div class="panel-heading">
11
                    <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_format">
12
                        <b>MdStore Info</b>
13
                    </a>
14
                </div>
15
                <div id="collapse_format" class="panel-collapse collapse in">
16
                    <div class="panel-body">
17
                        <table cellpadding="10">
18
                            <tr>
19
                                <td align="right">
20
                                    <b>Id: </b>
21
                                </td>
22
                                <td>
23
                                    <i style=" padding-left:10px">{{mdStoreInfo.id}}</i>
24
                                </td>
25
                                <td style=" padding-left:10px">
26
                                    <a style=" padding-left:10px" href="isManager.do#/profile/{{mdStoreInfo.id}}"
27
                                       class="btn btn-primary btn-sm">
28
                                        <span class="glyphicon glyphicon-search"></span>
29
                                        View Profile
30
                                    </a>
31
                                </td>
32
                                <td style=" padding-left:10px">
33
                                    <a href="" class="btn btn-primary btn-sm" ng-click="loadInfo()"><span
34
                                            class="glyphicon glyphicon-refresh"></span> Refresh Info</a>
35
                                </td>
36
                            </tr>
37
                            <tr>
38
                                <td align="right">
39
                                    <b>format: </b>
40
                                </td>
41
                                <td>
42
                                    <i style=" padding-left:10px">{{mdStoreInfo.format}}</i>
43
                                </td>
44
                                <td></td>
45
                            </tr>
46
                            <tr>
47
                                <td align="right">
48
                                    <b>layout: </b>
49
                                </td>
50
                                <td>
51
                                    <i style=" padding-left:10px">{{mdStoreInfo.layout}}</i>
52
                                </td>
53
                                <td></td>
54
                            </tr>
55
                            <tr>
56
                                <td align="right">
57
                                    <b>interpretation: </b>
58
                                </td>
59
                                <td>
60
                                    <i style=" padding-left:10px">{{mdStoreInfo.interpretation}}</i>
61
                                </td>
62
                                <td></td>
63
                            </tr>
64
                            <tr>
65
                                <td align="right">
66
                                    <b>last storage date: </b>
67
                                </td>
68
                                <td>
69
                                    <i style=" padding-left:10px">{{mdStoreInfo.lastStorageDate}}</i>
70
                                </td>
71
                                <td></td>
72
                            </tr>
73
                            <tr>
74
                                <td align="right">
75
                                    <b>Number of Elements: </b>
76
                                </td>
77
                                <td>
78
                                    <i style=" padding-left:10px">{{mdStoreInfo.size}}</i>
79
                                </td>
80
                                <td></td>
81
                            </tr>
82
                            <tr>
83
                                <td align="right">
84
                                    <b>Service URI: </b>
85
                                </td>
86
                                <td>
87
                                    <i style=" padding-left:10px">
88
                                        <a href="{{mdStoreInfo.serviceURI}}">{{mdStoreInfo.serviceURI}}</a>
89
                                    </i>
90
                                </td>
91
                                <td></td>
92
                            </tr>
93

  
94
                        </table>
95

  
96
                    </div>
97
                </div>
98
            </div>
99
        </div>
100
    </div>
101

  
102

  
103
    <div class="row">
104
        <div class="col-md-12">
105

  
106
            <div class="panel panel-default">
107
                <div class="panel-heading">
108
                    <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_query">
109
                        <b>MdStore Query</b>
110
                    </a>
111
                </div>
112
                <div id="collapse_query" class="panel-collapse collapse in">
113
                    <div class="panel-body">
114
                        <table cellpadding="10">
115
                            <tr>
116
                                <td align="right" style="width:10%">
117
                                    <b>Id: </b>
118
                                </td>
119
                                <td style=" padding-left:10px; width:90%">
120
                                    <input type="text" class="form-control" ng-model="queryValues['id']"
121
                                           placeholder="Enter an identifier to search (fast)">
122
                                </td>
123
                            </tr>
124
                            <tr>
125
                                <td align="right">
126
                                    <b>Free search: </b>
127
                                </td>
128
                                <td style=" padding-left:10px">
129
                                    <input type="text" class="form-control" ng-model="queryValues['body']"
130
                                           placeholder="Enter a free text to search (slow)">
131
                                </td>
132
                            </tr>
133

  
134
                            <tr ng-repeat="item in mdStoreInfo.indexFields">
135
                                <td align="right">
136
                                    <b>{{item}}: </b>
137
                                </td>
138
                                <td style=" padding-left:10px">
139
                                    <input type="text" class="form-control" ng-model="queryValues[item]"
140
                                           placeholder="Search for {{item}} (fast)">
141
                                </td>
142
                            </tr>
143
                            <tr>
144
                                <td></td>
145
                                <td></td>
146
                                <td align="center">
147
                                    <a style=" padding-left:10px" href=""
148
                                       class="btn btn-primary btn-lg" ng-click=startSearch()>
149
                                        <span class="glyphicon glyphicon-search"></span>
150
                                        Search
151
                                    </a>
152
                                </td>
153
                            </tr>
154

  
155

  
156
                        </table>
157

  
158
                    </div>
159
                </div>
160
            </div>
161
        </div>
162
    </div>
163

  
164
    <div class="row">
165
        <div class="col-md-12 ">
166
            <h3>Number of results: {{searchResult.total}}</h3>
167
        </div>
168
    </div>
169
    <div class="row">
170
        <div class="col-md-2 text-left">
171
            results from {{from_page + 1 }} to {{to_page}}
172
        </div>
173
        <div class="col-md-9 text-center">
174
            <ul class="pagination">
175
                <li>
176
                    <a href="" ng-click="prevPage()">&laquo;
177
                    </a>
178
                </li>
179
                <li>
180
                    <a href="" ng-click="nextPage()">&raquo;
181
                    </a>
182
                </li>
183
            </ul>
184
        </div>
185
    </div>
186

  
187
    <div class="row" ng-repeat="item in searchResult.records">
188
        <div class="col-md-12">
189
            <div class="panel panel-default">
190
                <div class="panel-heading">
191
                    <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_{{$index}}">
192
                        <b>{{$index+1 + from_page}}</b>
193
                    </a>
194
                </div>
195
                <div id="collapse_{{$index}}" class="panel-collapse collapse in">
196
                    <div class="panel-body">
197
                        <div ng-bind-html="to_trusted(item)" compile-template></div>
198
                    </div>
199

  
200

  
201
                </div>
202
            </div>
203
        </div>
204
    </div>
205

  
206

  
207
</div>
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/resources/eu/dnetlib/web/resources/html/mdstore/list.html
1
<style>
2
    .gridStyle {
3
        width: 100%;
4
        height: 150px;
5
        margin-bottom: 20px;
6
        margin-top: 20px;
7
        font-size: 11px;
8
    }
9

  
10
    .gridStyle-big {
11
        width: 100%;
12
        height: 300px;
13
        margin-top: 20px;
14
        margin-bottom: 20px;
15
        font-size: 11px;
16
    }
17
</style>
18
<div class="row">
19
    <div class="col-md-12">
20
        <a href="" ng-click="refreshInfo()" class="btn btn-primary btn-sm"><span
21
                class="glyphicon glyphicon-refresh"></span>
22
            Refresh</a>
23
    </div>
24
    <div class="col-md-12">
25
        Search MdStore: <input type="text" size="100"/>
26
        <a href="#" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-search"></span> Search</a>
27
    </div>
28

  
29

  
30
    <div class="col-md-12" style="height: 100%">
31
        <div class="gridStyle" id="gridMdstores" ng-grid="gridOptions"></div>
32
    </div>
33
</div>
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.0/src/main/resources/eu/dnetlib/web/resources/js/mdstore_inspector_controllers.js
1
var mdstoreInspectorControllers = angular.module('mdstoreInspectorControllers', ['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
function ngGridFlexibleHeightPlugin(opts) {
29
    var self = this;
30
    self.grid = null;
31
    self.scope = null;
32
    self.init = function (scope, grid, services) {
33
        self.domUtilityService = services.DomUtilityService;
34
        self.grid = grid;
35
        self.scope = scope;
36
        var recalcHeightForData = function () {
37
            setTimeout(innerRecalcForData, 1);
38
        };
39
        var innerRecalcForData = function () {
40
            var gridId = self.grid.gridId;
41
            var footerPanelSel = '.' + gridId + ' .ngFooterPanel';
42
            var extraHeight = self.grid.$topPanel.height() + $(footerPanelSel).height();
43
            var naturalHeight = self.grid.$canvas.height() + 1;
44
            if (opts != null) {
45
                if (opts.minHeight != null && (naturalHeight + extraHeight) < opts.minHeight) {
46
                    naturalHeight = opts.minHeight - extraHeight - 2;
47
                }
48
                if (opts.maxHeight != null && (naturalHeight + extraHeight) > opts.maxHeight) {
49
                    naturalHeight = opts.maxHeight;
50
                }
51
            }
52

  
53
            var newViewportHeight = naturalHeight + 3;
54
            if (!self.scope.baseViewportHeight || self.scope.baseViewportHeight !== newViewportHeight) {
55
                self.grid.$viewport.css('height', newViewportHeight + 'px');
56
                self.grid.$root.css('height', (newViewportHeight + extraHeight) + 'px');
57
                self.scope.baseViewportHeight = newViewportHeight;
58
                self.domUtilityService.RebuildGrid(self.scope, self.grid);
59
            }
60
        };
61
        self.scope.catHashKeys = function () {
62
            var hash = '',
63
                idx;
64
            for (idx in self.scope.renderedRows) {
65
                hash += self.scope.renderedRows[idx].$$hashKey;
66
            }
67
            return hash;
68
        };
69
        self.scope.$watch('catHashKeys()', innerRecalcForData);
70
        self.scope.$watch(self.grid.config.data, recalcHeightForData);
71
    };
72
}
73

  
74
mdstoreInspectorControllers.directive('compileTemplate', function ($compile, $parse) {
75
    return {
76
        link: function (scope, element, attr) {
77
            var parsed = $parse(attr.ngBindHtml);
78

  
79
            function getStringValue() {
80
                return (parsed(scope) || '').toString();
81
            }
82

  
83
            //Recompile if the template changes
84
            scope.$watch(getStringValue, function () {
85
                $compile(element, null, -9999)(scope);  //The -9999 makes it skip directives so that we do not recompile ourselves
86
            });
87
        }
88
    }
89
});
90

  
91
function hasOwnProperty(obj, prop) {
92
    var proto = obj.__proto__ || obj.constructor.prototype;
93
    return (prop in obj) &&
94
        (!(prop in proto) || proto[prop] !== obj[prop]);
95
}
96

  
97

  
98
mdstoreInspectorControllers.controller('inspectMdstoresController', [
99
    '$scope', '$http', '$sce', '$location', '$routeParams',
100
    function ($scope, $http, $sce, $location, $routeParams) {
101
        common_init($scope, $http, $sce, $location);
102

  
103
        $scope.mdId = $routeParams.id;
104
        $scope.from_page = 0;
105
        $scope.to_page = 0;
106
        $scope.queryValues = {}
107

  
108

  
109

  
110
        $scope.loadInfo = function () {
111
            $scope.showSpinner();
112
            $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
113
            $http.post('mdstore/getMdStoreInfo.do', $.param({
114
                'id': $routeParams.id
115
            })).success(function (data) {
116
                $scope.hideSpinner();
117
                $scope.mdStoreInfo = data;
118
                if (hasOwnProperty($scope, 'searchResult') == false) {
119
                    $scope.searchResult = {}
120
                }
121
                $scope.queryValues = {"body": "", "id": ""};
122
                if (hasOwnProperty(data, 'indexFields') != false) {
123
                    for (var i = 0; i < data['indexFields'].length; i++) {
124
                        $scope.queryValues[data['indexFields'][i]] = "";
125
                    }
126
                }
127
                $scope.searchResult.total = data.size;
128
            }).error(function () {
129
                $scope.showError('Error getting info from mdstore');
130
                $scope.hideSpinner();
131
            });
132
            $scope.hideSpinner();
133
        }
134

  
135
        $scope.findIndexFields = function (indexField) {
136
            $scope.showSpinner();
137
            if ($scope.query == null) {
138
                if ($scope.searchResult != null)
139
                    $scope.searchResult.total = $scope.mdStoreInfo.size
140
            }
141
            $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
142
            $http.post('mdstore/findByIndexField', $.param({
143
                'mdId': $routeParams.id, 'from': $scope.from_page, 'query': $scope.query,
144
                'indexField': indexField
145
            })).success(function (data) {
146
                $scope.hideSpinner();
147
                $scope.searchResult.records = data;
148
                $scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
149
            }).error(function () {
150
                $scope.showError('Error getting info from mdstore');
151
                $scope.hideSpinner();
152
            });
153

  
154
        }
155

  
156
        $scope.getResults = function () {
157
            $scope.showSpinner();
158
            $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
159
            if ($scope.query == null) {
160
                if ($scope.searchResult != null)
161
                    $scope.searchResult.total = $scope.mdStoreInfo.size
162
            }
163
            $http.post('mdstore/mdStoreResults', $.param({
164
                'mdId': $routeParams.id, 'from': $scope.from_page
165
            })).success(function (data) {
166
                $scope.hideSpinner();
167
                $scope.searchResult.records = data.result;
168
                $scope.searchResult.total = data.count;
169
                $scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
170
            }).error(function () {
171
                $scope.showError('Error getting info from mdstore');
172
                $scope.hideSpinner();
173
            });
174
        };
175

  
176

  
177
        $scope.startSearch = function () {
178
            $scope.from_page = 0;
179
            return $scope.searchByQuery()
180
        }
181

  
182
        $scope.searchByQuery = function () {
183
            $scope.showSpinner();
184
            if ($scope.query == null) {
185
                if ($scope.searchResult != null)
186
                    $scope.searchResult.total = $scope.mdStoreInfo.size
187
            }
188
            var query = {};
189
            var setValue;
190
            for (var key in $scope.queryValues) {
191
                if ($scope.queryValues[key].length > 0) {
192
                    query[key] = $scope.queryValues[key];
193
                    setValue = true;
194
                }
195
            }
196
            if (setValue == false)
197
                return $scope.getResults();
198
            query["mdId"] = $routeParams.id;
199
            query["page"] = $scope.from_page;
200
            $http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
201
            $http.post('mdstore/findRecords', query)
202
                .success(function (data) {
203
                    $scope.hideSpinner();
204
                    $scope.searchResult.records = data.result;
205
                    $scope.searchResult.total = data.count;
206
                    $scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
207
                }).error(function () {
208
                $scope.showError('Error getting info from mdstore');
209
                $scope.hideSpinner();
210
            });
211
        };
212

  
213
        $scope.getRecordById = function () {
214

  
215
            if (($scope.record_id != null) && ($scope.record_id.length > 0)) {
216
                $scope.showSpinner();
217
            }
218

  
219
            $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
220
            $http.post('mdstore/mdStoreResults', $.param({
221
                'mdId': $routeParams.id, 'from': $scope.from_page, 'id_query': $scope.record_id
222
            })).success(function (data) {
223
                $scope.hideSpinner();
224
                $scope.searchResult.records = data.records.result;
225
                $scope.searchResult.total = data.records.total;
226
                $scope.to_page = 0
227
                if (data == null) {
228
                    $scope.to_page = 0
229
                    $scope.searchResult.total = 0
230
                }
231
                else {
232
                    $scope.to_page = data.length
233
                    $scope.searchResult.total = data.length
234
                }
235

  
236
            }).error(function () {
237
                $scope.showError('Error getting info from mdstore');
238
                $scope.hideSpinner();
239
            });
240
        };
241

  
242
        $scope.nextPage = function () {
243
            if ($scope.from_page < $scope.searchResult.total - 10) {
244
                $scope.from_page = $scope.from_page + 10;
245
                $scope.searchByQuery();
246
                $scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
247
            }
248

  
249
        };
250

  
251
        $scope.prevPage = function () {
252
            if ($scope.from_page + 10 > 10) {
253
                $scope.from_page = $scope.from_page - 10;
254
                $scope.searchByQuery();
255
                $scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
256
            }
257

  
258
        }
259

  
260
        $scope.loadInfo();
261

  
262
        $scope.getResults();
263
    }]);
264

  
265

  
266
mdstoreInspectorControllers.controller('mdstoresController', [
267
    '$scope', '$http', '$sce', '$location',
268
    function ($scope, $http, $sce, $location) {
269
        common_init($scope, $http, $sce, $location);
270
        $scope.showSpinner();
271
        $http.get('mdstore/listMDStores.do').success(function (data) {
272
            $scope.hideSpinner();
273
            $scope.mdTable = data;
274
        }).error(function () {
275
            $scope.showError('Error listing xmldb collections');
276
            $scope.hideSpinner();
277
        });
278

  
279
        $scope.refreshInfo = function () {
280

  
281
            $scope.showSpinner();
282
            $http.get('mdstore/reloadInfo').success(function (data) {
283
                $scope.hideSpinner();
284
                $scope.mdTable = data;
285
            }).error(function () {
286
                $scope.showError('Error listing xmldb collections');
287
                $scope.hideSpinner();
288
            });
289

  
290
        }
291

  
292
        $scope.gridOptions = {
293
            data: 'mdTable',
294
            enableRowSelection: false,
295
            enableCellEditOnFocus: false,
296
            enableHighlighting: true,
297
            plugins: [new ngGridFlexibleHeightPlugin()],
298

  
299
            columnDefs: [
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff