@Transactional
private VolumeSnapshotStruct newChain(VolumeSnapshotVO vo, boolean fullsnapshot) {
VolumeSnapshotTreeVO chain = new VolumeSnapshotTreeVO();
chain.setCurrent(true);
chain.setVolumeUuid(vo.getVolumeUuid());
chain.setUuid(Platform.getUuid());
chain = dbf.getEntityManager().merge(chain);
logger.debug(String.format("created new volume snapshot tree[tree uuid:%s, volume uuid:%s, full snapshot uuid:%s]",
chain.getUuid(), vo.getVolumeUuid(), vo.getUuid()));
vo.setTreeUuid(chain.getUuid());
vo.setDistance(fullsnapshot ? 0 : 1);
vo.setParentUuid(null);
vo.setLatest(true);
vo.setFullSnapshot(fullsnapshot);
dbf.getEntityManager().persist(vo);
dbf.getEntityManager().flush();
dbf.getEntityManager().refresh(vo);
VolumeSnapshotStruct struct = new VolumeSnapshotStruct();
struct.setCurrent(VolumeSnapshotInventory.valueOf(vo));
struct.setFullSnapshot(fullsnapshot);
return struct;
}