@Mapping(from = org.ovirt.engine.core.common.job.ExternalSystemType.class, to = ExternalSystemType.class) public static ExternalSystemType map(org.ovirt.engine.core.common.job.ExternalSystemType type) { switch (type) { case VDSM: return ExternalSystemType.VDSM; case GLUSTER: return ExternalSystemType.GLUSTER; default: return null; } }
@Mapping(from = GraphicsType.class, to = DisplayType.class) public static DisplayType map(GraphicsType graphicsType, DisplayType displayType) { if (graphicsType == GraphicsType.SPICE) { return DisplayType.SPICE; } else if (graphicsType == GraphicsType.VNC) { return DisplayType.VNC; } return null; }
@Mapping(from = DiskFormat.class, to = String.class) public static VolumeFormat map(DiskFormat diskFormat, VolumeFormat template) { switch (diskFormat) { case COW: return VolumeFormat.COW; case RAW: return VolumeFormat.RAW; default: return VolumeFormat.Unassigned; } }
@Mapping(from = org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStage.class, to = HookStage.class) public static HookStage map(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStage hookStage, HookStage template) { switch (hookStage) { case POST: return HookStage.POST; case PRE: return HookStage.PRE; default: return null; } }
@Mapping(from = org.ovirt.engine.core.common.businessentities.gluster.TransportType.class, to = TransportType.class) public static TransportType map(org.ovirt.engine.core.common.businessentities.gluster.TransportType transportType, TransportType template) { switch (transportType) { case TCP: return TransportType.TCP; case RDMA: return TransportType.RDMA; default: return null; } }
@Mapping(from = org.ovirt.engine.api.model.CloudInitNetworkProtocol.class, to = CloudInitNetworkProtocol.class) public static CloudInitNetworkProtocol map(org.ovirt.engine.api.model.CloudInitNetworkProtocol protocol) { switch (protocol) { case ENI: return CloudInitNetworkProtocol.ENI; case OPENSTACK_METADATA: return CloudInitNetworkProtocol.OPENSTACK_METADATA; default: return null; } }
@Mapping (from=GlusterBrick.class, to=GlusterVolumeAdvancedDetails.class) public static GlusterVolumeAdvancedDetails map(GlusterBrick model, GlusterVolumeAdvancedDetails toEntity) { //AdvancedDetails is a read only from server and no support for setting these. //Hence mapping from REST model to Business entity not required. GlusterVolumeAdvancedDetails entity = (toEntity == null) ? new GlusterVolumeAdvancedDetails() : toEntity; return entity; }
@Mapping (from=GlusterVolumeProfileDetails.class, to=GlusterVolumeProfileInfo.class) public static GlusterVolumeProfileInfo map(GlusterVolumeProfileDetails model, GlusterVolumeProfileInfo toEntity) { //GlusterVolumeProfileInfo is read only from server and no support for setting these. //Hence mapping from REST model to Business entity not required. GlusterVolumeProfileInfo entity = (toEntity == null) ? new GlusterVolumeProfileInfo() : toEntity; return entity; }
@Mapping(from = Map.class, to = Options.class) public static Options map(Map<String, String> entity, Options template) { Options model = template != null ? template : new Options(); for (Map.Entry<String, String> option : entity.entrySet()) { model.getOptions().add(map(option, null)); } return model; }
@Mapping(from = String.class, to = File.class) public static File map(String entity, File template) { File model = template != null ? template : new File(); model.setId(entity); model.setName(entity); return model; } }
@Mapping(from = HostDeviceView.class, to = HostDevice.class) public static HostDevice map(HostDeviceView entity, HostDevice model) { model = map((org.ovirt.engine.core.common.businessentities.HostDevice) entity, model); if (entity.isIommuPlaceholder()) { model.setPlaceholder(true); } return model; }
@Mapping(from = org.ovirt.engine.core.common.businessentities.network.pseudo.NetworkLabel.class, to = NetworkLabel.class) public static NetworkLabel map(org.ovirt.engine.core.common.businessentities.network.pseudo.NetworkLabel entity, NetworkLabel template) { NetworkLabel model = template != null ? template : new NetworkLabel(); if (entity.getId() != null) { model.setId(entity.getId()); } return model; } }
@Mapping(from = Directory.class, to = Domain.class) public static Domain map(Directory dir, Domain template) { Domain directory = template != null ? template : new Domain(); directory.setName(dir.getDomain()); directory.setId(dir.getId()); return directory; } }
@Mapping(from = HostNicVirtualFunctionsConfiguration.class, to = UpdateHostNicVfsConfigParameters.class) public static UpdateHostNicVfsConfigParameters map(HostNicVirtualFunctionsConfiguration apiModel, UpdateHostNicVfsConfigParameters params) { if (apiModel.isSetAllNetworksAllowed()) { params.setAllNetworksAllowed(apiModel.isAllNetworksAllowed()); } if (apiModel.isSetNumberOfVirtualFunctions()) { params.setNumOfVfs(apiModel.getNumberOfVirtualFunctions()); } return params; }
@Mapping(from = HostNicVfsConfig.class, to = UpdateHostNicVfsConfigParameters.class) public static UpdateHostNicVfsConfigParameters map(HostNicVfsConfig entity, UpdateHostNicVfsConfigParameters params) { params.setNicId(entity.getNicId()); params.setAllNetworksAllowed(entity.isAllNetworksAllowed()); params.setNumOfVfs(entity.getNumOfVfs()); return params; } }
@Mapping(from = InstanceType.class, to = Display.class) public static Display map(InstanceType instanceType, Display display) { Display result = (display == null) ? new Display() : display; result.setMonitors(instanceType.getNumOfMonitors()); result.setSingleQxlPci(instanceType.getSingleQxlPci()); result.setSmartcardEnabled(instanceType.isSmartcardEnabled()); return result; }
@Mapping(from = IFoo.class, to = IBar.class) public static IBar mapFooToBarInterfaces(IFoo foo, IBar template) { IBar bar = template != null ? template : new BarImpl(); bar.set(foo.get()); return bar; }
@Mapping(from = IBar.class, to = IFoo.class) public static IFoo mapBarToFooInterfaces(IBar bar, IFoo template) { IFoo foo = template != null ? template : new FooImpl(); foo.set(bar.get()); return foo; }
@Mapping(from = RepoImage.class, to = Image.class) public static Image map(RepoImage entity, Image template) { Image model = template != null ? template : new Image(); model.setId(entity.getRepoImageId()); model.setName(entity.getRepoImageName()); model.setSize(entity.getSize()); model.setType(mapImageType(entity.getFileType())); return model; }
@Mapping(from = VdsStatic.class, to = Ssh.class) public static Ssh map(VdsStatic entity, Ssh template) { Ssh model = template != null ? template : new Ssh(); model.setPort(entity.getSshPort()); model.setUser(new User()); model.getUser().setUserName(entity.getSshUsername()); model.setFingerprint(entity.getSshKeyFingerprint()); return model; }