Compare commits
5 Commits
main
...
publicendp
Author | SHA1 | Date |
---|---|---|
Kavishka Madhusankha | 40af45a650 | 3 hours ago |
Kavishka Madhusankha | 7ac7a535ef | 8 hours ago |
Kavishka Madhusankha | 52d68cd33f | 3 days ago |
Kavishka Madhusankha | 9f181d088a | 4 days ago |
Kavishka Madhusankha | fdbae4bd57 | 4 days ago |
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.controller;
|
||||||
|
|
||||||
|
import com.example.Public.Configuration.model.DeviceConfig;
|
||||||
|
import com.example.Public.Configuration.response.Response;
|
||||||
|
import com.example.Public.Configuration.service.impl.DeviceConfigServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/device-config")
|
||||||
|
public class DeviceConfigController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceConfigServiceImpl deviceConfigService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
public ResponseEntity<?> createDeviceConfigProfile(@RequestBody DeviceConfig deviceConfig) {
|
||||||
|
DeviceConfig newDeviceConfig = deviceConfigService.getByConfigId(deviceConfig.getConfigId());
|
||||||
|
if (newDeviceConfig == null) {
|
||||||
|
deviceConfigService.saveConfigProfile(deviceConfig);
|
||||||
|
return new ResponseEntity<>(new Response(HttpStatus.CREATED.value(),
|
||||||
|
"Device Config created successfully"), HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>("Device already exists", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
@GetMapping("/configs")
|
||||||
|
public List<DeviceConfig> getConfigsDevices() {
|
||||||
|
return deviceConfigService.getAllDeviceConfigs();
|
||||||
|
}
|
||||||
|
@GetMapping("one-config/:configId")
|
||||||
|
public ResponseEntity<?> fetchConfigByConfigId(@PathVariable int configId) {
|
||||||
|
DeviceConfig deviceConfig1 = deviceConfigService.getByConfigId(configId);
|
||||||
|
if (deviceConfig1 == null) {
|
||||||
|
return new ResponseEntity<>(new Response(HttpStatus.NOT_FOUND.value(),
|
||||||
|
"No Device found for Config ID: +configId"), HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(deviceConfig1, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
@PutMapping("/{configId}")
|
||||||
|
public DeviceConfig updateDeviceDetails(@RequestBody DeviceConfig deviceConfig) {
|
||||||
|
return deviceConfigService.UpdateConfigDetails(deviceConfig);
|
||||||
|
}
|
||||||
|
@DeleteMapping("/{configId}")
|
||||||
|
public String deleteConfigConfigId(@PathVariable int configId) {
|
||||||
|
System.out.println("Deleting Device Config with ID: " + configId);
|
||||||
|
return deviceConfigService.deleteConfigProfile(configId);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.controller;
|
||||||
|
|
||||||
|
import com.example.Public.Configuration.dto.EnrolmentRequestDTO;
|
||||||
|
import com.example.Public.Configuration.model.EnrolmentRequestLog;
|
||||||
|
import com.example.Public.Configuration.response.Response;
|
||||||
|
import com.example.Public.Configuration.service.impl.EnrolmentRequestServiceImpl;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/enrolment-request")
|
||||||
|
public class EnrolmentRequestController {
|
||||||
|
|
||||||
|
@Autowired // This annotation is used to inject the DeviceService object into the DeviceController class.
|
||||||
|
private EnrolmentRequestServiceImpl enrolmentRequestService; // This object is used to perform CRUD operations on the Device table in the database.
|
||||||
|
|
||||||
|
@PostMapping("/create") // add a new device to the database.
|
||||||
|
public ResponseEntity<?> createEnrolmentRequest(@RequestBody EnrolmentRequestDTO enrolmentRequestLog) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String ER = gson.toJson(enrolmentRequestLog.getEnrolmentRequest());
|
||||||
|
enrolmentRequestLog.setResponseTime(String.valueOf(Instant.now().toEpochMilli()));
|
||||||
|
EnrolmentRequestLog deviceEnrolmentRequest = enrolmentRequestService.getEnrolmentRequestByRequestId(enrolmentRequestLog.getRequestId());
|
||||||
|
|
||||||
|
if (deviceEnrolmentRequest == null) {
|
||||||
|
EnrolmentRequestLog enrolmentRequest = new EnrolmentRequestLog();
|
||||||
|
enrolmentRequest.setRequestId(enrolmentRequestLog.getRequestId());
|
||||||
|
enrolmentRequest.setEnrolmentRequest(ER);
|
||||||
|
enrolmentRequest.setResponseTime(Long.parseLong(enrolmentRequestLog.getResponseTime()));
|
||||||
|
enrolmentRequestService.saveEnrolmentRequest(enrolmentRequest);
|
||||||
|
return new ResponseEntity<>(new Response(HttpStatus.CREATED.value(),
|
||||||
|
"Device added successfully"), HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>("Device already exists", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
@GetMapping("/requests")
|
||||||
|
public List<EnrolmentRequestLog> getDevicesByRequests() {
|
||||||
|
return enrolmentRequestService.getAllEnrolmentRequests();
|
||||||
|
}
|
||||||
|
@GetMapping("/{requestId}")
|
||||||
|
public ResponseEntity<?> fetchEnrolmentRequest(@PathVariable int requestId) {
|
||||||
|
EnrolmentRequestLog deviceEnrolment = enrolmentRequestService.getEnrolmentRequestByRequestId(requestId);
|
||||||
|
if (deviceEnrolment == null) {
|
||||||
|
return new ResponseEntity<>(new Response(HttpStatus.NOT_FOUND.value()
|
||||||
|
,"No Device found for Enrolment Request : +imei"), HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(deviceEnrolment, HttpStatus.OK); // return the device object if it exists in the database.
|
||||||
|
}
|
||||||
|
@PutMapping("/{requestId}")
|
||||||
|
public EnrolmentRequestLog updateEnrolmentRequestLog(@RequestBody EnrolmentRequestLog enrolmentRequestLog) { // update a device in the database.
|
||||||
|
return enrolmentRequestService.updateEnrolmentRequest(enrolmentRequestLog);
|
||||||
|
|
||||||
|
}
|
||||||
|
@DeleteMapping("/{requestId}")
|
||||||
|
public String deleteEnrolmentRequestId(@PathVariable int requestId) {
|
||||||
|
return enrolmentRequestService.deleteEnrolmentRequest(requestId); // delete a device from the database.
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.dao;
|
||||||
|
|
||||||
|
import com.example.Public.Configuration.model.DeviceConfig;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface DeviceConfigDao extends JpaRepository<DeviceConfig, Integer> {
|
||||||
|
|
||||||
|
DeviceConfig findByConfigId(int configId);
|
||||||
|
|
||||||
|
void deleteByConfigId(int configId);
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
package com.example.Public.Configuration.dao;
|
package com.example.Public.Configuration.dao;
|
||||||
|
|
||||||
import com.example.Public.Configuration.model.Device;
|
import com.example.Public.Configuration.model.Device;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface DeviceDao extends JpaRepository<Device, Long> {
|
public interface DeviceDao extends JpaRepository<Device, Integer> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.dao;
|
||||||
|
|
||||||
|
import com.example.Public.Configuration.model.EnrolmentRequestLog;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface EnrolmentRequestLogDao extends JpaRepository<EnrolmentRequestLog, Integer> {
|
||||||
|
|
||||||
|
EnrolmentRequestLog findByRequestId(int requestId);
|
||||||
|
|
||||||
|
void deleteByRequestId(int requestId);
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.example.Public.Configuration.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class EnrolmentRequestDTO {
|
||||||
|
private int requestId;
|
||||||
|
private EnrolmentRequest enrolmentRequest;
|
||||||
|
private String responseTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static class EnrolmentRequest {
|
||||||
|
|
||||||
|
private String imei;
|
||||||
|
private String ipAddress;
|
||||||
|
private int subTypeId;
|
||||||
|
private String smsPIN;
|
||||||
|
private int mfwVersion;
|
||||||
|
private int rssi;
|
||||||
|
private String network;
|
||||||
|
private int comTypeId;
|
||||||
|
private String cellId;
|
||||||
|
private String lac;
|
||||||
|
private int sysTick;
|
||||||
|
private String meFwVersion;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.model;
|
||||||
|
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Table(name = "device_config-profile")
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DeviceConfig {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "config_id")
|
||||||
|
private int configId;
|
||||||
|
|
||||||
|
@Column(name = "config_profile")
|
||||||
|
private String configProfile;
|
||||||
|
|
||||||
|
@Column(name = "config_content")
|
||||||
|
private String configContent;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.model;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Table(name = "enrolment_request_log")
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class EnrolmentRequestLog {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "enrolment_id")
|
||||||
|
private int requestId;
|
||||||
|
|
||||||
|
@Column(name = "enrolment_request")
|
||||||
|
private String EnrolmentRequest;
|
||||||
|
|
||||||
|
@Column(name = "response_time")
|
||||||
|
private long responseTime;
|
||||||
|
|
||||||
|
@Column(name = "author")
|
||||||
|
private String author;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Response {
|
||||||
|
|
||||||
|
private int code;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
}
|
@ -1,12 +0,0 @@
|
|||||||
package com.example.Public.Configuration.response;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
|
|
||||||
public class ResponseMessage {
|
|
||||||
|
|
||||||
private int status;
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.service;
|
||||||
|
|
||||||
|
import com.example.Public.Configuration.model.DeviceConfig;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DeviceConfigService {
|
||||||
|
|
||||||
|
// static final String CONFIG_ID = "configId";
|
||||||
|
|
||||||
|
DeviceConfig saveConfigProfile(DeviceConfig deviceConfig);
|
||||||
|
|
||||||
|
List<DeviceConfig> getAllDeviceConfigs();
|
||||||
|
|
||||||
|
DeviceConfig getByConfigId(String configId);
|
||||||
|
|
||||||
|
DeviceConfig UpdateConfigDetails(DeviceConfig deviceConfig);
|
||||||
|
|
||||||
|
String deleteConfigProfile(String configId);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.service;
|
||||||
|
|
||||||
|
import com.example.Public.Configuration.model.EnrolmentRequestLog;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface EnrolmentRequestService {
|
||||||
|
|
||||||
|
EnrolmentRequestLog saveEnrolmentRequest(EnrolmentRequestLog enrolmentRequestLog);
|
||||||
|
|
||||||
|
List<EnrolmentRequestLog> getEnrolmentRequests();
|
||||||
|
|
||||||
|
EnrolmentRequestLog getEnrolmentRequestByRequestId(String imei);
|
||||||
|
|
||||||
|
EnrolmentRequestLog updateEnrolmentRequest(EnrolmentRequestLog enrolmentRequestLog);
|
||||||
|
|
||||||
|
String deleteEnrolmentRequest(String imei);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.service.impl;
|
||||||
|
|
||||||
|
import com.example.Public.Configuration.dao.DeviceConfigDao;
|
||||||
|
import com.example.Public.Configuration.model.DeviceConfig;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DeviceConfigServiceImpl {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceConfigDao deviceConfigDao;
|
||||||
|
|
||||||
|
public void saveConfigProfile(DeviceConfig deviceConfig) {
|
||||||
|
deviceConfigDao.save(deviceConfig); // use to save the device details to the database
|
||||||
|
}//autowire the deviceDao object
|
||||||
|
|
||||||
|
|
||||||
|
public List<DeviceConfig> getAllDeviceConfigs() {
|
||||||
|
return deviceConfigDao.findAll(); // use to command using the deviceDao object to get all the device details from the database
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceConfig getByConfigId(int configId) {
|
||||||
|
return deviceConfigDao.findByConfigId(configId); // use to get the device details by id
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceConfig UpdateConfigDetails(DeviceConfig deviceConfig) {
|
||||||
|
DeviceConfig updatedConfig = deviceConfigDao.findByConfigId(deviceConfig.getConfigId());
|
||||||
|
if (updatedConfig != null) {
|
||||||
|
updatedConfig.setConfigProfile(deviceConfig.getConfigProfile());
|
||||||
|
updatedConfig.setConfigContent(deviceConfig.getConfigContent());
|
||||||
|
deviceConfigDao.save(updatedConfig);
|
||||||
|
}
|
||||||
|
return updatedConfig; // return the updated device object
|
||||||
|
}
|
||||||
|
|
||||||
|
public String deleteConfigProfile(int configId) {
|
||||||
|
deviceConfigDao.deleteByConfigId(configId); // use to delete the device details by id
|
||||||
|
return "Config profile deleted successfully"; // return the message to the user
|
||||||
|
}
|
||||||
|
}
|
@ -1,73 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
package com.example.Public.Configuration.service.impl;
|
package com.example.Public.Configuration.service.impl;
|
||||||
|
|
||||||
import com.example.Public.Configuration.dao.DeviceDao;
|
import com.example.Public.Configuration.dao.DeviceDao;
|
||||||
import com.example.Public.Configuration.model.Device;
|
import com.example.Public.Configuration.model.Device;
|
||||||
import com.example.Public.Configuration.service.DeviceService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DeviceServiceImpl implements DeviceService {
|
public class DeviceServiceImpl {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceDao deviceDao;
|
private DeviceDao deviceDao; //autowire the deviceDao object
|
||||||
|
|
||||||
public Device saveDevice(Device device) {
|
public void saveDetails(Device device) { //used to save the device details in the database
|
||||||
return deviceDao.save(device);
|
deviceDao.save(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Device> getAllDevices() {
|
public List<Device> getAllDevices() {
|
||||||
return deviceDao.findAll();
|
return deviceDao.findAll(); // use to command using
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Device getDeviceById(long device_id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Device updateDevice(Device device) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Device getDeviceById(int device_id) {
|
||||||
public String deleteDevice(long device_id) {
|
return deviceDao.findById(device_id).orElse(null); // use to get the device details by id
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Device getDeviceById(Long device_id) {
|
public Device UpdateDetailsById(Device device) { //used to update the device details in the database
|
||||||
return deviceDao.findById(device_id).orElse(null);
|
Device updatedDevice = deviceDao.findById(device.getDeviceId()).orElse(null); //This command is used to get the device details by id
|
||||||
}
|
|
||||||
public Device UpdateDevice(Device device) { //used to update the device details in the database
|
|
||||||
Device updatedDevice = deviceDao.findById(device.getDevice_id()).orElse(null); //This command is used to get the device details by id
|
|
||||||
|
|
||||||
if (updatedDevice != null) { // device details are present in the database then update the device details
|
if (updatedDevice != null) { // device details are present in the database then update the device details
|
||||||
updatedDevice.setImei(device.getImei());
|
updatedDevice.setDeviceId(device.getDeviceId());
|
||||||
updatedDevice.setDevice_model(device.getDevice_model());
|
updatedDevice.setDevice_model(device.getDevice_model());
|
||||||
updatedDevice.setUpdate_time(device.getUpdate_time());
|
updatedDevice.setConfigId(device.getConfigId());
|
||||||
updatedDevice.setNetwork(device.getNetwork());
|
|
||||||
updatedDevice.setMFW_Version(device.getMFW_Version());
|
|
||||||
updatedDevice.setLAC(device.getLAC());
|
|
||||||
updatedDevice.setDevice_organization(device.getDevice_organization());
|
|
||||||
updatedDevice.setMEFW_Version(device.getMEFW_Version());
|
|
||||||
updatedDevice.setRSSI(device.getRSSI());
|
|
||||||
deviceDao.save(updatedDevice);
|
deviceDao.save(updatedDevice);
|
||||||
}
|
}
|
||||||
return updatedDevice;
|
return updatedDevice; // return the updated device object
|
||||||
}
|
|
||||||
public String deleteDevice(Long device_id) {
|
|
||||||
deviceDao.deleteById(device_id);
|
|
||||||
return "deleted " +device_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String deleteDevice(int device_id) {//used to delete the device details from the database
|
||||||
|
deviceDao.deleteById(device_id);//delete the device details by id
|
||||||
|
return "deleted" + device_id;//return the message that the device is deleted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||||
|
*
|
||||||
|
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package com.example.Public.Configuration.service.impl;
|
||||||
|
|
||||||
|
import com.example.Public.Configuration.dao.EnrolmentRequestLogDao;
|
||||||
|
import com.example.Public.Configuration.model.EnrolmentRequestLog;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class EnrolmentRequestServiceImpl {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EnrolmentRequestLogDao enrolmentRequestLogDao;
|
||||||
|
|
||||||
|
public void saveEnrolmentRequest(EnrolmentRequestLog enrolmentRequestLog) {
|
||||||
|
|
||||||
|
enrolmentRequestLogDao.save(enrolmentRequestLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EnrolmentRequestLog> getAllEnrolmentRequests() {
|
||||||
|
return enrolmentRequestLogDao.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnrolmentRequestLog getEnrolmentRequestByRequestId(int requestId) {
|
||||||
|
return enrolmentRequestLogDao.findByRequestId(requestId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnrolmentRequestLog updateEnrolmentRequest(EnrolmentRequestLog enrolmentRequestLog) { //used to update the device details in the database
|
||||||
|
EnrolmentRequestLog updatedEnrolmentRequest = enrolmentRequestLogDao.findByRequestId(enrolmentRequestLog.getRequestId()); //This command is used to get the device details by id
|
||||||
|
|
||||||
|
if (updatedEnrolmentRequest != null) { // device details are present in the database then update the device details
|
||||||
|
updatedEnrolmentRequest.setRequestId(Integer.parseInt(enrolmentRequestLog.getEnrolmentRequest()));
|
||||||
|
updatedEnrolmentRequest.setResponseTime(enrolmentRequestLog.getResponseTime());
|
||||||
|
enrolmentRequestLogDao.save(updatedEnrolmentRequest);
|
||||||
|
}
|
||||||
|
return updatedEnrolmentRequest; // return the updated device object
|
||||||
|
}
|
||||||
|
|
||||||
|
public String deleteEnrolmentRequest(int requestId) {
|
||||||
|
enrolmentRequestLogDao.deleteByRequestId(requestId);
|
||||||
|
return "deleted" + requestId;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue