Fork me on GitHub

CPD Results

The following document contains the results of PMD's CPD 6.13.0.

Duplications

File Line
fr/paris/lutece/plugins/workflow/modules/appointmentants/web/TaskAddAntsAppointmentComponent.java 84
fr/paris/lutece/plugins/workflow/modules/appointmentants/web/TaskDeleteAntsAppointmentComponent.java 84
	private static final String MESSAGE_TASK_APPOINTMENT_NO_ANTS_NUMBER = "module.workflow.appointmentants.ants_appointment.message.noAntsApplicationNumber";

	/**
     * {@inheritDoc}
     */
	@Override
	public String getDisplayConfigForm( HttpServletRequest request, Locale locale, ITask task )
	{
		String taskTitle = I18nService.getLocalizedString( PROPERTY_TASK_TITLE, locale );
		
		return getDisplayConfigForm( request, taskTitle, locale, task, _config );
	}

	/**
     * {@inheritDoc}
     */
    @Override
    public String doSaveConfig( HttpServletRequest request, Locale locale, ITask task )
    {
        return doSaveConfig( request, task, _config );
    }

    /**
     * {@inheritDoc}
     */
	@Override
	public String getDisplayTaskInformation( int nIdHistory, HttpServletRequest request, Locale locale, ITask task )
	{
		// Retrieve the task's history
		TaskAntsAppointmentHistory taskAppointmentHistory = _antsAppointmentHistoryService.findByPrimaryKey(
				nIdHistory,
				task.getId( ),
				WorkflowUtils.getPlugin( ) );

		// If the task has history data, display it in the appointment's history
		if( taskAppointmentHistory != null )
		{
			Object[] args = new Object[1];
			// Get the ANTS application numbers to be displayed in the task's history
			if( StringUtils.isNotBlank( taskAppointmentHistory.getAntsApplicationNumbers( ) ) )
			{
				args[0] = taskAppointmentHistory.getAntsApplicationNumbers( );
			}
			// If there are no ANTS application numbers, then display a specific message instead
			else
			{
				args[0] = I18nService.getLocalizedString(
						MESSAGE_TASK_APPOINTMENT_NO_ANTS_NUMBER,
						locale );
			}

			// Return the message to be displayed in the task's history informations
			return I18nService.getLocalizedString(
					taskAppointmentHistory.isTaskSuccessful( ) ? MESSAGE_TASK_APPOINTMENT_ADDED_SUCCESS : MESSAGE_TASK_APPOINTMENT_ADDED_FAILURE,
File Line
fr/paris/lutece/plugins/workflow/modules/appointmentants/service/TaskAddAntsAppointment.java 115
fr/paris/lutece/plugins/workflow/modules/appointmentants/service/TaskDeleteAntsAppointment.java 111
			isTaskResultPositive = _antsAppointmentService.createAntsAppointment( request, resourceHistory.getIdResource( ), this.getId( ), antsAppointmentHistory );
		}
		catch ( Exception e )
		{
			AppLogService.error( CLASS_NAME, e );
		}

		saveTaskHistory( antsAppointmentHistory, nIdResourceHistory, isTaskResultPositive );
		return isTaskResultPositive;
	}

	/**
	 * Save the current task's history in the database
	 * 
	 * @param antsAppointmentHistory
	 *            Instance of TaskAntsAppointmentHistory object to save
	 * @param idResourceHistory
	 *            ID of the resource history used for the task
	 * @param isTaskSuccessful
	 *            Boolean result returned by the task
	 */
	private void saveTaskHistory( TaskAntsAppointmentHistory antsAppointmentHistory, int idResourceHistory, boolean isTaskSuccessful )
	{
		antsAppointmentHistory.setIdResourceHistory( idResourceHistory );
		antsAppointmentHistory.setIdTask( this.getId( ) );
		antsAppointmentHistory.setTaskSuccessState( isTaskSuccessful );

		_antsAppointmentHistoryService.create( antsAppointmentHistory, WorkflowUtils.getPlugin( ) );
	}

	/**
     * {@inheritDoc}
     */
	@Override
	public String getTitle( Locale locale )
	{
		return I18nService.getLocalizedString( PROPERTY_LABEL_TITLE, locale );
	}

	/**
     * {@inheritDoc}
     */
	@Override
	public void doRemoveConfig( )
	{
		_config.remove( this.getId( ) );
		_antsAppointmentHistoryService.removeByTask( this.getId( ), WorkflowUtils.getPlugin( ) );
	}

	/**
     * {@inheritDoc}
     */
	@Override
	public void doRemoveTaskInformation( int nIdHistory )
	{
		_antsAppointmentHistoryService.removeByHistory( nIdHistory, this.getId( ), WorkflowUtils.getPlugin( ) );
	}
}
File Line
fr/paris/lutece/plugins/workflow/modules/appointmentants/service/TaskAntsAppointmentService.java 599
fr/paris/lutece/plugins/workflow/modules/appointmentants/service/TaskAntsAppointmentService.java 653
	public static boolean isApplicationNumberListValidForCreation( int idAppointment, List<String> applicationNumberList ) 
	{
		List<AntsStatusResponsePOJO> statusResponseList = null;
		try
		{
			// Get the status of the given ANTS application number(s)
			statusResponseList = getAntsStatusResponseAsObjects( applicationNumberList );
		}
		catch ( Exception e )
		{
			AppLogService.error( BEAN_SERVICE, e );
			return false;
		}

		if( CollectionUtils.isEmpty( statusResponseList ) )
		{
			AppLogService.info( "{} - No status retrieved for the ANTS numbers {}",
					BEAN_SERVICE, Arrays.toString( applicationNumberList.toArray( ) ) );
			return false;
		}

		// Check the validity of each application number's status and appointments
		for( AntsStatusResponsePOJO statusResponse : statusResponseList )
		{
			String statusAntsNumber = statusResponse.getStatus( );
			Object[] listAntsNumberAppointments = statusResponse.getAppointments( );

			/* If the application number hasn't been validated, or if it already has
			 * appointments tied to it, then we shouldn't create any appointment
			 * */
			if( !StringUtils.equals( statusAntsNumber, STATUS_VALIDATED ) ||
					ArrayUtils.isNotEmpty( listAntsNumberAppointments ) )