mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
14.34.2007 67e18193aaa82a4c7052eaf1ca4dc668e5492716
Modify the aggregation definition property stylesheet to generate two server-side getter methods for each aggregation property. The first is a "default" getter of the form:

String getXXX()
SortedSet<String> getXXX()

Where XXX is the name of the property. This getter follows the same pattern as all other property getters. In this case it returns a String (or set of Strings) containing the common name(s) of the referenced component(s).

The second server-side getter is of the form:

DN getXXXDN()
SortedSet<DN> getXXXDNs()

Where again XXX is the name of the property. This getter returns the distinguished name(s) associated with the referenced component(s). It is useful on the server-side where component implementations need to retrieve referenced implementations from a DirectoryServer table based on their DN.
1 files modified
124 ■■■■■ changed files
opends/resource/admin/property-types/aggregation.xsl 124 ●●●●● patch | view | raw | blame | history
opends/resource/admin/property-types/aggregation.xsl
@@ -46,12 +46,21 @@
      <xsl:value-of select="'.meta.'" />
      <xsl:call-template name="get-definition-type" />
    </xsl:element>
    <xsl:if test="../../@multi-valued = 'true'">
      <import>java.util.TreeSet</import>
    </xsl:if>
    <import>org.opends.server.admin.ManagedObjectPath</import>
    <import>org.opends.server.admin.AggregationPropertyDefinition</import>
  </xsl:template>
  <xsl:template match="adm:aggregation" mode="java-value-type">
    <xsl:value-of select="'String'" />
  </xsl:template>
  <xsl:template match="adm:aggregation" mode="java-value-imports">
    <xsl:param name="interface" select="/.." />
    <xsl:if test="$interface = 'server'">
      <import>org.opends.server.types.DN</import>
    </xsl:if>
  </xsl:template>
  <xsl:template match="adm:aggregation" mode="java-definition-type">
    <xsl:value-of select="'AggregationPropertyDefinition'" />
  </xsl:template>
@@ -110,6 +119,121 @@
    <xsl:value-of select="');&#xa;'" />
  </xsl:template>
  <!--
    Generate property getter declaration(s).
  -->
  <xsl:template match="adm:aggregation"
    mode="java-property-getter-declaration">
    <xsl:param name="interface" select="/.." />
    <xsl:call-template
      name="generate-default-property-getter-declaration">
      <xsl:with-param name="interface" select="$interface" />
    </xsl:call-template>
    <xsl:if test="$interface='server'">
      <xsl:variable name="name" select="../../@name" />
      <xsl:variable name="java-property-name">
        <xsl:call-template name="name-to-java">
          <xsl:with-param name="value" select="$name" />
        </xsl:call-template>
      </xsl:variable>
      <xsl:variable name="comment">
        <xsl:if test="../../adm:synopsis">
          <xsl:value-of select="'&lt;p&gt;&#xa;'" />
          <xsl:value-of select="normalize-space(../../adm:synopsis)" />
          <xsl:value-of select="'&#xa;'" />
        </xsl:if>
        <xsl:if test="../../adm:description">
          <xsl:value-of select="'&lt;p&gt;&#xa;'" />
          <xsl:value-of select="normalize-space(../../adm:description)" />
          <xsl:value-of select="'&#xa;'" />
        </xsl:if>
      </xsl:variable>
      <xsl:text>&#xa;</xsl:text>
      <xsl:text>&#xa;</xsl:text>
      <xsl:text>&#xa;</xsl:text>
      <xsl:choose>
        <xsl:when test="string(../../@multi-valued) != 'true'">
          <xsl:call-template name="add-java-comment2">
            <xsl:with-param name="indent" select="2" />
            <xsl:with-param name="content"
              select="concat(
                       'Gets the &quot;', $name,'&quot; property as a DN.&#xa;',
                       $comment,
                       '&#xa;',
                       '@return Returns the DN value of the &quot;', $name, '&quot; property.&#xa;')" />
          </xsl:call-template>
          <xsl:value-of
            select="concat('  DN get', $java-property-name, 'DN();&#xa;')" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="add-java-comment2">
            <xsl:with-param name="indent" select="2" />
            <xsl:with-param name="content"
              select="concat(
                       'Gets the &quot;', $name,'&quot; property as a set of DNs.&#xa;',
                       $comment,
                       '&#xa;',
                       '@return Returns the DN values of the &quot;', $name, '&quot; property.&#xa;')" />
          </xsl:call-template>
          <xsl:value-of
            select="concat('  SortedSet&lt;DN&gt; get', $java-property-name, 'DNs();&#xa;')" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>
  <!--
    Generate property getter implementation(s).
  -->
  <xsl:template match="adm:aggregation"
    mode="java-property-getter-implementation">
    <xsl:param name="interface" select="/.." />
    <xsl:call-template
      name="generate-default-property-getter-implementation">
      <xsl:with-param name="interface" select="$interface" />
    </xsl:call-template>
    <xsl:if test="$interface='server'">
      <xsl:variable name="name" select="../../@name" />
      <xsl:variable name="java-property-name">
        <xsl:call-template name="name-to-java">
          <xsl:with-param name="value" select="$name" />
        </xsl:call-template>
      </xsl:variable>
      <xsl:text>&#xa;</xsl:text>
      <xsl:text>&#xa;</xsl:text>
      <xsl:text>&#xa;</xsl:text>
      <xsl:call-template name="add-java-comment2">
        <xsl:with-param name="indent" select="4" />
        <xsl:with-param name="content" select="'{@inheritDoc}&#xa;'" />
      </xsl:call-template>
      <xsl:choose>
        <xsl:when test="string(../../@multi-valued) != 'true'">
          <xsl:value-of
            select="concat('    public DN get', $java-property-name, 'DN() {&#xa;')" />
          <xsl:value-of
            select="concat('      String value = get', $java-property-name, '();&#xa;')" />
          <xsl:value-of
            select="concat('      return INSTANCE.get', $java-property-name, 'PropertyDefinition().getChildDN(value);&#xa;')" />
          <xsl:value-of select="'    }&#xa;'" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of
            select="concat('    public SortedSet&lt;DN&gt; get', $java-property-name, 'DNs() {&#xa;')" />
          <xsl:value-of
            select="concat('      SortedSet&lt;String&gt; values = get', $java-property-name, '();&#xa;')" />
          <xsl:value-of
            select="'      SortedSet&lt;DN&gt; dnValues = new TreeSet&lt;DN&gt;();&#xa;'" />
          <xsl:value-of
            select="'      for (String value : values) {&#xa;'" />
          <xsl:value-of
            select="concat('        DN dn = INSTANCE.get', $java-property-name, 'PropertyDefinition().getChildDN(value);&#xa;')" />
          <xsl:value-of select="'        dnValues.add(dn);&#xa;'" />
          <xsl:value-of select="'      }&#xa;'" />
          <xsl:value-of select="'      return dnValues;&#xa;'" />
          <xsl:value-of select="'    }&#xa;'" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>
  <!--
    Gets the Java client configuration interface for the referenced type.
  -->
  <xsl:template name="get-client-type">