Sunday, September 18, 2011

Understanding Effective Dated Entities Behavior - Delete

JDev Version: 11.1.2.

In this blog, I have documented the results of the tests I did for Effective Dated Entities delete behavior. For the setup, and project details, please refer to the earlier blog: 'Understanding Effective Dated Entities Behavior - Creation/Update'.

The following modes in the oracle.jbo.Row interface are available to delete Effective Dated rows:

  • Row.EFFDT_DELETE_MODE: When an effective dated row is deleted in "delete" mode, the end date of the row is set to the row's effective date and all the future rows for the same key values are deleted.
  • Row.EFFDT_DELETE_FUTURE_CHANGE_MODE: When an effective dated row is deleted in "delete future change" mode, the end date of the row is set to the end of time and all the future rows for the same key values are deleted.
  • Row.EFFDT_DELETE_NEXT_CHANGE_MODE: When an effective dated row is deleted in "delete next change" mode, the end date of the row is set to the end date of adjoining row and the adjoining row is deleted.
  • Row.EFFDT_DELETE_ZAP_MODE: When an effective dated row is deleted in "zap" mode, all the effective dated rows with the same key values are deleted.
  • Row.EFFDT_DELETE_THIS_CHANGE_MODE: When an effective dated row is deleted in "delete this change" mode, the current row is removed.
I am using the following method to delete the rows of MultiChangesSingleDayVO:

    public void deleteMultiChangesSingleDayEffDatedVORow( Date effectiveDate, int mode){
       
        if (effectiveDate != null) {
            ApplicationModuleImpl rootAM = this.getRootApplicationModule();
            rootAM.setProperty(EFF_DT_PROPERTY_STR, effectiveDate);
        }

        ViewObjectImpl vo = this.getMultiChangesSingeDayVO1();
        Row row = null;
        row = (vo.findByKey(new Key(new Object[]{ 1, null, null, "Y"}), 1))[0];
        if(mode==1)
            row.seteffectiveDateMode(Row.EFFDT_DELETE_MODE      );
        else if(mode==2)
            row.seteffectiveDateMode(Row.EFFDT_DELETE_FUTURE_CHANGE_MODE        );
        else if(mode==3)
            row.seteffectiveDateMode(Row.EFFDT_DELETE_NEXT_CHANGE_MODE        );
        else if(mode==4)
            row.seteffectiveDateMode(Row.EFFDT_DELETE_ZAP_MODE          );   
        else if(mode==5)
            row.seteffectiveDateMode(Row.EFFDT_DELETE_THIS_CHANGE_MODE          );          

    row.remove();

        this.getDBTransaction().commit();
    }

As you can see, I am using the following mode value to identify which mode to use:

1 = Row.EFFDT_DELETE_MODE
2 = Row.EFFDT_DELETE_FUTURE_CHANGE_MODE
3 = Row.EFFDT_DELETE_NEXT_CHANGE_MODE 
4 = Row.EFFDT_DELETE_ZAP_MODE         
5 = Row.EFFDT_DELETE_THIS_CHANGE_MODE 

Testing Effective Dated Table Delete:

Documenting some of results I got when I tested the Effective Dated entities delete using all the above flags:

Here it the initial table content used for all the delete test cases:

IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG
1First01-JAN-0131-DEC-041Y
1Second01-JAN-0531-DEC-081Y
1Third01-JAN-0931-DEC-121Y

Test Cases on the above data:


1.


Parameter Passed:
       
effectiveDate = 2006-01-01       
mode = 1       

Output: Success

Table Content After Method Call:

IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG
1First01-JAN-0131-DEC-041Y
1Second01-JAN-0501-JAN-061Y

Recalling the definition of Row.EFFDT_DELETE_MODE: When an effective dated row is deleted in "delete" mode, the end date of the row is set to the row's effective date and all the future rows for the same key values are deleted.
Perfect.

2.

Parameter Passed:
       
effectiveDate = 2006-01-01       
mode = 2       


Output: Success

Table Content After Method Call:

IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG
1First01-JAN-0131-DEC-041Y
1Second01-JAN-0531-DEC-121Y

Recalling the definition of Row.EFFDT_DELETE_FUTURE_CHANGE_MODE: When an effective dated row is deleted in "delete future change" mode, the end date of the row is set to the end of time and all the future rows for the same key values are deleted.
Perfect.

3.

Parameter Passed:   
       
effectiveDate = 2002-01-01       
mode = 3       

Output: Success

Table Content After Method Call:

IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG
1First01-JAN-0131-DEC-081Y
1Third01-JAN-0931-DEC-121Y

Recalling the definition of Row.EFFDT_DELETE_NEXT_CHANGE_MODE: When an effective dated row is deleted in "delete next change" mode, the end date of the row is set to the end date of adjoining row and the adjoining row is deleted.
Perfect.

4.

Parameter Passed:
       
effectiveDate = 2006-01-01
mode = 4

Output: Success

Table Content After Method Call:

IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG

No records.

Recalling the definition of Row.EFFDT_DELETE_ZAP_MODE: When an effective dated row is deleted in "zap" mode, all the effective dated rows with the same key values are deleted.
Perfect.

5.

Parameter Passed:
       
effectiveDate = 2006-01-01
mode = 5

Output: Success

Table Content After Method Call:

IDTEXTSTART_DATEEND_DATESEQUENCESEQUENCE_FLAG
1First01-JAN-0131-DEC-081Y
1Third01-JAN-0931-DEC-121Y

Recalling the definition of Row.EFFDT_DELETE_THIS_CHANGE_MODE: When an effective dated row is deleted in "delete this change" mode, the current row is removed.
Perfect again.

So, I found understanding delete test cases easier than understanding the update test cases, could be because I found the documentation of delete test cases clearer than update scenarios.

No comments:

Post a Comment