Project

General

Profile

« Previous | Next » 

Revision 45273

codebase used to migrate to java8 the production system

View differences:

modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-1.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/objectStore/info/ObjectStoreInfo.java
1
package eu.dnetlib.functionality.modular.ui.objectStore.info;
2

  
3
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
4

  
5
import java.util.List;
6

  
7
/**
8
 * Created by Sandro La Bruzzo on 11/19/15.
9
 */
10
public class ObjectStoreInfo {
11

  
12
    private String objectStoreId;
13

  
14
    private int size;
15

  
16
    private String interpretation;
17

  
18
    private List<ObjectStoreFile> results;
19

  
20
    private String lastStorageDate;
21

  
22
    private String serviceURI;
23

  
24
    private boolean missingProfile = true;
25

  
26
    private boolean missingObjectStore = true;
27

  
28
    public boolean isMissingProfile() {
29
        return missingProfile;
30
    }
31

  
32
    public void setMissingProfile(boolean missingProfile) {
33
        this.missingProfile = missingProfile;
34
    }
35

  
36
    public boolean isMissingObjectStore() {
37
        return missingObjectStore;
38
    }
39

  
40
    public void setMissingObjectStore(boolean missingObjectStore) {
41
        this.missingObjectStore = missingObjectStore;
42
    }
43

  
44
    public String getLastStorageDate() {
45
        return lastStorageDate;
46
    }
47

  
48
    public void setLastStorageDate(String lastStorageDate) {
49
        this.lastStorageDate = lastStorageDate;
50
    }
51

  
52
    public String getServiceURI() {
53
        return serviceURI;
54
    }
55

  
56
    public void setServiceURI(String serviceURI) {
57
        this.serviceURI = serviceURI;
58
    }
59

  
60
    public List<ObjectStoreFile> getResults() {
61
        return results;
62
    }
63

  
64
    public void setResults(List<ObjectStoreFile> results) {
65
        this.results = results;
66
    }
67

  
68
    public String getObjectStoreId() {
69
        return objectStoreId;
70
    }
71

  
72
    public void setObjectStoreId(String objectStoreId) {
73
        this.objectStoreId = objectStoreId;
74
    }
75

  
76
    public int getSize() {
77
        return size;
78
    }
79

  
80
    public void setSize(int size) {
81
        this.size = size;
82
    }
83

  
84

  
85
    public String getInterpretation() {
86
        return interpretation;
87
    }
88

  
89
    public void setInterpretation(String interpretation) {
90
        this.interpretation = interpretation;
91
    }
92
}
modules/dnet-objectStore-ui/trunk/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
	<modelVersion>4.0.0</modelVersion>
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet-parent</artifactId>
6
		<version>1.0.0</version>
7
	</parent>
8

  
9
	<scm>
10
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-objectStore-ui/trunk</developerConnection>
11
	</scm>
12
	<groupId>eu.dnetlib</groupId>
13
	<artifactId>dnet-objectStore-ui</artifactId>
14
	<version>1.0.3-SNAPSHOT</version>
15
	<dependencies>
16
		<dependency>
17
			<groupId>eu.dnetlib</groupId>
18
			<artifactId>cnr-resultset-client</artifactId>
19
			<version>[2.0.0,3.0.0)</version>
20
		</dependency>
21

  
22
		<dependency>
23
			<groupId>eu.dnetlib</groupId>
24
			<artifactId>dnet-modular-ui</artifactId>
25
			<version>[3.0.0,4.0.0)</version>
26
		</dependency>
27
		<dependency>
28
			<groupId>javax.servlet</groupId>
29
			<artifactId>javax.servlet-api</artifactId>
30
			<version>${javax.servlet.version}</version>
31
			<scope>provided</scope>
32
		</dependency>
33
		<dependency>
34
			<groupId>junit</groupId>
35
			<artifactId>junit</artifactId>
36
			<version>${junit.version}</version>
37
			<scope>test</scope>
38
		</dependency>
39

  
40
		<dependency>
41
			<groupId>eu.dnetlib</groupId>
42
			<artifactId>dnet-modular-objectstore-service</artifactId>
43
			<version>[4.2.0,5.0.0)</version>
44
		</dependency>
45

  
46
	</dependencies>
47
</project>
modules/dnet-objectStore-ui/trunk/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-objectStore-ui/trunk/", "deploy_repository": "dnet4-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/dnet4-snapshots", "name": "dnet-objectStore-ui"}
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-1.0.1/src/main/java/eu/dnetlib/functionality/modular/ui/objectStore/ObjectStoreServiceEntryPointController.java
1
/**
2
 * Created by Sandro La Bruzzo on 11/18/15.
3
 */
4

  
5
package eu.dnetlib.functionality.modular.ui.objectStore;
6

  
7
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
8
import org.springframework.ui.ModelMap;
9

  
10
import javax.servlet.http.HttpServletRequest;
11
import javax.servlet.http.HttpServletResponse;
12

  
13
public class ObjectStoreServiceEntryPointController extends ModuleEntryPoint {
14
    @Override
15
    protected void initialize(ModelMap modelMap, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
16

  
17
    }
18
}
modules/dnet-objectStore-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/objectStore/ObjectStoreServiceInternalController.java
1
package eu.dnetlib.functionality.modular.ui.objectStore;
2

  
3
import com.google.common.base.Function;
4
import com.google.common.collect.Lists;
5
import com.google.common.collect.Maps;
6
import com.google.gson.Gson;
7
import eu.dnetlib.data.objectstore.modular.ModularObjectStoreDeliver;
8
import eu.dnetlib.data.objectstore.modular.ModularObjectStoreService;
9
import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
10
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
11
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
12
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
13
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
14
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
15
import eu.dnetlib.enabling.resultset.ResultSetListener;
16
import eu.dnetlib.functionality.modular.ui.objectStore.info.ObjectStoreInfo;
17
import org.apache.commons.lang.StringUtils;
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.stereotype.Controller;
22
import org.springframework.ui.ModelMap;
23
import org.springframework.web.bind.annotation.RequestMapping;
24
import org.springframework.web.bind.annotation.RequestParam;
25
import org.springframework.web.bind.annotation.ResponseBody;
26

  
27
import java.util.List;
28
import java.util.Map;
29

  
30
/**
31
 * Created by Sandro La Bruzzo on 11/18/15.
32
 */
33

  
34
@Controller
35
public class ObjectStoreServiceInternalController {
36

  
37

  
38
    private static final Log log = LogFactory.getLog(ObjectStoreServiceInternalController.class);
39

  
40
    @Autowired
41
    public UniqueServiceLocator serviceLocator;
42

  
43

  
44
    @Autowired
45
    public ModularObjectStoreService objectStoreservice;
46

  
47
    private final Gson gson = new Gson();
48

  
49

  
50
    private final Function<String, ObjectStoreFile> convertFunction = new Function<String, ObjectStoreFile>() {
51
        @Override
52
        public ObjectStoreFile apply(String input) {
53
            return gson.fromJson(input, ObjectStoreFile.class);
54
        }
55
    };
56

  
57

  
58
    @RequestMapping(value = "/ui/objectStore/listObjectStores.do")
59
    @ResponseBody
60
    public List<ObjectStoreInfo> listObjectStoreInfo(final ModelMap map) throws ObjectStoreServiceException {
61
        final Map<String, ObjectStoreInfo> inputObjectStore = Maps.newHashMap();
62
        retrieveObjectStoreFromProfiles(inputObjectStore);
63
        retrieveObjectStoreFromService(inputObjectStore);
64
        return Lists.newArrayList(inputObjectStore.values());
65
    }
66

  
67

  
68
    private void retrieveObjectStoreFromService(final Map<String, ObjectStoreInfo> inputMap) {
69

  
70
        final List<String> stores = objectStoreservice.getFeeder().getDao().listObjectStores();
71
        for (final String s : stores) {
72
            if (!inputMap.containsKey(s)) {
73
                try {
74
                    final ObjectStoreInfo info = new ObjectStoreInfo();
75
                    final ObjectStore store = objectStoreservice.getObjectStoreDeliver().getDao().getObjectStore(s);
76
                    info.setInterpretation(store.getInterpretation());
77
                    info.setSize(store.getSize());
78
                    info.setObjectStoreId(s);
79
                    info.setMissingObjectStore(false);
80
                    inputMap.put(s, info);
81
                } catch (ObjectStoreServiceException e) {
82
                    log.error(e);
83
                }
84
            } else {
85
                inputMap.get(s).setMissingObjectStore(false);
86
            }
87
        }
88
    }
89

  
90

  
91
    private void retrieveObjectStoreFromProfiles(final Map<String, ObjectStoreInfo> inputMap) {
92
        final String query = "for $x in  collection('/db/DRIVER/ObjectStoreDSResources/ObjectStoreDSResourceType') \n" +
93
                "let $interpretation :=$x//OBJECTSTORE_INTERPRETATION\n" +
94
                "let $uri := $x//RESOURCE_URI/@value/string()  \n" +
95
                "let $id := $x//RESOURCE_IDENTIFIER/@value/string() \n" +
96
                "let $lastDate := $x//LAST_STORAGE_DATE  \n" +
97
                "let $size :=$x//STORE_SIZE \n" +
98
                "return concat($uri,'@::@',$id,'@::@',$interpretation,'@::@',$lastDate,'@::@',$size) ";
99

  
100

  
101
        ISLookUpService lookUpService = serviceLocator.getService(ISLookUpService.class);
102
        try {
103
            List<String> results = lookUpService.quickSearchProfile(query);
104
            if (results == null) return;
105
            for (String result : results) {
106
                String dataInfo[] = result.split("@::@");
107
                if (dataInfo != null && dataInfo.length == 5) {
108
                    final String webUri = dataInfo[0];
109
                    final String id = dataInfo[1];
110
                    final String interpretation = dataInfo[2];
111
                    final String lastDate = dataInfo[3];
112
                    final int size = Integer.parseInt(dataInfo[4]);
113
                    final ObjectStoreInfo currentInfo = new ObjectStoreInfo();
114
                    currentInfo.setObjectStoreId(id);
115
                    currentInfo.setInterpretation(interpretation);
116
                    currentInfo.setLastStorageDate(lastDate);
117
                    currentInfo.setSize(size);
118
                    currentInfo.setServiceURI(webUri);
119
                    currentInfo.setMissingProfile(false);
120
                    inputMap.put(id, currentInfo);
121
                }
122
            }
123
        } catch (ISLookUpException e) {
124
            log.error(String.format("%s", "Error on making query on is " + query, e));
125
        }
126
    }
127

  
128

  
129
    @RequestMapping(value = "/ui/objectStore/getObjectStoreInfo.do")
130
    @ResponseBody
131
    public ObjectStoreInfo getObjectStoreInfo(
132
            final ModelMap map, @RequestParam(value = "objId", required = true) final String objId,
133
            @RequestParam(value = "from", required = true) final int from,
134
            @RequestParam(value ="id",required = false) final String recordId) {
135
        try {
136
            final ModularObjectStoreDeliver objectStoreDeliver = objectStoreservice.getObjectStoreDeliver();
137
            final ObjectStore store = objectStoreDeliver.getDao().getObjectStore(objId);
138

  
139
            ResultSetListener rs;
140
            if (recordId!=null && !StringUtils.isEmpty(recordId)){
141
                rs = store.deliverIds(Lists.newArrayList(recordId));
142
            }
143
            else {
144
             rs = store.deliver((long) 0, System.currentTimeMillis());
145
            }
146
            final List<String> page = rs.getResult((1 + from), (from + 25));
147

  
148

  
149
            final ObjectStoreInfo info = new ObjectStoreInfo();
150
            info.setInterpretation(store.getInterpretation());
151
            info.setObjectStoreId(store.getId());
152
            info.setSize(store.getSize());
153
            info.setMissingObjectStore(false);
154
            info.setMissingProfile(existId(objId));
155
            info.setResults(Lists.transform(page, convertFunction));
156
            return info;
157
        } catch (ObjectStoreServiceException e) {
158
            return null;
159
        }
160
    }
161

  
162

  
163
    private boolean existId(final String objectStoreId) {
164

  
165
        ISLookUpService lookUpService = serviceLocator.getService(ISLookUpService.class);
166
        try {
167
            final String resourceProfile = lookUpService.getResourceProfile(objectStoreId);
168
            return resourceProfile == null;
169
        } catch (ISLookUpException e) {
170
            log.debug(objectStoreId + " not found!");
171
        }
172
        return true;
173
    }
174

  
175
}
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-1.0.1/src/main/resources/eu/dnetlib/web/resources/html/objectStore/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

  
25

  
26
    <div class="col-md-12" style="height: 100%">
27
        <div class="gridStyle" id="gridObjectstores" ng-grid="gridOptions"></div>
28
    </div>
29
</div>
modules/dnet-objectStore-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/objectStore/info/ObjectStoreInfo.java
1
package eu.dnetlib.functionality.modular.ui.objectStore.info;
2

  
3
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
4

  
5
import java.util.List;
6

  
7
/**
8
 * Created by Sandro La Bruzzo on 11/19/15.
9
 */
10
public class ObjectStoreInfo {
11

  
12
    private String objectStoreId;
13

  
14
    private int size;
15

  
16
    private String interpretation;
17

  
18
    private List<ObjectStoreFile> results;
19

  
20
    private String lastStorageDate;
21

  
22
    private String serviceURI;
23

  
24
    private boolean missingProfile = true;
25

  
26
    private boolean missingObjectStore = true;
27

  
28
    public boolean isMissingProfile() {
29
        return missingProfile;
30
    }
31

  
32
    public void setMissingProfile(boolean missingProfile) {
33
        this.missingProfile = missingProfile;
34
    }
35

  
36
    public boolean isMissingObjectStore() {
37
        return missingObjectStore;
38
    }
39

  
40
    public void setMissingObjectStore(boolean missingObjectStore) {
41
        this.missingObjectStore = missingObjectStore;
42
    }
43

  
44
    public String getLastStorageDate() {
45
        return lastStorageDate;
46
    }
47

  
48
    public void setLastStorageDate(String lastStorageDate) {
49
        this.lastStorageDate = lastStorageDate;
50
    }
51

  
52
    public String getServiceURI() {
53
        return serviceURI;
54
    }
55

  
56
    public void setServiceURI(String serviceURI) {
57
        this.serviceURI = serviceURI;
58
    }
59

  
60
    public List<ObjectStoreFile> getResults() {
61
        return results;
62
    }
63

  
64
    public void setResults(List<ObjectStoreFile> results) {
65
        this.results = results;
66
    }
67

  
68
    public String getObjectStoreId() {
69
        return objectStoreId;
70
    }
71

  
72
    public void setObjectStoreId(String objectStoreId) {
73
        this.objectStoreId = objectStoreId;
74
    }
75

  
76
    public int getSize() {
77
        return size;
78
    }
79

  
80
    public void setSize(int size) {
81
        this.size = size;
82
    }
83

  
84

  
85
    public String getInterpretation() {
86
        return interpretation;
87
    }
88

  
89
    public void setInterpretation(String interpretation) {
90
        this.interpretation = interpretation;
91
    }
92
}
modules/dnet-objectStore-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/objectStore/ObjectStoreServiceEntryPointController.java
1
/**
2
 * Created by Sandro La Bruzzo on 11/18/15.
3
 */
4

  
5
package eu.dnetlib.functionality.modular.ui.objectStore;
6

  
7
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
8
import org.springframework.ui.ModelMap;
9

  
10
import javax.servlet.http.HttpServletRequest;
11
import javax.servlet.http.HttpServletResponse;
12

  
13
public class ObjectStoreServiceEntryPointController extends ModuleEntryPoint {
14
    @Override
15
    protected void initialize(ModelMap modelMap, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
16

  
17
    }
18
}
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-1.0.1/src/main/resources/eu/dnetlib/web/resources/js/objectstore_inspector_controllers.js
1
var objecStoreInspectorControllers = angular.module('objecStoresControllers', ['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
window.onresize = function () {
75

  
76

  
77
    var elem = document.getElementById('gridObjectstores');
78
    var height = 0;
79
    var body = window.document.body;
80
    if (window.innerHeight) {
81
        height = window.innerHeight;
82
    } else if (body.parentElement.clientHeight) {
83
        height = body.parentElement.clientHeight;
84
    } else if (body && body.clientHeight) {
85
        height = body.clientHeight;
86
    }
87
    elem.style.height = ((height - elem.offsetTop - 280) + "px");
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
objecStoreInspectorControllers.directive('compileTemplate', function ($compile, $parse) {
98
    return {
99
        link: function (scope, element, attr) {
100
            var parsed = $parse(attr.ngBindHtml);
101

  
102
            function getStringValue() {
103
                return (parsed(scope) || '').toString();
104
            }
105

  
106
            //Recompile if the template changes
107
            scope.$watch(getStringValue, function () {
108
                $compile(element, null, -9999)(scope);  //The -9999 makes it skip directives so that we do not recompile ourselves
109
            });
110
        }
111
    }
112
});
113

  
114
objecStoreInspectorControllers.controller('inspectObjecStoreController', [
115
    '$scope', '$http', '$sce', '$location', '$routeParams',
116
    function ($scope, $http, $sce, $location, $routeParams) {
117
        common_init($scope, $http, $sce, $location);
118

  
119
        $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
120
        $scope.id = $routeParams.id;
121

  
122
        $scope.start = $routeParams['start'];
123
        if ($scope.start == null)
124
            $scope.start = 0;
125
        else
126
            $scope.start = parseInt($scope.start);
127

  
128

  
129
        $scope.previousPage = 0
130

  
131
        $scope.nextPage = 0
132

  
133
        $scope.loadInfo = function () {
134

  
135
            $http.post('objectStore/getObjectStoreInfo.do', $.param({
136
                'objId': $routeParams.id,
137
                'from': $scope.start
138
            })).success(function (data) {
139

  
140
                $scope.objectStoreInfo = data;
141
                if (hasOwnProperty($scope, 'results') == false) {
142
                    $scope.searchResult = {}
143
                }
144

  
145
                $scope.searchResult.total = data.size;
146

  
147
                $scope.previousPage = Math.max($scope.start - 25, 0);
148
                $scope.nextPage = Math.min($scope.searchResult.total, $scope.start + 25);
149
            }).error(function () {
150
                $scope.showError('Error getting info from objectStore');
151

  
152
            });
153

  
154
        };
155

  
156
        $scope.loadInfo();
157

  
158

  
159
    }]);
160

  
161
objecStoreInspectorControllers.controller('objecStoresController', [
162
    '$scope', '$http', '$sce', '$location',
163

  
164
    function ($scope, $http, $sce, $location) {
165
        common_init($scope, $http, $sce, $location);
166
        $scope.showSpinner();
167
        $http.get('objectStore/listObjectStores.do').success(function (data) {
168
            $scope.hideSpinner();
169
            $scope.objTable = data;
170
        }).error(function () {
171
            $scope.showError('Error listing xmldb collections');
172
            $scope.hideSpinner();
173
        });
174

  
175
        $scope.refreshInfo = function () {
176
            console.log("Should reload Info")
177
        }
178

  
179
        $scope.gridOptions = {
180
            data: 'objTable',
181
            enableRowSelection: false,
182
            enableCellEditOnFocus: false,
183
            enableHighlighting: true,
184
            plugins: [new ngGridFlexibleHeightPlugin()],
185

  
186
            columnDefs: [
187
                {
188
                    field: 'objectStoreId',
189
                    displayName: 'ID',
190
                    cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b>{{row.getProperty(col.field)}}</b></div>',
191
                    headerClass: 'text-center',
192
                    width: '500px'
193
                },
194
                {field: 'interpretation', displayName: 'Interpretation'},
195
                {field: 'size', displayName: 'Size'},
196
                {
197
                    field: 'serviceURI',
198
                    displayName: 'Service URI',
199
                    cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b ng-show="row.getProperty(col.field)"> {{row.getProperty(col.field)}} </b><b ng-hide="row.getProperty(col.field)" style="color: red"> Profile Missing! </b> </div>',
200
                    headerClass: 'text-center'
201
                },
202
                {
203
                    field: 'objectStoreId',
204
                    displayName: 'View',
205
                    cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b style="color:red" ng-show=\'row.getProperty("missingObjectStore")\'>Missing ObjectStore</b> <a ng-hide=\'row.getProperty("missingObjectStore")\'  href="objectstoreInspector.do#/inspect.do/{{row.getProperty(col.field)}}" class="btn btn-primary btn-xs" data-placement="top" title="{{row.getProperty(col.field)}}"><span class="glyphicon glyphicon-zoom-in"></span> inspect</a></div>',
206
                    width: '130px',
207
                    headerClass: 'text-center'
208
                }
209
            ]
210
        };
211

  
212

  
213
    }]);
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-1.0.0/src/main/resources/eu/dnetlib/web/resources/html/objectStore/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

  
25

  
26
    <div class="col-md-12" style="height: 100%">
27
        <div class="gridStyle" id="gridObjectstores" ng-grid="gridOptions"></div>
28
    </div>
29
</div>
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-1.0.0/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/objectstoreInspector.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/objectstore_inspector_controllers.js"></script>
7
	<script type="text/javascript" src="../resources/js/objectstore_inspector.js"></script>
8
	<link rel="stylesheet" type="text/css" href="../resources/css/ng-grid.min.css" />
9
}, body={
10
	<div ng-app="objecStoreInspector" 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-objectStore-ui/tags/dnet-objectStore-ui-1.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/objectStore/ObjectStoreServiceInternalController.java
1
package eu.dnetlib.functionality.modular.ui.objectStore;
2

  
3
import com.google.common.base.Function;
4
import com.google.common.collect.Lists;
5
import com.google.common.collect.Maps;
6
import com.google.gson.Gson;
7
import eu.dnetlib.data.objectstore.modular.ModularObjectStoreDeliver;
8
import eu.dnetlib.data.objectstore.modular.ModularObjectStoreService;
9
import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
10
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
11
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
12
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
13
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
14
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
15
import eu.dnetlib.enabling.resultset.ResultSetListener;
16
import eu.dnetlib.functionality.modular.ui.objectStore.info.ObjectStoreInfo;
17
import org.apache.commons.logging.Log;
18
import org.apache.commons.logging.LogFactory;
19
import org.springframework.beans.factory.annotation.Autowired;
20
import org.springframework.stereotype.Controller;
21
import org.springframework.ui.ModelMap;
22
import org.springframework.web.bind.annotation.RequestMapping;
23
import org.springframework.web.bind.annotation.RequestParam;
24
import org.springframework.web.bind.annotation.ResponseBody;
25

  
26
import java.util.List;
27
import java.util.Map;
28

  
29
/**
30
 * Created by Sandro La Bruzzo on 11/18/15.
31
 */
32

  
33
@Controller
34
public class ObjectStoreServiceInternalController {
35

  
36

  
37
    private static final Log log = LogFactory.getLog(ObjectStoreServiceInternalController.class);
38

  
39
    @Autowired
40
    public UniqueServiceLocator serviceLocator;
41

  
42

  
43
    @Autowired
44
    public ModularObjectStoreService objectStoreservice;
45

  
46

  
47
    @RequestMapping(value = "/ui/objectStore/listObjectStores.do")
48
    @ResponseBody
49
    public List<ObjectStoreInfo> listObjectStoreInfo(final ModelMap map) throws ObjectStoreServiceException {
50
        final Map<String, ObjectStoreInfo> inputObjectStore = Maps.newHashMap();
51
        retrieveObjectStoreFromProfiles(inputObjectStore);
52
        retrieveObjectStoreFromService(inputObjectStore);
53
        return Lists.newArrayList(inputObjectStore.values());
54
    }
55

  
56

  
57
    private void retrieveObjectStoreFromService(final Map<String, ObjectStoreInfo> inputMap) {
58

  
59
        final List<String> stores = objectStoreservice.getFeeder().getDao().listObjectStores();
60
        for (final String s : stores) {
61
            if (!inputMap.containsKey(s)) {
62
                try {
63
                    final ObjectStoreInfo info = new ObjectStoreInfo();
64
                    final ObjectStore store = objectStoreservice.getObjectStoreDeliver().getDao().getObjectStore(s);
65
                    info.setInterpretation(store.getInterpretation());
66
                    info.setSize(store.getSize());
67
                    info.setObjectStoreId(s);
68
                    info.setMissingObjectStore(false);
69
                    inputMap.put(s, info);
70
                } catch (ObjectStoreServiceException e) {
71
                    log.error(e);
72
                }
73
            } else {
74
                inputMap.get(s).setMissingObjectStore(false);
75
            }
76
        }
77
    }
78

  
79

  
80
    private void retrieveObjectStoreFromProfiles(final Map<String, ObjectStoreInfo> inputMap) {
81
        final String query = "for $x in  collection('/db/DRIVER/ObjectStoreDSResources/ObjectStoreDSResourceType') \n" +
82
                "let $interpretation :=$x//OBJECTSTORE_INTERPRETATION\n" +
83
                "let $uri := $x//RESOURCE_URI/@value/string()  \n" +
84
                "let $id := $x//RESOURCE_IDENTIFIER/@value/string() \n" +
85
                "let $lastDate := $x//LAST_STORAGE_DATE  \n" +
86
                "let $size :=$x//STORE_SIZE \n" +
87
                "return concat($uri,'@::@',$id,'@::@',$interpretation,'@::@',$lastDate,'@::@',$size) ";
88

  
89

  
90
        ISLookUpService lookUpService = serviceLocator.getService(ISLookUpService.class);
91
        try {
92
            List<String> results = lookUpService.quickSearchProfile(query);
93
            if (results == null) return;
94
            for (String result : results) {
95
                String dataInfo[] = result.split("@::@");
96
                if (dataInfo != null && dataInfo.length == 5) {
97
                    final String webUri = dataInfo[0];
98
                    final String id = dataInfo[1];
99
                    final String interpretation = dataInfo[2];
100
                    final String lastDate = dataInfo[3];
101
                    final int size = Integer.parseInt(dataInfo[4]);
102
                    final ObjectStoreInfo currentInfo = new ObjectStoreInfo();
103
                    currentInfo.setObjectStoreId(id);
104
                    currentInfo.setInterpretation(interpretation);
105
                    currentInfo.setLastStorageDate(lastDate);
106
                    currentInfo.setSize(size);
107
                    currentInfo.setServiceURI(webUri);
108
                    currentInfo.setMissingProfile(false);
109
                    inputMap.put(id, currentInfo);
110
                }
111
            }
112
        } catch (ISLookUpException e) {
113
            log.error(String.format("%s", "Error on making query on is " + query, e));
114
        }
115
    }
116

  
117

  
118
    @RequestMapping(value = "/ui/objectStore/getObjectStoreInfo.do")
119
    @ResponseBody
120
    public ObjectStoreInfo getObjectStoreInfo(
121
            final ModelMap map, @RequestParam(value = "objId", required = true) final String objId,
122
            @RequestParam(value = "from", required = true) final int from) {
123
        try {
124
            ModularObjectStoreDeliver objectStoreDeliver = objectStoreservice.getObjectStoreDeliver();
125
            ObjectStore store = objectStoreDeliver.getDao().getObjectStore(objId);
126

  
127
            ResultSetListener rs = store.deliver((long) 0, System.currentTimeMillis());
128
            List<String> page = rs.getResult((1 + from), (from + 25));
129
            final Gson g = new Gson();
130
            Function<String, ObjectStoreFile> convertFunction = new Function<String, ObjectStoreFile>() {
131
                @Override
132
                public ObjectStoreFile apply(String input) {
133
                    return g.fromJson(input, ObjectStoreFile.class);
134
                }
135
            };
136
            final ObjectStoreInfo info = new ObjectStoreInfo();
137
            info.setInterpretation(store.getInterpretation());
138
            info.setObjectStoreId(store.getId());
139
            info.setSize(store.getSize());
140
            info.setMissingObjectStore(false);
141
            info.setMissingProfile(existId(objId));
142
            info.setResults(Lists.transform(page, convertFunction));
143
            return info;
144
        } catch (ObjectStoreServiceException e) {
145
            return null;
146
        }
147
    }
148

  
149

  
150
    private boolean existId(final String objectStoreId) {
151

  
152
        ISLookUpService lookUpService = serviceLocator.getService(ISLookUpService.class);
153
        try {
154
            final String resourceProfile = lookUpService.getResourceProfile(objectStoreId);
155
            return resourceProfile == null;
156
        } catch (ISLookUpException e) {
157
            log.debug(objectStoreId + " not found!");
158
        }
159
        return true;
160
    }
161

  
162
}
modules/dnet-objectStore-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/objectstoreInspector.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/objectstore_inspector_controllers.js"></script>
7
	<script type="text/javascript" src="../resources/js/objectstore_inspector.js"></script>
8
	<link rel="stylesheet" type="text/css" href="../resources/css/ng-grid.min.css" />
9
}, body={
10
	<div ng-app="objectStoreInspector" 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-objectStore-ui/tags/dnet-objectStore-ui-1.0.0/src/main/resources/eu/dnetlib/web/resources/html/objectStore/inspect.html
1
<div class="container">
2
    <div class="row">
3
        <div class="col-md-6">
4
            <h2>Inspect ObjectStore </h2>
5
        </div>
6
        <div class="col-md-6 text-right">
7
            <a href="#/list" class="btn btn-primary btn-sm"><span
8
                    class="glyphicon glyphicon-step-backward"></span>
9
                Back</a>
10
        </div>
11

  
12

  
13
    </div>
14
    <div class="panel panel-default">
15
        <div class="panel-heading">
16
            <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_format">
17
                <b>ObjectStore Info</b>
18
            </a>
19
        </div>
20
        <div objectStoreId="collapse_format" class="panel-collapse collapse in">
21
            <div class="panel-body">
22
                <table cellpadding="10">
23
                    <tr>
24
                        <td align="right">
25
                            <b>objectStoreId: </b>
26
                        </td>
27
                        <td>
28
                            <i style=" padding-left:10px">{{objectStoreInfo.objectStoreId}}</i>
29
                        </td>
30
                        <td style=" padding-left:10px">
31

  
32

  
33
                            <a ng-hide="objectStoreInfo.missingProfile" style=" padding-left:10px"
34
                               href="isManager.do#/profile/{{id}}"
35
                               class="btn btn-primary btn-sm">
36
                                <span class="glyphicon glyphicon-search"></span>
37
                                View Profile
38
                            </a>
39

  
40
                            <a ng-show="objectStoreInfo.missingProfile" style=" padding-left:10px"
41
                               class="btn btn-danger btn-sm">
42
                                <span class="glyphicon glyphicon-remove"></span>
43
                                Missing Profile
44
                            </a>
45

  
46
                        </td>
47
                        <td style=" padding-left:10px">
48
                            <a href="" class="btn btn-primary btn-sm" ng-click="loadInfo()"><span
49
                                    class="glyphicon glyphicon-refresh"></span> Refresh Info</a>
50
                        </td>
51
                    </tr>
52
                    <tr>
53
                        <td align="right">
54
                            <b>interpretation: </b>
55
                        </td>
56
                        <td>
57
                            <i style=" padding-left:10px">{{objectStoreInfo.interpretation}}</i>
58
                        </td>
59
                        <td></td>
60
                    </tr>
61
                    <tr>
62
                        <td align="right">
63
                            <b>last storage date: </b>
64
                        </td>
65
                        <td>
66
                            <i style=" padding-left:10px">{{objectStoreInfo.lastStorageDate}}</i>
67
                        </td>
68
                        <td></td>
69
                    </tr>
70
                    <tr>
71
                        <td align="right">
72
                            <b>Number of Elements: </b>
73
                        </td>
74
                        <td>
75
                            <i style=" padding-left:10px">{{objectStoreInfo.size}}</i>
76
                        </td>
77
                        <td></td>
78
                    </tr>
79
                    <tr>
80
                        <td align="right">
81
                            <b>Service URI: </b>
82
                        </td>
83
                        <td>
84
                            <i style=" padding-left:10px">
85
                                <a href="{{objectStoreInfo.serviceURI}}">{{objectStoreInfo.serviceURI}}</a>
86
                            </i>
87
                        </td>
88
                        <td></td>
89
                    </tr>
90

  
91
                </table>
92

  
93
            </div>
94
        </div>
95
    </div>
96

  
97

  
98
    <div class="row">
99
        <div class="col-md-12">
100

  
101
            <div class="panel panel-default">
102
                <div class="panel-heading">
103
                    <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_query">
104
                        <b>ObjectStore Query</b>
105
                    </a>
106
                </div>
107
                <div id="collapse_query" class="panel-collapse collapse in">
108
                    <div class="panel-body">
109
                        <table cellpadding="10">
110
                            <tr>
111
                                <td align="right" style="width:10%">
112
                                    <b>Id: </b>
113
                                </td>
114
                                <td style=" padding-left:10px; width:90%">
115
                                    <input type="text" class="form-control" ng-model="record_id"
116
                                           placeholder="Enter an identifier to search (fast)">
117
                                </td>
118
                                <td style=" padding-left:10px" style="width:10%" align="right">
119
                                    <a style=" padding-left:10px" ng-click="getRecordById()" href=""
120
                                       class="btn btn-primary btn-sm">
121
                                        <span class="glyphicon glyphicon-search"></span>
122
                                        Search Id
123
                                    </a>
124
                                </td>
125
                            </tr>
126
                        </table>
127
                    </div>
128
                </div>
129
            </div>
130
        </div>
131
    </div>
132

  
133
    <div class="row">
134
        <div class="col-md-12 ">
135
            <h3>Number of results: {{searchResult.total}}</h3>
136
        </div>
137
    </div>
138
    <div class="row">
139
        <div class="col-md-2 text-left">
140
            results from {{start + 1 }} to {{nextPage }}
141
        </div>
142
        <div class="col-md-9 text-center">
143
            <ul class="pagination">
144
                <li>
145
                    <a href="#/inspect.do/{{id}}/{{previousPage}}" ng-click="prevPage()">&laquo;
146
                    </a>
147
                </li>
148
                <li>
149
                    <a href="#/inspect.do/{{id}}/{{nextPage}}">&raquo;
150
                    </a>
151
                </li>
152
            </ul>
153
        </div>
154
    </div>
155

  
156
    <div class="row" ng-repeat="item in objectStoreInfo.results">
157
        <div class="col-md-12">
158
            <div class="panel panel-default">
159
                <div class="panel-heading">
160
                    <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_{{$index}}">
161
                        <b>{{$index+(1 + start)}}</b>
162
                    </a>
163
                </div>
164
                <div id="collapse_{{$index}}" class="panel-collapse collapse in">
165
                    <div class="panel-body">
166
                        <div class="col-lg-3 text-right"><b>Object Identifier:</b></div>
167
                        <div class="col-lg-8 text-left"> {{item.objectID}}</div>
168
                        <div class="col-lg-3 text-right"><b>Related Metadata Identifier:</b></div>
169
                        <div class="col-lg-8 text-left"> {{item.metadataRelatedID}}</div>
170
                        <div class="col-lg-3 text-right"><b>Mime Type:</b></div>
171
                        <div class="col-lg-8 text-left"> {{item.mimeType}}</div>
172
                        <div class="col-lg-3 text-right"><b>File Size:</b></div>
173
                        <div class="col-lg-8 text-left"> {{item.fileSizeKB}} Kb</div>
174
                        <div class="col-lg-3 text-right"><b>MD5:</b></div>
175
                        <div class="col-lg-8 text-left"> {{item.md5Sum}}</div>
176
                        <div class="col-lg-3 text-right"><b>Downloaded URL:</b></div>
177
                        <div class="col-lg-8 text-left"><a href="{{item.downloadedURL}}">{{item.downloadedURL}}</a>
178
                        </div>
179
                        <div class="col-lg-3 text-right"><b>Download:</b></div>
180
                        <div class="col-lg-8 text-left"><a href="{{item.uri}}">Download from ObjectStore</a></div>
181
                    </div>
182

  
183

  
184
                </div>
185
            </div>
186
        </div>
187
    </div>
188

  
189

  
190
</div>
191

  
192

  
193
</div>
194

  
195

  
196

  
197

  
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-1.0.0/src/main/resources/eu/dnetlib/web/resources/js/objectstore_inspector_controllers.js
1
var objecStoreInspectorControllers = angular.module('objecStoresControllers', ['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
window.onresize = function () {
75

  
76

  
77
    var elem = document.getElementById('gridObjectstores');
78
    var height = 0;
79
    var body = window.document.body;
80
    if (window.innerHeight) {
81
        height = window.innerHeight;
82
    } else if (body.parentElement.clientHeight) {
83
        height = body.parentElement.clientHeight;
84
    } else if (body && body.clientHeight) {
85
        height = body.clientHeight;
86
    }
87
    elem.style.height = ((height - elem.offsetTop - 280) + "px");
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
objecStoreInspectorControllers.directive('compileTemplate', function ($compile, $parse) {
98
    return {
99
        link: function (scope, element, attr) {
100
            var parsed = $parse(attr.ngBindHtml);
101

  
102
            function getStringValue() {
103
                return (parsed(scope) || '').toString();
104
            }
105

  
106
            //Recompile if the template changes
107
            scope.$watch(getStringValue, function () {
108
                $compile(element, null, -9999)(scope);  //The -9999 makes it skip directives so that we do not recompile ourselves
109
            });
110
        }
111
    }
112
});
113

  
114
objecStoreInspectorControllers.controller('inspectObjecStoreController', [
115
    '$scope', '$http', '$sce', '$location', '$routeParams',
116
    function ($scope, $http, $sce, $location, $routeParams) {
117
        common_init($scope, $http, $sce, $location);
118

  
119
        $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
120
        $scope.id = $routeParams.id;
121

  
122
        $scope.start = $routeParams['start'];
123
        if ($scope.start == null)
124
            $scope.start = 0;
125
        else
126
            $scope.start = parseInt($scope.start);
127

  
128

  
129
        $scope.previousPage = 0
130

  
131
        $scope.nextPage = 0
132

  
133
        $scope.loadInfo = function () {
134

  
135
            $http.post('objectStore/getObjectStoreInfo.do', $.param({
136
                'objId': $routeParams.id,
137
                'from': $scope.start
138
            })).success(function (data) {
139

  
140
                $scope.objectStoreInfo = data;
141
                if (hasOwnProperty($scope, 'results') == false) {
142
                    $scope.searchResult = {}
143
                }
144

  
145
                $scope.searchResult.total = data.size;
146

  
147
                $scope.previousPage = Math.max($scope.start - 25, 0);
148
                $scope.nextPage = Math.min($scope.searchResult.total, $scope.start + 25);
149
            }).error(function () {
150
                $scope.showError('Error getting info from objectStore');
151

  
152
            });
153

  
154
        };
155

  
156
        $scope.loadInfo();
157

  
158

  
159
    }]);
160

  
161
objecStoreInspectorControllers.controller('objecStoresController', [
162
    '$scope', '$http', '$sce', '$location',
163

  
164
    function ($scope, $http, $sce, $location) {
165
        common_init($scope, $http, $sce, $location);
166
        $scope.showSpinner();
167
        $http.get('objectStore/listObjectStores.do').success(function (data) {
168
            $scope.hideSpinner();
169
            $scope.objTable = data;
170
        }).error(function () {
171
            $scope.showError('Error listing xmldb collections');
172
            $scope.hideSpinner();
173
        });
174

  
175
        $scope.refreshInfo = function () {
176
            console.log("Should reload Info")
177
        }
178

  
179
        $scope.gridOptions = {
180
            data: 'objTable',
181
            enableRowSelection: false,
182
            enableCellEditOnFocus: false,
183
            enableHighlighting: true,
184
            plugins: [new ngGridFlexibleHeightPlugin()],
185

  
186
            columnDefs: [
187
                {
188
                    field: 'objectStoreId',
189
                    displayName: 'ID',
190
                    cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b>{{row.getProperty(col.field)}}</b></div>',
191
                    headerClass: 'text-center',
192
                    width: '500px'
193
                },
194
                {field: 'interpretation', displayName: 'Interpretation'},
195
                {field: 'size', displayName: 'Size'},
196
                {
197
                    field: 'serviceURI',
198
                    displayName: 'Service URI',
199
                    cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b ng-show="row.getProperty(col.field)"> {{row.getProperty(col.field)}} </b><b ng-hide="row.getProperty(col.field)" style="color: red"> Profile Missing! </b> </div>',
200
                    headerClass: 'text-center'
201
                },
202
                {
203
                    field: 'objectStoreId',
204
                    displayName: 'View',
205
                    cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b style="color:red" ng-show=\'row.getProperty("missingObjectStore")\'>Missing ObjectStore</b> <a ng-hide=\'row.getProperty("missingObjectStore")\'  href="objectstoreInspector.do#/inspect.do/{{row.getProperty(col.field)}}" class="btn btn-primary btn-xs" data-placement="top" title="{{row.getProperty(col.field)}}"><span class="glyphicon glyphicon-zoom-in"></span> inspect</a></div>',
206
                    width: '130px',
207
                    headerClass: 'text-center'
208
                }
209
            ]
210
        };
211

  
212

  
213
    }]);
modules/dnet-objectStore-ui/trunk/src/main/resources/eu/dnetlib/web/resources/html/objectStore/inspect.html
1
<div class="container">
2
    <div class="row">
3
        <div class="col-md-6">
4
            <h2>Inspect ObjectStore </h2>
5
        </div>
6
        <div class="col-md-6 text-right">
7
            <a href="#/list" class="btn btn-primary btn-sm"><span
8
                    class="glyphicon glyphicon-step-backward"></span>
9
                Back</a>
10
        </div>
11

  
12

  
13
    </div>
14
    <div class="panel panel-default">
15
        <div class="panel-heading">
16
            <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_format">
17
                <b>ObjectStore Info</b>
18
            </a>
19
        </div>
20
        <div objectStoreId="collapse_format" class="panel-collapse collapse in">
21
            <div class="panel-body">
22
                <table cellpadding="10">
23
                    <tr>
24
                        <td align="right">
25
                            <b>objectStoreId: </b>
26
                        </td>
27
                        <td>
28
                            <i style=" padding-left:10px">{{objectStoreInfo.objectStoreId}}</i>
29
                        </td>
30
                        <td style=" padding-left:10px">
31

  
32

  
33
                            <a ng-hide="objectStoreInfo.missingProfile" style=" padding-left:10px"
34
                               href="isManager.do#/profile/{{id}}"
35
                               class="btn btn-primary btn-sm">
36
                                <span class="glyphicon glyphicon-search"></span>
37
                                View Profile
38
                            </a>
39

  
40
                            <a ng-show="objectStoreInfo.missingProfile" style=" padding-left:10px"
41
                               class="btn btn-danger btn-sm">
42
                                <span class="glyphicon glyphicon-remove"></span>
43
                                Missing Profile
44
                            </a>
45

  
46
                        </td>
47
                        <td style=" padding-left:10px">
48
                            <a href="" class="btn btn-primary btn-sm" ng-click="loadInfo()"><span
49
                                    class="glyphicon glyphicon-refresh"></span> Refresh Info</a>
50
                        </td>
51
                    </tr>
52
                    <tr>
53
                        <td align="right">
54
                            <b>interpretation: </b>
55
                        </td>
56
                        <td>
57
                            <i style=" padding-left:10px">{{objectStoreInfo.interpretation}}</i>
58
                        </td>
59
                        <td></td>
60
                    </tr>
61
                    <tr>
62
                        <td align="right">
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff