class DataValueCheck implements Checker {

    @Override
    public ImportSummary check( ImmutableEvent event, WorkContext ctx )
    {
        final Set<DataValue> dataValues = event.getDataValues();
        final ImportSummary importSummary = new ImportSummary();
        final User user = ctx.getImportOptions().getUser();

        for ( DataValue dataValue : dataValues )
        {
            if ( !checkHasValidDataElement( importSummary, ctx, dataValue )
                || !checkSerializeToJson( importSummary, ctx, dataValue ) )
            {
                importSummary.setStatus( ImportStatus.ERROR );
                importSummary.setReference( event.getUid() );
                importSummary.incrementIgnored();

                return importSummary;
            }
        }

        if ( importSummary.getConflicts().isEmpty() )
        {
            if ( doValidationOfMandatoryAttributes( user ) && isValidationRequired( event, ctx ) )
            {
                validateMandatoryAttributes( importSummary, ctx, event );
            }
        }

        if ( !importSummary.getConflicts().isEmpty() )
        {
            importSummary.setStatus( ImportStatus.ERROR );
            importSummary.setReference( event.getUid() );
            importSummary.incrementIgnored();
        }

        return importSummary;
    }

}