Search in sources :

Example 16 with Mapping

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

the class OpenStackVolumeAuthenticationKeyMapper method map.

@Mapping(from = LibvirtSecret.class, to = OpenstackVolumeAuthenticationKey.class)
public static OpenstackVolumeAuthenticationKey map(LibvirtSecret entity, OpenstackVolumeAuthenticationKey template) {
    OpenstackVolumeAuthenticationKey model = template != null ? template : new OpenstackVolumeAuthenticationKey();
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
        model.setUuid(entity.getId().toString());
    }
    if (entity.getDescription() != null) {
        model.setDescription(entity.getDescription());
    }
    if (entity.getCreationDate() != null) {
        model.setCreationDate(DateMapper.map(entity.getCreationDate(), null));
    }
    if (entity.getUsageType() != null) {
        model.setUsageType(map(entity.getUsageType(), null));
    }
    if (entity.getProviderId() != null) {
        OpenStackVolumeProvider provider = new OpenStackVolumeProvider();
        provider.setId(entity.getProviderId().toString());
        model.setOpenstackVolumeProvider(provider);
    }
    return model;
}
Also used : OpenstackVolumeAuthenticationKey(org.ovirt.engine.api.model.OpenstackVolumeAuthenticationKey) OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 17 with Mapping

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

the class OpenStackVolumeProviderMapper method map.

@Mapping(from = Provider.class, to = OpenStackVolumeProvider.class)
public static OpenStackVolumeProvider map(Provider<OpenStackVolumeProviderProperties> entity, OpenStackVolumeProvider template) {
    OpenStackVolumeProvider model = template != null ? template : new OpenStackVolumeProvider();
    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);
    }
    OpenStackVolumeProviderProperties additionalProperties = entity.getAdditionalProperties();
    if (additionalProperties != null) {
        if (additionalProperties.getTenantName() != null) {
            model.setTenantName(additionalProperties.getTenantName());
        }
        if (additionalProperties.getStoragePoolId() != null) {
            DataCenter dataCenter = new DataCenter();
            dataCenter.setId(additionalProperties.getStoragePoolId().toString());
            model.setDataCenter(dataCenter);
        }
    }
    return model;
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) OpenStackVolumeProviderProperties(org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties) OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider) Properties(org.ovirt.engine.api.model.Properties) OpenStackVolumeProviderProperties(org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.ovirt.engine.api.model.Property) 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