class FilteringOutUndeclaredDataElementsProcessor implements Processor {

    @Override
    public void process( final Event event, final WorkContext ctx )
    {
        if ( StringUtils.isNotBlank( event.getProgramStage() ) )
        {
            Set<String> programStageDataElementUids = getDataElementUidsFromProgramStage( event.getProgramStage(),
                ctx );
            event.setDataValues(
                event.getDataValues().stream()
                    .filter( dataValue -> programStageDataElementUids.contains( dataValue.getDataElement() ) )
                    .collect( Collectors.toSet() ) );
        }
    }

}