All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.aemds.guide.common.GuideTermsAndConditions Maven / Gradle / Ivy

/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2014 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/

package com.adobe.aemds.guide.common;

import com.adobe.aemds.guide.utils.GuideConstants;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import java.util.Arrays;

import java.util.List;

/**
 * GuideTermsAndConditions class encapsulates basic properties of the adaptive forms Terms and Conditions component.
 * Some of the properties that it encapsulates are listed below:
 * 
    *
  • Text content of Terms and condition
  • *
  • Link Text for Terms and condition
  • *
  • Screen reader text for Terms and condition
  • *
* * @since AEM 6.0 */ public class GuideTermsAndConditions extends GuideField{ public String getStyles() { String style = super.getStyles(); style += ((getHeight().length()) > 0 ? ("max-height:none;") : ("")); // Return the style return style; } /** * Returns the text content of terms and conditions component configured in authoring dialog * @return String representing the terms and condition text content */ public String getTncTextContent(){ return externalize(this.resourceProps.get("tncTextContent", String.class)); } /** * Returns the link text of terms and conditions component configured in authoring dialog * @return String representing link text */ public List getLinkText(){ String[] arr = this.resourceProps.get("linkText",new String[0]); return Arrays.asList(arr); } public Boolean getShowLink(){ return this.resourceProps.get("showLink", Boolean.class); } // When showAsPopUp is true, then showApprovalOption will always be true. // So, first check whether showAsPopUp is true, if it's true then return true, else check showApprovalOption public Boolean getShowApprovalOption(){ Boolean showAsPopUp = this.getShowAsPopUp(); return showAsPopUp || this.resourceProps.get("showApprovalOption", false); } /** * Returns if TNC Component is to be shown as pop up * @return true, if TNC component is configured to show as pop up else false */ public Boolean getShowAsPopUp(){ return this.resourceProps.get("showAsPopUp", false); } /** * Returns the consent text set for the TNC Component * @return consent text configured for the TNC Component */ public String getTncCheckBoxContent(){ return externalize(this.resourceProps.get("tncCheckBoxContent", String.class)); } public String getAssistProperty(){ return externalize(this.resourceProps.get("assistPriority", String.class)); } public String getScreenReaderText(){ String screenReaderText = null; String assistPriority = this.getAssistProperty(); if (assistPriority != null) { if ("label".equals(assistPriority)){ String title = this.resourceProps.get("jcr:title", String.class); if (title != null) { screenReaderText = title; } } else if ("custom".equals(assistPriority)){ String customText = this.resourceProps.get("custom", String.class); if (customText != null) { screenReaderText = customText; } } } return externalize(screenReaderText); } /** * Returns the field type of the Adaptive Forms Component * @return String representing guide field type */ public String getGuideFieldType(){ return GuideConstants.GUIDE_FIELD_TERMSANDCONDITIONS; } /** * Returns the boolean if tnc is mandatory or not. * @return Boolean representing mandatory state of tnc. */ public boolean isMandatory () { String tncReviewStatusPath = GuideConstants.ITEMS_NODENAME + "/" + GuideConstants.TNC_REVIEW_STATUS_NODE_NAME; Resource tncReviewStatusResource = getResource().getChild(tncReviewStatusPath); if(tncReviewStatusResource != null) { ValueMap reviewStatusProp = tncReviewStatusResource.adaptTo(ValueMap.class); return reviewStatusProp.get("mandatory", false); } return false; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy