2 * ============LICENSE_START========================================================================
3 * ONAP : tr-069-adapter
4 * =================================================================================================
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
6 * =================================================================================================
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
9 * may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14 * either express or implied. See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ===============LICENSE_END=======================================================================
19 package org.commscope.tr069adapter.acs.requestprocessor.util;
21 import java.util.Date;
23 import org.commscope.tr069adapter.acs.common.dto.TR069DeviceDetails;
24 import org.commscope.tr069adapter.acs.requestprocessor.entity.TR069DeviceEntity;
26 public class TR069NBIUtility {
28 private TR069NBIUtility() {
33 * A utility method to convert the DTO to Domain object
35 * @param tr069DeviceDetails
39 public static TR069DeviceEntity convertToEntity(TR069DeviceDetails tr069DeviceDetails) {
40 TR069DeviceEntity tr069DeviceEntity = new TR069DeviceEntity();
41 tr069DeviceEntity.setDeviceId(tr069DeviceDetails.getDeviceId());
42 tr069DeviceEntity.setUserName(tr069DeviceDetails.getUsername());
43 tr069DeviceEntity.setPassword(tr069DeviceDetails.getPassword());
44 tr069DeviceEntity.setLastUpdatedTime(new Date());
45 tr069DeviceEntity.setConnStatus(true);
46 tr069DeviceEntity.setErrorMsg(null);
48 if (tr069DeviceDetails.getConnectionRequestURL() != null) {
49 tr069DeviceEntity.setConnectionReqURL(tr069DeviceDetails.getConnectionRequestURL());
51 if (tr069DeviceDetails.getSoftwareVersion() != null) {
52 tr069DeviceEntity.setSwVersion(tr069DeviceDetails.getSoftwareVersion());
54 if (tr069DeviceDetails.getHardwareVersion() != null) {
55 tr069DeviceEntity.setHwVersion(tr069DeviceDetails.getHardwareVersion());
58 return tr069DeviceEntity;
62 * A utility method to convert the Domain object to DTO
67 public static TR069DeviceDetails convertToDTO(TR069DeviceEntity entity) {
68 TR069DeviceDetails tr069DeviceDetails = new TR069DeviceDetails();
70 tr069DeviceDetails.setDeviceId(entity.getDeviceId());
71 tr069DeviceDetails.setUsername(entity.getUserName());
72 tr069DeviceDetails.setPassword(entity.getPassword());
73 tr069DeviceDetails.setSoftwareVersion(entity.getSwVersion());
74 tr069DeviceDetails.setHardwareVersion(entity.getHwVersion());
75 tr069DeviceDetails.setConnectionRequestURL(entity.getConnectionReqURL());
77 return tr069DeviceDetails;