main/src/main/java/org/onap/policy/pap/main/rest/depundep/PdpGroupDeployProvider.java
/**
     * Adds or updates subgroups within the group.
     *
     * @param data session data
     * @param dbgroup the group, as it appears within the DB
     * @param group the group to be added
     * @param result the validation result
     * @return {@code true} if the DB group was modified, {@code false} otherwise
     * @throws PfModelException if an error occurred
     */
Adds or updates subgroups within the group.
Adds or updates subgroups within the group .
private boolean addOrUpdateSubGroups(SessionData data, PdpGroup dbgroup, PdpGroup group,
                    BeanValidationResult result) throws PfModelException {
        Map<String, PdpSubGroup> type2sub = new HashMap<>();
        dbgroup.getPdpSubgroups().forEach(subgrp -> type2sub.put(subgrp.getPdpType(), subgrp));
        boolean updated = false;
        for (PdpSubGroup subgrp : group.getPdpSubgroups()) {
            PdpSubGroup dbsub = type2sub.get(subgrp.getPdpType());
            BeanValidationResult subResult = new BeanValidationResult(subgrp.getPdpType(), subgrp);
            if (dbsub == null) {
                updated = true;
                subResult.addResult(addSubGroup(data, subgrp));
                dbgroup.getPdpSubgroups().add(subgrp);
            } else {
                updated = updateSubGroup(data, group, dbsub, subgrp, subResult) || updated;
            }
            result.addResult(subResult);
        }
        return updated;
    }
private boolean addOrUpdateSubGroups ( SessionData data , PdpGroup dbgroup , PdpGroup group , BeanValidationResult result ) throws PfModelException { Map < String , PdpSubGroup > type2sub = new HashMap < > ( ) ; dbgroup . getPdpSubgroups ( ) . forEach ( subgrp -> type2sub . put ( subgrp . getPdpType ( ) , subgrp ) ) ; boolean updated = false ; for ( PdpSubGroup subgrp : group . getPdpSubgroups ( ) ) { PdpSubGroup dbsub = type2sub . get ( subgrp . getPdpType ( ) ) ; BeanValidationResult subResult = new BeanValidationResult ( subgrp . getPdpType ( ) , subgrp ) ; if ( dbsub == null ) { updated = true ; subResult . addResult ( addSubGroup ( data , subgrp ) ) ; dbgroup . getPdpSubgroups ( ) . add ( subgrp ) ; } else { updated = updateSubGroup ( data , group , dbsub , subgrp , subResult ) || updated ; } result . addResult ( subResult ) ; } return updated ; }
Adds or updates subgroups within the group.
Adds or updates subgroups within the group .
// create a map of existing subgroups