All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javers.repository.sql.finders.CdoSnapshotsEnricher Maven / Gradle / Ivy

package org.javers.repository.sql.finders;

import org.javers.common.collections.Pair;
import org.javers.core.json.CdoSnapshotSerialized;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

class CdoSnapshotsEnricher {
    void enrichWithCommitProperties(List> serializedSnapshots,
                                    List commitPropertyDTOs) {

        final Map> commitsProperties = convertCommitPropertiesToMap(commitPropertyDTOs);

        for (Pair serializedSnapshot : serializedSnapshots) {
            serializedSnapshot.left().withCommitProperties(commitsProperties.get(serializedSnapshot.right()));
        }
    }

    private Map> convertCommitPropertiesToMap(List commitPropertyDTOs) {
        Map> commitsProperties = new HashMap<>();
        for (CommitPropertyDTO commitPropertyDTO : commitPropertyDTOs) {
            if (!commitsProperties.containsKey(commitPropertyDTO.getCommitPK())) {
                commitsProperties.put(commitPropertyDTO.getCommitPK(), new HashMap());
            }
            commitsProperties.get(commitPropertyDTO.getCommitPK()).put(commitPropertyDTO.getName(), commitPropertyDTO.getValue());
        }
        return commitsProperties;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy