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

    Copyright 2005-2013 The Kuali Foundation

    Licensed under the Educational Community License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.opensource.org/licenses/ecl2.php

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<chapter xml:id="conditional_logic" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook"
         version="5.0">
  <title>Conditional Logic</title>
  <section>
    <title>Conditional Logic</title>
    <para>Coming Soon!</para>
    <!-- TODO: Add content here.
      -->
  </section>
  <section>
    <title>Presentation Controllers and Authorizers</title>
    <para>Coming Soon!</para>
    <!-- TODO: Add content here.
      -->
  </section>
  <section>
    <title>Configuration with Expressions</title><commit_msg>[KULRICE-11122][KULRICE-11123] Inquiry demos for view authorizer and view presentation controller.  Added some documentation.<commit_after><?xml version='1.0' encoding='UTF-8'?>
<!--

    Copyright 2005-2013 The Kuali Foundation

    Licensed under the Educational Community License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.opensource.org/licenses/ecl2.php

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<chapter xml:id="conditional_logic" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook"
         version="5.0">
  <title>Conditional Logic</title>
  <section>
    <title>Conditional Logic</title>
    <para>Coming Soon!</para>
    <!-- TODO: Add content here.
      -->
  </section>
  <section>
    <title>Presentation Controllers and Authorizers</title>
    <para>The View Presentation Controller is the class where business logic authorizations are handled.   The base
      class is org.kuali.rice.krad.uif.view.ViewPresentationControllerBase.  The example below shows
      how a Presentation Controller is configured to a view.
    </para>
    <programlisting linenumbering="numbered">
      &lt;bean id=&quot;LabsInquiry-PresentationController&quot; parent=&quot;LabsInquiry-PerDiemSections&quot;&gt;
        &lt;property name=&quot;presentationControllerClass&quot; value=&quot;org.kuali.rice.krad.demo.uif.controller.DemoInquiryViewPresentationController&quot;/&gt;
        &lt;property name=&quot;viewName&quot; value=&quot;LabsInquiry-PresentationControllerView&quot;/&gt;
        &lt;property name=&quot;headerText&quot; value=&quot;Inquiry with presentation controller controlling field and section visibility&quot;/&gt;
      &lt;/bean&gt;
    </programlisting>
    <para>Overriding the Presentation Controller methods provides the capability to control things like visibility,
      and edit modes of both fields and sections within a view.  The example below shows how
      business logic can be implemented to control the visibility for both a field and
      a section within a view.</para>
    <programlisting linenumbering="numbered">
      @Override
      public boolean canViewField(View view, ViewModel model, Field field, String propertyName) {

        //hide travel authorization number
        if (propertyName.equals(&quot;travelAuthorizationDocumentId&quot;)) {
           return false;
        }

        return super.canViewField(view, model, field, propertyName);
      }

      @Override
      public boolean canViewGroup(View view, ViewModel model, Group group, String groupId) {

        //hide the estimates section
        if (groupId.equals(&quot;TravelAccount-InquiryView-Costs&quot;)) {
          return false;
        }

        return super.canViewGroup(view, model, group, groupId);
      }
    </programlisting>
    <para>
      The View Authorizer is the class that handles the KIM permission checks for the view. The base class
      is org.kuali.rice.krad.uif.view.ViewAuthorizerBase.  The example below shows how a
      View Authorizer is configured to a view.
    </para>
    <programlisting linenumbering="numbered">
      &lt;bean id=&quot;LabsInquiry-Authorizer&quot; parent=&quot;LabsInquiry-PerDiemSections&quot;&gt;
        &lt;property name=&quot;authorizerClass&quot; value=&quot;org.kuali.rice.krad.demo.uif.authorizer.DemoInquiryViewAuthorizer&quot;/&gt;
        &lt;property name=&quot;viewName&quot; value=&quot;LabsInquiry-AuthorizerView&quot;/&gt;
        &lt;property name=&quot;headerText&quot; value=&quot;Inquiry with authorizer controlling field and section visibility&quot;/&gt;
      &lt;/bean&gt;
    </programlisting>
    <para>
      Overriding the View Authorizer methods gives provides the ability to control things like visibility,
      and edit modes (based on KIM permissions) for both fields and sections within a view.
      The example below shows how business logic based on KIM permissions can be implemented to control the visibility
      for both a field and section within a view.
    </para>
    <programlisting linenumbering="numbered">
      @Override
      public boolean canViewField(View view, ViewModel model, Field field, String propertyName, Person user) {

        //hide travel authorization number from admin
        if(propertyName.equals(&amp;&quot;travelAuthorizationDocumentId&amp;&quot;) &amp;&amp;
        user.getPrincipalName().equals(&amp;&quot;admin&amp;&quot;))   {
          return false;
        }

        return super.canViewField(view,model,field,propertyName,user);
      }

      @Override
      public boolean canViewGroup(View view, ViewModel model, Group group, String groupId, Person user) {

        //hide the estimates section if the user is admin
        if(groupId.equals(&amp;&quot;TravelAccount-InquiryView-Costs&amp;&quot;) &amp;&amp;
        user.getPrincipalName().equals(&amp;&quot;admin&amp;&quot;))  {
          return false;
        }

        return super.canViewGroup(view,model,group,groupId,user);
      }
    </programlisting>
  </section>
  <section>
    <title>Configuration with Expressions</title>
{'fraction_non_alphanumeric': 0.09891093540205878, 'fraction_numerical': 0.0077577204236908845, 'mean_word_length': 3.6107290233837688, 'pattern_counts': {'":': 0, '<': 60, '<?xml version=': 2, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4434775', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1812, 'n_words': 574}