From 77292eb8537168a94255739ad8f590a35a74788f Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Wed, 24 Jul 2019 16:17:54 +0200 Subject: [PATCH] imported information system modular UIs --- ...nformationServiceEntryPointController.java | 17 + .../InformationServiceInternalController.java | 307 +++++++++++++ .../modular/ui/is/bulk/ProfileImporter.java | 103 +++++ .../ui/is/objects/BlackboardMessage.java | 79 ++++ .../modular/ui/is/objects/CollectionDesc.java | 59 +++ .../ui/is/objects/CollectionTypeDesc.java | 35 ++ .../modular/ui/is/objects/ServiceDesc.java | 72 +++ .../ui/is/objects/ServiceGrouperDesc.java | 52 +++ .../ui/is/objects/SubscriptionDesc.java | 67 +++ .../ui/applicationContext-modular-ui-is.xml | 19 + .../modular/ui/views/ui/isManager.st | 24 + .../modular/ui/webContext-modular-ui-is.xml | 32 ++ .../modular/workflows/backup/backup-issn.xml | 26 ++ .../workflows/backup/backup-isstore.xml | 26 ++ .../workflows/backup/backup-metawf.xml | 28 ++ .../validation/validation-metawf.xml | 25 + .../workflows/validation/validation.xml | 26 ++ .../modular/xquery/listServices.xquery | 7 + .../dnetlib/web/resources/html/is/backup.html | 15 + .../web/resources/html/is/blackboard.html | 28 ++ .../dnetlib/web/resources/html/is/bulk.html | 54 +++ .../web/resources/html/is/isQuery.html | 59 +++ .../dnetlib/web/resources/html/is/list.html | 17 + .../web/resources/html/is/profile.html | 18 + .../web/resources/html/is/profiles.html | 14 + .../web/resources/html/is/register.html | 7 + .../dnetlib/web/resources/html/is/schema.html | 8 + .../web/resources/html/is/schemas.html | 10 + .../web/resources/html/is/services.html | 76 ++++ .../dnetlib/web/resources/html/is/verify.html | 13 + .../eu/dnetlib/web/resources/js/is_manager.js | 41 ++ .../resources/js/is_manager_controllers.js | 426 ++++++++++++++++++ 32 files changed, 1790 insertions(+) create mode 100644 dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceEntryPointController.java create mode 100644 dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceInternalController.java create mode 100644 dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/bulk/ProfileImporter.java create mode 100644 dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/BlackboardMessage.java create mode 100644 dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/CollectionDesc.java create mode 100644 dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/CollectionTypeDesc.java create mode 100644 dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/ServiceDesc.java create mode 100644 dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/ServiceGrouperDesc.java create mode 100644 dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/SubscriptionDesc.java create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/applicationContext-modular-ui-is.xml create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/isManager.st create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-is.xml create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-issn.xml create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-isstore.xml create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-metawf.xml create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/validation/validation-metawf.xml create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/validation/validation.xml create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/xquery/listServices.xquery create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/backup.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/blackboard.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/bulk.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/isQuery.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/list.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/profile.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/profiles.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/register.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/schema.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/schemas.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/services.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/verify.html create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/js/is_manager.js create mode 100644 dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/js/is_manager_controllers.js diff --git a/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceEntryPointController.java b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceEntryPointController.java new file mode 100644 index 0000000..02406cc --- /dev/null +++ b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceEntryPointController.java @@ -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 { + + } + +} diff --git a/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceInternalController.java b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceInternalController.java new file mode 100644 index 0000000..6d580be --- /dev/null +++ b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/InformationServiceInternalController.java @@ -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 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 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 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 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 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 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 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 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 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 listBlackboards() throws Exception { + final List 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 {$x/../../..//RESOURCE_TYPE}{$x/../../..//RESOURCE_IDENTIFIER}{$x}")) { + 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 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 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 listServices() throws Exception { + final String xq = IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/xquery/listServices.xquery")); + + final List 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 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())); + } + 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(); + } + +} diff --git a/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/bulk/ProfileImporter.java b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/bulk/ProfileImporter.java new file mode 100644 index 0000000..9a58370 --- /dev/null +++ b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/bulk/ProfileImporter.java @@ -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 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 res = Maps.newHashMap(); + res.put("schemasDone", done); + res.put("schemasTotal", total); + + return res; + } + + public Map 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 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; + } + +} diff --git a/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/BlackboardMessage.java b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/BlackboardMessage.java new file mode 100644 index 0000000..0e79b95 --- /dev/null +++ b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/BlackboardMessage.java @@ -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; + } +} diff --git a/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/CollectionDesc.java b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/CollectionDesc.java new file mode 100644 index 0000000..3ecf957 --- /dev/null +++ b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/CollectionDesc.java @@ -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 { + private String kind; + private int size = 0; + private List types = Lists.newArrayList(); + + public CollectionDesc() {} + + public CollectionDesc(String kind, List types, int size) { + this.kind = kind; + this.types = types; + this.size = size; + } + + public CollectionDesc(String kind) { + this(kind, new ArrayList(), 0); + } + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + public List getTypes() { + return types; + } + + public void setTypes(List 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()); + } + +} diff --git a/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/CollectionTypeDesc.java b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/CollectionTypeDesc.java new file mode 100644 index 0000000..2b5c856 --- /dev/null +++ b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/CollectionTypeDesc.java @@ -0,0 +1,35 @@ +package eu.dnetlib.functionality.modular.ui.is.objects; + +public class CollectionTypeDesc implements Comparable { + 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()); + } + +} diff --git a/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/ServiceDesc.java b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/ServiceDesc.java new file mode 100644 index 0000000..b961183 --- /dev/null +++ b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/ServiceDesc.java @@ -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 subscriptions = new ArrayList(); + + public ServiceDesc() {} + + public ServiceDesc(final String id, final String name, final String wsdl) { + this(id, name, wsdl, ServiceStatus.UNKNOWN, new ArrayList()); + } + + public ServiceDesc(final String id, final String name, final String wsdl, final ServiceStatus status, final List 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 getSubscriptions() { + return subscriptions; + } + + public void setSubscriptions(final List subscriptions) { + this.subscriptions = subscriptions; + } + +} diff --git a/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/ServiceGrouperDesc.java b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/ServiceGrouperDesc.java new file mode 100644 index 0000000..52728ea --- /dev/null +++ b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/ServiceGrouperDesc.java @@ -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 services; + + public ServiceGrouperDesc() {} + + public ServiceGrouperDesc(final String host, final int port, final String context, final List 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 getServices() { + return services; + } + + public void setServices(final List services) { + this.services = services; + } +} diff --git a/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/SubscriptionDesc.java b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/SubscriptionDesc.java new file mode 100644 index 0000000..f8b7b25 --- /dev/null +++ b/dnet-modular-ui/src/main/java/eu/dnetlib/functionality/modular/ui/is/objects/SubscriptionDesc.java @@ -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; + } + +} diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/applicationContext-modular-ui-is.xml b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/applicationContext-modular-ui-is.xml new file mode 100644 index 0000000..1993b4a --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/applicationContext-modular-ui-is.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/isManager.st b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/isManager.st new file mode 100644 index 0000000..20c0e80 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/isManager.st @@ -0,0 +1,24 @@ +$common/master( header={ + + + + + +}, body={ + +} )$ diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-is.xml b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-is.xml new file mode 100644 index 0000000..4f72191 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-is.xml @@ -0,0 +1,32 @@ + + + + + + + + IS_ADMIN + + + + + diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-issn.xml b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-issn.xml new file mode 100644 index 0000000..569773e --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-issn.xml @@ -0,0 +1,26 @@ + + +
+ + + + + +
+ + IS-SN Backup + IS_BACKUP + 20 + + + Perform the backup of the IS-SN + + + + + + + + +
\ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-isstore.xml b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-isstore.xml new file mode 100644 index 0000000..aece721 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-isstore.xml @@ -0,0 +1,26 @@ + + +
+ + + + + +
+ + IS-Store Backup + IS_BACKUP + 20 + + + Perform the backup of the IS-Store + + + + + + + + +
diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-metawf.xml b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-metawf.xml new file mode 100644 index 0000000..e86b989 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/backup/backup-metawf.xml @@ -0,0 +1,28 @@ + + +
+ + + + + +
+ + Backup + + Information Service + + + + + + + + 29 5 22 ? * * + 10080 + + +
diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/validation/validation-metawf.xml b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/validation/validation-metawf.xml new file mode 100644 index 0000000..0242e2e --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/validation/validation-metawf.xml @@ -0,0 +1,25 @@ + + +
+ + + + + +
+ + Revalidate profiles + + Information Service + + + + + + 29 5 22 ? * * + 10080 + + +
diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/validation/validation.xml b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/validation/validation.xml new file mode 100644 index 0000000..7d5f335 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/workflows/validation/validation.xml @@ -0,0 +1,26 @@ + + +
+ + + + + +
+ + Revalidate profiles + IS_VALIDATION + 20 + + + Perform the validation of the IS Profiles + + + + + + + + +
diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/xquery/listServices.xquery b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/xquery/listServices.xquery new file mode 100644 index 0000000..7bdf9f8 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/functionality/modular/xquery/listServices.xquery @@ -0,0 +1,7 @@ +for $x in collection("/db/DRIVER/ServiceResources/")/RESOURCE_PROFILE/HEADER +return + + {$x/RESOURCE_IDENTIFIER/@value/string()} + {replace($x/RESOURCE_TYPE/@value/string(),'ServiceResourceType$','')} + {$x/RESOURCE_URI/@value/string()} + \ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/backup.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/backup.html new file mode 100644 index 0000000..fe22062 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/backup.html @@ -0,0 +1,15 @@ +
+
+ +
+ + +
\ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/blackboard.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/blackboard.html new file mode 100644 index 0000000..2771de2 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/blackboard.html @@ -0,0 +1,28 @@ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
Message IdResource TypeActionDateStatusError
No blackboard messsages
{{b.messageId}}{{b.resourceType}}{{b.action}}{{b.date}}{{b.actionStatus}}
\ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/bulk.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/bulk.html new file mode 100644 index 0000000..8d91574 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/bulk.html @@ -0,0 +1,54 @@ +
+
+

Bulk Importer

+
+
+ + +
+
+ +
+
+ +
+
+ Examples: +
file:///tmp/dnet_import			
+classpath*:/eu/dnetlib/test (use CAREFULLY to reload default profiles and schemas)
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
TotalAddedDiscarded
Schemas{{response.schemasTotal}}{{response.schemasDone}}{{response.schemasTotal - response.schemasDone}}
Profiles{{response.profilesTotal}}{{response.profilesDone}}{{response.profilesTotal - response.profilesDone}}
+ + +
+
\ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/isQuery.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/isQuery.html new file mode 100644 index 0000000..b5abf2f --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/isQuery.html @@ -0,0 +1,59 @@ +
+
+ + +
+ + +
+
+ +
+ +
+
+
{{error.stacktrace}}
+
+
+
+ + +

Number of results: {{results.length}}

+ +
+ +
+
+
{{r}}
+
+
+
+ + + diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/list.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/list.html new file mode 100644 index 0000000..f3008c4 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/list.html @@ -0,0 +1,17 @@ +
+
+ +

List collections

+
+ + +
+
\ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/profile.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/profile.html new file mode 100644 index 0000000..2379dd6 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/profile.html @@ -0,0 +1,18 @@ +
+
+
Profile (ID: {{id}})
+
+
+
+ + +
+
+ + +
+
+
+
{{profile}}
+ +
The requested profile is missing
\ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/profiles.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/profiles.html new file mode 100644 index 0000000..9587416 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/profiles.html @@ -0,0 +1,14 @@ +
+

+ path: {{path}}
+ size: {{profiles.length}} +

+
+ +

Profiles

+
+
    +
  1. {{id}}
  2. +
+
+
diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/register.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/register.html new file mode 100644 index 0000000..4280898 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/register.html @@ -0,0 +1,7 @@ +
+
+ + +
+ +
diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/schema.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/schema.html new file mode 100644 index 0000000..5a29388 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/schema.html @@ -0,0 +1,8 @@ +
+

Schema: {{name}}

+
+ +
+
+ +
{{schema}}
\ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/schemas.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/schemas.html new file mode 100644 index 0000000..0a9dbf2 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/schemas.html @@ -0,0 +1,10 @@ +
+
+ +

Registered schemas:

+
+
    +
  1. {{s}}
  2. +
+
+
diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/services.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/services.html new file mode 100644 index 0000000..9f1ce61 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/services.html @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
#ServiceWSDLStatus Subscriptions
+ Host: {{group.host}} - Port: {{group.port}} - Context: {{group.context}} +
No services
{{$index + 1}} + {{s.name}} + missing profile + {{s.wsdl}} + {{s.status}} + + {{s.subscriptions.length}} subscription(s) +
+ + diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/verify.html b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/verify.html new file mode 100644 index 0000000..68a7b36 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/html/is/verify.html @@ -0,0 +1,13 @@ +
+
+ +
+ + +
diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/js/is_manager.js b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/js/is_manager.js new file mode 100644 index 0000000..b65f2f0 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/js/is_manager.js @@ -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(); + } +}); \ No newline at end of file diff --git a/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/js/is_manager_controllers.js b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/js/is_manager_controllers.js new file mode 100644 index 0000000..7d41d33 --- /dev/null +++ b/dnet-modular-ui/src/main/resources/eu/dnetlib/web/resources/js/is_manager_controllers.js @@ -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(); + } +]);