Search in sources :

Example 11 with Mapping

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

the class ExternalHostGroupMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.ExternalHostGroup.class, to = ExternalHostGroup.class)
public static ExternalHostGroup map(org.ovirt.engine.core.common.businessentities.ExternalHostGroup entity, ExternalHostGroup template) {
    ExternalHostGroup model = template != null ? template : new ExternalHostGroup();
    String name = entity.getName();
    if (name != null) {
        model.setId(string2hex(name));
        model.setName(name);
    }
    if (entity.getArchitectureName() != null) {
        model.setArchitectureName(entity.getArchitectureName());
    }
    if (entity.getOperatingsystemName() != null) {
        model.setOperatingSystemName(entity.getOperatingsystemName());
    }
    if (entity.getDomainName() != null) {
        model.setDomainName(entity.getDomainName());
    }
    if (entity.getSubnetName() != null) {
        model.setSubnetName(entity.getSubnetName());
    }
    return model;
}
Also used : ExternalHostGroup(org.ovirt.engine.api.model.ExternalHostGroup) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 12 with Mapping

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

the class StaticMapper method mapFooToBarInterfaces.

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

Example 13 with Mapping

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

the class StaticMapper method mapBarToFooClasses.

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

Example 14 with Mapping

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

the class OpenStackImageProviderMapper method map.

@Mapping(from = Provider.class, to = OpenStackImageProvider.class)
public static OpenStackImageProvider map(Provider<OpenStackImageProviderProperties> entity, OpenStackImageProvider template) {
    OpenStackImageProvider model = template != null ? template : new OpenStackImageProvider();
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    if (entity.getName() != null) {
        model.setName(entity.getName());
    }
    if (entity.getDescription() != null) {
        model.setDescription(entity.getDescription());
    }
    if (entity.getUrl() != null) {
        model.setUrl(entity.getUrl());
    }
    if (entity.getAuthUrl() != null) {
        model.setAuthenticationUrl(entity.getAuthUrl());
    }
    model.setRequiresAuthentication(entity.isRequiringAuthentication());
    if (entity.getUsername() != null) {
        model.setUsername(entity.getUsername());
    }
    // The password isn't mapped for security reasons.
    // if (entity.getPassword() != null) {
    // model.setPassword(entity.getPassword());
    // }
    Map<String, String> customProperties = entity.getCustomProperties();
    if (customProperties != null) {
        Properties properties = new Properties();
        for (Map.Entry<String, String> entry : customProperties.entrySet()) {
            Property property = new Property();
            property.setName(entry.getKey());
            property.setValue(entry.getValue());
            properties.getProperties().add(property);
        }
        model.setProperties(properties);
    }
    OpenStackImageProviderProperties additionalProperties = entity.getAdditionalProperties();
    if (additionalProperties != null) {
        if (additionalProperties.getTenantName() != null) {
            model.setTenantName(additionalProperties.getTenantName());
        }
    }
    return model;
}
Also used : OpenStackImageProvider(org.ovirt.engine.api.model.OpenStackImageProvider) Properties(org.ovirt.engine.api.model.Properties) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.ovirt.engine.api.model.Property) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 15 with Mapping

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

the class OpenStackNetworkProviderMapper method map.

@Mapping(from = OpenstackNetworkProviderProperties.AgentConfiguration.class, to = AgentConfiguration.class)
public static AgentConfiguration map(OpenstackNetworkProviderProperties.AgentConfiguration entity, AgentConfiguration template) {
    AgentConfiguration model = template != null ? template : new AgentConfiguration();
    if (entity.getNetworkMappings() != null) {
        model.setNetworkMappings(entity.getNetworkMappings());
    }
    OpenstackNetworkProviderProperties.MessagingConfiguration messagingConfiguration = entity.getMessagingConfiguration();
    if (messagingConfiguration != null) {
        if (messagingConfiguration.getBrokerType() != null) {
            model.setBrokerType(map(messagingConfiguration.getBrokerType()));
        }
        if (messagingConfiguration.getAddress() != null) {
            model.setAddress(messagingConfiguration.getAddress());
        }
        if (messagingConfiguration.getPort() != null) {
            model.setPort(messagingConfiguration.getPort());
        }
        if (messagingConfiguration.getUsername() != null) {
            model.setUsername(messagingConfiguration.getUsername());
        }
    // The password isn't mapped for security reasons.
    // if (messagingConfiguration.getPassword() != null) {
    // model.setPassword(messagingConfiguration.getPassword());
    // }
    }
    return model;
}
Also used : AgentConfiguration(org.ovirt.engine.api.model.AgentConfiguration) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) 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