private int cleanUpOldCmdbItems(List<String> configurationItemNameList) {
        int inValidCount = 0;
        for(Cmdb cmdb:  cmdbRepository.findAllByValidConfigItem(true)){
            String configItem = cmdb.getConfigurationItem();

            if(configurationItemNameList != null && !configurationItemNameList.contains(configItem)){
                cmdb.setValidConfigItem(false);
                cmdbRepository.save(cmdb);
                inValidCount++;
            }
        }
        return inValidCount;
    }
private int cleanUpOldCmdbItems ( List < String > configurationItemNameList ) { int inValidCount = 0 ; for ( Cmdb cmdb : cmdbRepository . findAllByValidConfigItem ( true ) ) { String configItem = cmdb . getConfigurationItem ( ) ; if ( configurationItemNameList != null && ! configurationItemNameList . contains ( configItem ) ) { cmdb . setValidConfigItem ( false ) ; cmdbRepository . save ( cmdb ) ; inValidCount ++ ; } } return inValidCount ; }
Takes configurationItemNameList (list of all APP/component names) and List<Cmdb> from client and sets flag to false for old items in mongo
@param configurationItemNameList
@return return count of items invalidated