Skip to content

Commit

Permalink
Merge branch 'dev' into fix/be-540-remove-selected-role
Browse files Browse the repository at this point in the history
  • Loading branch information
furknbulbul authored Dec 12, 2023
2 parents 442148c + 369b0bb commit 01d6275
Show file tree
Hide file tree
Showing 95 changed files with 2,970 additions and 929 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<div align="center"><img src="https://user-images.githubusercontent.com/83069560/230832649-1788da25-6212-40a5-8eff-40955922ab59.png" alt="" width="150px" height="150px"><h1> CMPE352/451 Group 1 <br/> Disaster Response Platform </h1></div>

## Software
You can find the alpha version of our software in the `resq` subdirectory

***

## ⛑ About Us
Expand Down
48 changes: 48 additions & 0 deletions resq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ResQ

ResQ is REST based web service for the Disaster Response Application ResQ developed by CMPE451-GroupA1

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

### Prerequisites

- Docker and Docker-Compose

### Config Directory Structure

The backend application gets the actual path from `resq.appdir` property and checks for **resq** directory under that path.

Under main directory structure is:
- **conf**
- **appparam.txt**: application configuration items are located under this file (web service url, username and pass etc.)
- **logConf.xml**: log configuration file.
- **log**: Application writes all logs under this directory

### Installing with Docker

First clone all files into local repo.

Place the config folder named as project_env under the directory bounswe2023group1\resq\backend\resq.
Then, run the following commands:

docker-compose up

## Project Specific Information

The local buld of the frontend application is available on http://localhost:3000

Production frontend URL: https://resq.org.tr


Backend application context root is /resq/api/v1/. You can reach the backend application via
https://localhost:8081/resq/api/v1/.
To reach the API documentation:
https://localhost:8081/resq/api/v1/swagger-ui.html


Production backend URL: https://api.resq.org.tr/resq/api/v1

Production backend API Documentation:
https://api.resq.org.tr/resq/api/v1/swagger-ui/index.html
10 changes: 10 additions & 0 deletions resq/backend/resq/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ services:
- POSTGRES_PASSWORD=compose-postgres
networks:
- app_network

frontend:
container_name: frontend
image: frontend:latest
build:
context: ../../frontend
ports:
- "3000:3000"
expose:
- "3000"

networks:
app_network:
8 changes: 8 additions & 0 deletions resq/backend/resq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.firebase/firebase-admin
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>9.2.0</version>
</dependency>
-->

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.groupa1.resq.controller;


import com.groupa1.resq.request.CreateEventRequest;
import com.groupa1.resq.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.groupa1.resq.response.EventResponse;
import java.util.List;

@RestController
@RequestMapping("/event")
public class EventController {

@Autowired
private EventService eventService;

@PreAuthorize("hasRole('RESPONDER') or hasRole('COORDINATOR') or hasRole('FACILITATOR') or hasRole('VICTIM')")
@PostMapping("/createEvent")
public ResponseEntity<String> createEvent(@RequestBody CreateEventRequest createEventRequest){
return eventService.createEvent(createEventRequest);
}

@PreAuthorize("hasRole('RESPONDER') or hasRole('COORDINATOR') or hasRole('FACILITATOR') or hasRole('VICTIM')")
@GetMapping("/viewEvents")
public ResponseEntity<List<EventResponse>> viewEvents(@RequestParam Long reporterId) {
return eventService.viewEvents( reporterId);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ public class NeedController {

@GetMapping("/viewNeedsByFilter")
@PreAuthorize("hasRole('FACILITATOR') or hasRole('COORDINATOR')")
public ResponseEntity<List<NeedDto>> viewNeedsByFilter(@RequestParam(required = false) BigDecimal longitude,
@RequestParam(required = false) BigDecimal latitude,
public ResponseEntity<List<NeedDto>> viewNeedsByFilter(@RequestParam(required = false) BigDecimal longitude1,
@RequestParam(required = false) BigDecimal latitude1,
@RequestParam(required = false) BigDecimal longitude2,
@RequestParam(required = false) BigDecimal latitude2,
@RequestParam(required = false) String categoryTreeId,
@RequestParam(required = false) Long userId) {
log.info("Viewing needs for location: {}, {}, category: {}, user: {}", longitude, latitude, categoryTreeId, userId);
return needService.viewNeedsByFilter(longitude, latitude, categoryTreeId, userId);
log.info("Viewing needs for location: {}-{} / {}-{}, category: {}, user: {}", longitude1, latitude1, longitude2, latitude2, categoryTreeId, userId);
return needService.viewNeedsByFilter(longitude1, latitude1, longitude2, latitude2, categoryTreeId, userId);
}

@PostMapping("/createNeed")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.groupa1.resq.controller;

import com.groupa1.resq.config.ResqAppProperties;
import com.groupa1.resq.dto.NeedDto;
import com.groupa1.resq.dto.RequestDto;
import com.groupa1.resq.entity.Need;
import com.groupa1.resq.entity.Request;
Expand All @@ -11,6 +12,7 @@
import com.groupa1.resq.service.RequestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

Expand All @@ -31,13 +33,15 @@ public class RequestController {

@GetMapping("/viewRequestsByFilter")
@PreAuthorize("hasRole('FACILITATOR')")
public List<RequestDto> viewRequestsByFilter(@RequestParam(required = false) BigDecimal longitude,
@RequestParam(required = false) BigDecimal latitude,
public List<RequestDto> viewRequestsByFilter(@RequestParam(required = false) BigDecimal longitude1,
@RequestParam(required = false) BigDecimal latitude1,
@RequestParam(required = false) BigDecimal longitude2,
@RequestParam(required = false) BigDecimal latitude2,
@RequestParam(required = false) EStatus status,
@RequestParam(required = false) EUrgency urgency,
@RequestParam(required = false) Long userId) {
log.info("Viewing requests for location: {}, {}, status: {}, urgency: {}, user: {}", longitude, latitude, status, urgency, userId);
return requestService.viewRequestsByFilter(longitude, latitude, status, urgency, userId);
log.info("Viewing requests for location: {}-{} / {}-{}, status: {}, urgency: {}, user: {}", longitude1, latitude1, longitude2, latitude2, status, urgency, userId);
return requestService.viewRequestsByFilter(longitude1, latitude1, longitude2, latitude2, status, urgency, userId);
}


Expand Down Expand Up @@ -72,6 +76,15 @@ public String deleteRequest(@RequestParam Long userId, @RequestParam Long reques
return "Request successfully deleted.";
}

@GetMapping("/filterByDistance")
@PreAuthorize("hasRole('FACILITATOR') or hasRole('COORDINATOR')")
public ResponseEntity<List<RequestDto>> filterByDistance(@RequestParam BigDecimal longitude,
@RequestParam BigDecimal latitude,
@RequestParam BigDecimal distance) {
log.info("Filtering requests by distance");
return requestService.filterByDistance(longitude, latitude, distance);
}




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public NeedDto convertToDto(Need need) {
needDto.setLatitude(need.getLatitude());
needDto.setLongitude(need.getLongitude());
needDto.setCreatedDate(need.getCreatedAt());
needDto.setSize(need.getSize());
Request request = need.getRequest();
if (request != null) {
needDto.setRequestId(request.getId());
Expand All @@ -51,6 +52,7 @@ public Need convertToEntity(NeedDto needDto) {
need.setLongitude(needDto.getLongitude());
need.setStatus(needDto.getStatus());
need.setCreatedAt(needDto.getCreatedDate());
need.setSize(needDto.getSize());
Request request = requestRepository.findById(needDto.getRequestId()).orElse(null);
need.setRequest(request);
return need;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.groupa1.resq.dto.ProfileDto;
import com.groupa1.resq.entity.UserProfile;
import com.groupa1.resq.exception.EntityNotFoundException;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand All @@ -13,6 +14,9 @@ public class ProfileConverter {
ModelMapper modelMapper;

public ProfileDto convertToDto(UserProfile userProfile) {
if(userProfile == null) {
throw new EntityNotFoundException("User profile not found");
}
ProfileDto profileDto = modelMapper.map(userProfile, ProfileDto.class);
return profileDto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.groupa1.resq.dto.ResourceDto;
import com.groupa1.resq.entity.Resource;
import com.groupa1.resq.entity.enums.ESize;
import com.groupa1.resq.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand All @@ -26,6 +27,7 @@ public ResourceDto convertToDto(Resource resource){
resourceDto.setLatitude(resource.getLatitude());
resourceDto.setLongitude(resource.getLongitude());
resourceDto.setCreatedDate(resource.getCreatedAt());
resourceDto.setSize(resource.getSize().toString());
return resourceDto;

}
Expand All @@ -47,6 +49,7 @@ public Resource convertToEntity(ResourceDto resourceDto){
resource.setLatitude(resourceDto.getLatitude());
resource.setLongitude(resourceDto.getLongitude());
resource.setCreatedAt(resourceDto.getCreatedDate());
resource.setSize(ESize.valueOf(resourceDto.getSize()));
return resource;
}
}
25 changes: 25 additions & 0 deletions resq/backend/resq/src/main/java/com/groupa1/resq/dto/EventDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.groupa1.resq.dto;


import com.groupa1.resq.entity.User;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
public class EventDto {

private Long reporterId;

private String description;

private LocalDateTime reportDate;

private boolean isVerified;

private BigDecimal eventLatitude;
private BigDecimal eventLongitude;


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.groupa1.resq.dto;

import com.groupa1.resq.entity.enums.ENeedStatus;
import com.groupa1.resq.entity.enums.ESize;
import lombok.Data;

import java.math.BigDecimal;
Expand All @@ -18,4 +19,5 @@ public class NeedDto {
private Long requestId;
private ENeedStatus status;
private LocalDateTime createdDate;
private ESize size;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public class ResourceDto {
private BigDecimal latitude;
private BigDecimal longitude;
private LocalDateTime createdDate;
private String size;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public class Action extends BaseEntity {
@JoinColumn(name = "verifier_id")
private User verifier;

@Lob
@Column(length = 3000)
@Column(length = 2048)
private String description;

private LocalDateTime dueDate;
Expand Down
38 changes: 38 additions & 0 deletions resq/backend/resq/src/main/java/com/groupa1/resq/entity/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.groupa1.resq.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@NoArgsConstructor
@Entity
@Table( name = "EVENT")
@Data
@EqualsAndHashCode(callSuper = true, exclude = {"reporter"})
@ToString(callSuper = true, exclude = {"reporter"})
public class Event extends BaseEntity {

//@Enumerated(EnumType.STRING)
//private EEventType eventType;

@ManyToOne
@JoinColumn(name = "reporter_id")
private User reporter;

@Column(length = 2048)
private String description;

private LocalDateTime reportDate;

private boolean isVerified;

private BigDecimal eventLatitude;
private BigDecimal eventLongitude;

}

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class Feedback extends BaseEntity {
@JoinColumn(name = "creator_id")
private User creator;

@Lob
@Column(length = 3000)
@Column(length = 2048)
private String message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public class Info extends BaseEntity{
@JoinColumn(name = "user_id")
private User user;

@Lob
@Column(length = 3000)
@Column(length = 2048)
private String description;

private BigDecimal latitude;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.groupa1.resq.entity;

import com.groupa1.resq.entity.enums.EGender;
import com.groupa1.resq.entity.enums.ENeedStatus;
import com.groupa1.resq.entity.enums.ESize;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
Expand Down Expand Up @@ -34,6 +36,13 @@ public class Need extends BaseEntity{
private BigDecimal latitude;
private BigDecimal longitude;

@Enumerated(EnumType.STRING)
private EGender gender;

// These field only for clothing
@Enumerated(EnumType.STRING)
private ESize size;

@ManyToOne
@JoinColumn(name = "request_id")
private Request request;
Expand Down
Loading

0 comments on commit 01d6275

Please sign in to comment.