Skip to content

Commit

Permalink
Move the MDUI statistics generator into /charting
Browse files Browse the repository at this point in the history
With this change, the MDUI charting is based on the cached monthly
aggregate rather than being dependent on the current registered
metadata on the day the script happens to be run. This means it can
be run retrospectively as far back as 2012, when we started
including registrationAuthority metadata.
  • Loading branch information
iay committed Nov 7, 2016
1 parent 6f2320d commit b21288b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 52 deletions.
27 changes: 0 additions & 27 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2223,33 +2223,6 @@
x="${build.dir}/list_uiinfo.xsl"/>
</target>

<!--
*******************************
*** ***
*** M D U I S T A T S ***
*** ***
*******************************
-->

<target name="mdui.stats">
<input addproperty="channel">
Please select the channel to use (e.g., us_incommon):
</input>
<if>
<equals arg1="${channel}" arg2="uk"/>
<then>
<CHANNEL.do verb="collect" channel="uk"/>
<XALAN.noout i="${mdx.dir}/uk/collected.xml"
x="${build.dir}/statistics_mdui.xsl"/>
</then>
<else>
<CHANNEL.do verb="importRaw" channel="${channel}"/>
<XALAN.noout i="${mdx.dir}/${channel}/imported.xml"
x="${build.dir}/statistics_mdui.xsl"/>
</else>
</if>
</target>

<!--
*******************************
*** ***
Expand Down
36 changes: 36 additions & 0 deletions charting/mdui.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env perl -w

#
# mdui.pl
#
use lib "../build";
use Xalan;
use Months;

# Parse command line arguments
use Getopt::Long;
my $allMonths;
my $oneYear;
GetOptions('all' => \$allMonths, 'year' => \$oneYear);

# By default, only show results for the most recent month
if ($allMonths) {
# leave table intact
} elsif ($oneYear) {
# reduce months table to just the last 12 entries
@months = @months[-12..-1];
} else {
# reduce months table to one element
@months = @months[-1..-1];
}

# ingest files
foreach $month (@months) {
print "Processing $month\n";

my $command = xalanCall . " -IN cache/$month.xml -XSL statistics_mdui.xsl";
# print "command is $command\n";
system($command); # || print "ignoring claimed failure in sub command\n";
# print "Xalan run on $fn\n";
print "\n";
}
52 changes: 27 additions & 25 deletions build/statistics_mdui.xsl → charting/statistics_mdui.xsl
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
statistics_mdui.xsl
XSL stylesheet taking a metadata aggregate and giving some statistics about MDUI
element use as textual output.
Author: Ian A. Young <ian@iay.org.uk>
-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:math="http://exslt.org/math"
Expand All @@ -22,111 +23,112 @@
version="1.0">

<xsl:output method="text" omit-xml-declaration="yes"/>

<xsl:template match="/md:EntitiesDescriptor">

<xsl:variable name="entities" select="//md:EntityDescriptor"/>

<xsl:variable name="entities" select="//md:EntityDescriptor
[descendant::mdrpi:RegistrationInfo/@registrationAuthority='http://ukfederation.org.uk']"/>
<xsl:variable name="idps" select="$entities[md:IDPSSODescriptor]"/>
<xsl:variable name="sps" select="$entities[md:SPSSODescriptor]"/>

<xsl:call-template name="entities.category">
<xsl:with-param name="category">Total entities</xsl:with-param>
<xsl:with-param name="entities" select="$entities"/>
</xsl:call-template>

<xsl:call-template name="entities.category">
<xsl:with-param name="category">Identity providers</xsl:with-param>
<xsl:with-param name="entities" select="$idps"/>
</xsl:call-template>

<xsl:call-template name="entities.category">
<xsl:with-param name="category">Service providers</xsl:with-param>
<xsl:with-param name="entities" select="$sps"/>
</xsl:call-template>

</xsl:template>

<xsl:template name="entities.category">
<xsl:param name="entities"/>
<xsl:param name="category"/>
<xsl:variable name="entities.count" select="count($entities)"/>

<xsl:value-of select="$category"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="$entities.count"/>
<xsl:text>&#10;</xsl:text>

<xsl:if test="$entities.count > 0">

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:UIInfo</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:UIInfo]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:Logo</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:Logo]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:Description</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:Description]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:DisplayName</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:DisplayName]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:Keywords</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:Keywords]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:InformationURL</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:InformationURL]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:PrivacyStatementURL</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:PrivacyStatementURL]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:DiscoHints</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:DiscoHints]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:IPHint</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:IPHint]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:DomainHint</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:DomainHint]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

<xsl:call-template name="mdui.element">
<xsl:with-param name="element">mdui:GeolocationHint</xsl:with-param>
<xsl:with-param name="has" select="$entities[descendant::mdui:GeolocationHint]"/>
<xsl:with-param name="total.count" select="$entities.count"/>
</xsl:call-template>

</xsl:if>
</xsl:template>

<xsl:template name="mdui.element">
<xsl:param name="element"/>
<xsl:param name="has"/>
Expand All @@ -142,5 +144,5 @@
<xsl:text>)&#10;</xsl:text>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

0 comments on commit b21288b

Please sign in to comment.