imported information system modular UIs

master
Claudio Atzori 5 years ago
parent b8d15d09f8
commit 77292eb853

@ -0,0 +1,17 @@
package eu.dnetlib.functionality.modular.ui.is;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.ui.ModelMap;
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
public class InformationServiceEntryPointController extends ModuleEntryPoint {
@Override
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
}
}

@ -0,0 +1,307 @@
package eu.dnetlib.functionality.modular.ui.is;
import java.io.IOException;
import java.io.StringReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletResponse;
import javax.xml.transform.dom.DOMResult;
import javax.xml.xpath.XPathFactory;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
import eu.dnetlib.enabling.is.sn.SubscriptionRegistry;
import eu.dnetlib.enabling.is.sn.resourcestate.ResourceStateSubscription;
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController;
import eu.dnetlib.functionality.modular.ui.is.bulk.ProfileImporter;
import eu.dnetlib.functionality.modular.ui.is.objects.*;
import eu.dnetlib.functionality.modular.ui.is.objects.ServiceDesc.ServiceStatus;
import eu.dnetlib.miscutils.datetime.DateUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.dom4j.io.SAXReader;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class InformationServiceInternalController extends AbstractAjaxController {
@Resource
private UniqueServiceLocator serviceLocator;
@Resource(name = "modularUiProfileImporter")
private ProfileImporter profileImporter;
/**
* is sn subscription registries.
*/
@Resource(name = "issResourceStateNotificationRegistry")
private transient SubscriptionRegistry registry;
private static final Log log = LogFactory.getLog(InformationServiceInternalController.class);
@RequestMapping("/ui/is/xquery.do")
public @ResponseBody
List<String> query(@RequestParam(value = "query", required = true) final String query) throws Exception {
log.debug("Executing xquery: " + query);
return serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
}
@RequestMapping("/ui/is/listSchemas.do")
public @ResponseBody
List<String> listSchemas() throws Exception {
return serviceLocator.getService(ISLookUpService.class).listResourceTypes();
}
@RequestMapping("/ui/is/getSchema.do")
public @ResponseBody
String getSchema(@RequestParam(value = "name", required = true) final String name) throws Exception {
return serviceLocator.getService(ISLookUpService.class).getResourceTypeSchema(name);
}
@RequestMapping("/ui/is/listCollections.do")
public @ResponseBody
List<CollectionDesc> listCollections() throws Exception {
final String xquery = "for $kind in xmldb:get-child-collections('/db/DRIVER') " +
"for $type in xmldb:get-child-collections(concat('/db/DRIVER/', $kind)) " +
"return concat ($kind, ' @@@ ', $type, ' @@@ ', count(xmldb:get-child-resources(concat('/db/DRIVER/', $kind, '/', $type))))";
final Map<String, CollectionDesc> map = Maps.newHashMap();
for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
final String[] arr = s.split("@@@");
final String kind = arr[0].trim();
final String type = arr[1].trim();
final int size = NumberUtils.toInt(arr[2].trim(), 0);
if (!map.containsKey(kind)) {
map.put(kind, new CollectionDesc(kind));
}
map.get(kind).addType(type, size);
}
final List<CollectionDesc> res = Lists.newArrayList(map.values());
for (CollectionDesc d : res) {
Collections.sort(d.getTypes());
}
Collections.sort(res);
return res;
}
@RequestMapping("/ui/is/listProfiles.do")
public @ResponseBody
List<String> listProfiles(@RequestParam(value = "kind", required = true) final String kind,
@RequestParam(value = "type", required = true) final String type) throws Exception {
final String collName = "/db/DRIVER/" + kind + "/" + type;
final String xquery = "distinct-values(for $x in collection('" + collName + "') return $x//RESOURCE_IDENTIFIER/@value/string())";
final List<String> res = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
Collections.sort(res);
return res;
}
@RequestMapping("/ui/is/getProfile.do")
public @ResponseBody
String getProfiles(@RequestParam(value = "id", required = true) final String id) throws Exception {
return serviceLocator.getService(ISLookUpService.class).getResourceProfile(id);
}
@RequestMapping("/ui/is/registerProfile.do")
public @ResponseBody
String registerProfile(@RequestParam(value = "profile", required = true) final String profile) throws Exception {
return serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
}
@RequestMapping("/ui/is/updateProfile.do")
public @ResponseBody
String updateProfile(@RequestParam(value = "profile", required = true) final String profile) throws Exception {
final SAXReader reader = new SAXReader();
final Document doc = reader.read(new StringReader(profile));
final String id = doc.valueOf("//RESOURCE_IDENTIFIER/@value");
final String type = doc.valueOf("//RESOURCE_TYPE/@value");
if (StringUtils.isEmpty(id)) {
throw new Exception("RESOURCE_IDENTIFIER is empty");
} else if (StringUtils.isEmpty(type)) {
throw new Exception("RESOURCE_TYPE is empty");
} else if (serviceLocator.getService(ISRegistryService.class).updateProfile(id, profile, type)) {
return id;
} else {
throw new Exception("Profile not updated");
}
}
@RequestMapping("/ui/is/deleteProfile.do")
public @ResponseBody
boolean deleteProfile(@RequestParam(value = "id", required = true) final String id) throws Exception {
return serviceLocator.getService(ISRegistryService.class).deleteProfile(id);
}
@RequestMapping("/ui/is/import.do")
public @ResponseBody
Map<String, Integer> importProfiles(
@RequestParam(value = "path", required = true) final String path,
@RequestParam(value = "profiles", required = true) final boolean profiles,
@RequestParam(value = "schemas", required = true) final boolean schemas) throws Exception {
log.info("importing profiles/schemas from " + path);
final Map<String, Integer> res = Maps.newHashMap();
if (schemas) {
res.putAll(profileImporter.importSchemas(path + "/**/*.xsd"));
}
if (profiles) {
res.putAll(profileImporter.importProfiles(path + "/**/*.xml"));
}
return res;
}
@RequestMapping("/ui/is/listBlackboards.do")
public @ResponseBody
List<BlackboardMessage> listBlackboards() throws Exception {
final List<BlackboardMessage> list = Lists.newArrayList();
final SAXReader reader = new SAXReader();
for (String xml : serviceLocator
.getService(ISLookUpService.class)
.quickSearchProfile(
"for $x in collection('/db/DRIVER/ServiceResources')//MESSAGE return <message>{$x/../../..//RESOURCE_TYPE}{$x/../../..//RESOURCE_IDENTIFIER}{$x}</message>")) {
final BlackboardMessage info = new BlackboardMessage();
final Document doc = reader.read(new StringReader(xml));
info.setProfId(doc.valueOf(".//RESOURCE_IDENTIFIER/@value"));
info.setMessageId(doc.valueOf(".//@id"));
info.setResourceType(doc.valueOf(".//RESOURCE_TYPE/@value"));
info.setAction(doc.valueOf(".//ACTION"));
info.setDate(doc.valueOf(".//@date"));
info.setActionStatus(doc.valueOf(".//ACTION_STATUS"));
info.setError(doc.valueOf(".//PARAMETER[@name='error']/@value"));
list.add(info);
}
return list;
}
@RequestMapping("/ui/is/getMetaWfIdForFamily.do")
public @ResponseBody
Map<String, String> getMetaWfId(@RequestParam(value = "family", required = true) final String family) throws ISLookUpException {
final String xq = "for $x in collection('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType') " +
"where $x//WORKFLOW_FAMILY='" + family + "' " +
"return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x//WORKFLOW_NAME/@menuSection)";
final Map<String, String> map = Maps.newHashMap();
try {
final String[] arr = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xq).split("@@@");
map.put("id", arr[0].trim());
map.put("section", arr[1].trim());
} catch (ISLookUpDocumentNotFoundException e) {
map.put("id", "");
map.put("section", "");
}
map.put("family", family);
return map;
}
@RequestMapping("/ui/is/listServices.do")
public @ResponseBody
Collection<ServiceGrouperDesc> listServices() throws Exception {
final String xq = IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/xquery/listServices.xquery"));
final List<ServiceDesc> list = Lists.newArrayList();
final SAXReader reader = new SAXReader();
for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xq)) {
final Document doc = reader.read(new StringReader(s));
final String id = doc.valueOf("/service/id").trim();
final String name = doc.valueOf("/service/name").trim();
final String wsdl = doc.valueOf("/service/wsdl").trim();
list.add(new ServiceDesc(id, name, wsdl));
}
final XPathFactory xpathFactory = XPathFactory.newInstance();
for (ResourceStateSubscription sub : registry.listSubscriptions()) {
boolean notFound = true;
final DOMResult result = new DOMResult(); // NOPMD
sub.getSubscriberAsEpr().writeTo(result);
final String wsdl = xpathFactory.newXPath().evaluate("//*[local-name() = 'Address']", result.getNode()) + "?wsdl";
for (ServiceDesc s : list) {
if (s.getWsdl().equalsIgnoreCase(wsdl)) {
s.getSubscriptions().add(new SubscriptionDesc(sub));
notFound = false;
}
}
if (notFound) {
final ServiceDesc desc = new ServiceDesc("", "", wsdl);
desc.getSubscriptions().add(new SubscriptionDesc(sub));
desc.setStatus(ServiceStatus.MISSING);
list.add(desc);
}
}
final Map<String, ServiceGrouperDesc> map = Maps.newHashMap();
for (ServiceDesc s : list) {
final URL url = new URL(s.getWsdl());
final String host = url.getHost();
final int port = url.getPort();
final String context = Iterables.getFirst(Splitter.on("/").omitEmptyStrings().split(url.getPath()), "");
final String tmpKey = host + "@@@" + port + "@@@" + context;
if (!map.containsKey(tmpKey)) {
map.put(tmpKey, new ServiceGrouperDesc(host, port, context, new ArrayList<ServiceDesc>()));
}
map.get(tmpKey).getServices().add(s);
}
return map.values();
}
@RequestMapping("/ui/is/ping.do")
public @ResponseBody
long pingUrl(@RequestParam(value = "url", required = true) final String url, @RequestParam(value = "timeout", required = true) final int timeout)
throws IOException {
final long start = DateUtils.now();
final HttpURLConnection urlConn = (HttpURLConnection) new URL(url).openConnection();
urlConn.setConnectTimeout(timeout);
urlConn.setReadTimeout(timeout);
if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
return DateUtils.now() - start;
} else {
throw new IllegalArgumentException("Invalid Url");
}
}
public void sendXML(final ServletResponse response, final String xml) throws IOException {
response.setContentType("text/xml");
final ServletOutputStream out = response.getOutputStream();
IOUtils.copy(new StringReader(xml), out);
out.flush();
out.close();
}
}

@ -0,0 +1,103 @@
package eu.dnetlib.functionality.modular.ui.is.bulk;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePatternUtils;
import com.google.common.collect.Maps;
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
import eu.dnetlib.enabling.is.store.rmi.ISStoreService;
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
import eu.dnetlib.enabling.tools.StreamOpaqueResource;
public class ProfileImporter implements ResourceLoaderAware {
private ResourceLoader resourceLoader;
private static final Log log = LogFactory.getLog(ProfileImporter.class);
@javax.annotation.Resource
private UniqueServiceLocator serviceLocator;
public Map<String, Integer> importSchemas(final String path) throws IOException {
int done = 0;
int total = 0;
for (Resource res : ResourcePatternUtils.getResourcePatternResolver(getResourceLoader()).getResources(path)) {
total++;
try {
registerSchema(res.getURL());
done++;
} catch (Throwable e) {
log.error("Error registering schema " + res.getURL(), e);
}
}
final Map<String, Integer> res = Maps.newHashMap();
res.put("schemasDone", done);
res.put("schemasTotal", total);
return res;
}
public Map<String, Integer> importProfiles(final String path) throws IOException {
int done = 0;
int total = 0;
for (Resource res : ResourcePatternUtils.getResourcePatternResolver(getResourceLoader()).getResources(path)) {
total++;
try {
registerProfile(res.getURL());
done++;
} catch (Throwable e) {
log.error("Error registering profile " + res.getURL(), e);
}
}
final Map<String, Integer> res = Maps.newHashMap();
res.put("profilesDone", done);
res.put("profilesTotal", total);
return res;
}
private void registerSchema(final URL url) throws Exception {
final String resourceType = FilenameUtils.getBaseName(url.getPath());
log.info("registering schema: " + resourceType);
serviceLocator.getService(ISRegistryService.class).addResourceType(resourceType, IOUtils.toString(url.openStream()));
}
private void registerProfile(final URL url) throws Exception {
final StreamOpaqueResource resource = new StreamOpaqueResource(url.openStream());
final String name = resource.getResourceId().split("_")[0];
final String coll = "/db/DRIVER/" + resource.getResourceKind() + "/" + resource.getResourceType();
log.info("saving profile: " + name + " in coll " + coll);
serviceLocator.getService(ISStoreService.class).insertXML(name, coll, resource.asString());
}
public ResourceLoader getResourceLoader() {
return resourceLoader;
}
@Override
public void setResourceLoader(final ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
}

@ -0,0 +1,79 @@
package eu.dnetlib.functionality.modular.ui.is.objects;
public class BlackboardMessage {
private String profId;
private String messageId;
private String resourceType;
private String action;
private String date;
private String actionStatus;
private String error;
public BlackboardMessage() {}
public BlackboardMessage(String profId, String messageId, String resourceType, String action, String date, String actionStatus, String error) {
this.profId = profId;
this.messageId = messageId;
this.resourceType = resourceType;
this.action = action;
this.date = date;
this.actionStatus = actionStatus;
this.error = error;
}
public String getProfId() {
return profId;
}
public void setProfId(String profId) {
this.profId = profId;
}
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public String getResourceType() {
return resourceType;
}
public void setResourceType(String resourceType) {
this.resourceType = resourceType;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getActionStatus() {
return actionStatus;
}
public void setActionStatus(String actionStatus) {
this.actionStatus = actionStatus;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}

@ -0,0 +1,59 @@
package eu.dnetlib.functionality.modular.ui.is.objects;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Lists;
public class CollectionDesc implements Comparable<CollectionDesc> {
private String kind;
private int size = 0;
private List<CollectionTypeDesc> types = Lists.newArrayList();
public CollectionDesc() {}
public CollectionDesc(String kind, List<CollectionTypeDesc> types, int size) {
this.kind = kind;
this.types = types;
this.size = size;
}
public CollectionDesc(String kind) {
this(kind, new ArrayList<CollectionTypeDesc>(), 0);
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public List<CollectionTypeDesc> getTypes() {
return types;
}
public void setTypes(List<CollectionTypeDesc> types) {
this.types = types;
}
public void addType(String type, int n) {
types.add(new CollectionTypeDesc(type, n));
this.size += n;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
@Override
public int compareTo(CollectionDesc o) {
return kind.compareTo(o.getKind());
}
}

@ -0,0 +1,35 @@
package eu.dnetlib.functionality.modular.ui.is.objects;
public class CollectionTypeDesc implements Comparable<CollectionTypeDesc> {
private String name;
private int size;
public CollectionTypeDesc() {}
public CollectionTypeDesc(String name, int size) {
this.name = name;
this.size = size;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
@Override
public int compareTo(CollectionTypeDesc o) {
return name.compareTo(o.getName());
}
}

@ -0,0 +1,72 @@
package eu.dnetlib.functionality.modular.ui.is.objects;
import java.util.ArrayList;
import java.util.List;
public class ServiceDesc {
public enum ServiceStatus {
UNKNOWN, ACTIVE, PENDING, NOT_RESPONDING, MISSING
}
private String id = "";
private String name = "";
private String wsdl = "";
private ServiceStatus status = ServiceStatus.UNKNOWN;
private List<SubscriptionDesc> subscriptions = new ArrayList<SubscriptionDesc>();
public ServiceDesc() {}
public ServiceDesc(final String id, final String name, final String wsdl) {
this(id, name, wsdl, ServiceStatus.UNKNOWN, new ArrayList<SubscriptionDesc>());
}
public ServiceDesc(final String id, final String name, final String wsdl, final ServiceStatus status, final List<SubscriptionDesc> subscriptions) {
this.id = id;
this.name = name;
this.wsdl = wsdl;
this.status = status;
this.subscriptions = subscriptions;
}
public String getId() {
return id;
}
public void setId(final String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getWsdl() {
return wsdl;
}
public void setWsdl(final String wsdl) {
this.wsdl = wsdl;
}
public ServiceStatus getStatus() {
return status;
}
public void setStatus(final ServiceStatus status) {
this.status = status;
}
public List<SubscriptionDesc> getSubscriptions() {
return subscriptions;
}
public void setSubscriptions(final List<SubscriptionDesc> subscriptions) {
this.subscriptions = subscriptions;
}
}

@ -0,0 +1,52 @@
package eu.dnetlib.functionality.modular.ui.is.objects;
import java.util.List;
public class ServiceGrouperDesc {
private String host;
private int port;
private String context;
private List<ServiceDesc> services;
public ServiceGrouperDesc() {}
public ServiceGrouperDesc(final String host, final int port, final String context, final List<ServiceDesc> services) {
this.host = host;
this.port = port;
this.context = context;
this.services = services;
}
public String getHost() {
return host;
}
public void setHost(final String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(final int port) {
this.port = port;
}
public String getContext() {
return context;
}
public void setContext(final String context) {
this.context = context;
}
public List<ServiceDesc> getServices() {
return services;
}
public void setServices(final List<ServiceDesc> services) {
this.services = services;
}
}

@ -0,0 +1,67 @@
package eu.dnetlib.functionality.modular.ui.is.objects;
import eu.dnetlib.enabling.is.sn.resourcestate.ResourceStateSubscription;
public class SubscriptionDesc {
private String id;
private String prefix;
private String type;
private String resourceId;
private String xpath;
public SubscriptionDesc() {}
public SubscriptionDesc(final ResourceStateSubscription sub) {
this(sub.getSubscriptionId(), sub.getPrefix(), sub.getType(), sub.getResourceId(), sub.getXpath());
}
public SubscriptionDesc(final String id, final String prefix, final String type, final String resourceId, final String xpath) {
this.id = id;
this.prefix = prefix;
this.type = type;
this.resourceId = resourceId;
this.xpath = xpath;
}
public String getId() {
return id;
}
public void setId(final String id) {
this.id = id;
}
public String getPrefix() {
return prefix;
}
public void setPrefix(final String prefix) {
this.prefix = prefix;
}
public String getType() {
return type;
}
public void setType(final String type) {
this.type = type;
}
public String getResourceId() {
return resourceId;
}
public void setResourceId(final String resourceId) {
this.resourceId = resourceId;
}
public String getXpath() {
return xpath;
}
public void setXpath(final String xpath) {
this.xpath = xpath;
}
}

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="modularUiProfileImporter" class="eu.dnetlib.functionality.modular.ui.is.bulk.ProfileImporter" />
</beans>

@ -0,0 +1,24 @@
$common/master( header={
<script type="text/javascript" src="../resources/js/angular.min.js" ></script>
<script type="text/javascript" src="../resources/js/angular-route.min.js"></script>
<script type="text/javascript" src="../resources/js/angular-local-storage.min.js"></script>
<script type="text/javascript" src="../resources/js/is_manager.js"></script>
<script type="text/javascript" src="../resources/js/is_manager_controllers.js"></script>
}, body={
<div ng-app="isManager" class="row">
<div class="col-sm-3 col-lg-2" ng-controller="moduleMenuCtrl">
<ul class="nav nav-pills nav-stacked">
<li ng-class="{active : isActive('^\/(list|profile|profiles)')}"><a href="#/list">Profiles</a></li>
<li ng-class="{active : isActive('^\/(schemas|schema)')}"><a href="#/schemas">Schemas</a></li>
<li ng-class="{active : isActive('^\/q')}"><a href="#/q">XQuery</a></li>
<li ng-class="{active : isActive('^\/services')}"><a href="#/services">Registered services</a></li>
<li ng-class="{active : isActive('^\/register')}"><a href="#/register">Register new profile</a></li>
<li ng-class="{active : isActive('^\/bulk')}"><a href="#/bulk">Bulk importer</a></li>
<li ng-class="{active : isActive('^\/verify')}"><a href="#/verify">Validation checker</a></li>
<li ng-class="{active : isActive('^\/blackboard')}"><a href="#/blackboard">Blackboard messages</a></li>
<li ng-class="{active : isActive('^\/backup')}"><a href="#/backup">Backup</a></li>
</ul>
</div>
<div ng-view class="col-sm-9 col-lg-10"></div>
</div>
} )$

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean name="/ui/isManager.do"
class="eu.dnetlib.functionality.modular.ui.is.InformationServiceEntryPointController"
p:menu="Information Service Inspector"
p:title="Information Service Inspector"
p:description="Information Service Inspector"
p:order="1"
p:group="Tools">
<property name="permissionLevels">
<set>
<value>IS_ADMIN</value>
</set>
</property>
</bean>
</beans>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<RESOURCE_PROFILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HEADER>
<RESOURCE_IDENTIFIER
value="c245e501-a19d-4647-bd9f-68e5db522a5a_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl" />
<RESOURCE_TYPE value="WorkflowDSResourceType" />
<RESOURCE_KIND value="WorkflowDSResources" />
<RESOURCE_URI value="" />
<DATE_OF_CREATION value="2014-07-29T10:15:51.0Z" />
</HEADER>
<BODY>
<WORKFLOW_NAME>IS-SN Backup</WORKFLOW_NAME>
<WORKFLOW_TYPE>IS_BACKUP</WORKFLOW_TYPE>
<WORKFLOW_PRIORITY>20</WORKFLOW_PRIORITY>
<CONFIGURATION start="auto">
<NODE name="backup" isStart="true">
<DESCRIPTION>Perform the backup of the IS-SN</DESCRIPTION>
<PARAMETERS />
<ARCS>
<ARC to="success" />
</ARCS>
</NODE>
</CONFIGURATION>
<STATUS />
</BODY>
</RESOURCE_PROFILE>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<RESOURCE_PROFILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HEADER>
<RESOURCE_IDENTIFIER
value="8426b094-1f35-471e-8431-e75732dfa134_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl" />
<RESOURCE_TYPE value="WorkflowDSResourceType" />
<RESOURCE_KIND value="WorkflowDSResources" />
<RESOURCE_URI value="" />
<DATE_OF_CREATION value="2014-07-29T10:15:51.0Z" />
</HEADER>
<BODY>
<WORKFLOW_NAME>IS-Store Backup</WORKFLOW_NAME>
<WORKFLOW_TYPE>IS_BACKUP</WORKFLOW_TYPE>
<WORKFLOW_PRIORITY>20</WORKFLOW_PRIORITY>
<CONFIGURATION start="auto">
<NODE name="backup" isStart="true">
<DESCRIPTION>Perform the backup of the IS-Store</DESCRIPTION>
<PARAMETERS />
<ARCS>
<ARC to="success" />
</ARCS>
</NODE>
</CONFIGURATION>
<STATUS />
</BODY>
</RESOURCE_PROFILE>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<RESOURCE_PROFILE>
<HEADER>
<RESOURCE_IDENTIFIER
value="f9c630f2-29f9-4196-a75f-1d208d7ef6dc_TWV0YVdvcmtmbG93RFNSZXNvdXJjZXMvTWV0YVdvcmtmbG93RFNSZXNvdXJjZVR5cGU=" />
<RESOURCE_TYPE value="MetaWorkflowDSResourceType" />
<RESOURCE_KIND value="MetaWorkflowDSResources" />
<RESOURCE_URI value="" />
<DATE_OF_CREATION value="2014-07-29T10:15:51.0Z" />
</HEADER>
<BODY>
<METAWORKFLOW_NAME family="IS_BACKUP">Backup</METAWORKFLOW_NAME>
<METAWORKFLOW_DESCRIPTION />
<METAWORKFLOW_SECTION>Information Service</METAWORKFLOW_SECTION>
<ADMIN_EMAIL />
<CONFIGURATION status="EXECUTABLE">
<WORKFLOW name="IS-Store Backup"
id="8426b094-1f35-471e-8431-e75732dfa134_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl">
<WORKFLOW name="IS-SN Backup"
id="c245e501-a19d-4647-bd9f-68e5db522a5a_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl" />
</WORKFLOW>
</CONFIGURATION>
<SCHEDULING enabled="false">
<CRON>29 5 22 ? * *</CRON>
<MININTERVAL>10080</MININTERVAL>
</SCHEDULING>
</BODY>
</RESOURCE_PROFILE>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<RESOURCE_PROFILE>
<HEADER>
<RESOURCE_IDENTIFIER
value="e5288425-c599-4194-80d1-62c51d526b34_TWV0YVdvcmtmbG93RFNSZXNvdXJjZXMvTWV0YVdvcmtmbG93RFNSZXNvdXJjZVR5cGU=" />
<RESOURCE_TYPE value="MetaWorkflowDSResourceType" />
<RESOURCE_KIND value="MetaWorkflowDSResources" />
<RESOURCE_URI value="" />
<DATE_OF_CREATION value="2014-07-29T10:15:51.0Z" />
</HEADER>
<BODY>
<METAWORKFLOW_NAME family="IS_VALIDATION">Revalidate profiles</METAWORKFLOW_NAME>
<METAWORKFLOW_DESCRIPTION />
<METAWORKFLOW_SECTION>Information Service</METAWORKFLOW_SECTION>
<ADMIN_EMAIL />
<CONFIGURATION status="EXECUTABLE">
<WORKFLOW name="Revalidate profiles"
id="54898c83-8dcd-4cfb-b092-8ba6697f658b_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl" />
</CONFIGURATION>
<SCHEDULING enabled="false">
<CRON>29 5 22 ? * *</CRON>
<MININTERVAL>10080</MININTERVAL>
</SCHEDULING>
</BODY>
</RESOURCE_PROFILE>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<RESOURCE_PROFILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HEADER>
<RESOURCE_IDENTIFIER
value="54898c83-8dcd-4cfb-b092-8ba6697f658b_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl" />
<RESOURCE_TYPE value="WorkflowDSResourceType" />
<RESOURCE_KIND value="WorkflowDSResources" />
<RESOURCE_URI value="" />
<DATE_OF_CREATION value="2014-07-29T10:15:51.0Z" />
</HEADER>
<BODY>
<WORKFLOW_NAME>Revalidate profiles</WORKFLOW_NAME>
<WORKFLOW_TYPE>IS_VALIDATION</WORKFLOW_TYPE>
<WORKFLOW_PRIORITY>20</WORKFLOW_PRIORITY>
<CONFIGURATION start="auto">
<NODE name="Validate" type="ValidateProfiles" isStart="true">
<DESCRIPTION>Perform the validation of the IS Profiles</DESCRIPTION>
<PARAMETERS />
<ARCS>
<ARC to="success" />
</ARCS>
</NODE>
</CONFIGURATION>
<STATUS />
</BODY>
</RESOURCE_PROFILE>

@ -0,0 +1,7 @@
for $x in collection("/db/DRIVER/ServiceResources/")/RESOURCE_PROFILE/HEADER
return
<service>
<id>{$x/RESOURCE_IDENTIFIER/@value/string()}</id>
<name>{replace($x/RESOURCE_TYPE/@value/string(),'ServiceResourceType$','')}</name>
<wsdl>{$x/RESOURCE_URI/@value/string()}</wsdl>
</service>

@ -0,0 +1,15 @@
<div class="well">
<div class="row" style="margin: 40px">
<button class="btn btn-lg btn-primary col-xs-4 col-xs-offset-4" ng-click="registerBackupWfs()">
<span class="glyphicon glyphicon-import pull-left"></span>Register backup workflows
</button>
</div>
<div class="row" style="margin: 40px">
<a class="btn btn-lg btn-default col-xs-4 col-xs-offset-4" ng-disabled="!metaWfId" href="workflows.do?section={{section | encodeURIComponent}}&metaWf={{metaWfId | encodeURIComponent}}">
<span class="glyphicon glyphicon-log-in pull-left"></span>Go to workflow page</a>
</div>
<div class="row" style="margin: 40px">
<a class="btn btn-lg btn-default col-xs-4 col-xs-offset-4" ng-disabled="!family" href="workflow_journal.do?family={{family}}">
<span class="glyphicon glyphicon-list pull-left"></span>Show history</a>
</div>
</div>

@ -0,0 +1,28 @@
<p>
<button class="btn btn-sm btn-default" ng-click="refresh()"><span class="glyphicon glyphicon-refresh"></span> refresh</button>
</p>
<table class="table table-striped small">
<thead>
<tr>
<th>Message Id</th>
<th>Resource Type</th>
<th class="text-center">Action</th>
<th class="text-center">Date</th>
<th class="text-center">Status</th>
<th class="text-center">Error</th>
</tr>
</thead>
<tbody>
<tr ng-show="blackboards.length == 0">
<td colspan="6">No blackboard messsages</td>
</tr>
<tr ng-repeat="b in blackboards">
<td><a href="#/profile/{{b.profId}}">{{b.messageId}}</a></td>
<td>{{b.resourceType}}</td>
<td class="text-center">{{b.action}}</td>
<td class="text-center">{{b.date}}</td>
<td class="text-center"><span class="label label-default" ng-class="{'label-primary': b.actionStatus=='ASSIGNED', 'label-success': b.actionStatus=='ONGOING', 'label-success': b.actionStatus=='DONE', 'label-danger': b.actionStatus=='FAILED'}">{{b.actionStatus}}</span></td>
<td class="text-center"><span class="text-danger glyphicon glyphicon-warning-sign" title="{{b.error}}" ng-show="b.error"></span></td>
</tr>
</tbody>
</table>

@ -0,0 +1,54 @@
<div class="well">
<fieldset>
<legend><h4>Bulk Importer</h4></legend>
<form role="form">
<div class="form-group">
<label for="bulkPathInput" class="control-label">BaseURL Directory:</label>
<input type="text" class="form-control" id="bulkPathInput" ng-model="path" />
</div>
<div class="checkbox" style="margin-top: 20px">
<label>
<input type="checkbox" ng-model="profiles" /> <b>Import profiles:</b> <i>{{path}}/**/*.xml</i>
</label>
</div>
<div class="checkbox" style="margin-top: 20px;">
<label>
<input type="checkbox" ng-model="schemas" /> <b>Import schemas:</b> <i>{{path}}/**/*.xsd</i>
</label>
</div>
<div style="margin-top: 30px;">
<b>Examples:</b>
<pre>file:///tmp/dnet_import
classpath*:/eu/dnetlib/test (use CAREFULLY to reload default profiles and schemas)</pre>
</div>
<button class="btn btn-default" ng-click="bulkImport()" style="margin-top: 30px;">Import</button>
</form>
<table class="table" ng-show="(response.schemasTotal != null) || (response.profilesTotal != null)">
<thead>
<tr>
<th></th>
<th class="text-center col-xs-3">Total</th>
<th class="text-center col-xs-3">Added</th>
<th class="text-center col-xs-3">Discarded</th>
</tr>
</thead>
<tbody>
<tr ng-show="response.schemasTotal != null">
<th>Schemas</th>
<td class="text-center col-xs-1">{{response.schemasTotal}}</td>
<td class="text-center col-xs-1">{{response.schemasDone}}</td>
<td class="text-center col-xs-1" ng-class="{'text-danger' : response.schemasDone < response.schemasTotal}">{{response.schemasTotal - response.schemasDone}}</td>
</tr>
<tr ng-show="response.profilesTotal != null">
<th>Profiles</th>
<td class="text-center col-xs-1">{{response.profilesTotal}}</td>
<td class="text-center col-xs-1">{{response.profilesDone}}</td>
<td class="text-center col-xs-1" ng-class="{'text-danger' : response.profilesDone < response.profilesTotal}">{{response.profilesTotal - response.profilesDone}}</td>
</tr>
</tbody>
</table>
</fieldset>
</div>

@ -0,0 +1,59 @@
<form role="form">
<div class="form-group">
<label for="xqueryInput" class="control-label">XQuery</label>
<textarea class="form-control" id="xqueryInput" ng-model="query" rows="10"></textarea>
</div>
<button class="btn btn-default" ng-click="searchXQuery()">Search</button>
<button class="btn btn-primary pull-right" data-toggle="modal" data-target="#xqueryHistoryModal">History</button>
</form>
<br />
<div class="panel panel-default" ng-show="error">
<div class="panel-heading">
<a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_error"><b>Error:</b> <i>{{error.message}}</i></a>
</div>
<div id="collapse_error" class="panel-collapse collapse in">
<div class="panel-body">
<pre>{{error.stacktrace}}</pre>
</div>
</div>
</div>
<p ng-hide="error"><b>Number of results:</b> {{results.length}}<br /></p>
<div class="panel panel-default" ng-repeat="r in results track by $index">
<div class="panel-heading">
<a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_{{$index}}"><b> Result: </b><i>{{$index + 1}}</i></a>
</div>
<div id="collapse_{{$index}}" class="panel-collapse collapse in">
<div class="panel-body">
<pre>{{r}}</pre>
</div>
</div>
</div>
<div id="xqueryHistoryModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">History</h4>
</div>
<div class="modal-body" style="height: 400px; overflow-y: scroll">
<p class="text-center" ng-show="history.length == 0">
<b>History is empty</b>
</p>
<div ng-repeat="e in history | reverse">
<span><a href="javascript:void(0)" data-dismiss="modal" ng-click="updateXQuery(e.query)">{{e.date | date:"yyyy-MM-dd HH:mm:ss"}}</a></span>
<pre>{{e.query}}</pre>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal">Clear history</button>
<button class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,17 @@
<div class="well">
<fieldset>
<legend>
<h4>List collections</h4>
</legend>
<ul>
<li ng-repeat="r in results" ng-show="r.size > 0">{{r.kind}}
<ul>
<li ng-repeat="t in r.types" ng-show="t.size > 0">{{t.name}}
<a href="#/profiles/{{r.kind}}/{{t.name}}">{{t.size}} profiles(s)</a>
</li>
</ul>
</li>
</ul>
</fieldset>
</div>

@ -0,0 +1,18 @@
<div class="row">
<div class="col-xs-12 col-md-10">
<h5><b>Profile</b> (ID: <i>{{id}}</i>)</h5>
</div>
<div class="col-xs-12 col-md-2">
<div class="pull-right" ng-show="profile && !editProfile">
<button class="btn btn-sm btn-danger" ng-click="deleteProfile()">Delete</button>
<button class="btn btn-sm btn-default" ng-click="startEditing()">Edit</button>
</div>
<div class="pull-right" ng-show="editProfile">
<button class="btn btn-sm btn-warning" ng-click="abortEditing()">Abort</button>
<button class="btn btn-sm btn-default" ng-click="saveEditing()">Save</button>
</div>
</div>
</div>
<pre ng-show="profile && !editProfile">{{profile}}</pre>
<textarea class="form-control" ng-show="editProfile" ng-model="editProfile" rows="400"></textarea>
<pre ng-hide="profile">The requested profile is missing</pre>

@ -0,0 +1,14 @@
<div class="well">
<p>
<b>path:</b> <i>{{path}}</i><br />
<b>size: </b><i>{{profiles.length}}</i>
</p>
<fieldset>
<legend>
<h4>Profiles</h4>
</legend>
<ol>
<li ng-repeat="id in profiles"><a href="#/profile/{{id}}">{{id}}</a></li>
</ol>
</fieldset>
</div>

@ -0,0 +1,7 @@
<form role="form">
<div class="form-group">
<label for="newProfileInput" class="control-label">New Profile</label>
<textarea class="form-control" id="newProfileInput" ng-model="profile" rows="10"></textarea>
</div>
<button class="btn btn-default" ng-click="register()">Register</button>
</form>

@ -0,0 +1,8 @@
<div class="row">
<div class="col-xs-9"><h4><b>Schema:</b> <i>{{name}}</i></h4></div>
<div class="col-xs-3">
<!-- <button class="btn btn-sm btn-default pull-right">edit</button> -->
</div>
</div>
<pre>{{schema}}</pre>

@ -0,0 +1,10 @@
<div class="well">
<fieldset>
<legend>
<h4>Registered schemas:</h4>
</legend>
<ol>
<li ng-repeat="s in schemas"><a href="#/schema/{{s}}">{{s}}</a></li>
</ol>
</fieldset>
</div>

@ -0,0 +1,76 @@
<table class="table table-striped small">
<thead>
<tr>
<th>#</th>
<th>Service</th>
<th>WSDL</th>
<th class="text-center">Status <button type="button" class="btn btn-xs btn-primary" ng-click="pingServices()">verify</button></th>
<th class="text-right">Subscriptions</th>
</tr>
</thead>
<tbody ng-repeat="group in groups">
<tr>
<th colspan="5">
Host: <i>{{group.host}}</i> - Port: <i>{{group.port}}</i> - Context: <i>{{group.context}}</i>
</th>
</tr>
<tr ng-show="group.services.length == 0">
<td colspan="6">No services</td>
</tr>
<tr ng-repeat="s in group.services">
<td>{{$index + 1}}</td>
<td>
<a href="#/profile/{{s.id}}" title="{{s.id}}" ng-show="s.id">{{s.name}}</a>
<span ng-hide="s.id" class="text-muted"><i>missing profile</i></span>
</td>
<td><a href="{{s.wsdl}}">{{s.wsdl}}</a></td>
<td class="text-center">
<span class="label" ng-class="{'label-success' : s.status == 'ACTIVE', 'label-danger' : s.status == 'NOT_RESPONDING' || s.status == 'MISSING', 'label-default' : s.status == 'UNKNOWN', 'label-warning' : s.status == 'PENDING'}">{{s.status}}</span>
</td>
<td class="text-right">
<a href="javascript:void(0)"
ng-show="s.subscriptions.length > 0"
data-toggle="modal" data-target="#subscriptionsModal"
ng-click="setSubscriptions(s.subscriptions)">{{s.subscriptions.length}} subscription(s)</a>
</td>
</tr>
</tbody>
</table>
<div id="subscriptionsModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Subscriptions</h4>
</div>
<div class="modal-body">
<div class="panel panel-info" ng-repeat="s in subscriptions">
<div class="panel-heading">{{s.id}}</div>
<table class="table table-condensed small">
<tr>
<th>Prefix</th>
<td>{{s.prefix}}</td>
</tr>
<tr>
<th>Resource type</th>
<td>{{s.type}}</td>
</tr>
<tr>
<th>Resource ID</th>
<td>{{s.resourceId}}</td>
</tr>
<tr>
<th>Xpath</th>
<td>{{s.xpath}}</td>
</tr>
</table>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,13 @@
<div class="well">
<div class="row" style="margin: 40px">
<button class="btn btn-lg btn-primary col-xs-4 col-xs-offset-4" ng-click="registerValidationWfs()">
<span class="glyphicon glyphicon-import pull-left"></span>Register validation workflows
</button>
</div>
<div class="row" style="margin: 40px">
<a class="btn btn-lg btn-default col-xs-4 col-xs-offset-4" ng-disabled="!metaWfId" href="workflows.do?section={{section | encodeURIComponent}}&metaWf={{metaWfId | encodeURIComponent}}"><span class="glyphicon glyphicon-log-in pull-left"></span>Go to workflow page</a>
</div>
<div class="row" style="margin: 40px">
<a class="btn btn-lg btn-default col-xs-4 col-xs-offset-4" ng-disabled="!family" href="workflow_journal.do?family={{family}}"><span class="glyphicon glyphicon-list pull-left"></span>Show history</a>
</div>
</div>

@ -0,0 +1,41 @@
var module = angular.module('isManager', ['ngRoute', 'isManagerControllers']);
module.config([
'$routeProvider',
function($routeProvider) {
$routeProvider
.when('/list', { templateUrl: '../resources/html/is/list.html', controller: 'listCollectionsCtrl' })
.when('/profiles/:kind/:type', { templateUrl: '../resources/html/is/profiles.html', controller: 'profilesCtrl' })
.when('/profile/:id', { templateUrl: '../resources/html/is/profile.html', controller: 'profileCtrl' })
.when('/schemas', { templateUrl: '../resources/html/is/schemas.html', controller: 'schemasCtrl' })
.when('/schema/:name', { templateUrl: '../resources/html/is/schema.html', controller: 'schemaCtrl' })
.when('/services', { templateUrl: '../resources/html/is/services.html', controller: 'servicesCtrl' })
.when('/q', { templateUrl: '../resources/html/is/isQuery.html', controller: 'isQueryCtrl' })
.when('/register', { templateUrl: '../resources/html/is/register.html', controller: 'registerProfileCtrl' })
.when('/bulk', { templateUrl: '../resources/html/is/bulk.html', controller: 'bulkImporterCtrl' })
.when('/verify', { templateUrl: '../resources/html/is/verify.html', controller: 'validateProvilesCtrl' })
.when('/blackboard', { templateUrl: '../resources/html/is/blackboard.html', controller: 'blackboardCtrl' })
.when('/backup', { templateUrl: '../resources/html/is/backup.html', controller: 'backupCtrl' })
.otherwise({ redirectTo: '/list' });
}
]);
module.controller('moduleMenuCtrl', [ '$scope', '$location',
function ($scope, $location) {
$scope.isActive = function(regex) {
var re = new RegExp(regex);
return re.test($location.path());
}
}
]);
module.filter('encodeURIComponent', function() {
return window.encodeURIComponent;
});
module.filter('reverse', function () {
return function(items) {
return items.slice().reverse();
}
});

@ -0,0 +1,426 @@
var isManagerControllers = angular.module('isManagerControllers', ['LocalStorageModule']);
function common_init($scope, $http, $sce, $location) {
initSpinner();
$scope.showError = function(error) { show_notification("error", error); }
$scope.showNotification = function(message) { show_notification("info", message); }
$scope.showSpinner = function() { showSpinner(); }
$scope.hideSpinner = function() { hideSpinner(); }
$scope.to_trusted = function(html) { return $sce.trustAsHtml(html); }
$scope.go = function(path) { $location.path(path); }
$scope.encodeValue = function(val) { return val; }
}
isManagerControllers.controller('listCollectionsCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.results = [];
$scope.showSpinner();
$http.get('is/listCollections.do').success(function(data) {
$scope.hideSpinner();
$scope.results = data;
}).error(function() {
$scope.showError('Error listing xmldb collections');
$scope.hideSpinner();
});
}
]);
isManagerControllers.controller('profilesCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.profiles = [];
$scope.path = '/db/DRIVER/' + $routeParams.kind + '/' + $routeParams.type;
$scope.showSpinner();
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
$http.post('is/listProfiles.do', $.param({
'kind' : $routeParams.kind,
'type' : $routeParams.type
})).success(function(data) {
$scope.hideSpinner();
$scope.profiles = data;
}).error(function() {
$scope.showError('Error listing xmldb collections');
$scope.hideSpinner();
});
}
]);
isManagerControllers.controller('profileCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.id = $routeParams.id;
$scope.profile = '';
$scope.editProfile = '';
$scope.showSpinner();
$http.get('is/getProfile.do?id=' + $scope.id).success(function(data) {
$scope.hideSpinner();
$scope.profile = data;
}).error(function() {
$scope.showError('Error retreiving profile');
$scope.hideSpinner();
});
$scope.deleteProfile = function() {
if (confirm("Are you sure ?")) {
$scope.showSpinner();
$http.get('is/deleteProfile.do?id=' + $scope.id).success(function(data) {
$scope.hideSpinner();
$scope.showNotification('Profile deleted !');
$scope.profile = '';
}).error(function() {
$scope.showError('Error deleting profile');
$scope.hideSpinner();
});
}
}
$scope.startEditing = function() {
$scope.editProfile = '' + $scope.profile;
}
$scope.abortEditing = function() {
$scope.editProfile = '';
}
$scope.saveEditing = function() {
$scope.showSpinner();
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
$http.post('is/updateProfile.do', $.param({
'profile' : $scope.editProfile
})).success(function(data) {
$scope.hideSpinner();
$scope.showNotification('Profile updated !');
$scope.profile = '' + $scope.editProfile;
$scope.editProfile = '';
}).error(function(err) {
$scope.showError(err.message);
$scope.hideSpinner();
});
}
}
]);
isManagerControllers.controller('schemasCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.schemas = [];
$scope.showSpinner();
$http.get('is/listSchemas.do').success(function(data) {
$scope.hideSpinner();
$scope.schemas = data;
}).error(function() {
$scope.showError('Error retreiving schemas');
$scope.hideSpinner();
});
}
]);
isManagerControllers.controller('schemaCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.name = $routeParams.name;
$scope.schema = '';
$scope.showSpinner();
$http.get('is/getSchema.do?name=' + $scope.name).success(function(data) {
$scope.hideSpinner();
$scope.schema = data;
}).error(function() {
$scope.showError('Error obtaining schema' + $scope.name);
$scope.hideSpinner();
});
}
]);
isManagerControllers.controller('servicesCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.groups = [];
$scope.subscriptions = [];
$scope.showSpinner();
$http.get('is/listServices.do').success(function(data) {
$scope.hideSpinner();
$scope.groups = data;
}).error(function() {
$scope.showError('Error obtaining services');
$scope.hideSpinner();
});
$scope.setSubscriptions = function(subscriptions) {
$scope.subscriptions = subscriptions;
}
$scope.pingServices = function() {
var list = [];
angular.forEach($scope.groups, function(group) {
angular.forEach(group.services, function(service) {
if (service.id && service.wsdl) {
service.status = 'UNKNOWN';
list.push(service);
}
});
});
$scope.ping(list, 0);
}
$scope.ping = function(list, pos) {
if (list.length == 0) { return; }
if (pos >= list.length) { $scope.hideSpinner(); return; }
if (pos == 0) { $scope.showSpinner(); }
$http.get('is/ping.do?timeout=1500&url='+encodeURIComponent(list[pos].wsdl)).success(function(data) {
list[pos].status = 'ACTIVE';
$scope.ping(list, pos + 1);
}).error(function() {
list[pos].status = 'NOT_RESPONDING';
$scope.ping(list, pos + 1);
});
}
}
]);
isManagerControllers.controller('isQueryCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams', 'localStorageService',
function ($scope, $http, $sce, $location, $routeParams, localStorageService) {
common_init($scope, $http, $sce, $location);
$scope.history = localStorageService.get('xquery_history');
if (!$scope.history) {
$scope.history = [];
}
$scope.query = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType') return $x";
$scope.error = null;
$scope.results = [];
$scope.searchXQuery = function() {
$scope.results = [];
$scope.error = null;
$scope.showSpinner();
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
$http.post('is/xquery.do', $.param({
'query' : $scope.query
})).success(function(data) {
$scope.hideSpinner();
$scope.results = data;
$scope.history.push({ 'date' : new Date(), 'query' : $scope.query });
if ($scope.history.length > 100) {
$scope.history = $scope.history.splice($scope.history.length - 100);
}
localStorageService.set('xquery_history', $scope.history);
}).error(function(err) {
$scope.error = err;
$scope.hideSpinner();
});
}
$scope.updateXQuery = function(q) {
$scope.query = q;
$scope.searchXQuery();
}
$scope.clearHistory = function() {
$scope.history = [];
localStorageService.set('xquery_history', []);
}
}
]);
isManagerControllers.controller('registerProfileCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.profile = '';
$scope.register = function() {
$scope.showSpinner();
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
$http.post('is/registerProfile.do', $.param({
'profile' : $scope.profile
})).success(function(id) {
$scope.hideSpinner();
$scope.go('/profile/' + id)
}).error(function() {
$scope.showError('Error registerting profile');
$scope.hideSpinner();
});
}
}
]);
isManagerControllers.controller('bulkImporterCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.path = 'file:///tmp/dnet_import';
$scope.schemas = true;
$scope.profiles = true;
$scope.response = {};
$scope.bulkImport = function() {
$scope.response = {};
$scope.showSpinner();
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
$http.post('is/import.do', $.param({
'path' : $scope.path,
'schemas' : $scope.schemas,
'profiles' : $scope.profiles
})).success(function(data) {
$scope.hideSpinner();
$scope.response = data;
}).error(function() {
$scope.showError('Error registerting profile');
$scope.hideSpinner();
});
}
}
]);
isManagerControllers.controller('validateProvilesCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.metaWfId = '';
$scope.section = '';
$scope.family = '';
$scope.getValidationMetaWfId = function() {
$scope.metaWfId = '';
$scope.section = '';
$scope.family = '';
$scope.showSpinner();
$http.get('is/getMetaWfIdForFamily.do?family=IS_VALIDATION').success(function(data) {
$scope.hideSpinner();
$scope.metaWfId = data.id;
$scope.section = data.section;
$scope.family = data.family;
}).error(function() {
$scope.showError('Metaworkflow not registered');
$scope.hideSpinner();
});
}
$scope.registerValidationWfs = function() {
$scope.metaWfId = '';
$scope.showSpinner();
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
$http.post('is/import.do', $.param({
'path' : 'classpath*:/eu/dnetlib/functionality/modular/workflows/validation',
'schemas' : false,
'profiles' : true
})).success(function(data) {
$scope.hideSpinner();
$scope.showNotification('Profiles are been registered');
$scope.getValidationMetaWfId();
}).error(function() {
$scope.showError('Error registering profiles');
$scope.hideSpinner();
});
}
$scope.getValidationMetaWfId();
}
]);
isManagerControllers.controller('blackboardCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.refresh = function() {
$scope.blackboards = [];
$scope.showSpinner();
$http.get('is/listBlackboards.do').success(function(data) {
$scope.hideSpinner();
$scope.blackboards = data;
}).error(function() {
$scope.showError('Error retreiving schemas');
$scope.hideSpinner();
});
}
$scope.refresh();
}
]);
isManagerControllers.controller('backupCtrl', [
'$scope', '$http', '$sce', '$location', '$routeParams',
function ($scope, $http, $sce, $location, $routeParams) {
common_init($scope, $http, $sce, $location);
$scope.metaWfId = '';
$scope.section = '';
$scope.family = '';
$scope.getBackupMetaWfId = function() {
$scope.metaWfId = '';
$scope.section = '';
$scope.family = '';
$scope.showSpinner();
$http.get('is/getMetaWfIdForFamily.do?family=IS_BACKUP').success(function(data) {
$scope.hideSpinner();
$scope.metaWfId = data.id;
$scope.section = data.section;
$scope.family = data.family;
}).error(function() {
$scope.showError('Metaworkflow not registered');
$scope.hideSpinner();
});
}
$scope.registerBackupWfs = function() {
$scope.metaWfId = '';
$scope.showSpinner();
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
$http.post('is/import.do', $.param({
'path' : 'classpath*:/eu/dnetlib/functionality/modular/workflows/backup',
'schemas' : false,
'profiles' : true
})).success(function(data) {
$scope.hideSpinner();
$scope.showNotification('Profiles are been registered');
$scope.getBackupMetaWfId();
}).error(function() {
$scope.showError('Error registering profiles');
$scope.hideSpinner();
});
}
$scope.getBackupMetaWfId();
}
]);
Loading…
Cancel
Save