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

feat: implemented DemandAndCapacityNotification frontend #451

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
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ private DemandAndCapacityNotificationDto convertToDto(ReportedDemandAndCapacityN
dto.setPartnerBpnl(entity.getPartner().getBpnl());
return dto;
}

private OwnDemandAndCapacityNotification convertToEntity(DemandAndCapacityNotificationDto dto) {
OwnDemandAndCapacityNotification entity = modelMapper.map(dto, OwnDemandAndCapacityNotification.class);

Expand All @@ -202,6 +201,9 @@ private OwnDemandAndCapacityNotification convertToEntity(DemandAndCapacityNotifi
}
entity.setPartner(existingPartner);

if (dto.getAffectedMaterialNumbers() == null) {
dto.setAffectedMaterialNumbers(new ArrayList<>());
}
List<Material> materials = new ArrayList<>();
for (String ownMaterialNumber : dto.getAffectedMaterialNumbers()) {
Material material = materialService.findByOwnMaterialNumber(ownMaterialNumber);
Expand All @@ -214,6 +216,9 @@ private OwnDemandAndCapacityNotification convertToEntity(DemandAndCapacityNotifi
}
entity.setMaterials(materials);

if (dto.getAffectedSitesBpnsRecipient() == null) {
dto.setAffectedSitesBpnsRecipient(new ArrayList<>());
}
List<Site> affectedSitesRecipient = new ArrayList<>();
for (String bpns : dto.getAffectedSitesBpnsRecipient()) {
Site site = existingPartner.getSites().stream().filter(p -> p.getBpns().equals(bpns)).findFirst()
Expand All @@ -228,6 +233,9 @@ private OwnDemandAndCapacityNotification convertToEntity(DemandAndCapacityNotifi
entity.setAffectedSitesRecipient(affectedSitesRecipient);

Partner ownPartner = partnerService.getOwnPartnerEntity();
if (dto.getAffectedSitesBpnsSender() == null) {
dto.setAffectedSitesBpnsSender(new ArrayList<>());
}
List<Site> affectedSitesSender = new ArrayList<>();
for (String bpns : dto.getAffectedSitesBpnsSender()) {
Site site = ownPartner.getSites().stream().filter(p -> p.getBpns().equals(bpns)).findFirst().orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ public List<OwnDemandAndCapacityNotification> findAllByPartnerBpnl(String bpnl)
@Override
public boolean validate(OwnDemandAndCapacityNotification notification) {
return notification.getPartner() != null &&
notification.getText() != null &&
notification.getLeadingRootCause() != null &&
notification.getEffect() != null &&
notification.getStatus() != null &&
notification.getStartDateOfEffect() != null &&
notification.getExpectedEndDateOfEffect() != null &&
validateMaterials(notification) &&
validateSites(notification);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ public List<ReportedDemandAndCapacityNotification> findAllByPartnerBpnl(String b
@Override
public boolean validate(ReportedDemandAndCapacityNotification notification) {
return notification.getPartner() != null &&
notification.getText() != null &&
notification.getLeadingRootCause() != null &&
notification.getEffect() != null &&
notification.getStatus() != null &&
notification.getStartDateOfEffect() != null &&
notification.getExpectedEndDateOfEffect() != null &&
validateMaterials(notification) &&
validateSites(notification);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.util.PatternStore;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Address;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Site;
import org.eclipse.tractusx.puris.backend.masterdata.logic.dto.AddressDto;
import org.eclipse.tractusx.puris.backend.masterdata.logic.dto.PartnerDto;
import org.eclipse.tractusx.puris.backend.masterdata.logic.dto.SiteDto;
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialPartnerRelationService;
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.PartnerService;
import org.modelmapper.Conditions;
import org.modelmapper.ModelMapper;
Expand All @@ -60,6 +62,9 @@ public class PartnerController {
private Validator validator;
private final ModelMapper modelMapper = new ModelMapper();

@Autowired
private MaterialPartnerRelationService mpr;

private final Pattern bpnlPattern = PatternStore.BPNL_PATTERN;

@PostMapping
Expand Down Expand Up @@ -236,4 +241,20 @@ public ResponseEntity<List<SiteDto>> getOwnSites() {
HttpStatus.OK);
}

@GetMapping("{partnerBpnl}/materials")
@Operation(description = "Returns all materials the specified partner is associated with.")
public ResponseEntity<List<Material>> getMaterials(@PathVariable String partnerBpnl) {
if (!bpnlPattern.matcher(partnerBpnl).matches()) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}

Partner partner = partnerService.findByBpnl(partnerBpnl);
if (partner == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(mpr.findAll().stream()
.filter(rel -> rel.getPartner().equals(partner))
.map(rel -> rel.getMaterial()).collect(Collectors.toList()), HttpStatus.OK);
}

}
4 changes: 3 additions & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
VITE_APP_NAME=PURIS
VITE_BACKEND_BASE_URL=http://localhost:8081/catena/
VITE_BACKEND_API_KEY=test
VITE_ENDPOINT_MATERIALS=stockView/materials
VITE_ENDPOINT_STOCK_VIEW_MATERIALS=stockView/materials
VITE_ENDPOINT_MATERIALS=materials
VITE_ENDPOINT_PRODUCTS=stockView/products
VITE_ENDPOINT_MATERIAL_STOCKS=stockView/material-stocks
VITE_ENDPOINT_PRODUCT_STOCKS=stockView/product-stocks
Expand All @@ -17,6 +18,7 @@ VITE_ENDPOINT_DEMAND=demand
VITE_ENDPOINT_PRODUCTION=production
VITE_ENDPOINT_PRODUCTION_RANGE=production/range
VITE_ENDPOINT_DELIVERY=delivery
VITE_ENDPOINT_DEMAND_AND_CAPACITY_NOTIFICATION=demand-and-capacity-notification

VITE_IDP_DISABLE=true
VITE_IDP_URL=http://localhost:10081/
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/components/layout/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Typography } from '@catena-x/portal-shared-components';
import { Role } from '@models/types/auth/role';
import { useAuth } from '@hooks/useAuth';
import { Handshake, Logout, SyncAlt } from '@mui/icons-material';
import NotificationsIcon from '@mui/icons-material/Notifications';
import { OverridableComponent } from '@mui/material/OverridableComponent';
import { SvgIconTypeMap } from '@mui/material';
import AuthenticationService from '@services/authentication-service';
Expand Down Expand Up @@ -76,6 +77,11 @@ const sideBarItems: SideBarItemProps[] = [
path: '/transfers',
requiredRoles: ['PURIS_ADMIN'],
},
{
name: 'Notifications',
icon: NotificationsIcon,
path: '/notifications',
},
{
name: 'Logout',
icon: Logout,
Expand Down
Loading
Loading