<?xml version="1.0" encoding="UTF-8"?>
<!--

    The contents of this file are subject to the license and copyright
    detailed in the LICENSE and NOTICE files at the root of the source
    tree and available online at

    http://www.dspace.org/license/

-->

<!--

The Dashboard Aspect is responsible providing a dashboard for statistical inquiries to the system.

-->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
    <map:components>

        <map:transformers>
            <map:transformer name="ElasticSearchStatsViewer" src="org.dspace.app.xmlui.aspect.statisticsElasticSearch.ElasticSearchStatsViewer"/>
            <map:transformer name="RestrictedItem" src="org.dspace.app.xmlui.aspect.artifactbrowser.RestrictedItem"/>
            <map:transformer name="Navigation" src="org.dspace.app.xmlui.aspect.statisticsElasticSearch.Navigation"/>
        </map:transformers>

        <map:matchers default="wildcard">
            <map:matcher name="HandleTypeMatcher" src="org.dspace.app.xmlui.aspect.general.HandleTypeMatcher"/>
			<map:matcher name="StatisticsAuthorizedMatcher" src="org.dspace.app.xmlui.aspect.statistics.StatisticsAuthorizedMatcher"/>
		</map:matchers>

        <map:selectors>
            <map:selector name="AuthenticatedSelector" src="org.dspace.app.xmlui.aspect.general.AuthenticatedSelector"/>
            <map:selector name="SpecifiedGroupAuthenticatedSelector" src="org.dspace.app.xmlui.aspect.statisticsElasticSearch.SpecifiedGroupAuthenticatedSelector"/>
        </map:selectors>

    </map:components>

    <map:pipelines>
        <map:pipeline>

            <map:generate/>

            <!--Only show the stats link if we have read rights-->
            <map:match pattern="handle/*/**">
                <map:match type="StatisticsAuthorizedMatcher" pattern="READ">
                        <map:transform type="Navigation"/>
                </map:match>
            </map:match>


            <map:match pattern="handle/*/*/stats">
                <map:select type="SpecifiedGroupAuthenticatedSelector">
                    <map:when test="statistics_viewer">
                        <map:transform type="IncludePageMeta">
                            <map:parameter name="stylesheet.screen.statisticsElasticSearch#1" value="../../static/css/statisticsElasticSearch/style.css"/>
                            <map:parameter name="javascript.url#1" value="https://www.google.com/jsapi" />
                            <map:parameter name="javascript.static#1" value="loadJQuery.js"/>
                            <map:parameter name="javascript.static#2" value="static/js/statisticsElasticSearch/jquery.ui.datepicker-accessible.min.js"/>
                            <map:parameter name="javascript.static#3" value="static/js/statisticsElasticSearch/visualizeData.js"/>
                        </map:transform>
                        <map:transform type="ElasticSearchStatsViewer"/>
                    </map:when>
                    <map:otherwise>
                        <map:match type="StatisticsAuthorizedMatcher" pattern="READ">
                            <map:transform type="IncludePageMeta">
                                <map:parameter name="stylesheet.screen.statisticsElasticSearch#1" value="../../static/css/statisticsElasticSearch/style.css"/>
                                <map:parameter name="javascript.url#1" value="https://www.google.com/jsapi" />
                                <map:parameter name="javascript.static#1" value="loadJQuery.js"/>
                                <map:parameter name="javascript.static#2" value="static/js/statisticsElasticSearch/jquery.ui.datepicker-accessible.min.js"/>
                                <map:parameter name="javascript.static#3" value="static/js/statisticsElasticSearch/visualizeData.js"/>
                            </map:transform>
                            <map:transform type="ElasticSearchStatsViewer"/>
                        </map:match>

                        <map:match type="StatisticsAuthorizedMatcher" pattern="!READ">
                            <map:select type="SpecifiedGroupAuthenticatedSelector">
                                <map:when test="statistics_viewer">
                                    <map:transform type="RestrictedItem"/>
                                    <map:serialize/>
                                </map:when>
                                <map:otherwise>
                                    <map:act type="StartAuthentication">
                                        <map:parameter name="header" value="xmlui.ArtifactBrowser.RestrictedItem.auth_header"/>
                                        <map:parameter name="message" value="xmlui.ArtifactBrowser.RestrictedItem.auth_message"/>
                                    </map:act>
                                    <map:serialize/>
                                </map:otherwise>
                            </map:select>
                        </map:match>
                        <map:serialize type="xml"/>
                    </map:otherwise>
                </map:select>
            </map:match>

            <map:match pattern="handle/*/*/stats/*">
                <map:select type="SpecifiedGroupAuthenticatedSelector">
                    <map:when test="statistics_viewer">
                        <map:transform type="IncludePageMeta">
                            <map:parameter name="stylesheet.screen.statisticsElasticSearch#1" value="../../static/css/statisticsElasticSearch/style.css"/>
                            <map:parameter name="javascript.url#1" value="https://www.google.com/jsapi" />
                            <map:parameter name="javascript.static#1" value="loadJQuery.js"/>
                            <map:parameter name="javascript.static#2" value="static/js/statisticsElasticSearch/jquery.ui.datepicker-accessible.min.js"/>
                            <map:parameter name="javascript.static#3" value="static/js/statisticsElasticSearch/visualizeData.js"/>
                        </map:transform>
                        <map:transform type="ElasticSearchStatsViewer"/>
                    </map:when>
                    <map:otherwise>
                        <map:match type="StatisticsAuthorizedMatcher" pattern="READ">
                            <map:transform type="IncludePageMeta">
                                <map:parameter name="stylesheet.screen.statisticsElasticSearch#1" value="../../static/css/statisticsElasticSearch/style.css"/>
                                <map:parameter name="javascript.url#1" value="https://www.google.com/jsapi" />
                                <map:parameter name="javascript.static#1" value="loadJQuery.js"/>
                                <map:parameter name="javascript.static#2" value="static/js/statisticsElasticSearch/jquery.ui.datepicker-accessible.min.js"/>
                                <map:parameter name="javascript.static#3" value="static/js/statisticsElasticSearch/visualizeData.js"/>
                            </map:transform>
                            <map:transform type="ElasticSearchStatsViewer"/>
                        </map:match>

                        <map:match type="StatisticsAuthorizedMatcher" pattern="!READ">
                            <map:select type="AuthenticatedSelector">
                                <map:when test="eperson">
                                    <map:transform type="RestrictedItem"/>
                                    <map:serialize/>
                                </map:when>
                                <map:otherwise>
                                    <map:act type="StartAuthentication">
                                        <map:parameter name="header" value="xmlui.ArtifactBrowser.RestrictedItem.auth_header"/>
                                        <map:parameter name="message" value="xmlui.ArtifactBrowser.RestrictedItem.auth_message"/>
                                    </map:act>
                                    <map:serialize/>
                                </map:otherwise>
                            </map:select>
                        </map:match>
                        <map:serialize type="xml"/>
                    </map:otherwise>
                </map:select>
            </map:match>

            <!-- Not a URL we care about, so just pass it on. -->
            <map:serialize type="xml"/>

        </map:pipeline>
    </map:pipelines>
</map:sitemap>
