Processes Widget
The Processes widget is a widget that shows and provides feedback about processes triggered and run in the background. It shows the statuses of asynchronous calls running in the background.
Widget Definition
| Name | Processes Widget |
| ID | com.hybris.backoffice.widgets.processes |
| Category | Synchronization |
| Description | Provides feedback about processes triggered and run in the background. |
| Applied In | Backoffice |
| Based On | Not applicable |
| Author | SAP |
| Inputs |
Details of input sockets:
|
| Outputs |
Details of output sockets:
|
| Generated Events | Not applicable |
Configuration
The Processes widget doesn't have dedicated configuration delivered by config.xml. However, there are things that allow customization of what is displayed to the user.
/**
* POJO which represents cronJob history search criteria.
*/
public class CronJobHistoryInclude
{
private Set<String> jobCodes;
private String jobTypeCode;
private String cronJobTypeCode;
public CronJobHistoryInclude(final Set<String> jobCodes, final String jobTypeCode, final String cronJobTypeCode)
{
this.jobCodes = jobCodes;
this.jobTypeCode = jobTypeCode;
this.cronJobTypeCode = cronJobTypeCode;
}
...
}
The following example shows how to include processes, which run a job with a solrIndexerJob code:
<cng:map-extender bean="backofficeCronJobHistoryIncludes" xmlns:cng="http://www.hybris.com/cockpitng/spring">
<cng:put key-type="java.lang.String" value-type="de.hybris.platform.servicelayer.cronjob.CronJobHistoryInclude">
<entry key="solrIndexerProcesses">
<bean class="de.hybris.platform.servicelayer.cronjob.CronJobHistoryInclude">
<property name="jobCodes">
<set value-type="java.lang.String">
<value type="java.lang.String">solrIndexerJob</value>
</set>
</property>
</bean>
</entry>
</cng:put>
</cng:map-extender>
The key in the map is to be able to remove modified existing entries, so it should be unique in the configuration.
Having the above configured list of processes, includes all solr indexer processes.
Modification of process rendering
By default, the DefaultProcessItemRenderingStrategy strategy is used to render a process. However, not every process is the same, and it might be necessary to change the way it is rendered. It can be achieved by implementing the following interface:
/**
* Process item rendering strategy
*/
public interface ProcessItemRenderingStrategy extends Ordered
{
/**
* Checks if given process should be rendered by the strategy.
*
* @param cronJobHistory
* cron job history representing a process
* @return handle flag
*/
boolean canHandle(final CronJobHistoryModel cronJobHistory);
/**
* Checks if it's possible to rerun given process
*
* @param cronJobHistory
* cron job history representing a process
* @return rerun applicable flag
*/
boolean isRerunApplicable(CronJobHistoryModel cronJobHistory);
/**
* Reruns given process
*
* @param cronJobHistory
* cron job history representing a process
*/
void rerunCronJob(CronJobHistoryModel cronJobHistory);
/**
* Gets title
*
* @param cronJobHistory
* cron job history representing a process
* @return title
*/
String getTitle(CronJobHistoryModel cronJobHistory);
/**
* Gets job title
*
* @param cronJobHistory
* cron job history representing a process
* @return title of the job
*/
String getJobTitle(CronJobHistoryModel cronJobHistory);
/**
* Checks if process supports progress bar. If not then it will not be rendered.
*
* @param cronJobHistory
* cron job history representing a process
* @return rerun applicable flag
*/
boolean isProgressSupported(CronJobHistoryModel cronJobHistory);
}
A default implementation of methods related to rerunning processes, is to perform cron job once again, but if the cron job cannot be rerun, the isRerunApplicable method should return false.
Process on the list can have a progress bar - it's defined in the strategy (default value: false). The value of the progress bar is calculated basing on the progress field in CronJobHistoryModel, it's the job responsibility to update the percentage in the range between 0-100. Since the Backoffice heartbeat is triggered with certain frequency, the progress bar tries to predict what is the progress, basing on the achieved data. If it is beyond a new value in the next update, it slows down to match the real progress speed.
The strategy can be registered using following spring configuration in the Backoffice context:
<cng:list-extender bean="processItemRenderingStrategyRegistry" getter="strategiesList" setter="strategies" >
<cng:add value-type="com.hybris.backoffice.widgets.processes.ProcessItemRenderingStrategy">
<ref bean="solrProcessItemRenderingStrategy"/>
</cng:add>
</cng:list-extender>
For example:
public class SolrProcessItemRenderingStrategy extends DefaultProcessItemRenderingStrategy
{
@Override
public boolean canHandle(final CronJobHistoryModel cronJobHistory)
{
return "solrIndexerJob".equals(cronJobHistory.getJobCode());
}
Updating the list
Since Backoffice checks if there are new processes for it to display every heartbeat, which is every 10 seconds, it might be convenient to notify the Processes widget that there is a process started right away. It can be done through the updateCronJob socket, or by publishing global event in session scope with a started cron job code.
cockpitEventQueue.publishEvent(new DefaultCockpitEvent("updateProcessForCronJob", startedCronJob.getCode(), null));
//com.hybris.backoffice.widgets.processes.ProcessesController#GLOBAL_EVENT_UPDATE_PROCESS_FOR_CRON_JOB can be used for event name
Widget Preview
Preview of the Processes widget icon, the widget was designed for the System Toolbar:
The widget contains an opening button and a sidebar. After you click the Processes icon, the widget expands and you can see all the running and finished jobs. Each element on the list displays some information about a process: its name with an item counter, catalog, estimated progress, elapsed time, or a time when a job was finished and its status. You're able to accesses and choose the widget settings at runtime by clicking the Gear icon. There is also a Three Dots button available for each process, it shows a popup with available actions.
You can see a Yellow Marker in the Processes widget, when any new process is added to the widget, or when any job changes its status. The Yellow Marker was added to the Processes widget icon to show that there are some changes unseen by the user. When there's a new job started, the icon is rotating to show that there is a background process running.
If there are any new processes running, the Processes icons visible next to each job in the widget are marked with yellow. The markers disappear after closing the widget.
| Component Name | Description |
|---|---|
| Gear icon | Allows you to open a popup with more settings. |
| Show Global Jobs | Shows or hides all jobs run by different users. |
| Show Finished Jobs | Shows or hides finished jobs. |
| Show From | Enables you to display jobs during a given time range. |
| Three Dots icon | Shows a popup with actions available for given process:
|
Settings
| Setting | Type | Description |
|---|---|---|
| listitemRenderer | java.lang.String | Defines the name of a custom list item renderer bean for rendering processes. The renderer must implement WidgetComponentRenderer<Listitem, Object, ProcessData>. |
| showFinishedJobs | java.lang.Boolean | If set to true, then finished synchronizations are shown. |
| showGlobalJobs | java.lang.Boolean | If set to true, then synchronizations run by other users are visible on the list. |
| timeRanges | java.lang.String | Defines the list of available time ranges. The value should be a comma-separated list of following values
|
Widget Slots
| slotID | Multiplicity | Type | Slots Composition |
|---|---|---|---|
| cockpitWidgetChildrenInvisible | multi | Not applicable | A general-purpose slot available for widgets. Any widget placed on this slot is not displayed in the application view but can be accessed through its socket API. |