main/src/main/java/org/onap/policy/pap/main/rest/depundep/SessionData.java
/**
     * Update the DB with the changes.
     *
     * @throws PfModelException if an error occurred
     */
Update the DB with the changes.
@throws PfModelException if an error occurred
Update the DB with the changes . @throws PfModelException if an error occurred
public void updateDb() throws PfModelException {
        List<GroupData> created = groupCache.values().stream().filter(GroupData::isNew).collect(Collectors.toList());
        if (!created.isEmpty()) {
            if (logger.isInfoEnabled()) {
                created.forEach(group -> logger.info("creating DB group {}", group.getGroup().getName()));
            }
            dao.createPdpGroups(created.stream().map(GroupData::getGroup).collect(Collectors.toList()));
        }
        List<GroupData> updated =
                        groupCache.values().stream().filter(GroupData::isUpdated).collect(Collectors.toList());
        if (!updated.isEmpty()) {
            if (logger.isInfoEnabled()) {
                updated.forEach(group -> logger.info("updating DB group {}", group.getGroup().getName()));
            }
            dao.updatePdpGroups(updated.stream().map(GroupData::getGroup).collect(Collectors.toList()));
        }
    }
public void updateDb ( ) throws PfModelException { List < GroupData > created = groupCache . values ( ) . stream ( ) . filter ( GroupData :: isNew ) . collect ( Collectors . toList ( ) ) ; if ( ! created . isEmpty ( ) ) { if ( logger . isInfoEnabled ( ) ) { created . forEach ( group -> logger . info ( "creating DB group {}" , group . getGroup ( ) . getName ( ) ) ) ; } dao . createPdpGroups ( created . stream ( ) . map ( GroupData :: getGroup ) . collect ( Collectors . toList ( ) ) ) ; } List < GroupData > updated = groupCache . values ( ) . stream ( ) . filter ( GroupData :: isUpdated ) . collect ( Collectors . toList ( ) ) ; if ( ! updated . isEmpty ( ) ) { if ( logger . isInfoEnabled ( ) ) { updated . forEach ( group -> logger . info ( "updating DB group {}" , group . getGroup ( ) . getName ( ) ) ) ; } dao . updatePdpGroups ( updated . stream ( ) . map ( GroupData :: getGroup ) . collect ( Collectors . toList ( ) ) ) ; } }
Update the DB with the changes.
Update the DB with the changes .
// create new groups // update existing groups