class ProgramStageInstanceBasicCheck implements Checker {

    @Override
    public ImportSummary check( final ImmutableEvent event, final WorkContext ctx )
    {
        final ProgramStageInstance programStageInstance = ctx.getProgramStageInstanceMap().get( event.getEvent() );

        if ( programStageInstance == null )
        {
            final ImportSummary error = error( "Event ID " + event.getEvent() + " doesn't point to valid event",
                event.getEvent() );
            error.getConflicts().add( new ImportConflict( "Invalid Event ID", event.getEvent() ) );

            return error;
        }
        else if ( programStageInstance.isDeleted() || ctx.getImportOptions().getImportStrategy().isCreate() )
        {
            return error(
                "Event ID " + event.getEvent() + " was already used and/or deleted. This event can not be modified." )
                    .setReference( event.getEvent() );
        }

        return success();
    }

}