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

Commit

Permalink
favs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
OSousa117 committed Oct 26, 2023
1 parent 5bfa8f4 commit bf6e97e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@

import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.LoggingHistoryEntity;
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.util.UUID;

@Repository
public interface LoggingHistoryRepository extends JpaRepository<LoggingHistoryEntity, Integer> {
@Query("select l from LoggingHistoryEntity l where l.logID = ?1")
LoggingHistoryEntity findByLogID(@NonNull UUID logID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,15 @@ private CompanyDtoFavoriteResponse convertToCompanyDto(FavoriteEntity entity) {
}

private EventFavoriteResponse convertToEventDto(FavoriteEntity entity){
Optional<LoggingHistoryEntity> eEntity = Optional.ofNullable(eventRepository.findByLogID(entity.getFavoriteId()));
if(eEntity.isPresent()){
LoggingHistoryEntity eEntity = eventRepository.findByLogID(entity.getFavoriteId());
EventFavoriteResponse eventEntity = new EventFavoriteResponse();
LoggingHistoryEntity loggingHistoryEntity = eEntity.get();
eventEntity.setEventType(loggingHistoryEntity.getEventType().toString());
eventEntity.setDescription(loggingHistoryEntity.getDescription());
eventEntity.setUserAccount(loggingHistoryEntity.getUserAccount());
eventEntity.setId(String.valueOf(loggingHistoryEntity.getId()));
eventEntity.setLogID(loggingHistoryEntity.getLogID().toString());
eventEntity.setTimeCreated(loggingHistoryEntity.getTime_created().toString());
eventEntity.setEventType(eEntity.getEventType().toString());
eventEntity.setDescription(eEntity.getDescription());
eventEntity.setUserAccount(eEntity.getUserAccount());
eventEntity.setId(String.valueOf(eEntity.getId()));
eventEntity.setLogID(eEntity.getLogID().toString());
eventEntity.setTimeCreated(eEntity.getTime_created().toString());
return eventEntity;
} else return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ import {LoadingMessage} from '../common/LoadingMessages';
import DemandManagementTable from './DemandManagementTable';
import {
FavoriteType,
MaterialDemandFavoriteResponse,
SingleCapacityGroupFavoriteResponse
MaterialDemandFavoriteResponse
} from "../../interfaces/Favorite_interface";
import {FavoritesContext} from "../../contexts/FavoritesContextProvider";
import {de} from "date-fns/locale";
Expand Down

0 comments on commit bf6e97e

Please sign in to comment.