Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.bae.mobileapi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bae.mobileapi.service.MobileCallRecordsService;

@RestController
@RequestMapping("/Mobile")
public class MobileCallRecordsController {

private MobileCallRecordsService service;

public MobileCallRecordsController() {

}

@Autowired
public MobileCallRecordsController(MobileCallRecordsService service) {
this.service = service;
}

@GetMapping("/getAssociates")
public ResponseEntity<Object> getRecordsDTO(
@RequestParam(value = "phoneNumber", required = false) String phoneNumber) {
return new ResponseEntity<>(service.getMobileCallRecordsDTO(phoneNumber), HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,21 @@
import org.springframework.web.bind.annotation.RestController;

import com.bae.mobileapi.model.PeopleMobile;
import com.bae.mobileapi.service.AssociatesService;
import com.bae.mobileapi.service.MobileService;
import com.bae.mobileapi.service.PeopleMobileService;

@RestController
@RequestMapping("/Mobile")
public class MobileController {
public class PeopleMobileController {

private MobileService mobileService;
private PeopleMobileService service;

private AssociatesService associatesService;

public MobileController() {
public PeopleMobileController() {

}

@Autowired
public MobileController(MobileService mobileService, AssociatesService associatesService) {
this.mobileService = mobileService;
this.associatesService = associatesService;
public PeopleMobileController(PeopleMobileService service) {
this.service = service;
}

@GetMapping("/getMobile")
Expand All @@ -39,19 +35,13 @@ public ResponseEntity<Object> getMobile(@RequestParam(value = "forenames", requi
@RequestParam(value = "homeAddress", required = false) String homeAddress,
@RequestParam(value = "dateOfBirth", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateOfBirth) {

PeopleMobile peopleMobileEntity = new PeopleMobile();

peopleMobileEntity.setForenames(forenames);
peopleMobileEntity.setSurname(surname);
peopleMobileEntity.setAddress(homeAddress);
peopleMobileEntity.setDateOfBirth(dateOfBirth);
PeopleMobile peopleMobile = new PeopleMobile();

return new ResponseEntity<>(mobileService.getMobile(peopleMobileEntity), HttpStatus.OK);
}
peopleMobile.setForenames(forenames);
peopleMobile.setSurname(surname);
peopleMobile.setAddress(homeAddress);
peopleMobile.setDateOfBirth(dateOfBirth);

@GetMapping("/getAssociates")
public ResponseEntity<Object> getRecordsDTO(
@RequestParam(value = "phoneNumber", required = false) String phoneNumber) {
return new ResponseEntity<>(associatesService.getMobileCallRecordsDTO(phoneNumber), HttpStatus.OK);
return new ResponseEntity<>(service.findMobile(peopleMobile), HttpStatus.OK);
}
}
1 change: 0 additions & 1 deletion src/main/java/com/bae/mobileapi/model/PeopleMobile.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,4 @@ public String getNetwork() {
public void setNetwork(String network) {
this.network = network;
}

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.bae.mobileapi.repository;
package com.bae.mobileapi.repository.celltower;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import com.bae.mobileapi.model.CellTower;

@Repository
public interface CelltowerRepository extends JpaRepository<CellTower, Long>{
public interface CellTowerRepository extends JpaRepository<CellTower, Long>{

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bae.mobileapi.repository;
package com.bae.mobileapi.repository.mobilecallrecords;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bae.mobileapi.repository;
package com.bae.mobileapi.repository.mobilecallrecords;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bae.mobileapi.repository;
package com.bae.mobileapi.repository.mobilecallrecords;

import java.util.List;

Expand All @@ -14,6 +14,16 @@
@Repository
public class MobileCallRecordsRepositoryCustomImpl implements MobileCallRecordsRepositoryCustom {

private static final String CALLS_CALLED_QUERY = "SELECT NEW com.bae.mobileapi.model.DTO.MobileCallRecordsDTO("
+ "p.receiverMsisdn.forenames, p.receiverMsisdn.surname, p.receiverMsisdn.address,"
+ "p.receiverMsisdn.dateOfBirth, p.timestamp) FROM MobileCallRecords p where "
+ "p.callerMsisdn.phoneNumber = :phoneNumber";

private static final String CALLS_RECEIVED_QUERY = "SELECT NEW com.bae.mobileapi.model.DTO.MobileCallRecordsDTO("
+ "p.callerMsisdn.forenames, p.callerMsisdn.surname, p.callerMsisdn.address,"
+ "p.callerMsisdn.dateOfBirth, p.timestamp) FROM MobileCallRecords p where "
+ "p.receiverMsisdn.phoneNumber = :phoneNumber";

private EntityManager entityManager;

@Autowired
Expand All @@ -25,18 +35,10 @@ public MobileCallRecordsRepositoryCustomImpl(EntityManager entityManager) {
public List<MobileCallRecordsDTO> getMobileCallRecordsDTO(String phoneNumber) {

TypedQuery<MobileCallRecordsDTO> queryCaller = entityManager
.createQuery("SELECT NEW com.bae.mobileapi.model.DTO.MobileCallRecordsDTO("
+ "p.receiverMsisdn.forenames, p.receiverMsisdn.surname, p.receiverMsisdn.address,"
+ "p.receiverMsisdn.dateOfBirth, p.timestamp) FROM MobileCallRecords p where "
+ "p.callerMsisdn.phoneNumber = :phoneNumber", MobileCallRecordsDTO.class)
.setParameter("phoneNumber", phoneNumber);
.createQuery(CALLS_CALLED_QUERY, MobileCallRecordsDTO.class).setParameter("phoneNumber", phoneNumber);

TypedQuery<MobileCallRecordsDTO> queryReceiver = entityManager
.createQuery("SELECT NEW com.bae.mobileapi.model.DTO.MobileCallRecordsDTO("
+ "p.callerMsisdn.forenames, p.callerMsisdn.surname, p.callerMsisdn.address,"
+ "p.callerMsisdn.dateOfBirth, p.timestamp) FROM MobileCallRecords p where "
+ "p.receiverMsisdn.phoneNumber = :phoneNumber", MobileCallRecordsDTO.class)
.setParameter("phoneNumber", phoneNumber);
.createQuery(CALLS_RECEIVED_QUERY, MobileCallRecordsDTO.class).setParameter("phoneNumber", phoneNumber);

List<MobileCallRecordsDTO> queryCallers = queryCaller.getResultList();
List<MobileCallRecordsDTO> queryReceivers = queryReceiver.getResultList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.bae.mobileapi.repository;
package com.bae.mobileapi.repository.peoplemobile;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.QueryByExampleExecutor;
import org.springframework.stereotype.Repository;

import com.bae.mobileapi.model.PeopleMobile;

@Repository
public interface PeopleMobileRepository extends JpaRepository<PeopleMobile, String>, PeopleMobileRepositoryCustom {
public interface PeopleMobileRepository extends JpaRepository<PeopleMobile, String>, QueryByExampleExecutor<PeopleMobile> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.bae.mobileapi.model.DTO.MobileCallRecordsDTO;

@Service
public interface AssociatesService {
public interface MobileCallRecordsService {

List<MobileCallRecordsDTO> getMobileCallRecordsDTO(String phoneNumber);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import org.springframework.stereotype.Service;

import com.bae.mobileapi.model.DTO.MobileCallRecordsDTO;
import com.bae.mobileapi.repository.MobileCallRecordsRepository;
import com.bae.mobileapi.repository.mobilecallrecords.MobileCallRecordsRepository;

@Service
public class AssociatesServiceImpl implements AssociatesService {
public class MobileCallRecordsServiceImpl implements MobileCallRecordsService {

private MobileCallRecordsRepository repository;

public AssociatesServiceImpl(MobileCallRecordsRepository repository) {
public MobileCallRecordsServiceImpl(MobileCallRecordsRepository repository) {
this.repository = repository;
}

Expand Down
27 changes: 0 additions & 27 deletions src/main/java/com/bae/mobileapi/service/MobileServiceImpl.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.bae.mobileapi.model.PeopleMobile;

@Service
public interface MobileService {
public interface PeopleMobileService {

public List<PeopleMobile> getMobile(PeopleMobile peopleMobile);
}
public List<PeopleMobile> findMobile(PeopleMobile peopleMobile);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.bae.mobileapi.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.stereotype.Service;

import com.bae.mobileapi.model.PeopleMobile;
import com.bae.mobileapi.repository.peoplemobile.PeopleMobileRepository;

@Service
public class PeopleMobileServiceImpl implements PeopleMobileService {

private PeopleMobileRepository repository;

@Autowired
public PeopleMobileServiceImpl(PeopleMobileRepository repository) {
this.repository = repository;
}

@Override
public List<PeopleMobile> findMobile(PeopleMobile probe) {
return repository.findAll(Example.of(probe, ExampleMatcher.matchingAll().withIgnoreCase()));
}
}