Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Management: Lecture Dates, Holidays, School Entity #195

Merged
merged 5 commits into from
May 13, 2020
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# uPresent

uPresent is a smart, contactless attendance tracking system designed for academic institutions. It relies on facial recognition and geo-fencing.

**Build Status**
- Components: [![TravisCI](https://api.travis-ci.com/rajan123456/uPresent.svg?branch=master)](https://api.travis-ci.com/rajan123456/uPresent.svg?branch=master)
- Mobile App: [![BitRise](https://app.bitrise.io/app/94539fb2e1e99188/status.svg?token=UdpO7BVErEwwgVQ-IR-PRQ&branch=master)](https://app.bitrise.io/app/94539fb2e1e99188/status.svg?token=UdpO7BVErEwwgVQ-IR-PRQ&branch=master)
10 changes: 7 additions & 3 deletions attendance/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Config(object):
VAULT_PORT = 8200
VAULT_LOGIN_URL = "/v1/auth/cert/login"
VAULT_DATA_URL = "/v1/aws/data"
# KAFKA_ADDRESS = "localhost:29092"
# KAFKA_ADDRESS = "localhost:9092"
KAFKA_ADDRESS = "broker:29092"
KAFKA_PUBLISH_TOPIC = "attendanceEvents"
SAGA_ENABLED = 1
Expand All @@ -28,8 +28,12 @@ class Config(object):
FACENET_RECOGNITION_API = "http://facenet:5000/api/face/"
# MODULE_API_FETCH_DETAILS = 'https://dev.upresent.ga/management/manage/module?moduleCode='
MODULE_API_FETCH_DETAILS = "http://management:8080/manage/module?moduleCode="
# MANAGEMENT_API_GEO_FENCE = "http://localhost:8081/manage/geo-fence?universityName="
MANAGEMENT_API_GEO_FENCE = "http://management:8080/manage/geo-fence?universityName="
# MANAGEMENT_API_GEO_FENCE = (
# "http://localhost:8081/manage/school/geo-fence?schoolCode="
# )
MANAGEMENT_API_GEO_FENCE = (
"http://management:8080/manage/school/geo-fence?schoolCode="
)
# USER_API_FETCH_USER = "http://localhost:8084/user?username="
USER_API_FETCH_USER = "http://user:8080/user?username="
AZURE_FACE_ENDPOINT = "https://eastus.api.cognitive.microsoft.com/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ResponseEntity<RestResponse<String>> createModule(
@RequestBody ModuleData moduleInfo) {
return RestUtils.successResponse(adminModuleService.createModule(moduleInfo));
}

@PutMapping
public ResponseEntity<RestResponse<String>> updateModule(
@RequestBody ModuleData moduleInfo) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.upresent.management.controller;

import com.upresent.management.entity.GeoFenceData;
import com.upresent.management.entity.SchoolData;
import com.upresent.management.service.SchoolService;
import com.upresent.management.utils.RestResponse;
import com.upresent.management.utils.RestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/manage/school")
public class SchoolController {

@Autowired
private SchoolService schoolService;

@PostMapping
public ResponseEntity<RestResponse<String>> createSchool(
@RequestBody SchoolData schoolInfo) {
return RestUtils.successResponse(schoolService.createSchool(schoolInfo));
}

@PutMapping
public ResponseEntity<RestResponse<String>> updateSchool(
@RequestBody SchoolData schoolInfo) {
return RestUtils.successResponse(schoolService.updateSchool(schoolInfo));
}

@DeleteMapping
public ResponseEntity<RestResponse<String>> deleteSchool(
@RequestParam String schoolCode, HttpServletRequest request) {
return RestUtils.successResponse(schoolService.deleteSchool(request, schoolCode));
}

@GetMapping
public ResponseEntity<RestResponse<SchoolData>> getSchool(
@RequestParam String schoolCode) {
return RestUtils.successResponse(schoolService.getSchool(schoolCode));
}

@GetMapping(path="/all")
public ResponseEntity<RestResponse<List<SchoolData>>> getAllSchools() {
return RestUtils.successResponse(schoolService.getAllSchools());
}

@GetMapping(path="/geo-fence")
public ResponseEntity<RestResponse<GeoFenceData>> getGeoFence(@RequestParam String schoolCode) {
return RestUtils.successResponse(schoolService.fetchGeoFence(schoolCode));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class GeoFenceData {
private String id;
@JsonIgnore
private String username;
private String universityName;
private Float latitude;
private Float longitude;
private Float radiusInMeter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.upresent.management.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;

import java.util.Date;

@Data
public class LectureData {
@Id
@JsonIgnore
private String id;
private String date; //pattern = "MM/dd/yyyy"
private String startTime; //pattern = "13:59"
private String endTime; //pattern = "17:59"
private String createdBy;
@JsonIgnore
@LastModifiedDate
private Date updatedOn;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;

Expand All @@ -13,14 +14,13 @@ public class ModuleData {

@Id
private String moduleCode;
private String schoolCode;
private String moduleName;
// pattern = "MM/dd/yyyy"
private String startDate;
// pattern = "MM/dd/yyyy"
private String endDate;
// Mon, Tue, Wed, Thur, Fri, Sat, Sun
private List<String> scheduledDays;
private String startDate; //pattern = "MM/dd/yyyy"
private String endDate; //pattern = "MM/dd/yyyy"
private List<LectureData> schedule;
private String createdBy;
@JsonIgnore
@LastModifiedDate
private Date updatedOn;
private List<String> studentUsernames;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lombok.Data;

@Data
public class MetricsData {
public class ReportsData {

private String eventType;
private String eventData;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.upresent.management.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;

import java.util.Date;
import java.util.List;

@Data
public class SchoolData {
@Id
private String schoolCode;
private String schoolName;
private List<Date> holidays;
private String timeZone;
private GeoFenceData geoFenceData;
private String createdBy;
@JsonIgnore
@LastModifiedDate
private Date updatedOn;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ public enum ExceptionResponseCode {
UPLOADING_FILE_FAILED(4013, "Your request could not be served by the system. Please try again."),
DATA_NOT_FOUND(4014, "Required data not found."),
UNKNOWN_USER_TYPE_FOUND(4015, "'Unknown' type user found in request."),
MODULE_ALREADY_EXISTS(4016, "Module already exists."),
MODULE_DOES_NOT_EXIST(4017, "Module doesn't exist."),
USER_TYPES_NOT_FOUND(4018, "User types could not be fetched."),
ALL_USERS_NOT_STUDENTS(4019, "Check the provided users. Either users do not exist or they do not have correct permissions.");

MODULE_ALREADY_EXISTS(4016, "Module already exists"),
MODULE_DOES_NOT_EXIST(4017, "Module does not exist"),
USER_TYPES_NOT_FOUND(4018, "User types could not be fetched"),
ALL_USERS_NOT_STUDENTS(4019, "Check the provided users. Either users do not exist or they do not have correct permissions."),
SCHOOL_ALREADY_EXISTS(4020, "School already exists"),
SCHOOL_DOES_NOT_EXIST(4021, "School does not exist");
private int code;

private String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected ResponseEntity<?> handleUnknownException(Exception ex, WebRequest requ
}

@ExceptionHandler(value = {ManagementException.class})
protected ResponseEntity<?> handleknownException(ManagementException ex, WebRequest request) {
protected ResponseEntity<?> handleKnownException(ManagementException ex, WebRequest request) {
if(!CommonUtility.isNullObject(ex.getResponseCode())){
log.error("Custom Exception:: Error Code :: {} Custom Exception:: Error Description {}",ex.getResponseCode().getCode(), ex.getResponseCode().getDescription());
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.upresent.management.entity.MetricsData;
import com.upresent.management.entity.ReportsData;
import com.upresent.management.exception.ExceptionResponseCode;
import com.upresent.management.exception.ManagementException;

Expand All @@ -27,25 +27,25 @@ public class RestMessageProducer {
private RestTemplate restTemplate;

public String send(String message) {
String url = env.getProperty("metrics.publisher.api");
String url = env.getProperty("reporting.publisher.api");
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
HttpEntity<?> entity = new HttpEntity<>(constructMetricsData(message), headers);
HttpEntity<?> entity = new HttpEntity<>(constructReportingData(message), headers);
ResponseEntity<String> response =
restTemplate.exchange(url, HttpMethod.POST,
entity, String.class);
return response.getBody();
}

private MetricsData constructMetricsData(String eventString) {
private ReportsData constructReportingData(String eventString) {
try {
List<String> eventList = Arrays.asList(eventString.split(";"));
MetricsData metricsData = new MetricsData();
metricsData.setEventType(eventList.get(1));
metricsData.setEventData(eventList.get(0));
metricsData.setSourceId(eventList.get(4));
metricsData.setTimeStamp(eventList.get(2));
return metricsData;
ReportsData reportsData = new ReportsData();
reportsData.setEventType(eventList.get(1));
reportsData.setEventData(eventList.get(0));
reportsData.setSourceId(eventList.get(4));
reportsData.setTimeStamp(eventList.get(2));
return reportsData;
} catch (Exception e) {
throw new ManagementException(ExceptionResponseCode.INVALID_REQUEST);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.upresent.management.repository;

import com.upresent.management.entity.SchoolData;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface SchoolRepository extends MongoRepository<SchoolData, String> {
public Optional<SchoolData> findById(String schoolCode);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

import com.upresent.management.entity.ModuleData;
import com.upresent.management.exception.ManagementException;
import org.springframework.stereotype.Service;

@Service
public interface AdminModuleService {

String createModule(ModuleData moduleData) throws ManagementException;
Expand All @@ -17,5 +19,5 @@ public interface AdminModuleService {

ModuleData getModule(String moduleCode) throws ManagementException;

List<ModuleData> getAllModules() throws ManagementException;
List<ModuleData> getAllModules();
}
Loading