Search in sources :

Example 1 with Mapping

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

the class ErratumMapper method map.

@Mapping(from = Erratum.class, to = KatelloErratum.class)
public static KatelloErratum map(Erratum entity, KatelloErratum model) {
    model = model == null ? new KatelloErratum() : model;
    model.setId(string2hex(entity.getId()));
    model.setName(entity.getId());
    model.setTitle(entity.getTitle());
    model.setSummary(entity.getSummary());
    model.setSolution(entity.getSolution());
    model.setDescription(entity.getDescription());
    if (entity.getIssued() != null) {
        model.setIssued(DateMapper.map(entity.getIssued(), null));
    }
    model.setSeverity(entity.getSeverity() == null ? null : entity.getSeverity().getDescription());
    model.setType(entity.getType() == null ? null : entity.getType().getDescription());
    if (entity.getPackages() != null && !entity.getPackages().isEmpty()) {
        Packages packages = new Packages();
        for (String packageName : entity.getPackages()) {
            Package p = new Package();
            p.setName(packageName);
            packages.getPackages().add(p);
        }
        model.setPackages(packages);
    }
    return model;
}
Also used : Packages(org.ovirt.engine.api.model.Packages) KatelloErratum(org.ovirt.engine.api.model.KatelloErratum) Package(org.ovirt.engine.api.model.Package) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 2 with Mapping

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

the class ExternalDiscoveredHostMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost.class, to = ExternalDiscoveredHost.class)
public static ExternalDiscoveredHost map(org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost entity, ExternalDiscoveredHost template) {
    ExternalDiscoveredHost model = template != null ? template : new ExternalDiscoveredHost();
    String name = entity.getName();
    if (name != null) {
        model.setId(string2hex(name));
        model.setName(name);
    }
    if (entity.getMac() != null) {
        model.setMac(entity.getMac());
    }
    if (entity.getIp() != null) {
        model.setIp(entity.getIp());
    }
    if (entity.getSubnetName() != null) {
        model.setSubnetName(entity.getSubnetName());
    }
    if (entity.getLastReport() != null) {
        model.setLastReport(entity.getLastReport());
    }
    return model;
}
Also used : ExternalDiscoveredHost(org.ovirt.engine.api.model.ExternalDiscoveredHost) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 3 with Mapping

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

the class OpenStackNetworkProviderMapper method map.

@Mapping(from = Provider.class, to = OpenStackNetworkProvider.class)
public static OpenStackNetworkProvider map(Provider<OpenstackNetworkProviderProperties> entity, OpenStackNetworkProvider template) {
    OpenStackNetworkProvider model = template != null ? template : new OpenStackNetworkProvider();
    model.setType(mapProviderType(entity.getType()));
    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.setUnmanaged(entity.getIsUnmanaged());
    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);
    }
    OpenstackNetworkProviderProperties additionalProperties = entity.getAdditionalProperties();
    if (additionalProperties != null) {
        if (additionalProperties.getTenantName() != null) {
            model.setTenantName(additionalProperties.getTenantName());
        }
        String pluginType = additionalProperties.getPluginType();
        if (pluginType != null) {
            // for backwards compatibility, and should be removed in version 5 of the API.
            if (entity.getType() == ProviderType.OPENSTACK_NETWORK && OpenstackNetworkPluginType.OPEN_VSWITCH.name().equalsIgnoreCase(pluginType)) {
                model.setPluginType(NetworkPluginType.OPEN_VSWITCH);
            }
            model.setExternalPluginType(additionalProperties.getPluginType());
        }
        if (additionalProperties.getAgentConfiguration() != null) {
            model.setAgentConfiguration(map(additionalProperties.getAgentConfiguration(), null));
        }
        model.setReadOnly(additionalProperties.getReadOnly());
        model.setAutoSync(additionalProperties.getAutoSync());
    }
    return model;
}
Also used : OpenStackNetworkProvider(org.ovirt.engine.api.model.OpenStackNetworkProvider) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Properties(org.ovirt.engine.api.model.Properties) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.ovirt.engine.api.model.Property) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 4 with Mapping

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

the class ExternalHostProviderMapper method map.

@Mapping(from = ExternalHostProvider.class, to = Provider.class)
public static Provider map(ExternalHostProvider model, Provider template) {
    Provider entity = template != null ? template : new Provider();
    entity.setType(ProviderType.FOREMAN);
    if (model.isSetId()) {
        entity.setId(GuidUtils.asGuid(model.getId()));
    }
    if (model.isSetName()) {
        entity.setName(model.getName());
    }
    if (model.isSetDescription()) {
        entity.setDescription(model.getDescription());
    }
    if (model.isSetUrl()) {
        entity.setUrl(model.getUrl());
    }
    if (model.isSetRequiresAuthentication()) {
        entity.setRequiringAuthentication(model.isRequiresAuthentication());
    }
    if (model.isSetUsername()) {
        entity.setUsername(model.getUsername());
    }
    if (model.isSetPassword()) {
        entity.setPassword(model.getPassword());
    }
    return entity;
}
Also used : ExternalHostProvider(org.ovirt.engine.api.model.ExternalHostProvider) Provider(org.ovirt.engine.core.common.businessentities.Provider) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 5 with Mapping

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

the class OpenStackNetworkMapper method map.

@Mapping(from = Network.class, to = OpenStackNetwork.class)
public static OpenStackNetwork map(Network entity, OpenStackNetwork template) {
    OpenStackNetwork model = template != null ? template : new OpenStackNetwork();
    ProviderNetwork providedBy = entity.getProvidedBy();
    if (providedBy != null) {
        if (providedBy.getExternalId() != null) {
            model.setId(providedBy.getExternalId());
        }
    }
    if (entity.getName() != null) {
        model.setName(entity.getName());
    }
    return model;
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) OpenStackNetwork(org.ovirt.engine.api.model.OpenStackNetwork) 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