org.javers.repository.sql.finders.CdoSnapshotsEnricher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javers-persistence-sql Show documentation
Show all versions of javers-persistence-sql Show documentation
JaVers - object auditing and diff framework for Java
package org.javers.repository.sql.finders;
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 (CdoSnapshotSerialized serializedSnapshot : serializedSnapshots) {
serializedSnapshot.withCommitProperties(commitsProperties.get(serializedSnapshot.getCommitPk()));
}
}
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;
}
}