use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockMapper method map.
public static BlockSnapshotRestRep map(DbClient dbClient, BlockSnapshot from) {
if (from == null) {
return null;
}
BlockSnapshotRestRep to = new BlockSnapshotRestRep();
mapBlockObjectFields(from, to);
// Map the consistency group
to.setConsistencyGroup(toRelatedResource(ResourceTypeEnum.BLOCK_CONSISTENCY_GROUP, from.getConsistencyGroup()));
if (from.getParent() != null) {
URI parentURI = from.getParent().getURI();
URIQueryResultList results = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeByAssociatedVolumesConstraint(parentURI.toString()), results);
Iterator<URI> resultsIter = results.iterator();
if (resultsIter.hasNext()) {
parentURI = resultsIter.next();
}
to.setParent(toRelatedResource(ResourceTypeEnum.VOLUME, parentURI));
}
if (from.getProject() != null) {
to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject().getURI()));
}
to.setNewVolumeNativeId(from.getNewVolumeNativeId());
to.setSourceNativeId(from.getSourceNativeId());
to.setSyncActive(from.getIsSyncActive());
to.setReplicaState(getReplicaState(from));
to.setReadOnly(from.getIsReadOnly());
to.setSnapsetLabel(from.getSnapsetLabel() != null ? from.getSnapsetLabel() : "");
to.setProvisionedCapacity(CapacityUtils.convertBytesToGBInStr(from.getProvisionedCapacity()));
to.setAllocatedCapacity(CapacityUtils.convertBytesToGBInStr(from.getAllocatedCapacity()));
to.setTechnologyType(from.getTechnologyType());
return to;
}
Aggregations