HostDto.java 1.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
package adt.mainnode.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import adt.mainnode.entity.Host;
import lombok.Data;
import java.util.Date;
import java.util.List;

@Data
public class HostDto {

    @JsonProperty("ip_address")
    private String ip;

    @JsonProperty("vlan_id")
    private String vlanName;

    @JsonProperty("timestamp_device_scan_start")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date timestamp_ini;

    @JsonProperty("timestamp_device_scan_end")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date timestamp_end;

    @JsonProperty("hostname")
    private String hostname;

    @JsonProperty("mac_address")
    private String mac;

    @JsonProperty("mac_manufacturer")
    private String macManufacturer;

    @JsonProperty("ports")
    private List<PortDto> ports;

    @JsonProperty("operating_system")
    private String operatingSystem;

    public static HostDto createHostDto(Host host) {
        HostDto hostDto = new HostDto();
        hostDto.setIp(host.getIp());
        hostDto.setVlanName(host.getVlanName());
        hostDto.setHostname(host.getHostname());
        hostDto.setMac(host.getMac());
        hostDto.setMacManufacturer(host.getMacManufacturer());
        hostDto.setPorts(host.getPorts());
        hostDto.setTimestamp_ini(host.getTimestamp_ini());
        hostDto.setTimestamp_end(host.getTimestamp_end());
        hostDto.setOperatingSystem(host.getOperatingSystem());
        return hostDto;
    }
}