Search in sources :

Example 6 with Mapping

use of org.ovirt.engine.api.restapi.types.Mapping in project ovirt-engine by oVirt.

the class ExternalHostMapper method map.

@Mapping(from = VDS.class, to = ExternalHost.class)
public static ExternalHost map(VDS entity, ExternalHost template) {
    ExternalHost model = template != null ? template : new ExternalHost();
    String name = entity.getName();
    if (name != null) {
        model.setId(string2hex(name));
        model.setName(name);
    }
    if (entity.getHostName() != null) {
        model.setAddress(entity.getHostName());
    }
    return model;
}
Also used : ExternalHost(org.ovirt.engine.api.model.ExternalHost) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 7 with Mapping

use of org.ovirt.engine.api.restapi.types.Mapping in project ovirt-engine by oVirt.

the class StaticMapper method mapBarToFooInterfaces.

@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;
}
Also used : FooImpl(org.ovirt.engine.api.restapi.test.mappers.impl.FooImpl) IFoo(org.ovirt.engine.api.restapi.test.mappers.api.IFoo) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 8 with Mapping

use of org.ovirt.engine.api.restapi.types.Mapping in project ovirt-engine by oVirt.

the class StaticMapper method mapFooToBarClasses.

@Mapping(from = FooImpl.class, to = BarImpl.class)
public static BarImpl mapFooToBarClasses(IFoo foo, BarImpl template) {
    BarImpl bar = template != null ? template : new BarImpl();
    bar.set(foo.get());
    return bar;
}
Also used : BarImpl(org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 9 with Mapping

use of org.ovirt.engine.api.restapi.types.Mapping in project ovirt-engine by oVirt.

the class OpenStackSubnetMapper method map.

@Mapping(from = OpenStackSubnet.class, to = ExternalSubnet.class)
public static ExternalSubnet map(OpenStackSubnet model, ExternalSubnet template) {
    ExternalSubnet entity = template != null ? template : new ExternalSubnet();
    if (model.isSetId()) {
        entity.setId(model.getId());
    }
    if (model.isSetName()) {
        entity.setName(model.getName());
    }
    if (model.isSetCidr()) {
        entity.setCidr(model.getCidr());
    }
    if (model.isSetIpVersion()) {
        entity.setIpVersion(IpVersionMapper.map(IpVersion.fromValue(model.getIpVersion())));
    }
    if (model.isSetGateway()) {
        entity.setGateway(model.getGateway());
    }
    List<String> entityDnsServers = new ArrayList<>(1);
    if (model.isSetDnsServers()) {
        List<String> modelDnsServers = model.getDnsServers().getDnsServers();
        entityDnsServers.addAll(modelDnsServers);
    }
    entity.setDnsServers(entityDnsServers);
    return entity;
}
Also used : ExternalSubnet(org.ovirt.engine.core.common.businessentities.network.ExternalSubnet) ArrayList(java.util.ArrayList) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 10 with Mapping

use of org.ovirt.engine.api.restapi.types.Mapping in project ovirt-engine by oVirt.

the class ExternalComputeResourceMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.ExternalComputeResource.class, to = ExternalComputeResource.class)
public static ExternalComputeResource map(org.ovirt.engine.core.common.businessentities.ExternalComputeResource entity, ExternalComputeResource template) {
    ExternalComputeResource model = template != null ? template : new ExternalComputeResource();
    String name = entity.getName();
    if (name != null) {
        model.setId(string2hex(name));
        model.setName(name);
    }
    if (entity.getProvider() != null) {
        model.setProvider(entity.getProvider());
    }
    if (entity.getUser() != null) {
        model.setUser(entity.getUser());
    }
    if (entity.getUrl() != null) {
        model.setUrl(entity.getUrl());
    }
    return model;
}
Also used : ExternalComputeResource(org.ovirt.engine.api.model.ExternalComputeResource) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Aggregations

Mapping (org.ovirt.engine.api.restapi.types.Mapping)17 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Properties (org.ovirt.engine.api.model.Properties)3 Property (org.ovirt.engine.api.model.Property)3 OpenStackVolumeProvider (org.ovirt.engine.api.model.OpenStackVolumeProvider)2 BarImpl (org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl)2 FooImpl (org.ovirt.engine.api.restapi.test.mappers.impl.FooImpl)2 OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)2 ArrayList (java.util.ArrayList)1 AgentConfiguration (org.ovirt.engine.api.model.AgentConfiguration)1 DataCenter (org.ovirt.engine.api.model.DataCenter)1 ExternalComputeResource (org.ovirt.engine.api.model.ExternalComputeResource)1 ExternalDiscoveredHost (org.ovirt.engine.api.model.ExternalDiscoveredHost)1 ExternalHost (org.ovirt.engine.api.model.ExternalHost)1 ExternalHostGroup (org.ovirt.engine.api.model.ExternalHostGroup)1 ExternalHostProvider (org.ovirt.engine.api.model.ExternalHostProvider)1 KatelloErratum (org.ovirt.engine.api.model.KatelloErratum)1 OpenStackImageProvider (org.ovirt.engine.api.model.OpenStackImageProvider)1 OpenStackNetwork (org.ovirt.engine.api.model.OpenStackNetwork)1