package org.wso2.carbon.device.mgt.ios.util;

import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.ios.dep.beans.DeviceDetails;
import org.wso2.carbon.device.mgt.ios.dep.beans.DeviceDetailsFilter;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dto.DEPDevice;

public class DEPUtils {

    public static DEPDevice convertDeviceDetailsFilterToDevice(DeviceDetailsFilter deviceInfo, boolean
            needBasicAuth, String username, Integer depProfileId) {
        DEPDevice depDevice = new DEPDevice();
        depDevice.setSerial(deviceInfo.getSerialNumber());
        depDevice.setStatus(deviceInfo.getProfileStatus());
        depDevice.setDepProfileId(depProfileId);
        depDevice.setProfileAssignTime(deviceInfo.getProfileAssignTime());
        depDevice.setProfilePushTime(deviceInfo.getProfilePushTime());
        depDevice.setDeviceAssignedTime(deviceInfo.getDeviceAssignedDate());
        depDevice.setDeviceAssignedBy(deviceInfo.getDeviceAssignedBy());
        depDevice.setNeedBasicAuth(needBasicAuth);
        depDevice.setUsername(username);
        depDevice.setTenantDomain(PrivilegedCarbonContext.getThreadLocalCarbonContext()
                .getTenantDomain());
        depDevice.setOS(deviceInfo.getOs());
        depDevice.setDeviceFamily(deviceInfo.getDeviceFamily());
        depDevice.setModel(deviceInfo.getModel());
        depDevice.setDescription(deviceInfo.getDescription());
        depDevice.setColor(deviceInfo.getColor());
        return depDevice;
    }

    public static DEPDevice convertToDevice(DeviceDetails deviceInfo, DEPDevice device) {
        DEPDevice depDevice = new DEPDevice();
        depDevice.setSerial(deviceInfo.getSerialNumber());
        depDevice.setStatus(deviceInfo.getProfileStatus());
        depDevice.setDepProfileId(device.getDepProfileId());
        depDevice.setProfileAssignTime(deviceInfo.getProfileAssignTime());
        depDevice.setProfilePushTime(deviceInfo.getProfilePushTime());
        depDevice.setDeviceAssignedTime(deviceInfo.getDeviceAssignedDate());
        depDevice.setDeviceAssignedBy(deviceInfo.getDeviceAssignedBy());
        depDevice.setNeedBasicAuth(device.getNeedBasicAuth());
        depDevice.setUsername(device.getUsername());
        depDevice.setTenantDomain(PrivilegedCarbonContext.getThreadLocalCarbonContext()
                .getTenantDomain());
        depDevice.setOS(deviceInfo.getOs());
        depDevice.setDeviceFamily(deviceInfo.getDeviceFamily());
        depDevice.setModel(deviceInfo.getModel());
        depDevice.setDescription(deviceInfo.getDescription());
        depDevice.setColor(deviceInfo.getColor());
        depDevice.setAgentRequired(device.getAgentRequired());
        return depDevice;
    }
}
