Skip to content

Commit

Permalink
Bug fixes #389
Browse files Browse the repository at this point in the history
  • Loading branch information
suryayadavalli committed Jan 22, 2021
1 parent 362ee73 commit ef58ad2
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ClientsController extends BaseController {

@RequestMapping(value = "/{dedupId}/matches",method = RequestMethod.POST)
@APIMapping(checkSessionToken = true, checkTrustedApp = true,value = "CREATE_MATCH")
public void manualMatch(@PathVariable("dedupId") UUID dedulpClient, @RequestBody MatchReservationModel matchReservationModel) throws Exception{
matchReservationsService.createManualMatch(dedulpClient,matchReservationModel);
public MatchReservationModel manualMatch(@PathVariable("dedupId") UUID dedulpClient, @RequestBody MatchReservationModel matchReservationModel) throws Exception{
return matchReservationsService.createManualMatch(dedulpClient,matchReservationModel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class Match extends BaseEntity {
@Column(name = "inactive")
private Boolean inactive;

@Column(name = "housing_unit_id", nullable = false)
@Column(name = "housing_unit_id")
@org.hibernate.annotations.Type(type = "org.hibernate.type.PostgresUUIDType")
private UUID housingUnitId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ public interface MatchReservationsService {

public Page<StatusNotesEntity> getStatusNote(UUID resevationId, Integer statuscode,Pageable pageable);

public void createManualMatch(UUID dedulpClient, MatchReservationModel matchReservationModel) throws Exception;
public MatchReservationModel createManualMatch(UUID dedulpClient, MatchReservationModel matchReservationModel) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -449,22 +449,47 @@ public void matchClient(EligibleClient client,HousingInventory housingInventory,
@Autowired HousingUnitsRepository housingUnitsRepository;

@Transactional
public void createManualMatch(UUID dedulpClient, MatchReservationModel matchReservationModel) throws Exception {
List<EligibleClient> eligibleClients = repositoryFactory.getEligibleClientsRepository().findByClientDedupIdAndProjectGroupCodeAndDeletedOrderByDateCreatedDesc(dedulpClient,SecurityContextUtil.getUserProjectGroup(),false);
if(eligibleClients.isEmpty())
public MatchReservationModel createManualMatch(UUID dedulpClient, MatchReservationModel matchReservationModel) throws Exception {
List<EligibleClient> eligibleClients = repositoryFactory.getEligibleClientsRepository()
.findByClientDedupIdAndProjectGroupCodeAndDeletedOrderByDateCreatedDesc(dedulpClient,
SecurityContextUtil.getUserProjectGroup(), false);
if (eligibleClients.isEmpty())
throw new ResourceNotFoundException("dedulp client id not eligible for match");

List<HousingInventory> housingInventories = housingUnitsRepository.findByHousingInventoryIdAndProjectGroupCodeAndDeleted(matchReservationModel.getHousingUnitId(),SecurityContextUtil.getUserProjectGroup(), false);
if(housingInventories.isEmpty()) throw new ResourceNotFoundException("Housing unit not found");
if(housingInventories.get(0).getVacant()!= null && !housingInventories.get(0).getVacant().booleanValue()) throw new AccessDeniedException("Housing unit not vacant");
Match matchReservations = matchReservationTranslator.translatev2(matchReservationModel);

List<HousingInventory> housingInventories = housingUnitsRepository
.findByHousingInventoryIdAndProjectGroupCodeAndDeleted(matchReservationModel.getHousingUnitId(),
SecurityContextUtil.getUserProjectGroup(), false);
if (housingInventories.isEmpty())
throw new ResourceNotFoundException("Housing unit not found");
if (housingInventories.get(0).getVacant() != null && !housingInventories.get(0).getVacant().booleanValue())
throw new AccessDeniedException("Housing unit not vacant");

Match matchReservations = matchReservationTranslator.translatev2(matchReservationModel);
matchReservations.setEligibleClient(eligibleClients.get(0));
repositoryFactory.getMatchReservationsRepository().saveAndFlush(matchReservations);
HousingInventory housingInventory = housingInventories.get(0);
housingInventory.setVacant(false);
housingUnitsRepository.save(housingInventory);
EligibleClient eligibleClient = eligibleClients.get(0);
eligibleClient.setMatched(true);
repositoryFactory.getEligibleClientsRepository().save(eligibleClient);
}
matchReservations.setMatchStatus(0);
matchReservations.setClientDedupId(eligibleClients.get(0).getClientDedupId());
matchReservations.setHousingUnitId(matchReservationModel.getHousingUnitId());
matchReservations.setProjectGroupCode(SecurityContextUtil.getUserProjectGroup());
repositoryFactory.getMatchReservationsRepository().save(matchReservations);

HousingInventory housingInventory = housingInventories.get(0);
housingInventory.setVacant(false);
housingUnitsRepository.save(housingInventory);

EligibleClient eligibleClient = eligibleClients.get(0);
eligibleClient.setMatched(true);
repositoryFactory.getEligibleClientsRepository().save(eligibleClient);

MatchStatus status = new MatchStatus();
status.setComments("Housing unit assigned through manual match");
status.setStatus(0);
status.setReservationId(matchReservations.getReservationId());
status.setClientId(eligibleClients.get(0).getClientId());
status.setClientDedupId(eligibleClients.get(0).getClientDedupId());
repositoryFactory.getMatchStatusRepository().save(status);

MatchReservationModel model = new MatchReservationModel();
model.setReservationId(matchReservations.getReservationId());
return model;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void updateMatchStatus(UUID reservationID,UUID clientId, MatchStatusModel
if(match==null) throw new ResourceNotFoundException("No match reservation found");
client = match.getEligibleClient();
}
List<MatchStatusLevels> nextLevels = repositoryFactory.getMatchStatuLevelsRepository().findByProjectGroupCodeAndStatusCode(match.getProgramType(), match.getMatchStatus()+"");
List<MatchStatusLevels> nextLevels = repositoryFactory.getMatchStatuLevelsRepository().findByProjectGroupCodeAndStatusCode(match.getProjectGroupCode(), match.getMatchStatus()+"");


List newStatus = new ArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Match translatev2(MatchReservationModel matchReservationModel) {
} else {
return null;
}
match.setReservationId(matchReservationModel.getReservationId());

match.setMatchStatus(matchReservationModel.getMatchStatus());
match.setMatchDate(matchReservationModel.getMatchDate());
match.setManualMatch(true);
Expand Down
4 changes: 2 additions & 2 deletions housing_inventory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>com.servinglynk.hmis.warehouse</groupId>
<artifactId>core-client</artifactId>
<version>2.21.8</version>
<version>2.26.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -53,7 +53,7 @@
<dependency>
<groupId>com.servinglynk.hmis.warehouse</groupId>
<artifactId>hmis-base-serialize</artifactId>
<version>2.21.8</version>
<version>2.26.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hserv.coordinatedentry.housinginventory.model.Project;

@SuppressWarnings("serial")
Expand Down Expand Up @@ -55,6 +56,7 @@ public class HousingInventory extends HousingInventoryBaseEntity {
private Boolean vacant=true;

@Column(name="alias_name")
@JsonProperty("name")
private String aliasName;

@Column(name="schema_year")
Expand Down

0 comments on commit ef58ad2

Please sign in to comment.