Mover Trigger Rule

Hello,

I am working on moving an HR source over when I discovered a Rule that I am trying to figure out what it is doing.


            import java.text.ParseException;
            import java.text.SimpleDateFormat;
            import java.util.Date;
            import java.util.Calendar;
            import sailpoint.object.Identity;
            import sailpoint.rule.Account;
            import sailpoint.tools.Util;
            import java.util.Map;
            import java.util.HashMap;
            import java.lang.StringIndexOutOfBoundsException;
            log.error( "[ENTERING] IdentityAttribute :: Mover Trigger" );
            //Number of Days to Hold the mover in active mode.
            int certOffset = 1;
            String moverKey = "";
            //Setting the Date format to year-month-date hour:minute:second
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
            Calendar calendar = Calendar.getInstance();
             // Get current Workday data.
            Account workdayAccount = idn.getFirstAccount( "Workday Production Sandbox [source]", identity.getName() );
            Map workdayAttributes = workdayAccount.getAttributes();
            String termSubReason = workdayAttributes.get("Term SubReason Code__c");
            //Mover Key will have us determine if a mover certification needs to fire.
            if ( identity.getAttribute( "employeeType" ).equals( "Employee" ) ) {
              moverKey = identity.getAttribute( "ministryCode" ) + ":" + identity.getAttribute( "departmentCode" ) + ":" + identity.getAttribute( "jobFamily" ) + ":" + identity.getAttribute( "jobProfile" ) + ":" + identity.getAttribute( "organizationRegion" );
            } else {
              moverKey = identity.getAttribute( "ministryCode" ) + ":" + identity.getAttribute( "departmentCode" ) + ":" + identity.getAttribute( "jobFamily" ) + ":" + identity.getAttribute( "jobProfile" ) + ":" + identity.getAttribute( "organizationRegion" ) + ":" + identity.getAttribute("jobTitle") + ":" + identity.getAttribute("supplierId");
            }
            String appendingValue = termSubReason != null && termSubReason.contains( "Convert" ) ? ":" + termSubReason : "";
            moverKey += appendingValue;
            //This is the current date down to the milliseconds.
            Date today = new Date();
            String now = simpleDateFormat.format( today );
            //Make sure the current Date follows the same format set above.
            today = simpleDateFormat.parse( now );
            if ( oldValue == null ) {
                //if the oldValue is null, then Identity is new. Set the moverTrigger to the positionId.
                log.error( "[EXISTING] IdentityAttribute :: Mover Trigger" );
                return moverKey;
            } else {
                //else the moverTrigger is already set to a positionId.
                if ( Util.nullSafeEq( oldValue, moverKey ) || oldValue.contains( "Convert" ) ) {
                    //This means there's not change in positionId.
                    //return current positionId
                    log.error( "[EXISTING] IdentityAttribute :: Mover Trigger" );
                    return moverKey;
                } else {
                    //This means the positionId has Changed.
                    try {
                        //Since the first 18 characters of the current string is not a DateFormat we'll substring it out.
                        String oldValueDate = oldValue.substring( 18 );
                        log.error( "Mover Trigger :: oldValue = " + oldValueDate );
                        //Convert the String into a Date object.
                        Date changeDate = simpleDateFormat.parse( oldValueDate );
                        calendar.setTime( changeDate );
                        //increment by a date
                        calendar.add( Calendar.DATE, certOffset );
                        Date cutOffDate = calendar.getTime();
                        log.error( "Mover Trigger :: is " + simpleDateFormat.format( cutOffDate ) + " before " + simpleDateFormat.format( today ) + "?" );
                        if ( cutOffDate.before( today ) )  {
                            //This means the 24 hours cycle for this mover trigger is over.
                            log.error( "[EXISTING] IdentityAttribute :: Mover Trigger" );
                            return moverKey;
                        }
                    } catch ( StringIndexOutOfBoundsException e ) {
                        return "Mover Triggered on " + simpleDateFormat.format( today );
                    } catch ( ParseException e ) {
                        return "Mover Triggered on " + simpleDateFormat.format( today );
                    }
                }
            }
            log.error( "[EXISTING] IdentityAttribute :: Mover Trigger" );
            return oldValue;
      

I follow the data all the way down until I get to the following:

  //else the moverTrigger is already set to a positionId.
                if ( Util.nullSafeEq( oldValue, moverKey ) || oldValue.contains( "Convert" ) ) {
                    //This means there's not change in positionId.
                    //return current positionId
                    log.error( "[EXISTING] IdentityAttribute :: Mover Trigger" );
                    return moverKey;
                } else {
                    //This means the positionId has Changed.
                    try {
                        //Since the first 18 characters of the current string is not a DateFormat we'll substring it out.
                        String oldValueDate = oldValue.substring( 18 );
                        log.error( "Mover Trigger :: oldValue = " + oldValueDate );
                        //Convert the String into a Date object.
                        Date changeDate = simpleDateFormat.parse( oldValueDate );
                        calendar.setTime( changeDate );
                        //increment by a date
                        calendar.add( Calendar.DATE, certOffset );
                        Date cutOffDate = calendar.getTime();
                        log.error( "Mover Trigger :: is " + simpleDateFormat.format( cutOffDate ) + " before " + simpleDateFormat.format( today ) + "?" );
                        if ( cutOffDate.before( today ) )  {
                            //This means the 24 hours cycle for this mover trigger is over.
                            log.error( "[EXISTING] IdentityAttribute :: Mover Trigger" );
                            return moverKey;
                        }
                    } catch ( StringIndexOutOfBoundsException e ) {
                        return "Mover Triggered on " + simpleDateFormat.format( today );
                    } catch ( ParseException e ) {
                        return "Mover Triggered on " + simpleDateFormat.format( today );
                    }

I have reviewed the data from the source however I am struggling to figure out where it is getting a date from. All the attributes I look at that are called out in this rule no where is there a date. I am trying to determine if this rule is actually doing anything before I go through the effort of updating it.

Here is an example of the data:

"moverTrigger": "0188:818600:Health Plan:Information Technology Security Analyst, Health Plans:SSM Health Dean Health Service Company",

This is definitely an Identity attribute Rule.

  1. Extract workday account for the user
  2. Extract some set of attributes to form a mover key for user type employee and not an employee.
  3. oldValue defines the current value of the attribute before calculating using workday account attributes.
  4. Your question about date is extracted from oldValue.
String oldValueDate = oldValue.substring( 18 );
log.error( "Mover Trigger :: oldValue = " + oldValueDate );
//Convert the String into a Date object.
Date changeDate = simpleDateFormat.parse( oldValueDate );
calendar.setTime( changeDate );

Based on this mover key value, a certification campaign will be triggered.

Hope this helps.

Thanks
Krish

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.