private List < String > getBusinessServiceList ( String firstName , String lastName ) { List < String > businessServiceList = new ArrayList <> ( ) ; List < Cmdb > cmdbs = cmdbService . getAllBusServices ( ) ; /** Defining search parameters */ Predicate < Cmdb > supportOwnerLn = p -> p . getSupportOwner ( ) != null ? p . getSupportOwner ( ) . toLowerCase ( ) . contains ( lastName ) : false ; Predicate < Cmdb > serviceOwnerLn = p -> p . getAppServiceOwner ( ) != null ? p . getAppServiceOwner ( ) . toLowerCase ( ) . contains ( lastName ) : false ; Predicate < Cmdb > developmentOwnerLn = p -> p . getDevelopmentOwner ( ) != null ? p . getDevelopmentOwner ( ) . toLowerCase ( ) . contains ( lastName ) : false ; Predicate < Cmdb > businessOwnerLn = p -> p . getBusinessOwner ( ) != null ? p . getBusinessOwner ( ) . toLowerCase ( ) . contains ( lastName ) : false ; /** * Combining search parameters into one predicate OR search */ Predicate < Cmdb > fullPredicate = supportOwnerLn . or ( serviceOwnerLn ) . or ( developmentOwnerLn ) . or ( businessOwnerLn ) ; /** * Executes search based on parameters created above and returns matching list */ List < Cmdb > matching = cmdbs . stream ( ) . filter ( fullPredicate ) . collect ( Collectors . toList ( ) ) ; for ( Cmdb cmdb : matching ) { String businessServiceApp = cmdb . getConfigurationItem ( ) ; boolean serviceOwnerMatch = doesMatchFullName ( firstName , cmdb . getAppServiceOwner ( ) ) ; boolean businessOwnerMatch = doesMatchFullName ( firstName , cmdb . getBusinessOwner ( ) ) ; boolean supportOwnerMatch = doesMatchFullName ( firstName , cmdb . getSupportOwner ( ) ) ; boolean developmentOwnerMatch = doesMatchFullName ( firstName , cmdb . getDevelopmentOwner ( ) ) ; if ( ( serviceOwnerMatch || businessOwnerMatch || supportOwnerMatch || developmentOwnerMatch ) && ! businessServiceList . contains ( businessServiceApp ) ) { businessServiceList . add ( businessServiceApp ) ; } } return businessServiceList ; }
Takes First name and last name and returns any Business Services where one of the 4 owner fields match the input