Skip to content

Commit

Permalink
PB-28109. Add support for Time-based Expiry for packages
Browse files Browse the repository at this point in the history
  • Loading branch information
kalpeshonespan authored and john committed Jul 8, 2019
1 parent fff587b commit 3c43288
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 45 deletions.
48 changes: 44 additions & 4 deletions sdk/src/main/java/com/silanis/esl/api/model/CeremonySettings.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.silanis.esl.api.model;
//

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Expand Down Expand Up @@ -61,6 +60,10 @@ public class CeremonySettings extends ViewSettings
public static final String FIELD_FONT_SIZE = "fontSize";
@JsonIgnore
public static final String FIELD_STYLE = "style";
@JsonIgnore
public static final String FIELD_DEFAULT_TIME_BASED_EXPIRY = "defaultTimeBasedExpiry";
@JsonIgnore
public static final String FIELD_REMAINING_DAYS = "remainingDays";

// Empty Constructor
public CeremonySettings() {
Expand Down Expand Up @@ -89,6 +92,8 @@ public CeremonySettings() {
protected List<String> _optOutReasons = new ArrayList<String>();
protected Boolean _ada = false;
protected Integer _fontSize = null;
protected Boolean _defaultTimeBasedExpiry = false;
protected Integer _remainingDays = 0;

// Accessors

Expand Down Expand Up @@ -678,7 +683,45 @@ public boolean evalAda() {
return _ada == null ? false : _ada.booleanValue();
}

public Boolean getDefaultTimeBasedExpiry() {
return _defaultTimeBasedExpiry;
}

public CeremonySettings setDefaultTimeBasedExpiry(Boolean _defaultTimeBasedExpiry) {
SchemaSanitizer.throwOnNull(FIELD_DEFAULT_TIME_BASED_EXPIRY, _defaultTimeBasedExpiry);
this._defaultTimeBasedExpiry = _defaultTimeBasedExpiry;
setDirty(FIELD_DEFAULT_TIME_BASED_EXPIRY);
return this;
}

@JsonIgnore
public CeremonySettings safeSetDefaultTimeBasedExpiry(Boolean value) {
if (value != null)
this.setDefaultTimeBasedExpiry(value);
return this;
}

@JsonIgnore
public boolean evalDefaultTimeBasedExpiry() {
return _defaultTimeBasedExpiry == null ? false : _defaultTimeBasedExpiry.booleanValue();
}

public Integer getRemainingDays() {
return _remainingDays;
}

public CeremonySettings setRemainingDays(Integer _remainingDays) {
this._remainingDays = _remainingDays;
setDirty(FIELD_REMAINING_DAYS);
return this;
}

@JsonIgnore
public CeremonySettings safeSetRemainingDays(Integer value) {
if (value != null)
this.setRemainingDays(value);
return this;
}

public CeremonySettings setFontSize(Integer value) {
this._fontSize = value;
Expand All @@ -698,8 +741,6 @@ public Integer getFontSize() {
return _fontSize;
}



@Override
public CeremonySettings setStyle(LayoutStyle value) {
super.setStyle(value);
Expand All @@ -715,5 +756,4 @@ public CeremonySettings safeSetStyle(LayoutStyle value) {
return this;
}


}
13 changes: 13 additions & 0 deletions sdk/src/main/java/com/silanis/esl/sdk/DocumentPackageSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class DocumentPackageSettings {
private Boolean enforceCaptureSignature = null;
private Boolean ada = null;
private Integer fontSize = null;
private Boolean defaultTimeBasedExpiry = null;
private Integer remainingDays = null;

private String linkText;
private String linkTooltip;
Expand Down Expand Up @@ -214,4 +216,15 @@ public Integer getFontSize() {
public void setFontSize(Integer fontSize) {
this.fontSize = fontSize;
}

public Boolean getDefaultTimeBasedExpiry() { return defaultTimeBasedExpiry; }

public void setDefaultTimeBasedExpiry(Boolean enable) {
this.defaultTimeBasedExpiry = enable;
}

public Integer getRemainingDays() { return remainingDays; }

public void setRemainingDays(Integer remainingDays) { this.remainingDays = remainingDays; }

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class DocumentPackageSettingsBuilder {
private Boolean enforceCaptureSignature = null;
private Boolean ada = null;
private Integer fontSize = null;
private Boolean defaultTimeBasedExpiry = null;
private Integer remainingDays = null;

private String linkText = null;
private String linkTooltip = null;
Expand Down Expand Up @@ -330,6 +332,44 @@ public DocumentPackageSettingsBuilder withHandOverLinkText(String text) {
return this;
}

/**
* Use time based Expiry of package. If enabled, set the number
* of days #withRemainingDays since pacakge creation date the package should expire.
*
* @return This
* @see #withDefaultTimeBasedExpiry()
*/

public DocumentPackageSettingsBuilder withDefaultTimeBasedExpiry() {
this.defaultTimeBasedExpiry = true;
return this;
}

/**
* Do not use time based Expiry of package.
*
* @return This
* @see #withoutDefaultTimeBasedExpiry()
*/

public DocumentPackageSettingsBuilder withoutDefaultTimeBasedExpiry() {
this.defaultTimeBasedExpiry = false;
return this;
}

/**
* Set the number of days since Creation date the package should expire
*
* @param expireInDays Number of Days from Package Creation Date. @size(max="999")
* @return This
* @see #withDefaultTimeBasedExpiry()
*/

public DocumentPackageSettingsBuilder withRemainingDays(Integer expireInDays) {
this.remainingDays = expireInDays;
return this;
}

/**
* Set the text to be displayed for the @see
* #withHandOverLinkHref tool tip when the user over with the mouse over the
Expand Down Expand Up @@ -399,6 +439,8 @@ public DocumentPackageSettings build() {
result.setEnforceCaptureSignature(enforceCaptureSignature);
result.setAda(ada);
result.setFontSize(fontSize);
result.setDefaultTimeBasedExpiry(defaultTimeBasedExpiry);
result.setRemainingDays(remainingDays);

result.setCeremonyLayoutSettings(ceremonyLayoutSettings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class DocumentPackageSettingsExample extends SDKSample {
public static final String HAND_OVER_LINK_TEXT = "click here";
public static final String HAND_OVER_LINK_TOOLTIP = "link tooltip";
public static final Integer FONT_SIZE = 28;
public static final Integer EXPIRE_IN_DAYS = 12;

public static void main(String... args) {
new DocumentPackageSettingsExample().run();
Expand Down Expand Up @@ -55,6 +56,8 @@ public void execute() {
.withDialogOnComplete()
.withoutDeclineOther()
.withoutOptOutOther()
.withDefaultTimeBasedExpiry()
.withRemainingDays(EXPIRE_IN_DAYS)

.withCeremonyLayoutSettings(newCeremonyLayoutSettings()
// .withoutGlobalDownloadButton()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public com.silanis.esl.api.model.PackageSettings toAPIPackageSettings() {
ceremonySettings.safeSetEnforceCaptureSignature(sdkPackageSettings.getEnforceCaptureSignature());
ceremonySettings.safeSetAda(sdkPackageSettings.getAda());
ceremonySettings.safeSetFontSize(sdkPackageSettings.getFontSize());
ceremonySettings.safeSetDefaultTimeBasedExpiry(sdkPackageSettings.getDefaultTimeBasedExpiry());
ceremonySettings.safeSetRemainingDays(sdkPackageSettings.getRemainingDays());

if (sdkPackageSettings.getEnableFirstAffidavit() != null) {
ceremonySettings.safeSetDisableFirstInPersonAffidavit(!sdkPackageSettings.getEnableFirstAffidavit());
Expand Down Expand Up @@ -185,6 +187,12 @@ public com.silanis.esl.sdk.DocumentPackageSettings toSDKPackageSettings() {
if (apiPackageSettings.getCeremony().getFontSize() != null)
result.setFontSize(apiPackageSettings.getCeremony().getFontSize());

if (apiPackageSettings.getCeremony().getDefaultTimeBasedExpiry() != null)
result.setDefaultTimeBasedExpiry(apiPackageSettings.getCeremony().getDefaultTimeBasedExpiry());

if (apiPackageSettings.getCeremony().getRemainingDays() != null)
result.setRemainingDays(apiPackageSettings.getCeremony().getRemainingDays());

result.setCeremonyLayoutSettings(new CeremonyLayoutSettingsConverter(apiPackageSettings.getCeremony().getLayout()).toSDKCeremonyLayoutSettings());

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,117 +14,129 @@
*/
public class DocumentPackageSettingsBuilderTest {

private static final String NULL_ERROR_MSG = "Builder returned a null object";
private static final String STR_REASON = "reason";

@Test
public void buildWithSpecifiedValues() {

DocumentPackageSettings documentPackageSettings = newDocumentPackageSettings().showOwnerInPersonDropDown().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("showOwnerInPersonDropDown was not set correctly", documentPackageSettings.getShowPackageOwnerInPerson());

documentPackageSettings = newDocumentPackageSettings().withDocumentToolbarDownloadButton().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("showDocumentToolbarDownloadButton was not set correctly", documentPackageSettings.getShowDocumentToolbarDownloadButton());

documentPackageSettings = newDocumentPackageSettings().withoutDocumentToolbarDownloadButton().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertFalse("showDocumentToolbarDownloadButton was not set correctly", documentPackageSettings.getShowDocumentToolbarDownloadButton());

documentPackageSettings = newDocumentPackageSettings().disableFirstAffidavit().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertFalse("enableFirstAffidavit was not set correctly", documentPackageSettings.getEnableFirstAffidavit());

documentPackageSettings = newDocumentPackageSettings().disableSecondAffidavit().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertFalse("enableSecondAffidavit was not set correctly", documentPackageSettings.getEnableSecondAffidavit());

documentPackageSettings = newDocumentPackageSettings().enableFirstAffidavit().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("enableFirstAffidavit was not set correctly", documentPackageSettings.getEnableFirstAffidavit());

documentPackageSettings = newDocumentPackageSettings().enableSecondAffidavit().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("enableSecondAffidavit was not set correctly", documentPackageSettings.getEnableSecondAffidavit());

documentPackageSettings = newDocumentPackageSettings().hideOwnerInPersonDropDown().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertFalse("showPackageOwnerInPerson was not set correctly", documentPackageSettings.getShowPackageOwnerInPerson());

documentPackageSettings = newDocumentPackageSettings().showOwnerInPersonDropDown().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("showPackageOwnerInPerson was not set correctly", documentPackageSettings.getShowPackageOwnerInPerson());

documentPackageSettings = newDocumentPackageSettings().withCaptureText().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertFalse("hideCaptureText was not set correctly", documentPackageSettings.getHideCaptureText());

documentPackageSettings = newDocumentPackageSettings().withDecline().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("enableDecline was not set correctly", documentPackageSettings.getEnableDecline());

documentPackageSettings = newDocumentPackageSettings().withDeclineOther().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertFalse("disableDeclineOther was not set correctly", documentPackageSettings.getDisableDeclineOther());

documentPackageSettings = newDocumentPackageSettings().withDeclineReason("reason").build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
documentPackageSettings = newDocumentPackageSettings().withDeclineReason(STR_REASON).build();
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertThat("declineReasons was not set correctly", documentPackageSettings.getDeclineReasons(), hasSize(1));
assertThat("declineReasons was not set correctly", documentPackageSettings.getDeclineReasons().get(0), is("reason"));
assertThat("declineReasons was not set correctly", documentPackageSettings.getDeclineReasons().get(0), is(STR_REASON));

documentPackageSettings = newDocumentPackageSettings().withDialogOnComplete().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("showDialogOnComplete was not set correctly", documentPackageSettings.getShowDialogOnComplete());

documentPackageSettings = newDocumentPackageSettings().withHandOverLinkHref("href").build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertThat("linkHref was not set correctly", documentPackageSettings.getLinkHref(), is("https://href"));

documentPackageSettings = newDocumentPackageSettings().withHandOverLinkText("text").build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertThat("linkText was not set correctly", documentPackageSettings.getLinkText(), is("text"));

documentPackageSettings = newDocumentPackageSettings().withHandOverLinkTooltip("tooltip").build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertThat("linkTooltip was not set correctly", documentPackageSettings.getLinkTooltip(), is("tooltip"));

documentPackageSettings = newDocumentPackageSettings().withInPerson().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("enableInPerson was not set correctly", documentPackageSettings.getEnableInPerson());

documentPackageSettings = newDocumentPackageSettings().withLanguageDropDown().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("showLanguageDropDown was not set correctly", documentPackageSettings.getShowLanguageDropDown());

documentPackageSettings = newDocumentPackageSettings().withoutOptOut().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertFalse("enableOptOut was not set correctly", documentPackageSettings.getEnableOptOut());

documentPackageSettings = newDocumentPackageSettings().withOptOutOther().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertFalse("disableOptOutOther was not set correctly", documentPackageSettings.getDisableOptOutOther());

documentPackageSettings = newDocumentPackageSettings().withOptOutReason("reason").build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
documentPackageSettings = newDocumentPackageSettings().withOptOutReason(STR_REASON).build();
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertThat("optOutReasons was not set correctly", documentPackageSettings.getOptOutReasons(), hasSize(1));
assertThat("optOutReasons was not set correctly", documentPackageSettings.getOptOutReasons().get(0), is("reason"));
assertThat("optOutReasons was not set correctly", documentPackageSettings.getOptOutReasons().get(0), is(STR_REASON));

documentPackageSettings = newDocumentPackageSettings().withoutWatermark().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("hideWatermark was not set correctly", documentPackageSettings.getHideWatermark());

documentPackageSettings = newDocumentPackageSettings().withWatermark().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertFalse("hideWatermark was not set correctly", documentPackageSettings.getHideWatermark());

documentPackageSettings = newDocumentPackageSettings().withEnforceCaptureSignature().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("enforceCaptureSignature was not set correctly", documentPackageSettings.getEnforceCaptureSignature());

documentPackageSettings = newDocumentPackageSettings().withAda().build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("ada was not set correctly", documentPackageSettings.getAda());

documentPackageSettings = newDocumentPackageSettings().withFontSize(10).build();
assertThat("Builder returned a null object", documentPackageSettings, notNullValue());
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertThat("fontSize was not set correctly", documentPackageSettings.getFontSize(), is(10));

documentPackageSettings = newDocumentPackageSettings().withDefaultTimeBasedExpiry().build();
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertTrue("Time base expiry was could not be enabled..", documentPackageSettings.getDefaultTimeBasedExpiry());

documentPackageSettings = newDocumentPackageSettings().withRemainingDays(10).build();
assertThat(NULL_ERROR_MSG, documentPackageSettings, notNullValue());
assertThat("Expiry days was not set correctly", documentPackageSettings.getRemainingDays(), is(10));

}
}
Loading

0 comments on commit 3c43288

Please sign in to comment.