Thursday, February 9, 2023

Report for tasks and scheduled or not including those tasks present in sequential tasks.

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

<!DOCTYPE TaskDefinition PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<TaskDefinition executor="sailpoint.reporting.LiveReportExecutor" name="TaskDefSch-Report" progressMode="Percentage" resultAction="Rename" subType="Role Management Reports" template="true" type="LiveReport">

<Attributes>

<Map>

<entry key="TaskDefinition.runLengthAverage" value="422"/>

<entry key="TaskDefinition.runLengthTotal" value="422"/>

<entry key="TaskDefinition.runs" value="1"/>

<entry key="report">

<value>

<LiveReport title="Task Result Report">

<DataSource objectType="TaskDefinition" type="Filter">

<QueryParameters>

<Parameter argument="type" property="type">

<QueryScript>

<Source>

import sailpoint.object.Filter;

import sailpoint.tools.Util;


List allowedTypes = new ArrayList();

allowedTypes.add("AccountAggregation");

allowedTypes.add("AccountGroupAggregation");


queryOptions.addFilter(Filter.in("type", allowedTypes));

queryOptions.addFilter(Filter.notnull("parent"));

return queryOptions;

</Source>

</QueryScript>

</Parameter>

</QueryParameters>

</DataSource>

<Columns>

<ReportColumnConfig field="taskName" header="Task Name" property="name" sortable="true" width="110"/>

<ReportColumnConfig field="taskType" header="Task Type" property="type" sortable="true" width="110"/>

<ReportColumnConfig field="appName" header="Application Name" property="name" sortable="true" width="110">

<RenderScript>

<Source>

import sailpoint.object.TaskDefinition;


TaskDefinition taskDef = context.getObjectByName(TaskDefinition.class, value);

if(taskDef != null &amp;&amp; null != taskDef.getArguments() &amp;&amp; null!= taskDef.getArguments().get("applications")){

return taskDef.getArguments().get("applications");

}

else

return "";

</Source>

</RenderScript>

</ReportColumnConfig>

<ReportColumnConfig field="isSchedule" header="Is Sheduled" property="name" sortable="true" width="110">

<RenderScript>

<Source>

import sailpoint.object.TaskDefinition;

import sailpoint.object.TaskDefinition;

import sailpoint.object.TaskSchedule;

import sailpoint.object.QueryOptions;

import sailpoint.object.Attributes;

import sailpoint.object.Filter;

import sailpoint.api.IncrementalObjectIterator;

import java.util.List;

import java.util.ArayList;

import java.util.Set;


public static String isPresentInSchlTasks(String taskIdParam)

{

//log.error("Entered into the method isPresentInSchlTasks() ");

try{

QueryOptions qo = new QueryOptions();


IncrementalObjectIterator taskSchedule = new IncrementalObjectIterator(context, TaskSchedule.class, qo);

String returnStmt = "notscheduled";

while (taskSchedule.hasNext()) {

TaskSchedule taskScheduleObject = (TaskSchedule) taskSchedule.next();

if(taskScheduleObject.getArguments().get("executor").contains(taskIdParam))

{

returnStmt = "scheduled";

break;

}

}

return returnStmt;

}

catch (Exception e)

{

return e.getMessage();

}

}


public static String checkInSeqSchExe(String taskNameParam)

{

try{

Filter f = Filter.like("formPath","sequentialTask");

QueryOptions qo = new QueryOptions();

qo.add(f);


IncrementalObjectIterator taskDefSeq = new IncrementalObjectIterator(context, TaskDefinition.class, qo);

String returnValue = "No";

while (taskDefSeq.hasNext()) {

TaskDefinition taskDefSeqObject = (TaskDefinition) taskDefSeq.next();

String taskName = taskDefSeqObject.getName();

String taskId = taskDefSeqObject.getId();

if(taskDefSeqObject.getArgument("taskList")!=null &amp;&amp; taskDefSeqObject.getArgument("taskList").contains(taskNameParam))

{

returnValue = isPresentInSchlTasks(taskId);

break;

}

}

return returnValue;

}

catch (Exception e)

{

return e.getMessage();

}

}


try{


//log.error("value task: "+value);


TaskDefinition taskDef = context.getObjectByName(TaskDefinition.class, value);

String taskId = taskDef.getId();

String taskName = taskDef.getName();

if(taskDef != null &amp;&amp; null != taskId)

{

String isPresented = isPresentInSchlTasks(taskId);

if("scheduled".equalsIgnoreCase(isPresented))

{

return "Yes";

}

else if("notscheduled".equalsIgnoreCase(isPresented))

{

String result = checkInSeqSchExe(taskName);

if("scheduled".equalsIgnoreCase(result))

{

return "Yes";

}

else

{

return "No";

}

}

}

else

return null;

}

catch(Exception e){

return e.getMessage();

}

</Source>

</RenderScript>

</ReportColumnConfig>

<ReportColumnConfig field="executeTime" header="Execution Time" property="name" sortable="true" width="110">

<RenderScript>

<Source>

import sailpoint.object.QueryOptions;

import sailpoint.object.Filter;

import sailpoint.object.TaskDefinition;

import sailpoint.object.TaskSchedule;

import sailpoint.object.Attributes;

import sailpoint.api.IncrementalObjectIterator;

import java.util.List;

import java.util.ArayList;



public static String isPresentInSchlTasks(String taskIdParam)

{

try{

QueryOptions qo = new QueryOptions();

IncrementalObjectIterator taskSchedule = new IncrementalObjectIterator(context, TaskSchedule.class, qo);

String returnStmt = "NA";


while (taskSchedule.hasNext()) {

TaskSchedule taskScheduleObject = (TaskSchedule) taskSchedule.next();

//log.error("Inside the while loop ");

if(taskScheduleObject.getArguments().get("executor").equalsIgnoreCase(taskIdParam) &amp;&amp; null != taskScheduleObject.getNextExecution())

{

returnStmt = taskScheduleObject.getNextExecution().toString();

break;

}

}

return returnStmt;

}

catch (Exception e)

{

return e.getMessage();

}

}


public static String checkInSeqSchExe(String taskNameParam)

{

try{

Filter f = Filter.like("formPath","sequentialTask");

QueryOptions qo = new QueryOptions();

qo.add(f);


IncrementalObjectIterator taskDefSeq = new IncrementalObjectIterator(context, TaskDefinition.class, qo);

String returnValue = "NA";

while (taskDefSeq.hasNext()) {

TaskDefinition taskDefSeqObject = (TaskDefinition) taskDefSeq.next();

String taskName = taskDefSeqObject.getName();

String taskId = taskDefSeqObject.getId();

if(taskDefSeqObject.getArgument("taskList")!=null &amp;&amp; taskDefSeqObject.getArgument("taskList").contains(taskNameParam))

{

returnValue = isPresentInSchlTasks(taskId);

break;

}

}

return returnValue;

}

catch (Exception e)

{

return e.getMessage();

}

}


try{


TaskDefinition taskDef = context.getObjectByName(TaskDefinition.class, value);

String taskId = taskDef.getId();

String taskName = taskDef.getName();

if(taskDef != null &amp;&amp; null != taskId)

{

String exeTime = isPresentInSchlTasks(taskId);

if(exeTime!=null &amp;&amp; !"NA".equalsIgnoreCase(exeTime))

{

return exeTime;

}

else

{

String exeTime2 = checkInSeqSchExe(taskName);

if(exeTime2!=null &amp;&amp; !"NA".equalsIgnoreCase(exeTime2))

{

return exeTime2;

}

else

{

return "NA";

}

}

}

else

return null;

}

catch(Exception e){

return e.getMessage();

}

</Source>

</RenderScript>

</ReportColumnConfig>

<ReportColumnConfig field="executeFrequency" header="Execution Frequency" property="name" sortable="true" width="110">

<RenderScript>

<Source>

import sailpoint.object.QueryOptions;

import sailpoint.object.Filter;

import sailpoint.object.TaskDefinition;

import sailpoint.object.TaskSchedule;

import sailpoint.object.Attributes;

import sailpoint.api.IncrementalObjectIterator;

import java.util.List;

import java.util.ArayList;



public static long isPresentInSchlTasks(String taskIdParam)

{

try{

QueryOptions qo = new QueryOptions();

IncrementalObjectIterator taskSchedule = new IncrementalObjectIterator(context, TaskSchedule.class, qo);

long returnStmt = 0L;


while (taskSchedule.hasNext()) {

TaskSchedule taskScheduleObject = (TaskSchedule) taskSchedule.next();

if(taskScheduleObject.getArguments().get("executor").equalsIgnoreCase(taskIdParam) &amp;&amp; null != taskScheduleObject.getNextExecution() &amp;&amp; null != taskScheduleObject.getLastExecution())

{

returnStmt = (taskScheduleObject.getNextExecution().getTime())-(taskScheduleObject.getLastExecution().getTime());

break;

}

}

return returnStmt;

}

catch (Exception e)

{

return e.getMessage();

}

}


public static long checkInSeqSchExe(String taskNameParam)

{

try{

Filter f = Filter.like("formPath","sequentialTask");

QueryOptions qo = new QueryOptions();

qo.add(f);


IncrementalObjectIterator taskDefSeq = new IncrementalObjectIterator(context, TaskDefinition.class, qo);

long returnValue = 0L;

while (taskDefSeq.hasNext()) {

TaskDefinition taskDefSeqObject = (TaskDefinition) taskDefSeq.next();

String taskName = taskDefSeqObject.getName();

String taskId = taskDefSeqObject.getId();

if(taskDefSeqObject.getArgument("taskList")!=null &amp;&amp; taskDefSeqObject.getArgument("taskList").contains(taskNameParam))

{

returnValue = isPresentInSchlTasks(taskId);

break;

}

}

return returnValue;

}

catch (Exception e)

{

return e.getMessage();

}

}


try{


TaskDefinition taskDef = context.getObjectByName(TaskDefinition.class, value);

String taskId = taskDef.getId();

String taskName = taskDef.getName();

if(taskDef != null &amp;&amp; null != taskId)

{

long exeTime = isPresentInSchlTasks(taskId);

if(exeTime!=null &amp;&amp; exeTime!=0)

{

if((exeTime / (1000*60*60)) % 24==1)

{

return "Once in a hour";

}

else if((exeTime / (1000*60*60*24)) % 365==1)

{

return "Once in a day";

}

else if((exeTime / (1000*60*60*24)) % 365==7)

{

return "Once in a week";

}

else if((exeTime / (1000*60*60*24)) % 365==31)

{

return "Once in a month";

}

else if ((exeTime / (1000*60*60*24)) % 365==89)

{

return "Once in a quarter";

}

else if ((exeTime / (1000*60*60*24)) % 365==0)

{

return "Once in a year";

}

else

return "Once in a "+exeTime+" milliseconds";



}

else

{

long exeTime2 = checkInSeqSchExe(taskName);

if(exeTime2!=null &amp;&amp; exeTime2!=0)

{

if((exeTime2 / (1000*60*60)) % 24==1)

{

return "Once in a hour";

}

else if((exeTime2 / (1000*60*60*24)) % 365==1)

{

return "Once in a day";

}

else if((exeTime2 / (1000*60*60*24)) % 365==7)

{

return "Once in a week";

}

else if((exeTime2 / (1000*60*60*24)) % 365==31)

{

return "Once in a month";

}

else if ((exeTime2 / (1000*60*60*24)) % 365==89)

{

return "Once in a quarter";

}

else if ((exeTime2 / (1000*60*60*24)) % 365==0)

{

return "Once in a year";

}

else

return "Once in a "+exeTime2+" milliseconds";

}

else

{

return "NA";

}

}

}

else

return null;

}

catch(Exception e){

return e.getMessage();

}

</Source>

</RenderScript>

</ReportColumnConfig>

</Columns>

</LiveReport>

</value>

</entry>

</Map>

</Attributes>

<Description>Displays the tasks and schedules.</Description>

<RequiredRights>

<Reference class="sailpoint.object.SPRight" name="FullAccessIdentityRoleReport"/>

</RequiredRights>

</TaskDefinition>


No comments:

Post a Comment

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...