Liron Ar has posted comments on this change.

Change subject: core: added GetAllDiskSnapshotsByStorageDomainIdQuery
......................................................................


Patch Set 4:

(2 comments)

http://gerrit.ovirt.org/#/c/26323/4/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllDiskSnapshotsByStorageDomainIdQuery.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllDiskSnapshotsByStorageDomainIdQuery.java:

Line 8: import org.ovirt.engine.core.common.businessentities.Snapshot;
Line 9: import org.ovirt.engine.core.common.queries.IdQueryParameters;
Line 10: 
Line 11: public class GetAllDiskSnapshotsByStorageDomainIdQuery<P extends 
IdQueryParameters> extends QueriesCommandBase<P> {
Line 12: 
Following comments are relevant if you want to keep the code as -
I'd suggest to implement as which is better imo (one iteration, shorter and 
null safe)


 Map<Guid, Snapshot> snapshots = Entities.businessEntitiesById(...)
List<DiskImage>  
diskImages=getDbFacade().getDiskImageDao().getAllSnapshotsForStorageDomain(getParameters().getId())
;
List<DiskImage> toReturn = new LinkedList..
for (Diskimage disk : diskImages) {
Snapshot snapshot = snapshots.get(disk.getVmSnapshotId());
if (snapshot != null) {
diskImage.setVmSnapshotDescription(snapshots.get(disk.getVmSnapshotId)snapshot.getDescription());
toReturn.add(diskImage)
}
getQueryReturnValue().setReturnValue(toReturn);
Line 13:     public GetAllDiskSnapshotsByStorageDomainIdQuery(P parameters) {
Line 14:         super(parameters);
Line 15:     }
Line 16: 


Line 38:                     return 
diskImage.getVmSnapshotId().equals(((Snapshot) snapshot).getId());
Line 39:                 }
Line 40:             });
Line 41: 
Line 42:             
diskImage.setVmSnapshotDescription(snapshot.getDescription());
snapshot can be null here (race with other flows)
Line 43:         }
Line 44: 
Line 45:         getQueryReturnValue().setReturnValue(diskImages);
Line 46:     }


-- 
To view, visit http://gerrit.ovirt.org/26323
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I389579e4120cb33edca594caa762a8bad63362b7
Gerrit-PatchSet: 4
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Daniel Erez <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Liron Ar <[email protected]>
Gerrit-Reviewer: Maor Lipchuk <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to