Project

General

Profile

« Previous | Next » 

Revision 54510

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

View differences:

modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.1/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="FacetManager">
4
    <facet type="Spring" name="Spring">
5
      <configuration />
6
    </facet>
7
  </component>
8
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
9
    <output url="file://$MODULE_DIR$/target/classes" />
10
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
11
    <content url="file://$MODULE_DIR$">
12
      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
13
      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
14
      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
15
      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
16
      <excludeFolder url="file://$MODULE_DIR$/target" />
17
    </content>
18
    <orderEntry type="inheritedJdk" />
19
    <orderEntry type="sourceFolder" forTests="false" />
20
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-resultset-client:2.1.6" level="project" />
21
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-resultset-service:2.0.3" level="project" />
22
    <orderEntry type="library" name="Maven: com.google.guava:guava:23.3-jre" level="project" />
23
    <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
24
    <orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" level="project" />
25
    <orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
26
    <orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
27
    <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.2.5.RELEASE" level="project" />
28
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-spring-utils:1.0.2" level="project" />
29
    <orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
30
    <orderEntry type="library" name="Maven: jparsec:jparsec:2.0" level="project" />
31
    <orderEntry type="library" name="Maven: runcc:runcc:0.7" level="project" />
32
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-transports-http:3.1.5" level="project" />
33
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-core:3.1.5" level="project" />
34
    <orderEntry type="library" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.4.1" level="project" />
35
    <orderEntry type="library" name="Maven: org.codehaus.woodstox:stax2-api:3.1.4" level="project" />
36
    <orderEntry type="library" name="Maven: org.apache.ws.xmlschema:xmlschema-core:2.2.1" level="project" />
37
    <orderEntry type="library" name="Maven: eu.dnetlib:dnet-modular-ui:3.0.14" level="project" />
38
    <orderEntry type="library" name="Maven: org.springframework:spring-web:4.2.5.RELEASE" level="project" />
39
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.2.5.RELEASE" level="project" />
40
    <orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
41
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.2.5.RELEASE" level="project" />
42
    <orderEntry type="library" name="Maven: org.springframework:spring-context:4.2.5.RELEASE" level="project" />
43
    <orderEntry type="library" name="Maven: org.springframework:spring-core:4.2.5.RELEASE" level="project" />
44
    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
45
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.2.5.RELEASE" level="project" />
46
    <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.2.5.RELEASE" level="project" />
47
    <orderEntry type="library" name="Maven: eu.dnetlib:dnet-runtime:1.0.1" level="project" />
48
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-soap:3.1.5" level="project" />
49
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-wsdl:3.1.5" level="project" />
50
    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.3" level="project" />
51
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-databinding-jaxb:3.1.5" level="project" />
52
    <orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.2.11" level="project" />
53
    <orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.2.11" level="project" />
54
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-jaxws:3.1.5" level="project" />
55
    <orderEntry type="library" name="Maven: xml-resolver:xml-resolver:1.2" level="project" />
56
    <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
57
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-xml:3.1.5" level="project" />
58
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-simple:3.1.5" level="project" />
59
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-addr:3.1.5" level="project" />
60
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-policy:3.1.5" level="project" />
61
    <orderEntry type="library" name="Maven: org.apache.neethi:neethi:3.0.3" level="project" />
62
    <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
63
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-service-common:2.1.7" level="project" />
64
    <orderEntry type="library" name="Maven: org.antlr:stringtemplate:3.2" level="project" />
65
    <orderEntry type="library" name="Maven: org.antlr:antlr:2.7.7" level="project" />
66
    <orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.2.2" level="project" />
67
    <orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.1" level="project" />
68
    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
69
    <orderEntry type="library" name="Maven: org.springframework:spring-tx:4.2.5.RELEASE" level="project" />
70
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-service-utils:1.0.2" level="project" />
71
    <orderEntry type="library" name="Maven: apache:oro:2.0.8" level="project" />
72
    <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.2" level="project" />
73
    <orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.4.2" level="project" />
74
    <orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.9.13" level="project" />
75
    <orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-core-asl:1.9.13" level="project" />
76
    <orderEntry type="library" name="Maven: org.apache.maven:maven-model:3.2.3" level="project" />
77
    <orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-utils:3.0.17" level="project" />
78
    <orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
79
    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.9" level="project" />
80
    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
81
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-modular-mdstore-service:6.0.3" level="project" />
82
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-rmi-api:2.6.1" level="project" />
83
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-blackboard-common:2.2.2" level="project" />
84
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-notifications-common:2.1.1" level="project" />
85
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-misc-utils:1.0.5" level="project" />
86
    <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
87
    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
88
    <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
89
    <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
90
    <orderEntry type="library" name="Maven: jaxen:jaxen:1.1.6" level="project" />
91
    <orderEntry type="library" name="Maven: saxonica:saxon:9.1.0.8" level="project" />
92
    <orderEntry type="library" name="Maven: saxonica:saxon-dom:9.1.0.8" level="project" />
93
    <orderEntry type="library" name="Maven: jgrapht:jgrapht:0.7.2" level="project" />
94
    <orderEntry type="library" name="Maven: net.sf.ehcache:ehcache:2.8.0" level="project" />
95
    <orderEntry type="library" name="Maven: org.springframework:spring-test:4.2.5.RELEASE" level="project" />
96
    <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
97
  </component>
98
</module>
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.1/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.1/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.1/src/main/java/eu/dnetlib/functionality/modular/ui/mdstore/MDStoreServiceInternalController.java
1
package eu.dnetlib.functionality.modular.ui.mdstore;
2

  
3
import java.util.ArrayList;
4
import java.util.Iterator;
5
import java.util.List;
6
import java.util.Map;
7
import java.util.stream.Collectors;
8
import javax.annotation.Resource;
9
import javax.xml.ws.wsaddressing.W3CEndpointReference;
10

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

  
35
/**
36
 * The Class MDStoreServiceInternalController.
37
 */
38
@Controller
39
public class MDStoreServiceInternalController {
40

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

  
46
    @Value("${dnet.modular.ui.mdstore.xslt.record2document}")
47
    private String recordXsltClasspath;
48

  
49
    /**
50
     * The lookup locator.
51
     */
52
    @Resource
53
    private UniqueServiceLocator serviceLocator;
54

  
55
    @Autowired
56
    private MDStoreUtils mdStoreUtils;
57

  
58
    @Resource
59
    private ResultSetClientFactory resultSetClientFactory;
60

  
61
    @Autowired
62
    private ModularMDStoreService mdStoreService;
63

  
64

  
65
    private Map<String, Info> datasourceCache;
66

  
67
    /**
68
     * List md stores.
69
     *
70
     * @param map the map
71
     * @return the list
72
     * @throws Exception the exception
73
     */
74
    @RequestMapping(value = "/ui/mdstore/listMDStores.do")
75
    @ResponseBody
76

  
77
    public List<MDStoreInfo> listMDStores(final ModelMap map) throws Exception {
78
        if (datasourceCache == null) {
79
            datasourceCache = datasourceFromMdStore();
80
        }
81

  
82

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

  
89
        log.debug("Executing lookup query" + xquery);
90
        return Lists.transform(serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery), input -> {
91
            MDStoreInfo mdStoreInfo = MDStoreInfo.fromXqueryResult(input);
92
            Info currentInfo = datasourceCache.get(mdStoreInfo.getId());
93
            if (currentInfo != null) {
94
                Map<String, String> datasourcesInvolved = mdStoreInfo.getDatasourcesInvolved();
95
                if (datasourcesInvolved == null) {
96
                    datasourcesInvolved = Maps.newHashMap();
97
                    mdStoreInfo.setDatasourcesInvolved(datasourcesInvolved);
98
                }
99
                datasourcesInvolved.put("datasourceId", currentInfo.getDatasourceId());
100
                datasourcesInvolved.put("datasourceName", currentInfo.getDatasourceName());
101

  
102
            }
103
            return mdStoreInfo;
104
        });
105
    }
106

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

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

  
118
        final MDStoreInfo mdStoreInfo = retrieveMDStoreInfo(profileId);
119
        List<MDFormatDescription> indexFields = mdStoreUtils.getField(mdStoreInfo.getFormat(), mdStoreInfo.getLayout());
120
        List<String> idFields;
121
        if (indexFields != null) {
122
            idFields = indexFields.stream().map(MDFormatDescription::getName).collect(Collectors.toList());
123
            mdStoreInfo.setIndexFields(idFields);
124
        }
125
        return mdStoreInfo;
126
    }
127

  
128

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

  
134
        if (!queryParam.containsKey("mdId")) throw new MDStoreUIException("mdId parameters expected");
135

  
136
        final String mdId = queryParam.get("mdId");
137

  
138
        int offset = 0;
139

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

  
150
        final MDStoreResult res = new MDStoreResult();
151
        ClassPathResource cpr = new ClassPathResource(recordXsltClasspath);
152
        ApplyXslt xslt = new ApplyXslt(cpr);
153
        res.setResult(mdStoreService.getMDStoreRecords(mdId, 10, offset, queryParam).stream().map(xslt::evaluate).collect(Collectors.toList()));
154

  
155

  
156
        //TERRIBLE HACK SHAME SANDRO SHAME!
157
        int count = 0;
158
        try {
159
            count = Integer.parseInt(queryParam.get("count"));
160
        } catch (Exception e) {
161
            log.error(e);
162
        }
163

  
164
        res.setCount(count);
165

  
166
        return res;
167
    }
168

  
169
    @RequestMapping(value = "/ui/mdstore/mdStoreResults")
170
    @ResponseBody
171
    public MDStoreResult getMDStoreResults(final ModelMap map,
172
                                           @RequestParam(value = "mdId", required = true) final String mdId,
173
                                           @RequestParam(value = "from", required = true) final int from,
174
                                           @RequestParam(value = "id_query", required = false) final String idToQuery,
175
                                           @RequestParam(value = "free_query", required = false) final String freeQuery) throws Exception {
176

  
177
        MDStoreService mdService = serviceLocator.getService(MDStoreService.class, mdId);
178
        ClassPathResource cpr = new ClassPathResource(recordXsltClasspath);
179
        ApplyXslt xslt = new ApplyXslt(cpr);
180
        MDStoreResult resultValues = new MDStoreResult();
181
        resultValues.setCount(getMdStoreInfo(map, mdId).getSize());
182

  
183
        if (idToQuery != null && !idToQuery.isEmpty()) {
184
            try {
185
                String record = mdService.deliverRecord(mdId, idToQuery);
186
                resultValues.setResult(Lists.newArrayList(xslt.evaluate(record)));
187
                return resultValues;
188
            } catch (DocumentNotFoundException e) {
189
                return null;
190
            }
191
        }
192

  
193

  
194
        W3CEndpointReference epr = mdService.deliverMDRecords(mdId, null, null, null);
195
        Iterable<String> result = resultSetClientFactory.getClient(epr);
196
        List<String> convertedList = new ArrayList<>();
197
        Iterator<String> it = result.iterator();
198
        int currentCounter = 0;
199
        while (currentCounter < from) {
200
            if (it.hasNext()) {
201
                it.next();
202
                currentCounter++;
203
            } else {
204
                resultValues.setResult(convertedList);
205
                return resultValues;
206
            }
207
        }
208

  
209
        for (int i = 0; i < 10; i++) {
210
            if (it.hasNext()) {
211
                convertedList.add(xslt.evaluate(it.next()));
212
//                convertedList.add(it.next());
213
            } else {
214
                break;
215
            }
216
        }
217
        resultValues.setResult(convertedList);
218
        return resultValues;
219
    }
220

  
221

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

  
251
    private MDStoreInfo retrieveMDStoreInfo(final String identifier) {
252

  
253
        MDStoreInfo result = null;
254
        try {
255
            result = null;
256
            final String xquery = " for $x in collection('/db/DRIVER/MDStoreDSResources/MDStoreDSResourceType') "
257
                    + " where $x//RESOURCE_IDENTIFIER/@value/string()=\"%s\"   return concat($x//RESOURCE_URI/@value/string() "
258
                    + ", '@::@',$x//RESOURCE_IDENTIFIER/@value/string() ,'@::@',$x//METADATA_FORMAT,'(-)',$x//METADATA_FORMAT_LAYOUT,  "
259
                    + " '(-)', $x//METADATA_FORMAT_INTERPRETATION ,'@::@',$x//LAST_STORAGE_DATE,'@::@',$x//NUMBER_OF_RECORDS)";
260

  
261
            List<String> results = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(String.format(xquery, identifier));
262
            if (results != null && !results.isEmpty()) {
263
                result = MDStoreInfo.fromXqueryResult(results.get(0));
264
            }
265
        } catch (ISLookUpException e) {
266
            log.error(String.format("Error on getting information for mdstore with identifier: %s", identifier), e);
267
        }
268

  
269
        return result;
270
    }
271

  
272

  
273
    private Map<String, String> findDatasourceNameAssociatedToMdStore(final String mdStoreId) throws ISLookUpException {
274
        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())";
275
        final ISLookUpService lookupService = serviceLocator.getService(ISLookUpService.class);
276
        List<String> result = lookupService.quickSearchProfile(String.format(baseQuery, mdStoreId));
277
        Map<String, String> datasources = Maps.newHashMap();
278
        for (String item : result) {
279
            String[] splitted = item.split("<::>");
280
            if (splitted != null && splitted.length == 2) {
281
                datasources.put(splitted[0], splitted[1]);
282
            }
283
        }
284
        return datasources;
285
    }
286

  
287

  
288
    class Info {
289
        private String datasourceId;
290
        private String datasourceName;
291
        private String mdStoreId;
292

  
293

  
294
        public String getDatasourceName() {
295
            return datasourceName;
296
        }
297

  
298
        public void setDatasourceName(String datasourceName) {
299
            this.datasourceName = datasourceName;
300
        }
301

  
302
        public String getDatasourceId() {
303
            return datasourceId;
304
        }
305

  
306
        public void setDatasourceId(String datasourceId) {
307
            this.datasourceId = datasourceId;
308
        }
309

  
310
        public String getMdStoreId() {
311
            return mdStoreId;
312
        }
313

  
314
        public void setMdStoreId(String mdStoreId) {
315
            this.mdStoreId = mdStoreId;
316
        }
317
    }
318
}
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.1/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.1/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.1/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.1/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.1/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.1/src/main/resources/eu/dnetlib/functionality/modular/ui/applicationContext-modular-ui-mdstore.properties
1
dnet.modular.ui.mdstore.xslt.record2document = eu/dnetlib/functionality/modular/ui/xslt/indent.xslt
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.1/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" omit-xml-declaration="yes" />
8

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

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

  
19

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

  
28
	</xsl:template>
29

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

  
33
		<xsl:variable name="tag" select="name()" />
34

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

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

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

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

  
55

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

  
58

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

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

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

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

  
85

  
86

  
87
	</xsl:template>
88

  
89
</xsl:stylesheet>
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.1/src/main/resources/eu/dnetlib/functionality/modular/ui/xslt/indent.xslt
1
<xsl:stylesheet version="1.0"
2
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
4

  
5
    <xsl:template match="node()|@*">
6
        <xsl:copy>
7
            <xsl:apply-templates select="node()|@*"/>
8
        </xsl:copy>
9
    </xsl:template>
10
</xsl:stylesheet>
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.1/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

  
20

  
21
		<div ng-view class="col-xs-12"></div>
22
	</div>
23
} )$
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.1/src/main/resources/eu/dnetlib/web/resources/html/mdstore/inspect.html
1
<div style="margin-left: 10px; margin-right: 10px">
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 overrideFrom {{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
                        <pre><code class="xml_code">{{item}}</code></pre>
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.1/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

  
20

  
21

  
22
    <div class="col-md-12" style="height: 100%">
23
        <div class="gridStyle" id="gridMdstores" ng-grid="gridOptions"></div>
24
    </div>
25
</div>
modules/dnet-modular-mdstore-ui/tags/dnet-modular-mdstore-ui-1.0.1/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

  
123
                $scope.searchResult.total = data.size;
124
            }).error(function () {
125
                $scope.showError('Error getting info from mdstore');
126
                $scope.hideSpinner();
127
            });
128
            $scope.hideSpinner();
129
        }
130

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

  
150
        }
151

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

  
172

  
173
        $scope.startSearch = function () {
174
            $scope.from_page = 0;
175
            return $scope.searchByQuery()
176
        }
177

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

  
209
        $scope.getRecordById = function () {
210

  
211
            if (($scope.record_id != null) && ($scope.record_id.length > 0)) {
212
                $scope.showSpinner();
213
            }
214

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

  
232
            }).error(function () {
233
                $scope.showError('Error getting info from mdstore');
234
                $scope.hideSpinner();
235
            });
236
        };
237

  
238
        $scope.nextPage = function () {
239
            if ($scope.from_page < $scope.searchResult.total - 10) {
240
                $scope.from_page = $scope.from_page + 10;
241
                $scope.searchByQuery();
242
                $scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
243
            }
244

  
245
        };
246

  
247
        $scope.prevPage = function () {
248
            if ($scope.from_page + 10 > 10) {
249
                $scope.from_page = $scope.from_page - 10;
250
                $scope.searchByQuery();
251
                $scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
252
            }
253

  
254
        }
255

  
256
        $scope.loadInfo();
257

  
258
        $scope.getResults();
259
    }]);
260

  
261

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

  
275
        $scope.refreshInfo = function () {
276

  
277
            $scope.showSpinner();
278
            $http.get('mdstore/reloadInfo').success(function (data) {
279
                $scope.hideSpinner();
280
                $scope.mdTable = data;
281
            }).error(function () {
282
                $scope.showError('Error listing xmldb collections');
283
                $scope.hideSpinner();
284
            });
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff