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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations