Skip to content

Commit

Permalink
Merge branch 'eclipse-tractusx:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-crehm committed Jun 24, 2024
2 parents a539fd1 + e5e0669 commit 121c789
Show file tree
Hide file tree
Showing 24 changed files with 377 additions and 213 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- #965 Implement proxy functionality of the IRS policy store
- #962 Changed notification model to new one in frontend/backend
- #962 Removed initial notification message for notification flow
- #962 Adapt cucumber test to include the mandatory attributes for creating a quality notification
- #753 Refactored message history in notification detail view
- XXX updated local deployment documentation
- #1037 extended autocomplete api by contractAgreementId

### Added
- #832 added policymanagement list view, creator and editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ skinparam linetype ortho
title: Notification Domain

class Notification {
bpn : BPN;
id: Long,
title : String;
type: NotificationType;
notificationId : NotificationId;
notificationStatus : NotificationStatus;
description: String;
createdAt: Instant;
notificationSide: NotificationSide;
status : NotificationStatus;
createdBy: String;
createdByName: String;
createdDate: Instant;
updatedDate: Instant;
assetIds: ArrayList<String>();
closeReason: String;
acceptReason: String;
declineReason: String;
messages: List<NotificationMessage>;
channel: NotificationSide;
sentTo: String;
sentToName: String;
severity: NotificationSeverity;
targetDate: Instant;
messages: List<NotificationMessage>
description: String;
}

enum NotificationType{
Expand All @@ -39,18 +42,16 @@ bpn: String;
}
class NotificationMessage {
id: String
createdBy: String
createdByName: String
sentBy: String
sentByName: String
sendTo: String
sendToName: String
contractAgreementId: String
notificationReferenceId: String
targetDate: Instant
severity: NotificationSeverity;
edcNotificationId: String;
created: LocalDateTime;
updated: LocalDateTime;
messageDate: Instant;
messageId: String;
message: String;
status: NotificationStatus;
errorMessage: String;
}
Expand Down
32 changes: 18 additions & 14 deletions docs/src/uml-diagrams/arc42/cross-cutting/erm-trace-x.puml
Original file line number Diff line number Diff line change
Expand Up @@ -74,38 +74,42 @@ ENTITY public.notification {
+ id : int8 GENERATED
title : varchar(255)
type : varchar(50)
bpn : varchar(255)
close_reason : varchar(1000)
created : timestamp
description : varchar(1000)
status : varchar(50)
side : varchar(50)
accept_reason : varchar(1000)
decline_reason : varchar(1000)
updated : timestamp
error_message : varchar(255)
description : varchar(1000)
createdBy: varchar
createdByName: varchar
createdDate: timestamp
updatedDate : timestamp
assetIds: varchar
channel: boolean
sendTo: varchar
sentToName: varchar
severity: int4
targetDate: instant
messages: notification_message
}


ENTITY public.notification_message {
+ id : varchar(255)
sentBy: varchar
sentByName: varchar

contract_agreement_id : varchar(255)

edc_url : varchar(255)
notification_reference_id : varchar(255)
send_to : varchar(255)
created_by : varchar(255)
notification_id : bigint,
target_date : timestamp
severity : varchar(255)
created_by_name : varchar(255)
send_to_name : varchar(255)
edc_notification_id : varchar(255)
status : varchar(255)
created : timestamp
updated : timestamp
message_date: instant
error_message : varchar
message: varchar
message_id : varchar(255)
is_initial : boolean
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
matTooltipPosition="above"
[class.mdc-tooltip--multiline]="true"
[matTooltipShowDelay]="500"
(mouseenter)="validateAllFields()"
*ngIf="viewMode === ViewMode.EDIT || viewMode === ViewMode.CREATE"
>
<app-button
Expand Down Expand Up @@ -174,14 +175,14 @@ <h4 class="pb-2">{{ 'pageAdmin.policyManagement.constraints' | i18n }} {{ '(' +
</div>
<div class="constraints--header--label flex-1">
{{ "pageAdmin.policyManagement.operator" | i18n }}
</div>
<div class="constraints--header--label flex-1">
{{ "pageAdmin.policyManagement.rightOperand" | i18n }}
<div class="constraints--header--sub-label">
{{ "pageAdmin.policyManagement.rightOperandHint" | i18n }}

</div>
</div>
<div class="constraints--header--label flex-1">
{{ "pageAdmin.policyManagement.rightOperand" | i18n }}
</div>
</div>
<div *ngFor="let constraint of constraints.controls; let i=index;" [formGroupName]="i"
class="flex w-full gap-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { APP_INITIALIZER } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, convertToParamMap, Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { PoliciesFacade } from '@page/admin/presentation/policy-management/policies/policies.facade';
Expand Down Expand Up @@ -253,4 +253,76 @@ describe('PolicyEditorComponent', () => {

});

it('should mark all form controls and form array elements as touched', async () => {
const { fixture } = await renderPolicyEditorComponent();
const { componentInstance } = fixture;
componentInstance.policyForm = componentInstance.fb.group({
policyName: [ '', Validators.required ],
constraints: componentInstance.fb.array([
componentInstance.fb.group({
leftOperand: [ '', Validators.required ],
operator: [ '', Validators.required ],
rightOperand: [ '', Validators.required ],
}),
]),
});

spyOn(componentInstance.policyForm.get('policyName'), 'markAsTouched');
spyOn(componentInstance.constraints.at(0).get('leftOperand'), 'markAsTouched');

componentInstance.validateAllFields();

expect(componentInstance.policyForm.get('policyName').markAsTouched).toHaveBeenCalled();
expect(componentInstance.constraints.at(0).get('leftOperand').markAsTouched).toHaveBeenCalled();
});

it('should mark all elements in a FormArray as touched', async () => {
const { fixture } = await renderPolicyEditorComponent();
const { componentInstance } = fixture;
componentInstance.policyForm = componentInstance.fb.group({
constraints: componentInstance.fb.array([
componentInstance.fb.group({
leftOperand: [ '', Validators.required ],
operator: [ '', Validators.required ],
rightOperand: [ '', Validators.required ],
}),
componentInstance.fb.control(''),
]),
});

const formArray = componentInstance.policyForm.get('constraints') as FormArray;
spyOn(formArray.at(0).get('leftOperand'), 'markAsTouched');
spyOn(formArray.at(1), 'markAsTouched');

componentInstance.validateFormArray(formArray);

expect(formArray.at(0).get('leftOperand').markAsTouched).toHaveBeenCalled();
expect(formArray.at(1).markAsTouched).toHaveBeenCalled();
});

it('should mark all fields in a FormGroup within a FormArray as touched', async () => {
const { fixture } = await renderPolicyEditorComponent();
const { componentInstance } = fixture;
componentInstance.policyForm = componentInstance.fb.group({
constraints: componentInstance.fb.array([
componentInstance.fb.group({
leftOperand: [ '', Validators.required ],
operator: [ '', Validators.required ],
rightOperand: [ '', Validators.required ],
}),
]),
});

const formGroup = componentInstance.constraints.at(0) as FormGroup;
spyOn(formGroup.get('leftOperand'), 'markAsTouched');
spyOn(formGroup.get('operator'), 'markAsTouched');
spyOn(formGroup.get('rightOperand'), 'markAsTouched');

componentInstance.validateAllFieldsInFormGroup(formGroup);

expect(formGroup.get('leftOperand').markAsTouched).toHaveBeenCalled();
expect(formGroup.get('operator').markAsTouched).toHaveBeenCalled();
expect(formGroup.get('rightOperand').markAsTouched).toHaveBeenCalled();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class PolicyEditorComponent {


this.policyForm = this.fb.group({
policyName: new FormControl('', [ Validators.required, Validators.minLength(8), Validators.maxLength(40), this.noSpacesValidator() ]),
policyName: new FormControl('', [ Validators.required, Validators.maxLength(40), this.noSpacesValidator() ]),
validUntil: new FormControl('', [ Validators.required, this.futureDateValidator ]),
bpns: new FormControl('', [ Validators.required, this.viewMode === ViewMode.CREATE ? BaseInputHelper.getCustomPatternValidator(bpnRegex, 'bpn') : BaseInputHelper.getCustomPatternValidator(bpnListRegex, 'bpn') ]),
accessType: new FormControl<string>(PolicyAction.ACCESS),
Expand Down Expand Up @@ -333,9 +333,38 @@ export class PolicyEditorComponent {
};
}

validateAllFields() {
Object.keys(this.policyForm.controls).forEach(field => {
const control = this.policyForm.get(field);
if (control instanceof FormArray) {
this.validateFormArray(control);
} else {
control.markAsTouched({ onlySelf: true });
}
});
}

validateFormArray(formArray: FormArray) {
formArray.controls.forEach(control => {
control.markAsTouched();
if (control instanceof FormGroup) {
this.validateAllFieldsInFormGroup(control);
}
});
}

validateAllFieldsInFormGroup(formGroup: FormGroup) {
Object.keys(formGroup.controls).forEach(field => {
const control = formGroup.get(field);
control.markAsTouched({ onlySelf: true });
});
}


protected readonly ViewMode = ViewMode;
protected readonly OperatorTypesAsSelectOptionsList = OperatorTypesAsSelectOptionsList;
protected readonly ConstraintLogicTypeAsSelectOptionsList = ConstraintLogicTypeAsSelectOptionsList;


}

Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ export class NotificationReasonComponent {
const sortedMessagesAfterDates = messages.sort((a, b) => new Date(a.messageDate).valueOf() - new Date(b.messageDate).valueOf());

sortedMessagesAfterDates.forEach(message => {
this.textMessages.push({
message: message.message,
direction: environment.bpn === message.sentBy ? 'right' : 'left',
user: message.sentByName,
bpn: message.sentBy,
status: message.status,
date: message.messageDate,
errorMessage: message.errorMessage,
});
if (message?.message?.length > 0) {
this.textMessages.push({
message: message.message,
direction: environment.bpn === message.sentBy ? 'right' : 'left',
user: message.sentByName,
bpn: message.sentBy,
status: message.status,
date: message.messageDate,
errorMessage: message.errorMessage,
});
}
});

}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
"maxLength": "Bitte geben Sie maximal {{maxLength}} Zeichen ein. Momentan: {{current}}",
"pattern": "Bitte geben Sie die Daten in folgendem Format ein: {{- pattern}}.",
"url": "Bitte geben Sie eine valide URL ein.",
"bpn" : "Bitte geben Sie eine valide BPN ein.",
"bpn" : "Bitte geben Sie eine valide BPN ein (Beispiel: BPNL00000001ABC2).",
"maxDate": "Bitte wählen Sie ein Datum vor dem {{- maxDate}}.",
"minDate": "Bitte wählen Sie ein Datum nach dem {{- minDate}}.",
"currentDate": "Bitte wählen Sie ein Datum nach dem {{- currentDate}}.",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/assets/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@
"maxLength": "Please enter a text that is smaller than: {{maxLength}}. Current: {{current}}",
"pattern": "Please enter data that matches this pattern: {{- pattern}}.",
"url": "Please enter a valid URL.",
"bpn": "Please enter a valid BPN.",
"bpn" : "Please enter a valid BPN (example: BPNL00000001ABC2).",
"maxDate": "Please select a date that is before {{- maxDate}}.",
"minDate": "Please select a date that is after {{- minDate}}.",
"currentDate": "Please select a date that is after {{- currentDate}}.",
"generic": "Please enter valid data.",
"invalidBpn" : "Must not be own BPN.",
"pastDate" : "Please select a date in the future.",
"minimumOneConstraint" : "Please add atleast one valid constraint to the policy"
"minimumOneConstraint" : "Please add at least one valid constraint to the policy"
},
"unitTest": {
"test01": "This is for unit tests purposes.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public class AssetAsBuiltFieldMapper extends BaseRequestFieldMapper {
Map.entry("receivedQualityAlertIdsInStatusActive", "receivedActiveAlerts"),
Map.entry("receivedQualityInvestigationIdsInStatusActive", "receivedActiveInvestigations"),
Map.entry("importState", "importState"),
Map.entry("importNote", "importNote")
Map.entry("importNote", "importNote"),
Map.entry("contractAgreementId", "contractAgreementId")
);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public class AssetAsPlannedFieldMapper extends BaseRequestFieldMapper {
Map.entry("businessPartner", "manufacturerId"),
Map.entry("van", "van"),
Map.entry("importState", "importState"),
Map.entry("importNote", "importNote")
Map.entry("importNote", "importNote"),
Map.entry("contractAgreementId", "contractAgreementId")

);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public static Notification toDomain(NotificationEntity notificationEntity) {
List<String> assetIds = notificationEntity.getAssets().stream()
.map(AssetAsBuiltEntity::getId)
.toList();
String initialReceiverBpn = notificationEntity.getInitialReceiverBpn();
if (initialReceiverBpn == null){
initialReceiverBpn = notificationEntity.getBpn();
}
return Notification.builder()
.title(notificationEntity.getTitle())
.notificationId(new NotificationId(notificationEntity.getId()))
Expand All @@ -90,11 +94,11 @@ public static Notification toDomain(NotificationEntity notificationEntity) {
.description(notificationEntity.getDescription())
.notificationType(NotificationType.valueOf(notificationEntity.getType().name()))
.affectedPartIds(assetIds)
.sendTo(notificationEntity.getInitialReceiverBpn())
.sendTo(initialReceiverBpn)
.targetDate(convertInstantToString(notificationEntity.getTargetDate()))
.severity(NotificationSeverity.fromString(notificationEntity.getSeverity() != null ? notificationEntity.getSeverity().getRealName() : null))
.notifications(messages)
.initialReceiverBpns(List.of(notificationEntity.getInitialReceiverBpn()))
.initialReceiverBpns(List.of(initialReceiverBpn))
.build();
}

Expand Down
Loading

0 comments on commit 121c789

Please sign in to comment.