Skip to content

Commit

Permalink
favorite status
Browse files Browse the repository at this point in the history
  • Loading branch information
OSousa117 committed Oct 30, 2023
1 parent 74e4492 commit 304502d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@Repository
public interface LinkedCapacityGroupMaterialDemandRepository
extends JpaRepository<LinkedCapacityGroupMaterialDemandEntity, UUID> {
LinkedCapacityGroupMaterialDemandEntity findByMaterialDemandID(UUID materialDemandID);
List<LinkedCapacityGroupMaterialDemandEntity> findByCapacityGroupID(@NonNull UUID capacityGroupID);

@Query("select count(l) from LinkedCapacityGroupMaterialDemandEntity l where l.materialDemandID = ?1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,22 @@
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.impl;

import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventType;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.FavoriteType;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.FavoriteService;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

@RequiredArgsConstructor
@Service
@Slf4j
Expand All @@ -46,6 +48,8 @@ public class FavoriteServiceImpl implements FavoriteService {

private final CapacityGroupRepository capacityGroupRepository;
private final MaterialDemandRepository materialDemandRepository;

private final LinkedCapacityGroupMaterialDemandRepository linkedMaterialDemandRepository;
private final CompanyRepository companyRepository;

private final LoggingHistoryRepository eventRepository;
Expand Down Expand Up @@ -138,6 +142,7 @@ private SingleCapacityGroupFavoriteResponse convertToSingleCapacityGroup(Favorit
scgfv.setCapacityGroupId(capacityGroup.getId().toString());
scgfv.setCapacityGroupName(capacityGroup.getCapacityGroupName());
scgfv.setCustomer(capacityGroup.getCustomer().getBpn());
scgfv.setStatus(capacityGroup.getLinkStatus().toString());
scgfv.setSupplier(capacityGroup.getSupplier().getBpn());
scgfv.setFavoritedAt(entity.getFavorited_at().toString());
return scgfv;
Expand All @@ -154,6 +159,10 @@ private MaterialDemandFavoriteResponse convertToMaterialDemandResponse(FavoriteE
CompanyEntity cEntity = materialDemand.getCustomerId();
CompanyEntity sEntity = materialDemand.getSupplierId();
response.setCustomer(cEntity.getId().toString());
LinkedCapacityGroupMaterialDemandEntity lcgm = linkedMaterialDemandRepository.findByMaterialDemandID(cEntity.getId());
if(lcgm != null){
response.setStatus(EventType.LINKED.toString());
} else response.setStatus(EventType.TODO.toString());
response.setSupplier(sEntity.getId().toString());
response.setMaterialDescriptionCustomer(materialDemand.getMaterialDescriptionCustomer());
response.setMaterialNumberCustomer(materialDemand.getMaterialNumberCustomer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,8 @@ components:
type: string
customer:
type: string
status:
type: string
supplier:
type: string
unitOfMeasure:
Expand All @@ -1497,6 +1499,8 @@ components:
type: string
capacityGroupId:
type: string
status:
type: string
capacityGroupName:
type: string
favorited_at:
Expand Down

0 comments on commit 304502d

Please sign in to comment.