Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Commit

Permalink
events favorites
Browse files Browse the repository at this point in the history
  • Loading branch information
OSousa117 committed Oct 26, 2023
1 parent e8ae575 commit 1563fc7
Show file tree
Hide file tree
Showing 35 changed files with 497 additions and 336 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
import eclipse.tractusx.demand_capacity_mgmt_specification.api.CapacityGroupApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.CapacityGroupService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.UserUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@AllArgsConstructor
public class CapacityGroupsController implements CapacityGroupApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
import eclipse.tractusx.demand_capacity_mgmt_specification.api.DemandApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.DemandService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.UserUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@AllArgsConstructor
public class DemandController implements DemandApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public ResponseEntity<FavoriteResponse> getFavorite() throws Exception {
@Override
public ResponseEntity<FavoriteResponse> getFavoriteByType(String type) {
FavoriteResponse responseList = favoriteService.getAllFavoritesByType(
UserUtil.getUserID(request),
FavoriteType.valueOf(type)
UserUtil.getUserID(request),
FavoriteType.valueOf(type)
);
return ResponseEntity.status(200).body(responseList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public ResponseEntity<StatusesResponse> getStatuses() {
@Override
public ResponseEntity<StatusesResponse> postStatus(StatusRequest statusRequest) {
String userID = UserUtil.getUserID(request);
StatusesResponse responseDto = statusesService.postStatuses(statusRequest,userID);
StatusesResponse responseDto = statusesService.postStatuses(statusRequest, userID);
return ResponseEntity.status(HttpStatus.CREATED).body(responseDto);
}

@Override
public ResponseEntity<StatusesResponse> updateStatusesById(String statusId, StatusRequest statusRequest) {
String userID = UserUtil.getUserID(request);
statusesService.updateStatus(statusRequest,userID);
statusesService.updateStatus(statusRequest, userID);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupDtoRequest;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupDtoResponse;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.WeekBasedCapacityGroupService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.UserUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@AllArgsConstructor
public class WeekBasedCapacityGroupController implements WeekBasedCapacityGroupApi {
Expand All @@ -53,7 +52,7 @@ public ResponseEntity<Void> postWeekBasedCapacityGroup(
List<WeekBasedCapacityGroupDtoRequest> weekBasedCapacityGroupRequest
) {
String userID = UserUtil.getUserID(request);
weekBasedCapacityGroupService.createWeekBasedCapacityGroup(weekBasedCapacityGroupRequest,userID);
weekBasedCapacityGroupService.createWeekBasedCapacityGroup(weekBasedCapacityGroupRequest, userID);
return ResponseEntity.status(HttpStatus.OK).build();
}

Expand All @@ -66,7 +65,7 @@ public ResponseEntity<WeekBasedCapacityGroupDtoResponse> updateWeekBasedCapacity
WeekBasedCapacityGroupDtoResponse responseDto = weekBasedCapacityGroupService.updateWeekBasedCapacityGroup(
weekBasedCapacityId,
weekBasedCapacityGroupRequest,
userID
userID
);
return ResponseEntity.status(HttpStatus.OK).body(responseDto);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedMaterialDemandRequestDto;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedMaterialDemandResponseDto;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.WeekBasedMaterialService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.UserUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@AllArgsConstructor
public class WeekBasedMaterialController implements WeekBasedMaterialDemandApi {
Expand All @@ -53,7 +52,7 @@ public ResponseEntity<Void> postWeekBasedMaterialDemand(
List<WeekBasedMaterialDemandRequestDto> weekBasedMaterialDemandRequestDto
) {
String userID = UserUtil.getUserID(request);
weekBasedMaterialService.createWeekBasedMaterial(weekBasedMaterialDemandRequestDto,userID);
weekBasedMaterialService.createWeekBasedMaterial(weekBasedMaterialDemandRequestDto, userID);
return ResponseEntity.status(HttpStatus.OK).build();
}

Expand All @@ -66,7 +65,7 @@ public ResponseEntity<WeekBasedMaterialDemandResponseDto> updateWeekBasedMateria
WeekBasedMaterialDemandResponseDto responseDto = weekBasedMaterialService.updateWeekBasedMaterial(
demandId,
weekBasedMaterialDemandRequestDto,
userID
userID
);
return ResponseEntity.status(HttpStatus.OK).body(responseDto);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@

import jakarta.annotation.Nullable;
import jakarta.persistence.*;
import java.sql.Timestamp;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventObjectType;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventType;

import java.sql.Timestamp;
import java.util.UUID;

@Entity
@Table(name = "archived_log")
@Data
Expand All @@ -46,6 +47,10 @@ public class ArchivedLogEntity {
@Column(name = "id")
private int id;

@Column(name = "log_id")
@Nullable
private UUID logID;

@Column(name = "USER_ACCOUNT")
private String userAccount;

Expand All @@ -68,7 +73,4 @@ public class ArchivedLogEntity {

@Column(name = "OBJECT_TYPE")
private EventObjectType objectType;

@Column(name = "IS_FAVORITED")
private Boolean isFavorited;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities;

import jakarta.persistence.*;
import lombok.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventType;

import java.time.LocalDate;
import java.util.List;
import java.util.UUID;
import lombok.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventType;

@Entity
@Table(name = "capacity_group")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public class LoggingHistoryEntity {
@Column(name = "id")
private int id;

@Column(name = "log_id")
@Nullable
private UUID logID;

@Column(name = "USER_ACCOUNT")
@Nullable
private String userAccount;
Expand Down Expand Up @@ -74,8 +78,4 @@ public class LoggingHistoryEntity {
@Nullable
@Column(name = "OBJECT_TYPE")
private EventObjectType objectType;

@Column(name = "IS_FAVORITED")
@Nullable
private Boolean isFavorited;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public enum FavoriteType {
CAPACITY_GROUP,
COMPANY_BASE_DATA,
MATERIAL_DEMAND,
EVENT,
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories;

import java.util.List;
import java.util.UUID;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.FavoriteEntity;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.FavoriteType;
import org.springframework.data.jpa.repository.JpaRepository;
Expand All @@ -30,14 +32,12 @@
import org.springframework.lang.NonNull;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;

public interface FavoriteRepository extends JpaRepository<FavoriteEntity, UUID> {
@Transactional
@Modifying
@Query("delete from FavoriteEntity f where f.userID = ?1 and f.favoriteId = ?2")
void deleteFavorite(@NonNull UUID userID, @NonNull UUID favoriteId);

List<FavoriteEntity> findByUserIDAndType(UUID userID, FavoriteType type);
FavoriteEntity findByUserIDAndId(UUID userID, int id);
List<FavoriteEntity> findByUserID(@NonNull UUID userID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories;

import jakarta.transaction.Transactional;
import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.LinkedCapacityGroupMaterialDemandEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;

@Repository
public interface LinkedCapacityGroupMaterialDemandRepository
extends JpaRepository<LinkedCapacityGroupMaterialDemandEntity, UUID> {
List<LinkedCapacityGroupMaterialDemandEntity> findByCapacityGroupID(@NonNull UUID capacityGroupID);

@Query("select count(l) from LinkedCapacityGroupMaterialDemandEntity l where l.materialDemandID = ?1")
long countLinkedDemands(UUID materialDemandID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@

import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.LoggingHistoryEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Repository;

import java.util.UUID;

@Repository
public interface LoggingHistoryRepository extends JpaRepository<LoggingHistoryEntity, Integer> {}
public interface LoggingHistoryRepository extends JpaRepository<LoggingHistoryEntity, Integer> {
LoggingHistoryEntity findByLogID(@NonNull UUID logID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories;

import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.StatusesEntity;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;
import java.util.UUID;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.StatusesEntity;
import org.springframework.data.jpa.repository.JpaRepository;

public interface StatusesRepository extends JpaRepository<StatusesEntity, Integer> {
Optional<StatusesEntity> findByUserID(UUID userID);
void deleteByUserID(UUID userID);

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services;

import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import java.util.List;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.MaterialDemandEntity;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.MaterialDemandStatus;

import java.util.List;

public interface DemandService {
MaterialDemandResponse createDemand(MaterialDemandRequest materialDemandRequest, String userID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import eclipse.tractusx.demand_capacity_mgmt_specification.model.StatusesResponse;

public interface StatusesService {
StatusesResponse postStatuses(StatusRequest statusRequest,String userID);
StatusesResponse postStatuses(StatusRequest statusRequest, String userID);
StatusesResponse getAllStatuses(String userID);
void updateStatus(StatusRequest statusRequest,String userID);
void updateStatus(StatusRequest statusRequest, String userID);
void addOrSubtractTodos(boolean add, String userID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@

import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupDtoRequest;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupDtoResponse;
import java.util.List;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.CapacityGroupEntity;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.WeekBasedCapacityGroupEntity;

import java.util.List;

public interface WeekBasedCapacityGroupService {
void createWeekBasedCapacityGroup(List<WeekBasedCapacityGroupDtoRequest> weekBasedCapacityGroupRequest,String userID);
void createWeekBasedCapacityGroup(
List<WeekBasedCapacityGroupDtoRequest> weekBasedCapacityGroupRequest,
String userID
);

void receiveWeekBasedCapacityGroup();

void sendWeekBasedCapacityGroup();

List<WeekBasedCapacityGroupDtoResponse> getWeekBasedCapacityGroups();

void createWeekBasedCapacityGroupRequestFromEntity(CapacityGroupEntity capacityGroupEntity,String userID);
void createWeekBasedCapacityGroupRequestFromEntity(CapacityGroupEntity capacityGroupEntity, String userID);

WeekBasedCapacityGroupDtoResponse updateWeekBasedCapacityGroup(
String id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@

import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedMaterialDemandRequestDto;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedMaterialDemandResponseDto;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.MaterialDemandEntity;

import java.util.List;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.MaterialDemandEntity;

public interface WeekBasedMaterialService {
void createWeekBasedMaterial(List<WeekBasedMaterialDemandRequestDto> weekBasedMaterialDemandRequestDto,String userID);
void createWeekBasedMaterial(
List<WeekBasedMaterialDemandRequestDto> weekBasedMaterialDemandRequestDto,
String userID
);
void sendWeekBasedMaterial();
void receiveWeekBasedMaterial();

Expand All @@ -42,5 +44,5 @@ WeekBasedMaterialDemandResponseDto updateWeekBasedMaterial(
String userID
);

void createWeekBasedMaterialRequestFromEntity(MaterialDemandEntity materialDemandEntity,String userID);
void createWeekBasedMaterialRequestFromEntity(MaterialDemandEntity materialDemandEntity, String userID);
}
Loading

0 comments on commit 1563fc7

Please sign in to comment.