Skip to content

Commit

Permalink
Merge branch 'main' into feat/demand-and-capacity-notification-edc-in…
Browse files Browse the repository at this point in the history
…tegration
  • Loading branch information
ReneSchroederLJ authored Jun 18, 2024
2 parents 3048073 + 1c06609 commit 72755f6
Show file tree
Hide file tree
Showing 28 changed files with 942 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/chart-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: v3.8.1

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@66b90a5db151a8042fa97405c6cf843bbe433f7b # v2.227
uses: github/codeql-action/init@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -93,7 +93,7 @@ jobs:
# Automates dependency installation for Python, Ruby, and JavaScript, optimizing the CodeQL analysis setup.
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@66b90a5db151a8042fa97405c6cf843bbe433f7b # v2.227
uses: github/codeql-action/autobuild@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10

# Command-line programs to run using the OS shell.
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -106,6 +106,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@66b90a5db151a8042fa97405c6cf843bbe433f7b # v2.227
uses: github/codeql-action/analyze@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/helm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
tags: ${{ env.REGISTRY }}/${{ env.APP_BACKEND_NAME }}:${{ env.TAG }}

- name: Set up Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: ${{ github.event.inputs.helm_version || 'latest' }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/kics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: KICS scan
uses: checkmarx/kics-github-action@8a44970e3d2eca668be41abe9d4e06709c3b3609 # v1.7.0
uses: checkmarx/kics-github-action@aacf8e81cd48e227259c937c215b352e02ad447a # v2.1.0
with:
path: "."
fail_on: high
Expand All @@ -62,6 +62,6 @@ jobs:
# Upload findings to GitHub Advanced Security Dashboard
- name: Upload SARIF file for GitHub Advanced Security Dashboard
if: always()
uses: github/codeql-action/upload-sarif@66b90a5db151a8042fa97405c6cf843bbe433f7b # v2.227
uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
with:
sarif_file: kicsResults/results.sarif
2 changes: 1 addition & 1 deletion .github/workflows/render-puml-to-svg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: checkout source repo
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: download generated svg file from job before
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v3
id: download
with:
name: artifacts
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@ jobs:
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@b2933f565dbc598b29947660e66259e3c7bc8561 # v0.20.0
uses: aquasecurity/trivy-action@595be6a0f6560a0a8fc419ddf630567fc623531d # v0.22.0
with:
image-ref: "tractusx/app-puris-frontend:latest"
format: "sarif"
output: "trivy-results-1.sarif"
vuln-type: "os,library"
severity: "CRITICAL,HIGH" # While vulnerabilities of all severities are reported in the SARIF output, the exit code and workflow failure are triggered only by these specified severities (CRITICAL or HIGH).
exit-code: "1"
limit-severities-for-sarif: true

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@66b90a5db151a8042fa97405c6cf843bbe433f7b # v2.227
uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
if: always()
with:
sarif_file: "trivy-results-1.sarif"
Expand All @@ -64,14 +67,17 @@ jobs:
steps:
# Pull image from Docker Hub and run Trivy vulnerability scanner
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@2b6a709cf9c4025c5438138008beaddbb02086f0 # v0.14.0
uses: aquasecurity/trivy-action@595be6a0f6560a0a8fc419ddf630567fc623531d # v0.22.0
with:
image-ref: "tractusx/app-puris-backend:latest"
format: "sarif"
output: "trivy-results-2.sarif"
vuln-type: "os,library"
severity: "CRITICAL,HIGH" # While vulnerabilities of all severities are reported in the SARIF output, the exit code and workflow failure are triggered only by these specified severities (CRITICAL or HIGH).
exit-code: "1"
limit-severities-for-sarif: true

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@66b90a5db151a8042fa97405c6cf843bbe433f7b # v2.227
uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
with:
sarif_file: "trivy-results-2.sarif"
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,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 @@ -216,6 +215,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 @@ -228,6 +230,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 @@ -242,6 +247,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

0 comments on commit 72755f6

Please sign in to comment.