From bcf2fc7ae911d0edc19d79891f6f2f70cc015d29 Mon Sep 17 00:00:00 2001 From: nirmala Date: Sat, 14 Oct 2023 22:24:47 +0530 Subject: [PATCH] :recycle: code refactor --- pom.xml | 44 +++++++------------ .../biobeacon/BioBeaconApplication.java | 8 ++-- .../activities/ActivityController.java | 8 +++- .../biobeacon/activities/ActivityTime.java | 2 +- .../activities/ActivityTimeRepository.java | 3 +- .../biobeacon/athlete/AthleteService.java | 4 +- .../nimshub/biobeacon/auth/AuthService.java | 8 ++-- .../nimshub/biobeacon/coach/CoachService.java | 3 +- .../nimshub/biobeacon/config/AppConfig.java | 4 +- .../nimshub/biobeacon/config/JwtService.java | 4 ++ .../biobeacon/config/SecurityConfig.java | 2 +- .../biobeacon/constants/Constants.java | 18 +++++--- .../nimshub/biobeacon/email/EmailSender.java | 2 +- .../biobeacon/email/SMTPGmailService.java | 8 +++- .../exceptions/ByteCodeException.java | 2 +- .../exceptions/MqttConnectionException.java | 8 ++-- .../nimshub/biobeacon/ml/ModelService.java | 36 ++++++++++----- .../biobeacon/ml/PreProcessorService.java | 12 ++++- .../com/nimshub/biobeacon/scheduler/Task.java | 2 +- .../biobeacon/session/SessionController.java | 1 + .../session/SessionMotionDataRepository.java | 2 +- .../biobeacon/session/SessionRepository.java | 2 +- .../biobeacon/session/SessionService.java | 1 + .../nimshub/biobeacon/utils/Acceleration.java | 8 ++-- src/main/resources/application-dev.yml | 2 +- src/main/resources/application-prod.yml | 2 +- 26 files changed, 114 insertions(+), 82 deletions(-) diff --git a/pom.xml b/pom.xml index eae6b6b..086067c 100644 --- a/pom.xml +++ b/pom.xml @@ -98,16 +98,6 @@ org.springframework.boot spring-boot-starter-mail - - org.tensorflow - tensorflow - 1.8.0 - - - org.tensorflow - tensorflow-core-platform - 0.5.0 - @@ -130,23 +120,23 @@ maven-antrun-plugin 1.8 - - prepare - package - - - - - - - - - - - run - - + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/nimshub/biobeacon/BioBeaconApplication.java b/src/main/java/com/nimshub/biobeacon/BioBeaconApplication.java index 0da7905..ac20e90 100644 --- a/src/main/java/com/nimshub/biobeacon/BioBeaconApplication.java +++ b/src/main/java/com/nimshub/biobeacon/BioBeaconApplication.java @@ -9,15 +9,15 @@ @SpringBootApplication public class BioBeaconApplication { + @Value("${server.port}") + String port; + public static void main(String[] args) { SpringApplication.run(BioBeaconApplication.class, args); } - @Value("${server.port}") - String port; - @RestController - public class helloController { + public class HelloController { @GetMapping("/") public String hello() { return String.format("Up and Running on Port %s ...", port); diff --git a/src/main/java/com/nimshub/biobeacon/activities/ActivityController.java b/src/main/java/com/nimshub/biobeacon/activities/ActivityController.java index 2f1c8eb..85137d3 100644 --- a/src/main/java/com/nimshub/biobeacon/activities/ActivityController.java +++ b/src/main/java/com/nimshub/biobeacon/activities/ActivityController.java @@ -3,7 +3,10 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import java.util.UUID; @@ -16,8 +19,9 @@ @RequestMapping("/api/v1/activities") public class ActivityController { private final ActivityService activityService; + @GetMapping("/activity/{id}") - public ResponseEntity getActivityTimes(@PathVariable UUID id){ + public ResponseEntity getActivityTimes(@PathVariable UUID id) { return new ResponseEntity<>(activityService.getActivityTime(id), HttpStatus.OK); } } \ No newline at end of file diff --git a/src/main/java/com/nimshub/biobeacon/activities/ActivityTime.java b/src/main/java/com/nimshub/biobeacon/activities/ActivityTime.java index 3b53f20..593de5d 100644 --- a/src/main/java/com/nimshub/biobeacon/activities/ActivityTime.java +++ b/src/main/java/com/nimshub/biobeacon/activities/ActivityTime.java @@ -21,7 +21,7 @@ public class ActivityTime { @SequenceGenerator(name = "ActivityTime_SEQ", sequenceName = "ActivityTime_SEQ", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ActivityTime_SEQ") private Integer id; - @OneToOne(cascade = CascadeType.DETACH,fetch = FetchType.EAGER) + @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER) @JoinColumn(name = "session", referencedColumnName = "id", foreignKey = @ForeignKey(name = "fk_session_id") ) diff --git a/src/main/java/com/nimshub/biobeacon/activities/ActivityTimeRepository.java b/src/main/java/com/nimshub/biobeacon/activities/ActivityTimeRepository.java index 4763823..73868aa 100644 --- a/src/main/java/com/nimshub/biobeacon/activities/ActivityTimeRepository.java +++ b/src/main/java/com/nimshub/biobeacon/activities/ActivityTimeRepository.java @@ -1,6 +1,5 @@ package com.nimshub.biobeacon.activities; -import com.nimshub.biobeacon.activities.ActivityTime; import com.nimshub.biobeacon.session.Session; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -13,6 +12,6 @@ */ @Repository -public interface ActivityTimeRepository extends JpaRepository { +public interface ActivityTimeRepository extends JpaRepository { Optional findBySession(Session session); } diff --git a/src/main/java/com/nimshub/biobeacon/athlete/AthleteService.java b/src/main/java/com/nimshub/biobeacon/athlete/AthleteService.java index 5fd358e..096fe96 100644 --- a/src/main/java/com/nimshub/biobeacon/athlete/AthleteService.java +++ b/src/main/java/com/nimshub/biobeacon/athlete/AthleteService.java @@ -146,6 +146,7 @@ public List getAthletesByCoach(String authHeader) { /** * This method get athlete details by athlete ID + * * @param athleteId : UUID * @return : AthleteDetailsResponse */ @@ -170,7 +171,8 @@ public AthleteDetailsResponse getAthleteDetailsByAthleteId(UUID athleteId) { /** * This method updates the athlete - * @param request : CreateAthleteRequest + * + * @param request : CreateAthleteRequest * @param authHeader : String * @return : AuthenticationResponse */ diff --git a/src/main/java/com/nimshub/biobeacon/auth/AuthService.java b/src/main/java/com/nimshub/biobeacon/auth/AuthService.java index 18e84de..a1e2c18 100644 --- a/src/main/java/com/nimshub/biobeacon/auth/AuthService.java +++ b/src/main/java/com/nimshub/biobeacon/auth/AuthService.java @@ -2,7 +2,6 @@ import com.nimshub.biobeacon.config.JwtService; import com.nimshub.biobeacon.exceptions.UserAlreadyExistsException; -import com.nimshub.biobeacon.user.Role; import com.nimshub.biobeacon.user.User; import com.nimshub.biobeacon.user.UserRepository; import lombok.RequiredArgsConstructor; @@ -78,9 +77,9 @@ public AuthenticationResponse authenticate(AuthenticationRequest request) { .formatted(request.getEmail())); } Map extraClaims = new HashMap<>(); - extraClaims.put("role",user.getRole()); + extraClaims.put("role", user.getRole()); - var jwtToken = jwtService.generateToken(extraClaims,user); + var jwtToken = jwtService.generateToken(extraClaims, user); logger.info("User authentication success"); return AuthenticationResponse.builder() @@ -89,7 +88,8 @@ public AuthenticationResponse authenticate(AuthenticationRequest request) { } /** - * This method updates user + * This method updates user + * * @param user : User * @return AuthenticationResponse */ diff --git a/src/main/java/com/nimshub/biobeacon/coach/CoachService.java b/src/main/java/com/nimshub/biobeacon/coach/CoachService.java index a2635cd..a1638dd 100644 --- a/src/main/java/com/nimshub/biobeacon/coach/CoachService.java +++ b/src/main/java/com/nimshub/biobeacon/coach/CoachService.java @@ -104,7 +104,8 @@ public CoachDetailsResponse getCoach(String authHeader) { /** * This method updates the coach - * @param request : CreateCoachRequest + * + * @param request : CreateCoachRequest * @param authHeader : String * @return : AuthenticationResponse */ diff --git a/src/main/java/com/nimshub/biobeacon/config/AppConfig.java b/src/main/java/com/nimshub/biobeacon/config/AppConfig.java index 47636f3..4cf7af0 100644 --- a/src/main/java/com/nimshub/biobeacon/config/AppConfig.java +++ b/src/main/java/com/nimshub/biobeacon/config/AppConfig.java @@ -61,7 +61,7 @@ public PasswordEncoder passwordEncoder() { } @Bean - public CorsConfigurationSource corsConfigurationSource(){ + public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); configuration.setAllowedOrigins(Arrays.asList( "http://localhost:4200", @@ -69,7 +69,7 @@ public CorsConfigurationSource corsConfigurationSource(){ "https://d3bljg8pxxqty4.cloudfront.net", "http://d3bljg8pxxqty4.cloudfront.net")); // Replace with the allowed origins for your application configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); // Configure the allowed HTTP methods - configuration.setAllowedHeaders(Arrays.asList("Content-Type", "Authorization","X-Device-Id","X-Api-Key")); // Configure the allowed headers + configuration.setAllowedHeaders(Arrays.asList("Content-Type", "Authorization", "X-Device-Id", "X-Api-Key")); // Configure the allowed headers UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/**", configuration); return source; diff --git a/src/main/java/com/nimshub/biobeacon/config/JwtService.java b/src/main/java/com/nimshub/biobeacon/config/JwtService.java index 30665e6..dc27cc8 100644 --- a/src/main/java/com/nimshub/biobeacon/config/JwtService.java +++ b/src/main/java/com/nimshub/biobeacon/config/JwtService.java @@ -66,6 +66,7 @@ private Key getSignInKey() { /** * This method generates Jwt token with User details + * * @param userDetails : UserDetails * @return : String */ @@ -75,6 +76,7 @@ public String generateToken(UserDetails userDetails) { /** * This method generates Jwt token with User details and extraClaims + * * @param extraClaims : Map * @param userDetails : UserDetails * @return : String @@ -97,6 +99,7 @@ public boolean isTokenValid(String token, UserDetails userDetails) { /** * This method checks if the token is expired or not + * * @param token : String * @return boolean */ @@ -106,6 +109,7 @@ private boolean isTokenExpired(String token) { /** * This method extract the expiration time out of token + * * @param token : String * @return Date */ diff --git a/src/main/java/com/nimshub/biobeacon/config/SecurityConfig.java b/src/main/java/com/nimshub/biobeacon/config/SecurityConfig.java index 6f290b9..0571ab7 100644 --- a/src/main/java/com/nimshub/biobeacon/config/SecurityConfig.java +++ b/src/main/java/com/nimshub/biobeacon/config/SecurityConfig.java @@ -29,7 +29,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .authorizeHttpRequests() .requestMatchers("/actuator/**") .hasAuthority("ADMIN") - .requestMatchers("/api/v1/auth/**", "/","/message/**", + .requestMatchers("/api/v1/auth/**", "/", "/message/**", "/api/v1/sessions/update-session", "/api/v1/coaches/get-all", "/api/v1/coaches/create-coach", diff --git a/src/main/java/com/nimshub/biobeacon/constants/Constants.java b/src/main/java/com/nimshub/biobeacon/constants/Constants.java index adf2082..29ad463 100644 --- a/src/main/java/com/nimshub/biobeacon/constants/Constants.java +++ b/src/main/java/com/nimshub/biobeacon/constants/Constants.java @@ -1,14 +1,20 @@ package com.nimshub.biobeacon.constants; -public class Constants { - // creating a private constructor to hide the public implicit one - private Constants() { - throw new IllegalStateException("Constants class"); - } +public class Constants { public static final String NO_DATA = "*"; public static final String BASH = "bash"; - public static final String SCRIPT = "python3 "; public static final String COMMAND = "-c"; public static final String COMMA = ","; public static final Integer CHUNK_SIZE = 4; + public static final String CYCLING = "0"; + public static final String PUSH_UP = "1"; + public static final String RUNNING = "2"; + public static final String SQUAT = "3"; + public static final String TABLE_TENNIS = "4"; + public static final String WALKING = "5"; + public static final Integer SAMPLING_SIZE = 10; + // creating a private constructor to hide the public implicit one + private Constants() { + throw new IllegalStateException("Constants class"); + } } diff --git a/src/main/java/com/nimshub/biobeacon/email/EmailSender.java b/src/main/java/com/nimshub/biobeacon/email/EmailSender.java index 77818cd..3a05ea0 100644 --- a/src/main/java/com/nimshub/biobeacon/email/EmailSender.java +++ b/src/main/java/com/nimshub/biobeacon/email/EmailSender.java @@ -1,5 +1,5 @@ package com.nimshub.biobeacon.email; public interface EmailSender { - void send(String receiver,String subject,String body); + void send(String receiver, String subject, String body); } diff --git a/src/main/java/com/nimshub/biobeacon/email/SMTPGmailService.java b/src/main/java/com/nimshub/biobeacon/email/SMTPGmailService.java index 7b72044..314b4d9 100644 --- a/src/main/java/com/nimshub/biobeacon/email/SMTPGmailService.java +++ b/src/main/java/com/nimshub/biobeacon/email/SMTPGmailService.java @@ -1,15 +1,19 @@ package com.nimshub.biobeacon.email; import lombok.RequiredArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor -public class SMTPGmailService implements EmailSender{ +public class SMTPGmailService implements EmailSender { private final JavaMailSender mailSender; + Logger logger = LoggerFactory.getLogger(SMTPGmailService.class); + @Override public void send(String receiver, String subject, String body) { SimpleMailMessage email = new SimpleMailMessage(); @@ -19,6 +23,6 @@ public void send(String receiver, String subject, String body) { email.setText(body); mailSender.send(email); - System.out.println("Mail has been sent..."); + logger.info("Mail has been sent..."); } } diff --git a/src/main/java/com/nimshub/biobeacon/exceptions/ByteCodeException.java b/src/main/java/com/nimshub/biobeacon/exceptions/ByteCodeException.java index 0f5dfaa..3283b0f 100644 --- a/src/main/java/com/nimshub/biobeacon/exceptions/ByteCodeException.java +++ b/src/main/java/com/nimshub/biobeacon/exceptions/ByteCodeException.java @@ -4,7 +4,7 @@ import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(HttpStatus.BAD_REQUEST) -public class ByteCodeException extends RuntimeException{ +public class ByteCodeException extends RuntimeException { public ByteCodeException(String message) { super(message); } diff --git a/src/main/java/com/nimshub/biobeacon/exceptions/MqttConnectionException.java b/src/main/java/com/nimshub/biobeacon/exceptions/MqttConnectionException.java index 5785bfc..4867217 100644 --- a/src/main/java/com/nimshub/biobeacon/exceptions/MqttConnectionException.java +++ b/src/main/java/com/nimshub/biobeacon/exceptions/MqttConnectionException.java @@ -1,7 +1,7 @@ package com.nimshub.biobeacon.exceptions; -public class MqttConnectionException extends RuntimeException{ - public MqttConnectionException(String message) { - super(message); - } +public class MqttConnectionException extends RuntimeException { + public MqttConnectionException(String message) { + super(message); + } } diff --git a/src/main/java/com/nimshub/biobeacon/ml/ModelService.java b/src/main/java/com/nimshub/biobeacon/ml/ModelService.java index 05fd90c..e669a49 100644 --- a/src/main/java/com/nimshub/biobeacon/ml/ModelService.java +++ b/src/main/java/com/nimshub/biobeacon/ml/ModelService.java @@ -37,22 +37,29 @@ public class ModelService { @Value("${ml.process-directory}") String processDirectory; - + @Value("${ml.script-init-command}") + String scriptInitCommand; + + /** + * This method initialize the Machine learning model + * + * @return : String + */ public String doAnalyze() { String outputCsv = ""; try { String scriptName = "scripts/model5.py"; - String[] command = {BASH, COMMAND, SCRIPT + scriptName}; + String[] command = {BASH, COMMAND, scriptInitCommand + scriptName}; ProcessBuilder processBuilder = new ProcessBuilder(command); processBuilder.directory(new File(processDirectory)); Process process = processBuilder.start(); - - logger.info("Executing command : {}", Arrays.toString(command)); + String executionCommand = Arrays.toString(command); + logger.info("Executing command : {}", executionCommand); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; @@ -75,27 +82,32 @@ public String doAnalyze() { } } catch (IOException | InterruptedException e) { - e.printStackTrace(); + logger.warn(e.getMessage(), e); } return outputCsv; } + /** + * This method read the predicted output from the model and predict the activities + * + * @param id : Integer + */ public void predictActivities(Integer id) { Converters converter = new Converters(); String output = doAnalyze(); List predictionList = converter.getStringList(output); - int cyclingTime = Collections.frequency(predictionList, "0")*10; - int pushUpTime = Collections.frequency(predictionList, "1")*10; - int runTime = Collections.frequency(predictionList, "2")*10; - int squatTime = Collections.frequency(predictionList, "3")*10; - int tableTennisTime = Collections.frequency(predictionList, "4")*10; - int walkTime = Collections.frequency(predictionList, "5")*10; + int cyclingTime = Collections.frequency(predictionList, CYCLING) * SAMPLING_SIZE; + int pushUpTime = Collections.frequency(predictionList, PUSH_UP) * SAMPLING_SIZE; + int runTime = Collections.frequency(predictionList, RUNNING) * SAMPLING_SIZE; + int squatTime = Collections.frequency(predictionList, SQUAT) * SAMPLING_SIZE; + int tableTennisTime = Collections.frequency(predictionList, TABLE_TENNIS) * SAMPLING_SIZE; + int walkTime = Collections.frequency(predictionList, WALKING) * SAMPLING_SIZE; Session session = sessionRepository.findById(id) - .orElseThrow(()-> new SessionNotFoundException("Session not found")); + .orElseThrow(() -> new SessionNotFoundException("Session not found")); ActivityTime activityTime = ActivityTime.builder() .session(session) diff --git a/src/main/java/com/nimshub/biobeacon/ml/PreProcessorService.java b/src/main/java/com/nimshub/biobeacon/ml/PreProcessorService.java index 54b6893..5302036 100644 --- a/src/main/java/com/nimshub/biobeacon/ml/PreProcessorService.java +++ b/src/main/java/com/nimshub/biobeacon/ml/PreProcessorService.java @@ -36,6 +36,11 @@ public class PreProcessorService { String data; Logger logger = LoggerFactory.getLogger(PreProcessorService.class); + /** + * This method pre-process the data to feed in to the ML model + * + * @param session :Session + */ public void preProcessData(Session session) { Converters converter = new Converters(); SessionMotionData motionData = motionDataRepository.findSessionMotionDataBySession(session) @@ -76,13 +81,18 @@ public void preProcessData(Session session) { saveFile(builder.toString()); } + /** + * This method saves the preprocessed data file + * + * @param csvString : String + */ private void saveFile(String csvString) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(data))) { writer.write(csvString); logger.info("CSV file saved successfully at {}", data); } catch (IOException e) { - e.printStackTrace(); + logger.error(e.getMessage()); } } diff --git a/src/main/java/com/nimshub/biobeacon/scheduler/Task.java b/src/main/java/com/nimshub/biobeacon/scheduler/Task.java index 851f7b4..b2c55a6 100644 --- a/src/main/java/com/nimshub/biobeacon/scheduler/Task.java +++ b/src/main/java/com/nimshub/biobeacon/scheduler/Task.java @@ -21,7 +21,7 @@ public class Task { @Scheduled(fixedRateString = "${scheduling.fixed-rate}") @Async - void testRun() throws InterruptedException { + void runTask() { logger.info("Running scheduled job..."); sessionRepository.findTopByIsCompleteTrueAndAnalysisStatusFalse().ifPresent(session -> { Integer sessionId = session.getId(); diff --git a/src/main/java/com/nimshub/biobeacon/session/SessionController.java b/src/main/java/com/nimshub/biobeacon/session/SessionController.java index 9c19f97..bbd3ae7 100644 --- a/src/main/java/com/nimshub/biobeacon/session/SessionController.java +++ b/src/main/java/com/nimshub/biobeacon/session/SessionController.java @@ -49,6 +49,7 @@ public ResponseEntity getSessionDetailsBySessionId(@Path logger.info("getting session details of the session : {}", id); return new ResponseEntity<>(sessionDetailsResponse, HttpStatus.OK); } + @GetMapping("/session-motion-data/{id}") public ResponseEntity getSessionMotionDataBySessionId(@PathVariable("id") UUID id) { SessionMotionDataResponse motionData = sessionService.getMotionData(id); diff --git a/src/main/java/com/nimshub/biobeacon/session/SessionMotionDataRepository.java b/src/main/java/com/nimshub/biobeacon/session/SessionMotionDataRepository.java index 8526941..12b31c8 100644 --- a/src/main/java/com/nimshub/biobeacon/session/SessionMotionDataRepository.java +++ b/src/main/java/com/nimshub/biobeacon/session/SessionMotionDataRepository.java @@ -6,6 +6,6 @@ import java.util.Optional; @Repository -public interface SessionMotionDataRepository extends JpaRepository { +public interface SessionMotionDataRepository extends JpaRepository { Optional findSessionMotionDataBySession(Session session); } diff --git a/src/main/java/com/nimshub/biobeacon/session/SessionRepository.java b/src/main/java/com/nimshub/biobeacon/session/SessionRepository.java index c1f76c5..f6b599b 100644 --- a/src/main/java/com/nimshub/biobeacon/session/SessionRepository.java +++ b/src/main/java/com/nimshub/biobeacon/session/SessionRepository.java @@ -7,7 +7,6 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import javax.swing.text.html.Option; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @@ -25,6 +24,7 @@ public interface SessionRepository extends JpaRepository { Optional findTopByDeviceIdAndIsCompleteFalseOrderByCreateDateTimeDesc(Long deviceId); Optional findTopByAnalysisStatusEquals(boolean analysisStatus); + Optional findTopByIsCompleteTrueAndAnalysisStatusFalse(); @Modifying diff --git a/src/main/java/com/nimshub/biobeacon/session/SessionService.java b/src/main/java/com/nimshub/biobeacon/session/SessionService.java index 3372b90..1555f61 100644 --- a/src/main/java/com/nimshub/biobeacon/session/SessionService.java +++ b/src/main/java/com/nimshub/biobeacon/session/SessionService.java @@ -161,6 +161,7 @@ public SessionDetailsResponse getSessionDetails(UUID sessionId) { /** * This method retrieves motion data of a session + * * @param sessionId : UUID * @return SessionMotionDataResponse */ diff --git a/src/main/java/com/nimshub/biobeacon/utils/Acceleration.java b/src/main/java/com/nimshub/biobeacon/utils/Acceleration.java index 8b8b017..b9bf8ab 100644 --- a/src/main/java/com/nimshub/biobeacon/utils/Acceleration.java +++ b/src/main/java/com/nimshub/biobeacon/utils/Acceleration.java @@ -3,22 +3,20 @@ import org.springframework.lang.NonNull; public class Acceleration { + private String x; + private String y; + private String z; public Acceleration(@NonNull String x, @NonNull String y, @NonNull String z) { this.x = x; this.y = y; this.z = z; } - public Acceleration(String data) { this.x = data; this.y = data; this.z = data; } - private String x; - private String y; - private String z; - public String getX() { return x; } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 3cb7519..30cfbc2 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -51,7 +51,7 @@ scheduling: fixed-rate: 10000 ml: - enabled: false + script-init-command: "source env/bin/activate && python3 " scripts: /run/media/nims/Files/Dev/IdeaProjects/bio-beacon-api/src/main/resources data: /run/media/nims/Files/Dev/IdeaProjects/bio-beacon-api/src/main/resources/data/temp.csv process-directory: /run/media/nims/Files/Dev/IdeaProjects/bio-beacon-api/src/main/resources \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 04c1e1e..464ae54 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -47,7 +47,7 @@ scheduling: fixed-rate: 10000 ml: - enabled: ${ML_ENABLED} + script-init-command: "python3 " scripts: ${SCRIPTS_LOCATION} data: ${DATA_LOCATION} process-directory: ${PROCESS_DIRECTORY}