diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d9214a9af..4c10bd6575 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [UNRELEASED - DD.MM.YYYY] + +### Added +- Added Table columns settings in part tables to show/hide/reorder table columns + +### Changed +- Updated user manual to reflect the table column settings feature +- Fixed a bug which removed all parts asBuilt selection at once when creating notifications + +### Removed + + ## [8.0.0 - 16.10.2023] ### Added @@ -45,6 +57,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Changed date formats of assets to have offsetDateTime instead of Date or LocalDateTime - Aligned date formats in the rest api for assets - Increased version of jetty-http from 11.0.15 to 11.0.17 and excluded from edc package +- Reworked business logic of /registry/reload to always sync all assets ### Removed @@ -161,10 +174,32 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Environment [TRACEFOSS-2164]: HTTP Requests for syncing the submodel server inoperable~~ +## [6.0.1] - 2023-10-23 +### Added +- All elements from 6.0.1-rc1,rc2,rc3,rc4 + + +## [6.0.1-rc4] +### Added + +### Changed +- updated IRS helm chart from 6.6.1 to 6.7.2 +- updated policy related logic to reflect IRS changes + ### Removed -## [6.0.1-rc2] +## [6.0.1-rc3] - 2023-08-31 +### Added + +### Changed + +- Updated irs-registry-client from 1.1.0-SNAPSHOT to 1.2.0-SNAPSHOT +- Updated irs-helm from 6.4.1 to 6.5.0 + +### Removed + +## [6.0.1-rc2] ### Added - OAuth2 client credentials rest template interceptor @@ -176,13 +211,60 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Changed digitalTwinRegistryRestTemplate to use token in requests - Update asBuild test data to 1.5.3 and asPlanned to 1.5.1 -- Changed transfer notification logic not to break iteration loop when sending notifications to bpn with more than 1 - connector endpoints -- added handling for null manufacturerName in IrsJobResponse, if null is passed it is replaced with " - UNKNOWN_MANUFACTURER" +- Changed transfer notification logic not to break iteration loop when sending notifications to bpn with more than 1 connector endpoints +- added handling for null manufacturerName in IrsJobResponse, if null is passed it is replaced with "UNKNOWN_MANUFACTURER" ### Removed +## [6.0.0 - 2023-07-21] + +### Added + +- Moved all parts of app config to helm charts to be fully configurable +- Helmignore config params for wrong values.yaml files +- Home / Source URL in Helm Chart +- Name Overrides in Helmchart for pgadmin, irs-helm and tractusx-connector +- Added decentral registry approach +- Added discovery finder / edc discovery service for looking up edc urls of receiver of notifications +- Added about component with additional Workflow to load repo info into the component +- Add Transformer to support new EDC constraint operator format + +### Changed + +- Modified IRS Policies support to handle multiple policies +- Readme titles to match TRGs +- Updated Irs helm chart to 6.3.1 +- Update EDC dependencies to 0.1.3 +- Update implementation to use EDC 0.5.0 +- Spring Security Config Update from 6.0.3 to 6.0.5 +- Logic of commitId retrieval by frontend has changed +- Readme / Docker Notice information as required in TRGs +- Removed references to GitHub registry and added docker hub for tractusx instead +- Spring Boot Update from: 3.0.7 to 3.1.2 +- Spring Core Update from: 6.0.8 to 6.0.11 + +### Removed +- unused classes and methods + +### Known knowns + +- Backend [TRACEFOSS-1458]: AdminView: No validation of BPN for BPN EDC URL mapping +- Backend [TRACEFOSS-589]: Backend API access without login returns incorrect HTTP status code (500 instead of 401) +- Backend [TRACEFOSS-2148]: Endpoints for parts and notifications returns unsorted list +--- +- Frontend [TRACEFOSS-2149]: Sorting on empty table causes unhandled error view +--- +- Security [TRACEFOSS-829]: CVE Strict-Transport-Security header - The HSTS Warning and Error may allow attackers to bypass HSTS +- Security [TRACEFOSS-830]: CVE one stack trace disclosure (Java) in the target web server's HTTP response +- Security [TRACEFOSS-919]: Authorization Bypass Through User-Controlled SQL Primary Key CWE ID 566 +- Security [TRACEFOSS-984]: Improper Output Neutralization for Logs CWE ID 117 +- Security [TRACEFOSS-1313]: Using components with known vulnerabilities +- Security [TRACEFOSS-1314]: Open Redirect - host header injection +- Security [TRACEFOSS-1315]: No additional authentication component (MFA) during login process +--- +- Environment [TRACEFOSS-2164]: HTTP Requests for syncing the submodel server inoperable~~ + + ## [6.0.0 - 2023-07-21] ### Added diff --git a/DEPENDENCIES_FRONTEND b/DEPENDENCIES_FRONTEND index 4c69a9108f..bf1a4012b0 100644 --- a/DEPENDENCIES_FRONTEND +++ b/DEPENDENCIES_FRONTEND @@ -95,7 +95,7 @@ npm/npmjs/-/bytes/3.1.2, MIT, approved, clearlydefined npm/npmjs/-/cacache/16.1.3, ISC, approved, clearlydefined npm/npmjs/-/cacache/17.0.4, ISC, approved, #7610 npm/npmjs/-/cachedir/2.3.0, MIT, approved, clearlydefined -npm/npmjs/-/call-bind/1.0.2, MIT, approved, clearlydefined +npm/npmjs/-/call-bind/1.0.2, MIT, approved, #11092 npm/npmjs/-/callsites/3.1.0, MIT, approved, clearlydefined npm/npmjs/-/camelcase-css/2.0.1, MIT, approved, clearlydefined npm/npmjs/-/camelcase-keys/6.2.2, MIT, approved, clearlydefined @@ -434,7 +434,7 @@ npm/npmjs/-/has-ansi/4.0.1, MIT, approved, clearlydefined npm/npmjs/-/has-bigints/1.0.2, MIT, approved, clearlydefined npm/npmjs/-/has-flag/3.0.0, MIT, approved, clearlydefined npm/npmjs/-/has-flag/4.0.0, MIT, approved, clearlydefined -npm/npmjs/-/has-property-descriptors/1.0.0, MIT, approved, clearlydefined +npm/npmjs/-/has-property-descriptors/1.0.0, MIT, approved, #11098 npm/npmjs/-/has-proto/1.0.1, MIT, approved, #6175 npm/npmjs/-/has-symbols/1.0.3, MIT, approved, clearlydefined npm/npmjs/-/has-tostringtag/1.0.0, MIT, approved, clearlydefined diff --git a/docs/src/docs/user/user-manual.adoc b/docs/src/docs/user/user-manual.adoc index 59a9a47df6..6563af1d91 100644 --- a/docs/src/docs/user/user-manual.adoc +++ b/docs/src/docs/user/user-manual.adoc @@ -85,11 +85,27 @@ List view of own Parts with AsPlanned Lifecycle. Gives detailed information on the assets registered in the Digital Twin Registry of Catena-X for the company. This includes data based on the aspect models of Use Case Traceability: AsPlanned, SerialPart, Batch. Parts that are in a quality alert are highlighted yellow. -=== Parts select / Quality alert +=== Parts selection -> Create Quality alert Select one or multiple child components/parts/batches that are build into your part. Selection will enable you to create a quality alert (notification) to your customers. The quality alert will be added to a queue (queued & requested inbox) and not directly sent to the customers. Once the quality alert is created you will get a pop-up and can directly navigate to the inbox for further action. +=== Parts table column settings +On the right upper site of a table there is a settings icon in which you can set the table columns to a desired view. With a click on it a dialog opens where you can change the settings of the corresponding table: + +image::https://raw.githubusercontent.com/eclipse-tractusx/traceability-foss/main/docs/src/images/arc42/user-guide/table-settings-dialog.png[] + + +Hide/show table columns by clicking on the checkbox or the column name. It is possible to hide/show all columns by clicking on the "All"- checkbox. + +The reset icon resets the table columns to its default view. + +Reorder the table columns by selecting a list item (click on the right of the column name). By selecting the column, you can reorder it with the up and down arrow icons to move it in the front or back of other columns. + +Apply your changes by clicking on the "Save" - button. If you want to discard your changes, simply press you "ESC" - button, click anywhere else except in the dialog or close it explicitely with the close icon on the upper right of the dialog. + +The settings will be stored in the local storage of the browser and will be persisted until they get deleted. + === Part details Clicking on an item in the list opens "Part details" view. More detailed information on the asset is listed as well as a part tree that visually shows the parts relations. diff --git a/docs/src/images/arc42/user-guide/parts-list-view.png b/docs/src/images/arc42/user-guide/parts-list-view.png index a049463672..1cd833faa7 100644 Binary files a/docs/src/images/arc42/user-guide/parts-list-view.png and b/docs/src/images/arc42/user-guide/parts-list-view.png differ diff --git a/docs/src/images/arc42/user-guide/table-settings-dialog.png b/docs/src/images/arc42/user-guide/table-settings-dialog.png new file mode 100644 index 0000000000..229676e035 Binary files /dev/null and b/docs/src/images/arc42/user-guide/table-settings-dialog.png differ diff --git a/frontend/src/app/modules/core/user/table-settings.model.ts b/frontend/src/app/modules/core/user/table-settings.model.ts new file mode 100644 index 0000000000..b9a23db27c --- /dev/null +++ b/frontend/src/app/modules/core/user/table-settings.model.ts @@ -0,0 +1,25 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +export interface TableViewSettings { + columnsForDialog: string[], //--> string list in order how they are sorted + columnSettingsOptions: Map, //--> in order of sorted Rows - also source for table -> convert to list of truth + columnsForTable: string[], //--> string list that saves the column string in the order of the dialog and only if they are true + filterColumnsForTable: string[], +} diff --git a/frontend/src/app/modules/core/user/table-settings.service.ts b/frontend/src/app/modules/core/user/table-settings.service.ts new file mode 100644 index 0000000000..e2f93d02b2 --- /dev/null +++ b/frontend/src/app/modules/core/user/table-settings.service.ts @@ -0,0 +1,61 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +import { Injectable } from '@angular/core'; +import { PartTableType } from '@shared/components/table/table.model'; +import { Subject } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class TableSettingsService { + private settingsKey = 'TableViewSettings'; + private changeEvent = new Subject(); + + storeTableSettings(partTableType: PartTableType, tableSettingsList: any ): void { + // before setting anything, all maps in new tableSettingList should be stringified + Object.keys(tableSettingsList).forEach(tableSetting => { + const newMap = tableSettingsList[tableSetting].columnSettingsOptions; + tableSettingsList[tableSetting].columnSettingsOptions = JSON.stringify(Array.from(newMap.entries())); + }) + localStorage.setItem(this.settingsKey, JSON.stringify(tableSettingsList)); + } + + // this returns whole settings whether empty / not for part / etc. + getStoredTableSettings(): any { + const settingsJson = localStorage.getItem(this.settingsKey); + let settingsObject = settingsJson ? JSON.parse(settingsJson) : null; + if(!settingsObject) return; + + // iterate through all tabletypes and parse columnSettingsOption to a map + Object.keys(settingsObject).forEach(tableSetting => { + settingsObject[tableSetting].columnSettingsOptions = new Map(JSON.parse(settingsObject[tableSetting].columnSettingsOptions)); + + }); + return settingsObject; + } + + emitChangeEvent() { + this.changeEvent.next(); + } + + getEvent() { + return this.changeEvent.asObservable(); + } +} diff --git a/frontend/src/app/modules/page/alerts/presentation/alerts.component.ts b/frontend/src/app/modules/page/alerts/presentation/alerts.component.ts index a19667b3b4..d96891e586 100644 --- a/frontend/src/app/modules/page/alerts/presentation/alerts.component.ts +++ b/frontend/src/app/modules/page/alerts/presentation/alerts.component.ts @@ -25,8 +25,8 @@ import { AlertHelperService } from '@page/alerts/core/alert-helper.service'; import { AlertsFacade } from '@page/alerts/core/alerts.facade'; import { NotificationMenuActionsAssembler } from '@shared/assembler/notificationMenuActions.assembler'; import { NotificationCommonModalComponent } from '@shared/components/notification-common-modal/notification-common-modal.component'; +import { TableSortingUtil } from '@shared/components/table/table-sorting.util'; import { MenuActionConfig, TableEventConfig, TableHeaderSort } from '@shared/components/table/table.model'; -import { TableSortingUtil } from '@shared/components/table/tableSortingUtil'; import { NotificationTabInformation } from '@shared/model/notification-tab-information'; import { Notification, NotificationStatusGroup } from '@shared/model/notification.model'; import { TranslationContext } from '@shared/model/translation-context.model'; diff --git a/frontend/src/app/modules/page/investigations/presentation/investigations.component.ts b/frontend/src/app/modules/page/investigations/presentation/investigations.component.ts index 6d0224fba8..af46f2a1e3 100644 --- a/frontend/src/app/modules/page/investigations/presentation/investigations.component.ts +++ b/frontend/src/app/modules/page/investigations/presentation/investigations.component.ts @@ -26,8 +26,8 @@ import { InvestigationDetailFacade } from '@page/investigations/core/investigati import { InvestigationHelperService } from '@page/investigations/core/investigation-helper.service'; import { NotificationMenuActionsAssembler } from '@shared/assembler/notificationMenuActions.assembler'; import { NotificationCommonModalComponent } from '@shared/components/notification-common-modal/notification-common-modal.component'; +import { TableSortingUtil } from '@shared/components/table/table-sorting.util'; import { MenuActionConfig, TableEventConfig, TableHeaderSort } from '@shared/components/table/table.model'; -import { TableSortingUtil } from '@shared/components/table/tableSortingUtil'; import { NotificationTabInformation } from '@shared/model/notification-tab-information'; import { Notification, NotificationStatusGroup } from '@shared/model/notification.model'; import { TranslationContext } from '@shared/model/translation-context.model'; diff --git a/frontend/src/app/modules/page/other-parts/presentation/customer-parts/customer-parts.component.ts b/frontend/src/app/modules/page/other-parts/presentation/customer-parts/customer-parts.component.ts index 235c2f0236..ef9c0356bc 100644 --- a/frontend/src/app/modules/page/other-parts/presentation/customer-parts/customer-parts.component.ts +++ b/frontend/src/app/modules/page/other-parts/presentation/customer-parts/customer-parts.component.ts @@ -24,8 +24,8 @@ import { OtherPartsFacade } from '@page/other-parts/core/other-parts.facade'; import { MainAspectType } from '@page/parts/model/mainAspectType.enum'; import { Part } from '@page/parts/model/parts.model'; import { PartsTableComponent } from '@shared/components/parts-table/parts-table.component'; +import { TableSortingUtil } from '@shared/components/table/table-sorting.util'; import { PartTableType, TableEventConfig, TableHeaderSort } from '@shared/components/table/table.model'; -import { TableSortingUtil } from '@shared/components/table/tableSortingUtil'; import { toAssetFilter, toGlobalSearchAssetFilter } from '@shared/helper/filter-helper'; import { View } from '@shared/model/view.model'; import { PartDetailsFacade } from '@shared/modules/part-details/core/partDetails.facade'; diff --git a/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.html b/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.html index 4692600434..3ec646914b 100644 --- a/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.html +++ b/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.html @@ -30,6 +30,7 @@ @@ -69,7 +69,6 @@ [labelId]="customContext.labelId" (selected)="onSelectItem($event)" (configChanged)="onAsPlannedTableConfigChange($event)" - (multiSelect)="onMultiSelect($event)" (clickSelectAction)="isInvestigationOpen$.next(true)" [multiSortList]="tableSupplierAsPlannedSortList" [multiSelectActive]="true" @@ -95,11 +94,11 @@ diff --git a/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.spec.ts b/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.spec.ts index b2c5495856..8134f71ad7 100644 --- a/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.spec.ts +++ b/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.spec.ts @@ -22,11 +22,9 @@ import { OtherPartsState } from '@page/other-parts/core/other-parts.state'; import { OtherPartsModule } from '@page/other-parts/other-parts.module'; import { PartsState } from '@page/parts/core/parts.state'; import { MainAspectType } from '@page/parts/model/mainAspectType.enum'; -import { PartsAssembler } from '@shared/assembler/parts.assembler'; import { toGlobalSearchAssetFilter } from '@shared/helper/filter-helper'; import { fireEvent, screen, waitFor } from '@testing-library/angular'; import { getTableCheckbox, renderComponent } from '@tests/test-render.utils'; -import { OTHER_PARTS_MOCK_6 } from '../../../../../mocks/services/otherParts-mock/otherParts.test.model'; import { SupplierPartsComponent } from './supplier-parts.component'; @@ -61,52 +59,18 @@ describe('SupplierPartsComponent', () => { it('should add item to current list and then remove', async () => { const { fixture } = await renderSupplierParts({ roles: [ 'user' ] }); - const expectedPart = PartsAssembler.assembleOtherPart(OTHER_PARTS_MOCK_6, MainAspectType.AS_BUILT); // first click to check checkbox fireEvent.click(await getTableCheckbox(screen, 0)); const selectedText_1 = await waitFor(() => screen.getByText('page.selectedParts.info')); expect(selectedText_1).toBeInTheDocument(); - expect(fixture.componentInstance.currentSelectedItems).toEqual([ expectedPart ]); // second click to uncheck checkbox fireEvent.click(await getTableCheckbox(screen, 0)); const selectedText_2 = await waitFor(() => screen.getByText('page.selectedParts.info')); expect(selectedText_2).toBeInTheDocument(); - expect(fixture.componentInstance.currentSelectedItems).toEqual([]); - }); - - it('test addItemToSelection method', async () => { - const { fixture } = await renderSupplierParts(); - - const expectedPart = PartsAssembler.assembleOtherPart(OTHER_PARTS_MOCK_6, MainAspectType.AS_BUILT); - - fixture.componentInstance.addItemToSelection(expectedPart); - expect(fixture.componentInstance.currentSelectedItems).toEqual([ expectedPart ]); - }); - - it('test removeItemFromSelection method', async () => { - const { fixture } = await renderSupplierParts(); - - const expectedPart = PartsAssembler.assembleOtherPart(OTHER_PARTS_MOCK_6, MainAspectType.AS_BUILT); - - fixture.componentInstance.currentSelectedItems = [ expectedPart ]; - - fixture.componentInstance.removeItemFromSelection(expectedPart); - expect(fixture.componentInstance.currentSelectedItems).toEqual([]); - }); - - it('test clearSelected method', async () => { - const { fixture } = await renderSupplierParts(); - - const expectedPart = PartsAssembler.assembleOtherPart(OTHER_PARTS_MOCK_6, MainAspectType.AS_BUILT); - - fixture.componentInstance.currentSelectedItems = [ expectedPart ]; - - fixture.componentInstance.clearSelected(); - expect(fixture.componentInstance.currentSelectedItems).toEqual([]); }); it('sort supplier parts after name column', async () => { diff --git a/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.ts b/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.ts index ad6fc51b05..9d13278a56 100644 --- a/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.ts +++ b/frontend/src/app/modules/page/other-parts/presentation/supplier-parts/supplier-parts.component.ts @@ -22,10 +22,10 @@ import { Component, Input, OnDestroy, OnInit, QueryList, ViewChildren } from '@a import { Pagination } from '@core/model/pagination.model'; import { OtherPartsFacade } from '@page/other-parts/core/other-parts.facade'; import { MainAspectType } from '@page/parts/model/mainAspectType.enum'; -import { Part, SemanticDataModel } from '@page/parts/model/parts.model'; +import { Part } from '@page/parts/model/parts.model'; import { PartsTableComponent } from '@shared/components/parts-table/parts-table.component'; +import { TableSortingUtil } from '@shared/components/table/table-sorting.util'; import { PartTableType, TableEventConfig, TableHeaderSort } from '@shared/components/table/table.model'; -import { TableSortingUtil } from '@shared/components/table/tableSortingUtil'; import { toAssetFilter, toGlobalSearchAssetFilter } from '@shared/helper/filter-helper'; import { View } from '@shared/model/view.model'; import { PartDetailsFacade } from '@shared/modules/part-details/core/partDetails.facade'; @@ -44,9 +44,9 @@ export class SupplierPartsComponent implements OnInit, OnDestroy { public readonly deselectPartTrigger$ = new Subject(); public readonly addPartTrigger$ = new Subject(); + public readonly currentSelectedItems$ = new BehaviorSubject([]); public readonly isInvestigationOpen$ = new BehaviorSubject(false); - public selectedItems: Array = []; public readonly supplierTabLabelId = this.staticIdService.generateId('OtherParts.supplierTabLabel'); @@ -74,21 +74,6 @@ export class SupplierPartsComponent implements OnInit, OnDestroy { }); } - public get currentSelectedItems(): Part[] { - - this.selectedItems = this.selectedItems.map(part => { - return { - ...part, - semanticDataModel: SemanticDataModel[part.semanticDataModel.toUpperCase() as keyof typeof SemanticDataModel], - }; - }); - return this.selectedItems || []; - } - - public set currentSelectedItems(parts: Part[]) { - this.selectedItems = parts; - } - public ngOnInit(): void { if (this.bomLifecycle === MainAspectType.AS_BUILT) { this.supplierPartsAsBuilt$ = this.otherPartsFacade.supplierPartsAsBuilt$; @@ -137,29 +122,6 @@ export class SupplierPartsComponent implements OnInit, OnDestroy { this.otherPartsFacade.setSupplierPartsAsPlanned(page, pageSize, this.tableSupplierAsPlannedSortList); } - public onMultiSelect(event: unknown[]): void { - this.currentSelectedItems = event as Part[]; - } - - public removeItemFromSelection(part: Part): void { - this.deselectPartTrigger$.next([ part ]); - this.currentSelectedItems = this.currentSelectedItems.filter(({ id }) => id !== part.id); - } - - public clearSelected(): void { - this.deselectPartTrigger$.next(this.currentSelectedItems); - this.currentSelectedItems = []; - } - - public addItemToSelection(part: Part): void { - this.addPartTrigger$.next(part); - this.currentSelectedItems = [ ...this.currentSelectedItems, part ]; - } - - public submit(): void { - this.isInvestigationOpen$.next(false); - } - private setTableSortingList(sorting: TableHeaderSort, partTable: MainAspectType): void { const tableSortList = partTable === MainAspectType.AS_BUILT ? this.tableSupplierAsBuiltSortList : this.tableSupplierAsPlannedSortList; diff --git a/frontend/src/app/modules/page/parts/parts.module.ts b/frontend/src/app/modules/page/parts/parts.module.ts index 60db63ecf6..fd56165745 100644 --- a/frontend/src/app/modules/page/parts/parts.module.ts +++ b/frontend/src/app/modules/page/parts/parts.module.ts @@ -21,23 +21,24 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; +import { MatDialogModule } from '@angular/material/dialog'; import { getI18nPageProvider } from '@core/i18n'; import { PartsFacade } from '@page/parts/core/parts.facade'; import { PartsState } from '@page/parts/core/parts.state'; import { PartDetailsModule } from '@shared/modules/part-details/partDetails.module'; import { RelationsModule } from '@shared/modules/relations/relations.module'; import { FormatPartSemanticDataModelToCamelCasePipe } from '@shared/pipes/format-part-semantic-data-model-to-camelcase.pipe'; +import { BomLifecycleSettingsService } from '@shared/service/bom-lifecycle-settings.service'; import { SharedModule } from '@shared/shared.module'; import { TemplateModule } from '@shared/template.module'; +import { AngularSplitModule } from 'angular-split'; import { PartsRoutingModule } from './parts.routing'; import { PartsComponent } from './presentation/parts.component'; import { RelationComponent } from './presentation/relation/relation.component'; -import {AngularSplitModule} from "angular-split"; -import {BomLifecycleSettingsService} from "@shared/service/bom-lifecycle-settings.service"; @NgModule({ declarations: [PartsComponent, RelationComponent], - imports: [CommonModule, TemplateModule, SharedModule, PartsRoutingModule, RelationsModule, PartDetailsModule, AngularSplitModule], + imports: [CommonModule, TemplateModule, SharedModule, PartsRoutingModule, RelationsModule, PartDetailsModule, AngularSplitModule, MatDialogModule], providers: [PartsState, BomLifecycleSettingsService, PartsFacade, FormatPartSemanticDataModelToCamelCasePipe, ...getI18nPageProvider(['page.parts', 'partDetail'])], }) export class PartsModule {} diff --git a/frontend/src/app/modules/page/parts/presentation/parts.component.html b/frontend/src/app/modules/page/parts/presentation/parts.component.html index e75c998fe8..e81a5856c3 100644 --- a/frontend/src/app/modules/page/parts/presentation/parts.component.html +++ b/frontend/src/app/modules/page/parts/presentation/parts.component.html @@ -86,7 +86,6 @@ [addTrigger]="addPartTrigger$ | async" (selected)="onSelectItem($event)" (configChanged)="onAsPlannedTableConfigChange($event)" - (multiSelect)="currentSelectedItems$.next($event)" (clickSelectAction)="isAlertOpen$.next(true)" (filterActivated)="filterActivated(false, $event)" [multiSortList]="tableAsPlannedSortList" diff --git a/frontend/src/app/modules/shared/components/parts-table/parts-table.component.html b/frontend/src/app/modules/shared/components/parts-table/parts-table.component.html index a86aeefe48..cfdd69744e 100644 --- a/frontend/src/app/modules/shared/components/parts-table/parts-table.component.html +++ b/frontend/src/app/modules/shared/components/parts-table/parts-table.component.html @@ -19,9 +19,8 @@

{{tableHeader | i18n }}

-
-

{{ selectedPartsInfoLabel | i18n : {count: selection?.selected?.length || 0} }}

+

{{ selectedPartsInfoLabel | i18n : {count: selection?.selected?.length || 0} }}

+ + settings +
-
{{ 'table.filterTitle' | i18n }} + *ngIf="filter.headerKey==='Filter'">{{ ''}} @@ -101,7 +105,7 @@

{{ 'table.noResultFound' | i18n }}

- + @@ -111,7 +115,10 @@

{{ 'table.noResultFound' | i18n }}

-
+
{{ 'table.noResultFound' | i18n }}
{{ 'table.noResultFound' | i18n }} [mat-sort-header]="tableConfig.sortableColumns?.[column] ? '' : null" [disabled]="!tableConfig.sortableColumns?.[column]" mat-header-cell - class="table--cell" + class="table--cell table--header--normal--cell" > (); @Output() filterActivated = new EventEmitter(); + constructor(private readonly tableSettingsService: TableSettingsService, private dialog: MatDialog) {} + + public readonly dataSource = new MatTableDataSource(); public readonly selection = new SelectionModel(true, []); @@ -127,8 +132,11 @@ export class PartsTableComponent implements OnInit { public filterConfiguration: any[]; public displayedColumns: string[]; + public defaultColumns: string[]; + + private tableViewConfig: TableViewConfig - filterFormGroup = new FormGroup({}); + filterFormGroup = new FormGroup({}); public isDateElement(key: string){ return isDateFilter(key); @@ -249,7 +257,6 @@ export class PartsTableComponent implements OnInit { }; private readonly displayedColumnsAsPlannedCustomer: string[] = [ - 'Filter', 'filterSemanticDataModel', 'filterName', 'filterManufacturer', @@ -269,7 +276,6 @@ export class PartsTableComponent implements OnInit { private readonly displayedColumnsAsBuiltCustomer: string[] = [ - 'Filter', 'filterSemanticDataModel', 'filterName', 'filterManufacturer', @@ -294,7 +300,6 @@ export class PartsTableComponent implements OnInit { ]; private readonly displayedColumnsAsBuiltCustomerForTable: string[] = [ - 'select', 'semanticDataModel', 'name', 'manufacturer', @@ -318,7 +323,6 @@ export class PartsTableComponent implements OnInit { }; private readonly displayedColumnsAsPlannedCustomerForTable: string[] = [ - 'select', 'semanticDataModel', 'name', 'manufacturer', @@ -379,58 +383,135 @@ export class PartsTableComponent implements OnInit { private sorting: TableHeaderSort; ngOnInit() { - this.handleAsBuiltTableType(); - this.handleAsPlannedTableType(); + this.initializeTableViewSettings(); + this.tableSettingsService.getEvent().subscribe(() => { + this.setupTableViewSettings(); + }) + this.setupTableViewSettings(); this.filterFormGroup.valueChanges.subscribe((formValues) => { this.filterActivated.emit(formValues); }); } - private handleAsPlannedTableType(): void { - switch (this.tableType) { - case PartTableType.AS_PLANNED_CUSTOMER: - this.setupTableConfigurations(this.displayedColumnsAsPlannedCustomerForTable, this.displayedColumnsAsPlannedCustomer, this.sortableColumnsAsPlannedCustomer, this.assetAsPlannedCustomerFilterConfiguration, this.assetAsPlannedCustomerFilterFormGroup); - break; - case PartTableType.AS_PLANNED_OWN: - this.setupTableConfigurations(this.displayedColumnsAsPlannedForTable, this.displayedColumnsAsPlanned, this.sortableColumnsAsPlanned, this.assetAsPlannedFilterConfiguration, this.assetAsPlannedFilterFormGroup); - break; - case PartTableType.AS_PLANNED_SUPPLIER: - this.setupTableConfigurations(this.displayedColumnsAsPlannedSupplierForTable, this.displayedColumnsAsPlannedSupplier, this.sortableColumnsAsPlannedSupplier, this.assetAsPlannedSupplierFilterConfiguration, this.assetAsPlannedSupplierFilterFormGroup); - break; + private initializeTableViewSettings(): void { + switch (this.tableType) { + case PartTableType.AS_PLANNED_CUSTOMER: + this.tableViewConfig = { + displayedColumns: this.displayedColumnsAsPlannedCustomer, + displayedColumnsForTable: this.displayedColumnsAsPlannedCustomerForTable, + filterConfiguration: this.assetAsPlannedCustomerFilterConfiguration, + filterFormGroup: this.assetAsPlannedCustomerFilterFormGroup, + sortableColumns: this.sortableColumnsAsPlannedCustomer + } + break; + case PartTableType.AS_PLANNED_OWN: + this.tableViewConfig = { + displayedColumns: this.displayedColumnsAsPlanned, + displayedColumnsForTable: this.displayedColumnsAsPlannedForTable, + filterConfiguration: this.assetAsPlannedFilterConfiguration, + filterFormGroup: this.assetAsPlannedFilterFormGroup, + sortableColumns: this.sortableColumnsAsPlanned + } + break; + case PartTableType.AS_PLANNED_SUPPLIER: + this.tableViewConfig = { + displayedColumns: this.displayedColumnsAsPlannedSupplier, + displayedColumnsForTable: this.displayedColumnsAsPlannedSupplierForTable, + filterConfiguration: this.assetAsPlannedSupplierFilterConfiguration, + filterFormGroup: this.assetAsPlannedSupplierFilterFormGroup, + sortableColumns: this.sortableColumnsAsPlannedSupplier + } + break; + case PartTableType.AS_BUILT_OWN: + this.tableViewConfig = { + displayedColumns: this.displayedColumnsAsBuilt, + displayedColumnsForTable: this.displayedColumnsAsBuiltForTable, + filterConfiguration: this.assetAsBuiltFilterConfiguration, + filterFormGroup: this.assetAsBuiltFilterFormGroup, + sortableColumns: this.sortableColumnsAsBuilt } + break; + case PartTableType.AS_BUILT_CUSTOMER: + this.tableViewConfig = { + displayedColumns: this.displayedColumnsAsBuiltCustomer, + displayedColumnsForTable: this.displayedColumnsAsBuiltCustomerForTable, + filterConfiguration: this.assetAsBuiltCustomerFilterConfiguration, + filterFormGroup: this.assetAsBuiltCustomerFilterFormGroup, + sortableColumns: this.sortableColumnsAsBuiltCustomer + } + break; + case PartTableType.AS_BUILT_SUPPLIER: + this.tableViewConfig = { + displayedColumns: this.displayedColumnsAsBuiltSupplier, + displayedColumnsForTable: this.displayedColumnsAsBuiltSupplierForTable, + filterConfiguration: this.assetAsBuiltSupplierFilterConfiguration, + filterFormGroup: this.assetAsBuiltSupplierFilterFormGroup, + sortableColumns: this.sortableColumnsAsBuiltSupplier + } + break; } - - private setupTableConfigurations(displayedColumnsForTable: string[], displayedColumns: string[], sortableColumns: Record, filterConfiguration: any[], filterFormGroup: any): any { - const headerKey = 'table.column'; - this.tableConfig = { - displayedColumns: displayedColumnsForTable, - header: CreateHeaderFromColumns(displayedColumnsForTable, headerKey), - sortableColumns: sortableColumns, - }; - this.filterConfiguration = filterConfiguration; - this.displayedColumns = displayedColumns; - for (const controlName in filterFormGroup) { - if (filterFormGroup.hasOwnProperty(controlName)) { - this.filterFormGroup.addControl(controlName, filterFormGroup[controlName]); - } + } + + private setupTableViewSettings() { + const tableSettingsList = this.tableSettingsService.getStoredTableSettings(); + // check if there are table settings list + if(tableSettingsList) { + // if yes, check if there is a table-setting for this table type + if(tableSettingsList[this.tableType]) { + // if yes, get the effective displayedcolumns from the settings and set the tableconfig after it. + this.setupTableConfigurations(tableSettingsList[this.tableType].columnsForTable, tableSettingsList[this.tableType].filterColumnsForTable, this.tableViewConfig.sortableColumns, this.tableViewConfig.filterConfiguration, this.tableViewConfig.filterFormGroup); + } else { + // if no, create new a table setting for this.tabletype and put it into the list. Additionally, intitialize default table configuration + tableSettingsList[this.tableType] = { + columnsForDialog: this.tableViewConfig.displayedColumnsForTable, + columnSettingsOptions: this.getDefaultColumnVisibilityMap(), + columnsForTable: this.tableViewConfig.displayedColumnsForTable, + filterColumnsForTable: this.tableViewConfig.displayedColumns + }; + this.tableSettingsService.storeTableSettings(this.tableType, tableSettingsList); + this.setupTableConfigurations(this.tableViewConfig.displayedColumnsForTable, this.tableViewConfig.displayedColumns, this.tableViewConfig.sortableColumns, this.tableViewConfig.filterConfiguration, this.tableViewConfig.filterFormGroup); } + } else { + // if no, create new list and a settings entry for this.tabletype with default values and set correspondingly the tableconfig + const newTableSettingsList = { + [this.tableType]: { + columnsForDialog: this.tableViewConfig.displayedColumnsForTable, + columnSettingsOptions: this.getDefaultColumnVisibilityMap(), + columnsForTable: this.tableViewConfig.displayedColumnsForTable, + filterColumnsForTable: this.tableViewConfig.displayedColumns + } + } + this.tableSettingsService.storeTableSettings(this.tableType, newTableSettingsList); + this.setupTableConfigurations(this.tableViewConfig.displayedColumnsForTable, this.tableViewConfig.displayedColumns, this.tableViewConfig.sortableColumns, this.tableViewConfig.filterConfiguration, this.tableViewConfig.filterFormGroup); + } + } + private getDefaultColumnVisibilityMap(): Map { + const initialColumnMap = new Map(); + for(const column of this.tableViewConfig.displayedColumnsForTable) { + initialColumnMap.set(column,true); + } + return initialColumnMap; } - private handleAsBuiltTableType(): void { - switch (this.tableType) { - case PartTableType.AS_BUILT_OWN: - this.setupTableConfigurations(this.displayedColumnsAsBuiltForTable, this.displayedColumnsAsBuilt, this.sortableColumnsAsBuilt, this.assetAsBuiltFilterConfiguration, this.assetAsBuiltFilterFormGroup); - break; - case PartTableType.AS_BUILT_CUSTOMER: - this.setupTableConfigurations(this.displayedColumnsAsBuiltCustomerForTable, this.displayedColumnsAsBuiltCustomer, this.sortableColumnsAsBuiltCustomer, this.assetAsBuiltCustomerFilterConfiguration, this.assetAsBuiltCustomerFilterFormGroup); - break; - case PartTableType.AS_BUILT_SUPPLIER: - this.setupTableConfigurations(this.displayedColumnsAsBuiltSupplierForTable, this.displayedColumnsAsBuiltSupplier, this.sortableColumnsAsBuiltSupplier, this.assetAsBuiltSupplierFilterConfiguration, this.assetAsBuiltSupplierFilterFormGroup); - break; - } + + private setupTableConfigurations(displayedColumnsForTable: string[], displayedColumns: string[], sortableColumns: Record, filterConfiguration: any[], filterFormGroup: any): any { + const headerKey = 'table.column'; + this.tableConfig = { + displayedColumns: displayedColumnsForTable, + header: CreateHeaderFromColumns(displayedColumnsForTable, headerKey), + sortableColumns: sortableColumns, + }; + this.filterConfiguration = filterConfiguration; + this.displayedColumns = displayedColumns; + for (const controlName in filterFormGroup) { + if (filterFormGroup.hasOwnProperty(controlName)) { + this.filterFormGroup.addControl(controlName, filterFormGroup[controlName]); + } } + } + optionTextSearch = []; semanticDataModelOptions = [ { @@ -451,6 +532,7 @@ export class PartsTableComponent implements OnInit { }, ]; + // TODO: create a type for the filterconfig public readonly assetAsBuiltFilterConfiguration: any[] = [ {filterKey: 'Filter', headerKey: 'Filter', isTextSearch: true, option: this.optionTextSearch}, {filterKey: 'id', headerKey: 'filterId', isTextSearch: true, option: this.optionTextSearch}, @@ -517,7 +599,6 @@ export class PartsTableComponent implements OnInit { }; assetAsPlannedCustomerFilterFormGroup = { - select: new FormControl([]), semanticDataModel: new FormControl([]), nameAtManufacturer: new FormControl([]), manufacturerName: new FormControl([]), @@ -539,7 +620,6 @@ export class PartsTableComponent implements OnInit { }; assetAsBuiltCustomerFilterFormGroup = { - select: new FormControl([]), semanticDataModel: new FormControl([]), nameAtManufacturer: new FormControl([]), manufacturerName: new FormControl([]), @@ -551,7 +631,6 @@ export class PartsTableComponent implements OnInit { }; private readonly assetAsPlannedCustomerFilterConfiguration: any[] = [ - {filterKey: 'Filter', headerKey: 'Filter', isTextSearch: true, option: this.optionTextSearch}, {filterKey: 'semanticDataModel', headerKey: 'filterSemanticDataModel', isTextSearch: false, option: this.semanticDataModelOptions}, {filterKey: 'nameAtManufacturer', headerKey: 'filterName', isTextSearch: true, option: this.optionTextSearch}, {filterKey: 'manufacturerName', headerKey: 'filterManufacturer', isTextSearch: true, option: this.optionTextSearch}, @@ -570,7 +649,6 @@ export class PartsTableComponent implements OnInit { private readonly assetAsBuiltCustomerFilterConfiguration: any[] = [ - {filterKey: 'Filter', headerKey: 'Filter', isTextSearch: true, option: this.optionTextSearch}, {filterKey: 'semanticDataModel', headerKey: 'filterSemanticDataModel', isTextSearch: false, option: this.semanticDataModelOptions}, {filterKey: 'nameAtManufacturer', headerKey: 'filterName', isTextSearch: true, option: this.optionTextSearch}, {filterKey: 'manufacturerName', headerKey: 'filterManufacturer', isTextSearch: true, option: this.optionTextSearch}, @@ -684,4 +762,17 @@ export class PartsTableComponent implements OnInit { removeSelectedValues(this.selection, itemsToRemove); } + openDialog(): void { + const config = new MatDialogConfig(); + config.data = { + title: "table.tableSettings.title", + panelClass: "custom", + tableType: this.tableType, + defaultColumns: this.tableViewConfig.displayedColumnsForTable, + defaultFilterColumns: this.tableViewConfig.displayedColumns + }; + this.dialog.open(TableSettingsComponent, config ) + } + + } diff --git a/frontend/src/app/modules/shared/components/parts-table/table-view-config.model.ts b/frontend/src/app/modules/shared/components/parts-table/table-view-config.model.ts new file mode 100644 index 0000000000..d2b0600e15 --- /dev/null +++ b/frontend/src/app/modules/shared/components/parts-table/table-view-config.model.ts @@ -0,0 +1,25 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +export interface TableViewConfig { + displayedColumnsForTable: string[], + displayedColumns: string[], + sortableColumns: Record, + filterConfiguration: any[], + filterFormGroup: any +} diff --git a/frontend/src/app/modules/shared/components/table-settings/table-settings.component.html b/frontend/src/app/modules/shared/components/table-settings/table-settings.component.html new file mode 100644 index 0000000000..dc2097d368 --- /dev/null +++ b/frontend/src/app/modules/shared/components/table-settings/table-settings.component.html @@ -0,0 +1,90 @@ + + +
+
+

{{title | i18n}}

+ close +
+
+ +
+ arrow_downward + arrow_upward +
+
+ {{'table.tableSettings.selectAll' | i18n}} + + + + + {{'table.column.' + item | i18n}} + + + +
+
+ refresh +
+
+
+
+ + +
+ +
+
+ diff --git a/frontend/src/app/modules/shared/components/table-settings/table-settings.component.scss b/frontend/src/app/modules/shared/components/table-settings/table-settings.component.scss new file mode 100644 index 0000000000..fdd42215f2 --- /dev/null +++ b/frontend/src/app/modules/shared/components/table-settings/table-settings.component.scss @@ -0,0 +1,152 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +.dialog--content { + display: flex; + flex-direction: column; + width: 35vw; + + .table--header--tooltip{ + .mdc-tooltip__surface { + background-color: rgb(48,48,48); + @apply font-medium; + color: white; + max-width: 300px; + padding: 15px; + font-size: 14px; + line-height: 20px; + + } + .mdc-tooltip--multiline { + white-space: pre-line; + } + } + + + .dialog--header--container { + display: flex; + padding-bottom: 24px; + } + + .mat-icon { + width: 32px; + height: 32px; + font-size: 30px; + margin-top: 4px; + cursor: pointer; + display: flex; + justify-content: center; + align-items: center; + } + + .dialog--content--container { + display: flex; + justify-content: space-between; + } + + .dialog--content--menu--order { + display: flex; + gap: 8px; + margin-right: 12px; + } + + .dialog--header--text { + font-weight: 500; + line-height: 1.6; + color: rgb(17, 17, 17); + flex: 1; + font-family: LibreFranklin-SemiBold, -apple-system, + BlinkMacSystemFont, "Segoe UI", + Roboto, "Helvetica Neue", + Arial, sans-serif, "Apple Color Emoji", + "Segoe UI Emoji", "Segoe UI Symbol"; + font-size: 24px; + text-align: center; + margin-left: 32px; + } + + .dialog--columns--container { + display: flex; + flex-direction: column; + font-size: 18px; + font-family: LibreFranklin, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + width: 80% + } + + .dialog--columns--columns--list:hover { + background-color: rgb(237, 240, 244); + + } + + .selected-item { + background-color: rgba(139, 139, 139, 0.4); + } + +} + + + + +.dialog--actions--container { + background-color: rgb(237, 240, 244); + width: 100%; + display: flex; + justify-content: center; + + .dialog--actions--save--button { + display: inline-flex; + -webkit-box-align: center; + align-items: center; + -webkit-box-pack: center; + justify-content: center; + position: relative; + box-sizing: border-box; + -webkit-tap-highlight-color: transparent; + outline: 0px; + border: 0px; + margin: 0px; + cursor: pointer; + user-select: none; + vertical-align: middle; + appearance: none; + text-decoration: none; + font-family: LibreFranklin, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + font-weight: 500; + line-height: 1.5; + color: rgb(255, 255, 255); + min-width: 64px; + transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; + + background-color: rgb(15, 113, 203); + border-radius: 50px; + font-size: 18px; + padding: 14px 32px; + box-shadow: rgba(15, 113, 203, 0.4) 0px 0px 0px 3px; + } + + .dialog--actions--save--button:hover, .dialog--actions--save--button:active, .dialog--actions--save--button:focus { + background-color: rgb(13, 85, 175) + } + +} + + + + + diff --git a/frontend/src/app/modules/shared/components/table-settings/table-settings.component.spec.ts b/frontend/src/app/modules/shared/components/table-settings/table-settings.component.spec.ts new file mode 100644 index 0000000000..7a3f065136 --- /dev/null +++ b/frontend/src/app/modules/shared/components/table-settings/table-settings.component.spec.ts @@ -0,0 +1,159 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +import { APP_INITIALIZER } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { TableSettingsService } from '@core/user/table-settings.service'; +import { PartTableType } from '@shared/components/table/table.model'; +import { SharedModule } from '@shared/shared.module'; +import { I18NEXT_SERVICE, I18NextModule, ITranslationService } from 'angular-i18next'; +import { TableSettingsComponent } from './table-settings.component'; + +describe('TableSettingsComponent', () => { + let component: TableSettingsComponent; + let fixture: ComponentFixture; + let tableSettingsService: TableSettingsService; + + beforeEach(async () => { + const tableSettingsServiceSpy = jasmine.createSpyObj('TableSettingsService', [ + 'getStoredTableSettings', + 'storeTableSettings', + 'emitChangeEvent', + 'getEvent', + ]); + tableSettingsServiceSpy.getStoredTableSettings.and.callFake(() => { + return { + [PartTableType.AS_BUILT_OWN]: { + columnSettingsOptions: new Map(), + columnsForDialog: ['column1', 'column2'], + columnsForTable: ['column1'], + filterColumnsForTable: ['filterColumn1'], + }, + }; + }); + + tableSettingsServiceSpy.storeTableSettings.and.callFake((partTableType, tableSettingsList) => { + return; + }); + + TestBed.configureTestingModule({ + declarations: [TableSettingsComponent], + imports: [ + SharedModule, + I18NextModule.forRoot(), + ], + providers: [ + { + provide: MatDialogRef, + useValue: { + close: () => {}, + }, + }, + { + provide: MAT_DIALOG_DATA, + useValue: { + title: 'Test Title', + panelClass: 'test-dialog', + tableType: PartTableType.AS_BUILT_OWN, + defaultColumns: ['column1', 'column2'], + defaultFilterColumns: ['filterColumn1', 'filterColumn2'], + }, + }, + { + provide: TableSettingsService, + useValue: tableSettingsServiceSpy, + }, + { + provide: APP_INITIALIZER, + useFactory: (i18next: ITranslationService) => { + return () => + i18next.init({ + lng: 'en', + supportedLngs: ['en', 'de'], + resources: {}, + }); + }, + deps: [I18NEXT_SERVICE], + multi: true, + }, + ], + }); + + await TestBed.compileComponents(); + fixture = TestBed.createComponent(TableSettingsComponent); + component = fixture.componentInstance; + tableSettingsService = TestBed.inject(TableSettingsService); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + + it('should initialize the component properties', () => { + // Assert that component properties are correctly initialized based on MAT_DIALOG_DATA + expect(component.title).toEqual('Test Title'); + expect(component.panelClass).toEqual('test-dialog'); + expect(component.tableType).toEqual(PartTableType.AS_BUILT_OWN); + expect(component.defaultColumns).toEqual(['column1', 'column2']); + expect(component.defaultFilterColumns).toEqual(['filterColumn1', 'filterColumn2']); + expect(component.isCustomerTable).toEqual(false); + }); + + it('should call save method and update tableSettingsService', () => { + const columnOptions = new Map(); + columnOptions.set('column1', true); + + component.handleCheckBoxChange('column1', true); + component.save(); + + // Check that setColumnVisibilitySettings was called with the updated settings + expect(tableSettingsService.storeTableSettings).toHaveBeenCalledWith(PartTableType.AS_BUILT_OWN, { + [PartTableType.AS_BUILT_OWN]: { + columnSettingsOptions: columnOptions, + columnsForDialog: ['column1', 'column2'], + columnsForTable: ['column1'], + filterColumnsForTable: ['filterColumn1'], + }, + }); + }); + + it('should handle sort list item correctly', () => { + component.dialogColumns = ['column1', 'column2', 'column3']; + component.selectedColumn = 'column3'; + + component.handleSortListItem('up'); + + expect(component.dialogColumns).toEqual(['column1', 'column3', 'column2']); + }); + + it('should reset columns', () => { + component.dialogColumns = ['column1', 'column2', 'column3']; + + component.resetColumns(); + + expect(component.dialogColumns).toEqual(['column1', 'column2']); + expect(component.selectAllSelected).toBe(true); + }); + + it('should close the dialog', () => { + spyOn(component.dialogRef, 'close'); + component.dialogRef.close() + expect(component.dialogRef.close).toHaveBeenCalled(); + }); +}); diff --git a/frontend/src/app/modules/shared/components/table-settings/table-settings.component.ts b/frontend/src/app/modules/shared/components/table-settings/table-settings.component.ts new file mode 100644 index 0000000000..beab400bba --- /dev/null +++ b/frontend/src/app/modules/shared/components/table-settings/table-settings.component.ts @@ -0,0 +1,155 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +import {Component, EventEmitter, Inject, Output} from '@angular/core'; +import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; +import {TableViewSettings} from '@core/user/table-settings.model'; +import {TableSettingsService} from '@core/user/table-settings.service'; +import {PartTableType} from '@shared/components/table/table.model'; + +@Component({ + selector: 'app-table-settings', + templateUrl: 'table-settings.component.html', + styleUrls: [ 'table-settings.component.scss' ], +}) +export class TableSettingsComponent { + + @Output() changeSettingsEvent = new EventEmitter(); + title: string; + panelClass: string; + + tableType: PartTableType; + defaultColumns: string[]; + defaultFilterColumns: string[] + + columnOptions: Map; + dialogColumns: string[]; + tableColumns: string[]; + filterColumns: string[]; + + selectAllSelected: boolean; + selectedColumn: string = null; + + isCustomerTable: boolean; + + + constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, public readonly tableSettingsService: TableSettingsService) { + // Layout + this.title = data.title; + this.panelClass = data.panelClass; + this.isCustomerTable = data.tableType === PartTableType.AS_BUILT_CUSTOMER || data.tableType === PartTableType.AS_PLANNED_CUSTOMER + // Passed Data + this.tableType = data.tableType; + this.defaultColumns = data.defaultColumns; + this.defaultFilterColumns = data.defaultFilterColumns; + + // Storage Data + this.columnOptions = tableSettingsService.getStoredTableSettings()[this.tableType].columnSettingsOptions; + this.dialogColumns = tableSettingsService.getStoredTableSettings()[this.tableType].columnsForDialog; + this.tableColumns = tableSettingsService.getStoredTableSettings()[this.tableType].columnsForTable; + this.filterColumns = tableSettingsService.getStoredTableSettings()[this.tableType].filterColumnsForTable; + + this.selectAllSelected = this.dialogColumns.length === this.tableColumns.length; + + } + + save() { + // build new tableColumns how they should be displayed + let newTableColumns: string[] = []; + let newTableFilterColumns: string[] = []; + // iterate over dialogColumns + for(const column of this.dialogColumns) { + // if item in dialogColumns is true in columnOptions --> add to new tableColumns + if(this.columnOptions.get(column)) { + newTableColumns.push(column); + // ignore select column in customertable + if(column === 'select' && !this.isCustomerTable) { + newTableFilterColumns.push('Filter'); + } else { + newTableFilterColumns.push('filter'+ column.charAt(0).toUpperCase() + column.slice(1)) + } + } + } + + // get Settingslist + let tableSettingsList = this.tableSettingsService.getStoredTableSettings(); + + // set this tableType Settings from SettingsList to the new one + tableSettingsList[this.tableType] = { + columnSettingsOptions: this.columnOptions, + columnsForDialog: this.dialogColumns, + columnsForTable: newTableColumns, + filterColumnsForTable: newTableFilterColumns + } as TableViewSettings; + + // save all values back to localstorage + this.tableSettingsService.storeTableSettings(this.tableType, tableSettingsList); + + // trigger action that table will refresh + this.tableSettingsService.emitChangeEvent(); + this.dialogRef.close(); + } + + handleCheckBoxChange(item: string, isChecked: boolean) { + this.columnOptions.set(item, isChecked); + } + + handleListItemClick(event: MouseEvent, item: string) { + let element = event.target as HTMLElement; + + if (element.tagName !== 'INPUT') { + this.selectedColumn = item; + element.classList.toggle('selected-item'); + } + } + + + handleSortListItem(direction: string) { + if(!this.selectedColumn) { + return; + } + + let oldPosition = this.dialogColumns.indexOf(this.selectedColumn); + // in non customer table we have the select Column as first and why + let upperLimit = this.isCustomerTable ? 0 : 1 + let step = direction === 'up' ? -1 : 1; + console.log(oldPosition, upperLimit, step) + if((oldPosition == upperLimit && direction === 'up') || (oldPosition === this.dialogColumns.length-1 && direction === 'down')) { + return; + } + let temp = this.dialogColumns[oldPosition+step]; + this.dialogColumns[oldPosition+step] = this.selectedColumn; + this.dialogColumns[oldPosition] = temp; + } + + selectAll(isChecked: boolean) { + for(let column of this.dialogColumns) { + if(column === 'select'){ + continue; + } + this.columnOptions.set(column,isChecked); + } + this.selectAllSelected = true; + } + + resetColumns() { + this.dialogColumns = [...this.defaultColumns]; + this.selectAll(true); + } +} diff --git a/frontend/src/app/modules/shared/components/table/tableSortingUtil.ts b/frontend/src/app/modules/shared/components/table/table-sorting.util.ts similarity index 100% rename from frontend/src/app/modules/shared/components/table/tableSortingUtil.ts rename to frontend/src/app/modules/shared/components/table/table-sorting.util.ts diff --git a/frontend/src/app/modules/shared/components/table/table.component.html b/frontend/src/app/modules/shared/components/table/table.component.html index 047e5144cc..fe9f1d2ba3 100644 --- a/frontend/src/app/modules/shared/components/table/table.component.html +++ b/frontend/src/app/modules/shared/components/table/table.component.html @@ -188,9 +188,7 @@

{{ 'table.noResultFound' | i18n }}

{ } export enum PartTableType { - AS_BUILT_OWN, AS_PLANNED_OWN, AS_BUILT_SUPPLIER, AS_BUILT_CUSTOMER, AS_PLANNED_SUPPLIER, AS_PLANNED_CUSTOMER + AS_BUILT_OWN = "AS_BUILT_OWN", + AS_PLANNED_OWN = "AS_PLANNED_OWN", + AS_BUILT_SUPPLIER = "AS_BUILT_SUPPLIER", + AS_BUILT_CUSTOMER = "AS_BUILT_CUSTOMER", + AS_PLANNED_SUPPLIER = "AS_PLANNED_SUPPLIER", + AS_PLANNED_CUSTOMER = "AS_PLANNED_CUSTOMER" } export type DisplayColumns = 'select' | 'menu' | T; diff --git a/frontend/src/app/modules/shared/shared.module.ts b/frontend/src/app/modules/shared/shared.module.ts index 1e6b9affbc..10fb888242 100644 --- a/frontend/src/app/modules/shared/shared.module.ts +++ b/frontend/src/app/modules/shared/shared.module.ts @@ -23,8 +23,11 @@ import {DatePipe, TitleCasePipe} from '@angular/common'; import {NgModule} from '@angular/core'; import {MatPaginatorIntl} from '@angular/material/paginator'; import {RouterModule} from '@angular/router'; -import {DateTimeComponent} from '@shared/components/dateTime/dateTime.component'; -import {FormErrorMessageComponent} from '@shared/components/formErrorMessage/formErrorMessage.component'; +import {BomLifecycleActivatorComponent } from '@shared/components/bom-lifecycle-activator/bom-lifecycle-activator.component'; +import { CountryFlagGeneratorComponent } from '@shared/components/country-flag-generator/country-flag-generator.component'; +import { DateTimeComponent } from '@shared/components/dateTime/dateTime.component'; +import { FormErrorMessageComponent } from '@shared/components/formErrorMessage/formErrorMessage.component'; +import { InputComponent } from '@shared/components/input/input.component'; import { MultiSelectAutocompleteComponent } from '@shared/components/multi-select-autocomplete/multi-select-autocomplete.component'; @@ -32,63 +35,49 @@ import {NotificationOverviewComponent} from '@shared/components/notification-ove import {NotificationReasonComponent} from '@shared/components/notification-reason/notification-reason.component'; import {NotificationUserComponent} from '@shared/components/notification-user/notification-user.component'; import {PartsTableComponent} from '@shared/components/parts-table/parts-table.component'; -import {SeveritySelectComponent} from '@shared/components/severity-select/severity-select.component'; -import {SeverityComponent} from '@shared/components/severity/severity.component'; -import {TextWithIconComponent} from '@shared/components/text-with-icon/text-with-icon.component'; -import { - NotificationModalContentComponent -} from '@shared/modules/notification/modal/content/notification-modal-content.component'; -import {FlattenObjectPipe} from '@shared/pipes/flatten-object.pipe'; -import { - FormatPaginationSemanticDataModelToCamelCasePipe -} from '@shared/pipes/format-pagination-semantic-data-model-to-camelcase.pipe'; -import { - FormatPartSemanticDataModelToCamelCasePipe -} from '@shared/pipes/format-part-semantic-data-model-to-camelcase.pipe'; -import { - FormatPartlistSemanticDataModelToCamelCasePipe -} from '@shared/pipes/format-partlist-semantic-data-model-to-camelcase.pipe'; -import {I18NextModule} from 'angular-i18next'; -import { - BomLifecycleActivatorComponent -} from "@shared/components/bom-lifecycle-activator/bom-lifecycle-activator.component"; -import {BaseInputComponent} from './abstraction/baseInput/baseInput.component'; -import {AvatarComponent} from './components/avatar/avatar.component'; -import {BreadcrumbsComponent} from './components/breadcrumbs/breadcrumbs.component'; -import {ButtonComponent} from './components/button/button.component'; -import {CardIconComponent} from './components/card-icon/card-icon.component'; -import {CardListComponent} from './components/card-list/card-list.component'; -import {ToKeyValuePipe} from './components/card-list/card-list.pipe'; -import {DataLoadingErrorComponent} from './components/data-loading-error/data-loading-error.component'; -import {LanguageSelectorComponent} from './components/language-selector/language-selector.component'; -import {PaginatorIntlService} from './components/pagination/paginator-intl.service'; -import {QualityTypeComponent} from './components/quality-type/quality-type.component'; -import {RequestInvestigationComponent} from '@shared/components/request-notification'; -import {ScrollWithShadowComponent} from './components/scroll-with-shadow/scroll-with-shadow.component'; -import {SelectComponent} from './components/select/select.component'; -import {ValueToLablePipe} from './components/select/valueToLable.pipe'; -import {SidenavWrapperComponent} from './components/sidenav/sidenav-wrapper.component'; -import {TableComponent} from './components/table/table.component'; -import {TextareaComponent} from './components/textarea/textarea.component'; -import {ToastContainerComponent} from './components/toasts/toast-container/toast-container.component'; -import {ToastMessageComponent} from './components/toasts/toast-message/toast-message.component'; -import {RoleDirective} from './directives/role.directive'; -import {TabAsPanelDirective} from './directives/tabs/tab-as-panel.directive'; -import {TooltipDirective} from './directives/tooltip.directive'; -import {ViewContainerDirective} from './directives/view-container.directive'; -import {AutoFormatPipe} from './pipes/auto-format.pipe'; -import {ErrorMessagePipe} from './pipes/error-message.pipe'; -import {FormatDatePipe} from './pipes/format-date.pipe'; -import {I18nPipe} from './pipes/i18n.pipe'; -import {PartsService} from './service/parts.service'; -import {StaticIdService} from './service/staticId.service'; -import {TemplateModule} from './template.module'; -import {InputComponent} from '@shared/components/input/input.component'; -import {RequestAlertComponent} from '@shared/components/request-notification/request-alert.component'; -import {ViewSelectorComponent} from "@shared/components/view-selector/view-selector.component"; -import { - CountryFlagGeneratorComponent -} from "@shared/components/country-flag-generator/country-flag-generator.component"; +import {RequestInvestigationComponent } from '@shared/components/request-notification'; +import { RequestAlertComponent } from '@shared/components/request-notification/request-alert.component'; +import { SeveritySelectComponent } from '@shared/components/severity-select/severity-select.component'; +import { SeverityComponent } from '@shared/components/severity/severity.component'; +import { TableSettingsComponent } from '@shared/components/table-settings/table-settings.component'; +import { TextWithIconComponent } from '@shared/components/text-with-icon/text-with-icon.component'; +import { ViewSelectorComponent } from '@shared/components/view-selector/view-selector.component'; +import { NotificationModalContentComponent } from '@shared/modules/notification/modal/content/notification-modal-content.component'; +import { FlattenObjectPipe } from '@shared/pipes/flatten-object.pipe'; +import { FormatPaginationSemanticDataModelToCamelCasePipe } from '@shared/pipes/format-pagination-semantic-data-model-to-camelcase.pipe'; +import { FormatPartSemanticDataModelToCamelCasePipe } from '@shared/pipes/format-part-semantic-data-model-to-camelcase.pipe'; +import { FormatPartlistSemanticDataModelToCamelCasePipe } from '@shared/pipes/format-partlist-semantic-data-model-to-camelcase.pipe'; +import { I18NextModule } from 'angular-i18next'; +import { BaseInputComponent } from './abstraction/baseInput/baseInput.component'; +import { AvatarComponent } from './components/avatar/avatar.component'; +import { BreadcrumbsComponent } from './components/breadcrumbs/breadcrumbs.component'; +import { ButtonComponent } from './components/button/button.component'; +import { CardIconComponent } from './components/card-icon/card-icon.component'; +import { CardListComponent } from './components/card-list/card-list.component'; +import { ToKeyValuePipe } from './components/card-list/card-list.pipe'; +import { DataLoadingErrorComponent } from './components/data-loading-error/data-loading-error.component'; +import { LanguageSelectorComponent } from './components/language-selector/language-selector.component'; +import { PaginatorIntlService } from './components/pagination/paginator-intl.service'; +import { QualityTypeComponent } from './components/quality-type/quality-type.component'; +import { ScrollWithShadowComponent } from './components/scroll-with-shadow/scroll-with-shadow.component'; +import { SelectComponent } from './components/select/select.component'; +import { ValueToLablePipe } from './components/select/valueToLable.pipe'; +import { SidenavWrapperComponent } from './components/sidenav/sidenav-wrapper.component'; +import { TableComponent } from './components/table/table.component'; +import { TextareaComponent } from './components/textarea/textarea.component'; +import { ToastContainerComponent } from './components/toasts/toast-container/toast-container.component'; +import { ToastMessageComponent } from './components/toasts/toast-message/toast-message.component'; +import { RoleDirective } from './directives/role.directive'; +import { TabAsPanelDirective } from './directives/tabs/tab-as-panel.directive'; +import { TooltipDirective } from './directives/tooltip.directive'; +import { ViewContainerDirective } from './directives/view-container.directive'; +import { AutoFormatPipe } from './pipes/auto-format.pipe'; +import { ErrorMessagePipe } from './pipes/error-message.pipe'; +import { FormatDatePipe } from './pipes/format-date.pipe'; +import { I18nPipe } from './pipes/i18n.pipe'; +import { PartsService } from './service/parts.service'; +import { StaticIdService } from './service/staticId.service'; +import { TemplateModule } from './template.module'; @NgModule({ declarations: [ @@ -138,9 +127,10 @@ import { BomLifecycleActivatorComponent, ViewSelectorComponent, MultiSelectAutocompleteComponent, - CountryFlagGeneratorComponent - ], - imports: [TemplateModule, RouterModule, I18NextModule], + CountryFlagGeneratorComponent, + TableSettingsComponent, + ], + imports: [TemplateModule, RouterModule, I18NextModule], exports: [ ToastContainerComponent, ToastMessageComponent, diff --git a/frontend/src/assets/locales/de/common.json b/frontend/src/assets/locales/de/common.json index 60f261dbe9..997e29fa4d 100644 --- a/frontend/src/assets/locales/de/common.json +++ b/frontend/src/assets/locales/de/common.json @@ -57,7 +57,15 @@ "menuDescription": "Aktionsmenü", "clearPage": "Markierungen auf dieser Seite aufheben", "clearAll": "Alle Markierungen aufheben", + "multiSortingToolTip": "Erster Klick: aufsteigend sortieren ↑ Zweiter Klick: absteigend sortieren ↓ Dritter Klick: Sortierung zurücksetzen", "filterTitle" : "Filter", + "tableSettings": { + "title": "Tabellenspalten Einstellungen", + "selectAll": "Alle", + "orderTooltip": "Die Anordnung der Tabellenspalten kann über die Auswahl einer Spalte und einem Klick auf die Pfeilsymbole angepasst werden. ↑ (hoch) oder ↓ (runter)", + "refreshTooltip": "Zurücksetzen der individuellen Einstellung der Tabellenspalten auf die Standardeinstellung", + "saveAction": "Speichern" + }, "adminColumn": { "startDate": "Startdatum", "registryLookupStatus": "Status", diff --git a/frontend/src/assets/locales/en/common.json b/frontend/src/assets/locales/en/common.json index 1820a73295..8d2bda5e1c 100644 --- a/frontend/src/assets/locales/en/common.json +++ b/frontend/src/assets/locales/en/common.json @@ -57,7 +57,15 @@ "menuDescription": "Action menu", "clearPage": "Clear page selections", "clearAll": "Clear all selections", + "multiSortingTooltip": "First click: sort in ascending order ↑ Second click: sort in descending order ↓ Third click: reset sorting", "filterTitle": "Filter", + "tableSettings": { + "title": "Table column settings", + "selectAll": "All", + "orderTooltip": "Table column order can be changed by selecting a column and move it up or down by clicking on the icon ↑ (up) or ↓ (down)", + "refreshTooltip": "Reset individual table column settings to default", + "saveAction": "Save" + }, "adminColumn": { "startDate": "Start date", "registryLookupStatus": "Status", diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/repository/AssetAsBuildSpecification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/repository/AssetAsBuildSpecification.java index faedf2c737..ed7a3f2e05 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/repository/AssetAsBuildSpecification.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/repository/AssetAsBuildSpecification.java @@ -24,16 +24,11 @@ import jakarta.persistence.criteria.Predicate; import jakarta.persistence.criteria.Root; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; -import org.eclipse.tractusx.traceability.assets.infrastructure.base.repository.AssetSpecificationUtil; import org.eclipse.tractusx.traceability.common.model.SearchCriteriaFilter; -import org.eclipse.tractusx.traceability.common.model.SearchCriteriaOperator; import org.eclipse.tractusx.traceability.common.repository.BaseSpecification; -import org.glassfish.jersey.internal.guava.Lists; import org.jetbrains.annotations.NotNull; import org.springframework.data.jpa.domain.Specification; -import java.util.List; - public class AssetAsBuildSpecification extends BaseSpecification implements Specification { public AssetAsBuildSpecification(SearchCriteriaFilter criteria) { @@ -44,12 +39,4 @@ public AssetAsBuildSpecification(SearchCriteriaFilter criteria) { public Predicate toPredicate(@NotNull Root root, @NotNull CriteriaQuery query, @NotNull CriteriaBuilder builder) { return createPredicate(getSearchCriteriaFilter(), root, builder); } - - public static Specification toSpecification(final List allSpecifications, SearchCriteriaOperator searchCriteriaOperator) { - var specifications = Lists.newArrayList(allSpecifications); - if (specifications.isEmpty()) { - return Specification.allOf(); - } - return AssetSpecificationUtil.combineSpecifications(specifications, searchCriteriaOperator); - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asplanned/repository/AssetAsPlannedSpecification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asplanned/repository/AssetAsPlannedSpecification.java index df4b2e42f3..4cd0b96954 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asplanned/repository/AssetAsPlannedSpecification.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asplanned/repository/AssetAsPlannedSpecification.java @@ -24,16 +24,11 @@ import jakarta.persistence.criteria.Predicate; import jakarta.persistence.criteria.Root; import org.eclipse.tractusx.traceability.assets.infrastructure.asplanned.model.AssetAsPlannedEntity; -import org.eclipse.tractusx.traceability.assets.infrastructure.base.repository.AssetSpecificationUtil; import org.eclipse.tractusx.traceability.common.model.SearchCriteriaFilter; -import org.eclipse.tractusx.traceability.common.model.SearchCriteriaOperator; import org.eclipse.tractusx.traceability.common.repository.BaseSpecification; -import org.glassfish.jersey.internal.guava.Lists; import org.jetbrains.annotations.NotNull; import org.springframework.data.jpa.domain.Specification; -import java.util.List; - public class AssetAsPlannedSpecification extends BaseSpecification implements Specification { @@ -45,14 +40,4 @@ public AssetAsPlannedSpecification(SearchCriteriaFilter criteria) { public Predicate toPredicate(@NotNull Root root, @NotNull CriteriaQuery query, @NotNull CriteriaBuilder builder) { return createPredicate(getSearchCriteriaFilter(), root, builder); } - - public static Specification toSpecification(final List allSpecifications, SearchCriteriaOperator searchCriteriaOperator) { - var specifications = Lists.newArrayList(allSpecifications); - if (specifications.isEmpty()) { - return Specification.allOf(); - } - return AssetSpecificationUtil.combineSpecifications(specifications, searchCriteriaOperator); - - } - } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/IrsService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/IrsService.java index bc8a5752e9..dcf8881025 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/IrsService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/IrsService.java @@ -21,6 +21,7 @@ package org.eclipse.tractusx.traceability.assets.infrastructure.base.irs; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -72,7 +73,11 @@ public List findAssets(String globalAssetId, Direction direction, Lis JobStatus jobStatus = jobResponse.jobStatus(); long runtime = (jobStatus.lastModifiedOn().getTime() - jobStatus.startedOn().getTime()) / 1000; log.info("IRS call for globalAssetId: {} finished with status: {}, runtime {} s.", globalAssetId, jobStatus.state(), runtime); - + try { + log.info("Received HTTP Response: {}", objectMapper.writeValueAsString(jobResponse)); + } catch (Exception e) { + log.warn("Unable to log IRS Response", e); + } if (jobResponse.isCompleted()) { try { // TODO exception will be often thrown probably because two transactions try to commit same primary key - check if we need to update it here diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/repository/AssetSpecificationUtil.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/repository/AssetSpecificationUtil.java deleted file mode 100644 index 6ccd7d7014..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/repository/AssetSpecificationUtil.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.traceability.assets.infrastructure.base.repository; - -import org.eclipse.tractusx.traceability.common.model.SearchCriteriaOperator; -import org.eclipse.tractusx.traceability.common.repository.BaseSpecification; -import org.springframework.data.jpa.domain.Specification; - -import java.util.ArrayList; -import java.util.List; - -public class AssetSpecificationUtil { - - public static Specification combineSpecifications( - ArrayList> specifications, - SearchCriteriaOperator searchCriteriaOperator) { - - List> ownerSpecifications = specifications.stream() - .filter(AssetSpecificationUtil::isOwnerPredicate).toList(); - - List> semanticDataModelSpecifications = specifications.stream() - .filter(AssetSpecificationUtil::isSemanticDataModelPredicate).toList(); - - List> otherSpecifications = specifications.stream() - .filter(spec -> !isOwnerPredicate(spec) && !isSemanticDataModelPredicate(spec)).toList(); - - Specification resultAnd = null; - Specification resultOr = null; - - // Always add owner specifications with AND - for (BaseSpecification ownerSpecification : ownerSpecifications) { - resultAnd = Specification.where(resultAnd).and(ownerSpecification); - } - // Always add semanticDataModel specifications with OR - for (BaseSpecification semanticDataModelSpecification : semanticDataModelSpecifications) { - resultOr = Specification.where(resultOr).or(semanticDataModelSpecification); - } - if (searchCriteriaOperator.equals(SearchCriteriaOperator.AND)) { - for (BaseSpecification otherSpecification : otherSpecifications) { - resultAnd = Specification.where(resultAnd).and(otherSpecification); - } - } else { - for (BaseSpecification otherSpecification : otherSpecifications) { - resultOr = Specification.where(resultOr).or(otherSpecification); - } - } - - return Specification.where(resultAnd).and(resultOr); - } - - - private static boolean isOwnerPredicate(BaseSpecification baseSpecification) { - return "owner".equals(baseSpecification.getSearchCriteriaFilter().getKey()); - } - - private static boolean isSemanticDataModelPredicate(BaseSpecification baseSpecification) { - return "semanticDataModel".equals(baseSpecification.getSearchCriteriaFilter().getKey()); - } - -} - diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/repository/BaseSpecification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/repository/BaseSpecification.java index 1290f521b8..d34bebf0d6 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/repository/BaseSpecification.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/repository/BaseSpecification.java @@ -24,16 +24,24 @@ import jakarta.persistence.criteria.Root; import lombok.Getter; import org.eclipse.tractusx.traceability.common.model.SearchCriteriaFilter; +import org.eclipse.tractusx.traceability.common.model.SearchCriteriaOperator; import org.eclipse.tractusx.traceability.common.model.SearchStrategy; import org.springframework.data.jpa.domain.Specification; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static java.util.stream.Collectors.groupingBy; @Getter public abstract class BaseSpecification implements Specification { + private static final String OWNER_FIELD_NAME = "owner"; + private final SearchCriteriaFilter searchCriteriaFilter; protected BaseSpecification(SearchCriteriaFilter searchCriteriaFilter) { @@ -62,5 +70,66 @@ protected Predicate createPredicate(SearchCriteriaFilter criteria, Root root, return null; } + public static Specification toSpecification(List> specifications, SearchCriteriaOperator searchCriteriaOperator) { + if (specifications.isEmpty()) { + return null; + } + + Map>> groupedSpecifications = specifications.stream() + .collect(groupingBy(spec -> spec.getSearchCriteriaFilter().getKey())); + + Map> fieldSpecsByFieldName = groupedSpecifications.values().stream() + .map(BaseSpecification::combineFieldSpecifications) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + return combineSpecifications(fieldSpecsByFieldName, searchCriteriaOperator); + + } + + // Combines all fields into one specification + private static Specification combineSpecifications(Map> fieldSpecsByFieldName, SearchCriteriaOperator searchCriteriaOperator) { + Specification result; + + // global filtering specific logic + if (fieldSpecsByFieldName.containsKey(OWNER_FIELD_NAME) && SearchCriteriaOperator.OR.equals(searchCriteriaOperator)) { + result = fieldSpecsByFieldName.get(OWNER_FIELD_NAME); + List> otherFieldsSpecifications = fieldSpecsByFieldName.entrySet().stream() + .filter(entry -> !OWNER_FIELD_NAME.equals(entry.getKey())) + .map(Map.Entry::getValue).toList(); + + if (otherFieldsSpecifications.isEmpty()) { + return result; + } + return Specification.where(result).and(combineWithSpecificationsWith(otherFieldsSpecifications, SearchCriteriaOperator.OR)); + } else { + + List> fieldSpecList = fieldSpecsByFieldName.values().stream().toList(); + + result = combineWithSpecificationsWith(fieldSpecList, searchCriteriaOperator); + } + return result; + } + + // Combines specific field specifications + private static Map.Entry> combineFieldSpecifications(List> specifications) { + // TODO: Add here date range handling if list has BEFORE_LOCAL_DATE and AFTER_LOCAL_DATE then combine those with AND + String fieldName = specifications.get(0).searchCriteriaFilter.getKey(); + Specification result = combineWithSpecificationsWith( + specifications.stream().map(baseSpec -> (Specification) baseSpec).toList(), + SearchCriteriaOperator.OR); + + return Map.entry(fieldName, result); + } + private static Specification combineWithSpecificationsWith(List> specifications, SearchCriteriaOperator searchCriteriaOperator) { + Specification result = specifications.get(0); + for (int i = 1; i < specifications.size(); i++) { + if (SearchCriteriaOperator.OR.equals(searchCriteriaOperator)) { + result = Specification.where(result).or(specifications.get(i)); + } else { + result = Specification.where(result).and(specifications.get(i)); + } + } + return result; + } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/request/SearchCriteriaRequestParam.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/request/SearchCriteriaRequestParam.java index f4ea7fe272..5d243aa630 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/request/SearchCriteriaRequestParam.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/request/SearchCriteriaRequestParam.java @@ -86,5 +86,4 @@ public SearchCriteria toSearchCriteria() { } return SearchCriteria.builder().searchCriteriaOperator(operator).searchCriteriaFilterList(filters).build(); } - } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/shelldescriptor/domain/service/ShellDescriptorsServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/shelldescriptor/domain/service/ShellDescriptorsServiceImpl.java index f9937e6e7b..91a7c92b86 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/shelldescriptor/domain/service/ShellDescriptorsServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/shelldescriptor/domain/service/ShellDescriptorsServiceImpl.java @@ -50,24 +50,37 @@ public List determineExistingShellDescriptorsAndUpdate(List existingDescriptors = shellDescriptorRepository.findAll().stream() .collect(Collectors.toMap(ShellDescriptor::getGlobalAssetId, Function.identity())); - List descriptorsToSync = new ArrayList<>(); + List newDescriptorsToSync = new ArrayList<>(); + List existingDescriptorsToUpdate = new ArrayList<>(); ZonedDateTime now = ZonedDateTime.now(); for (ShellDescriptor descriptor : ownShellDescriptors) { if (existingDescriptors.containsKey(descriptor.getGlobalAssetId())) { - shellDescriptorRepository.update(existingDescriptors.get(descriptor.getGlobalAssetId())); + existingDescriptorsToUpdate.add(existingDescriptors.get(descriptor.getGlobalAssetId())); log.info("Updated existing shellDescriptor with id {}.", descriptor.getGlobalAssetId()); } else { - descriptorsToSync.add((descriptor)); + newDescriptorsToSync.add((descriptor)); } } - log.info("Updated new shellDescriptors list size {}.", descriptorsToSync.size()); - descriptorsToSync.forEach(this::persistDescriptor); + log.info("Added new shellDescriptors list size {}.", newDescriptorsToSync.size()); + newDescriptorsToSync.forEach(this::persistDescriptor); + existingDescriptorsToUpdate.forEach(this::updateDescriptor); shellDescriptorRepository.removeDescriptorsByUpdatedBefore(now); log.info("Finished update of {} shell descriptors.", ownShellDescriptors.size()); - return descriptorsToSync; + //Merge those two lists to sync all relevant shell descriptors + newDescriptorsToSync.addAll(existingDescriptorsToUpdate); + return newDescriptorsToSync; + } + + private void updateDescriptor(ShellDescriptor shellDescriptor) { + try { + shellDescriptorRepository.update(shellDescriptor); + } catch (DataIntegrityViolationException exception) { + log.warn("Failed to persist shellDescriptor with Id: {} With cause: {}", shellDescriptor.getId(), exception.getMessage()); + } + } private void persistDescriptor(ShellDescriptor shellDescriptor){ diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/shelldescriptor/infrastructure/repository/jpa/ShellDescriptorRepositoryImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/shelldescriptor/infrastructure/repository/jpa/ShellDescriptorRepositoryImpl.java index e1be9ddb9d..9f9515a0ac 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/shelldescriptor/infrastructure/repository/jpa/ShellDescriptorRepositoryImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/shelldescriptor/infrastructure/repository/jpa/ShellDescriptorRepositoryImpl.java @@ -62,6 +62,7 @@ public void saveAll(Collection values) { } @Override + @Transactional public void save(ShellDescriptor descriptor) { repository.save(ShellDescriptorEntity.newEntityFrom(descriptor)); } diff --git a/tx-backend/src/main/resources/db/migration/V10__alter_investigation_table_change_reason_field_lenght.sql b/tx-backend/src/main/resources/db/migration/V10__alter_investigation_table_change_reason_field_lenght.sql deleted file mode 100644 index fb5152adae..0000000000 --- a/tx-backend/src/main/resources/db/migration/V10__alter_investigation_table_change_reason_field_lenght.sql +++ /dev/null @@ -1,12 +0,0 @@ -ALTER TABLE investigation -ALTER COLUMN accept_reason TYPE VARCHAR(1000); - -ALTER TABLE investigation -ALTER COLUMN decline_reason TYPE VARCHAR(1000); - -ALTER TABLE investigation -ALTER COLUMN close_reason TYPE VARCHAR(1000); - -ALTER TABLE investigation -ALTER COLUMN description TYPE VARCHAR(1000); - diff --git a/tx-backend/src/main/resources/db/migration/V11__alter_notification_table_add_manufacturer_names.sql b/tx-backend/src/main/resources/db/migration/V11__alter_notification_table_add_manufacturer_names.sql deleted file mode 100644 index 5c8dfea492..0000000000 --- a/tx-backend/src/main/resources/db/migration/V11__alter_notification_table_add_manufacturer_names.sql +++ /dev/null @@ -1,5 +0,0 @@ -alter table if exists notification - add column sender_manufacturer_name varchar(255); - -alter table if exists notification - add column receiver_manufacturer_name varchar(255); diff --git a/tx-backend/src/main/resources/db/migration/V12__alter_notification_table_add_messageId_and_edcNotificationId.sql b/tx-backend/src/main/resources/db/migration/V12__alter_notification_table_add_messageId_and_edcNotificationId.sql deleted file mode 100644 index d612c6b15f..0000000000 --- a/tx-backend/src/main/resources/db/migration/V12__alter_notification_table_add_messageId_and_edcNotificationId.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table if exists notification - add column edc_notification_id varchar(255); diff --git a/tx-backend/src/main/resources/db/migration/V13__alter_notification_table_add_created_updated_and_status.sql b/tx-backend/src/main/resources/db/migration/V13__alter_notification_table_add_created_updated_and_status.sql deleted file mode 100644 index 983bef3d27..0000000000 --- a/tx-backend/src/main/resources/db/migration/V13__alter_notification_table_add_created_updated_and_status.sql +++ /dev/null @@ -1,8 +0,0 @@ -alter table if exists notification - add column status varchar(255); - -alter table if exists notification - add column created timestamp with time zone; - -alter table if exists notification - add column updated timestamp with time zone; diff --git a/tx-backend/src/main/resources/db/migration/V14__alter_notification_table_add_created_updated_and_status.sql b/tx-backend/src/main/resources/db/migration/V14__alter_notification_table_add_created_updated_and_status.sql deleted file mode 100644 index a46d131765..0000000000 --- a/tx-backend/src/main/resources/db/migration/V14__alter_notification_table_add_created_updated_and_status.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table if exists notification - add column message_id varchar(255); diff --git a/tx-backend/src/main/resources/db/migration/V15__change_asset_table_to_reflect_owner_and_add_parentdescriptions.sql b/tx-backend/src/main/resources/db/migration/V15__change_asset_table_to_reflect_owner_and_add_parentdescriptions.sql deleted file mode 100644 index 2f2fe2ca46..0000000000 --- a/tx-backend/src/main/resources/db/migration/V15__change_asset_table_to_reflect_owner_and_add_parentdescriptions.sql +++ /dev/null @@ -1,14 +0,0 @@ -create table asset_parent_descriptors -( - asset_entity_id varchar(255) not null, - id varchar(255), - id_short varchar(255) -); - -alter table if exists asset_parent_descriptors add constraint fk_asset foreign key (asset_entity_id) references asset; - -alter table if exists asset - add column owner int4; - -alter table if exists asset DROP COLUMN supplier_part; - diff --git a/tx-backend/src/main/resources/db/migration/V16__bpn_edc_url_mapping.sql b/tx-backend/src/main/resources/db/migration/V16__bpn_edc_url_mapping.sql deleted file mode 100644 index edcd38531d..0000000000 --- a/tx-backend/src/main/resources/db/migration/V16__bpn_edc_url_mapping.sql +++ /dev/null @@ -1,12 +0,0 @@ -create table bpn_edc_mappings -( - bpn varchar(255), - url varchar(255), - created timestamptz, - updated timestamptz, - primary key (bpn), - unique(url) -); - -insert into bpn_edc_mappings values('BPNL00000003AYRE', 'https://tracex-consumer-controlplane.dev.demo.catena-x.net', current_timestamp, null); -insert into bpn_edc_mappings values('BPNL00000003B2OM', 'https://tracex-test-consumer-controlplane.dev.demo.catena-x.net', current_timestamp, null); diff --git a/tx-backend/src/main/resources/db/migration/V17__alter_notification_table_add_is_initial.sql b/tx-backend/src/main/resources/db/migration/V17__alter_notification_table_add_is_initial.sql deleted file mode 100644 index 3688d3b49c..0000000000 --- a/tx-backend/src/main/resources/db/migration/V17__alter_notification_table_add_is_initial.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table if exists notification - add column is_initial boolean; diff --git a/tx-backend/src/main/resources/db/migration/V18__alter_asset_table_add_in_investigation.sql b/tx-backend/src/main/resources/db/migration/V18__alter_asset_table_add_in_investigation.sql deleted file mode 100644 index 8e16993c80..0000000000 --- a/tx-backend/src/main/resources/db/migration/V18__alter_asset_table_add_in_investigation.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table if exists asset - add column in_investigation boolean not null default (false); diff --git a/tx-backend/src/main/resources/db/migration/V19__insert_assets_for_notifications.sql b/tx-backend/src/main/resources/db/migration/V19__insert_assets_for_notifications.sql deleted file mode 100644 index c8a2fe6d53..0000000000 --- a/tx-backend/src/main/resources/db/migration/V19__insert_assets_for_notifications.sql +++ /dev/null @@ -1,11 +0,0 @@ -INSERT INTO asset (id, customer_part_id, id_short, manufacturer_id, manufacturer_name, manufacturer_part_id, - manufacturing_country, manufacturing_date, name_at_customer, name_at_manufacturer, quality_type, - batch_id, part_instance_id, van, owner) -VALUES ('urn:uuid:51ff7c73-34e9-45d4-816c-d92ownerbpna', '1O222E8-43', '--', 'BPNL00000003CML1', 'Tier A', '1O222E8-43', - 'DEU', '2022-02-04 13:48:54', 'Transmission', 'Transmission', 0, '--', 'NO-712627233731926672258402', NULL, 2); - -INSERT INTO asset (id, customer_part_id, id_short, manufacturer_id, manufacturer_name, manufacturer_part_id, - manufacturing_country, manufacturing_date, name_at_customer, name_at_manufacturer, quality_type, - batch_id, part_instance_id, van, owner) -VALUES ('urn:uuid:51ff7c73-34e9-45d4-816c-d92ownerbpnb', '1O222E8-43', '--', 'BPNL00000003CNKC', 'Tier A', '1O222E8-43', - 'DEU', '2022-02-04 13:48:54', 'Transmission', 'Transmission', 0, '--', 'NO-712627233731926672258402', NULL, 0); diff --git a/tx-backend/src/main/resources/db/migration/V1__base_sql_configuration.sql b/tx-backend/src/main/resources/db/migration/V1__base_sql_configuration.sql new file mode 100644 index 0000000000..7358333312 --- /dev/null +++ b/tx-backend/src/main/resources/db/migration/V1__base_sql_configuration.sql @@ -0,0 +1,426 @@ +-- DROP SEQUENCE public.alert_id_seq; + +CREATE SEQUENCE public.alert_id_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE public.investigation_id_seq; + +CREATE SEQUENCE public.investigation_id_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE public.shell_descriptor_id_seq; + +CREATE SEQUENCE public.shell_descriptor_id_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 2147483647 + START 1 + CACHE 1 + NO CYCLE; +-- public.alert definition + +-- Drop table + +-- DROP TABLE public.alert; + +CREATE TABLE public.alert +( + id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE), + bpn varchar(255) NULL, + close_reason varchar(1000) NULL, + created timestamp NULL, + description varchar(1000) NULL, + status varchar(50) NULL, + side varchar(50) NULL, + accept_reason varchar(1000) NULL, + decline_reason varchar(1000) NULL, + updated timestamp NULL, + error_message varchar(255) NULL, + CONSTRAINT alert_pkey PRIMARY KEY (id) +); + + +-- public.asset_as_built_alert_notifications definition + +-- Drop table + +-- DROP TABLE public.asset_as_built_alert_notifications; + +CREATE TABLE public.asset_as_built_alert_notifications +( + alert_notification_id varchar(255) NOT NULL, + asset_id varchar(255) NOT NULL +); + + +-- public.asset_as_planned_alert_notifications definition + +-- Drop table + +-- DROP TABLE public.asset_as_planned_alert_notifications; + +CREATE TABLE public.asset_as_planned_alert_notifications +( + alert_notification_id varchar(255) NOT NULL, + asset_id varchar(255) NOT NULL +); + + +-- public.assets_as_built definition + +-- Drop table + +-- DROP TABLE public.assets_as_built; + +CREATE TABLE public.assets_as_built +( + id varchar(255) NOT NULL, + customer_part_id varchar(255) NULL, + id_short varchar(255) NULL, + manufacturer_id varchar(255) NULL, + manufacturer_name varchar(255) NULL, + manufacturer_part_id varchar(255) NULL, + manufacturing_country varchar(255) NULL, + manufacturing_date timestamp NULL, + name_at_customer varchar(255) NULL, + name_at_manufacturer varchar(255) NULL, + quality_type varchar(50) NULL, + van varchar(255) NULL, + "owner" varchar(50) NULL, + in_investigation bool NOT NULL DEFAULT false, + active_alert bool NOT NULL DEFAULT false, + semantic_model_id varchar(255) NULL, + semantic_data_model varchar(50) NULL, + classification varchar(255) NULL, + product_type varchar(255) NULL, + traction_battery_code varchar(255) NULL, + CONSTRAINT asset_pkey PRIMARY KEY (id) +); + + +-- public.assets_as_planned definition + +-- Drop table + +-- DROP TABLE public.assets_as_planned; + +CREATE TABLE public.assets_as_planned +( + id varchar(255) NOT NULL, + id_short varchar(255) NULL, + manufacturer_part_id varchar(255) NULL, + name_at_manufacturer varchar(255) NULL, + quality_type varchar(50) NULL, + classification varchar(255) NULL, + "owner" varchar(50) NULL, + semantic_data_model varchar(50) NULL, + in_investigation bool NOT NULL DEFAULT false, + active_alert bool NOT NULL DEFAULT false, + validity_period_from varchar(255) NULL, + validity_period_to varchar(255) NULL, + function_valid_until varchar(255) NULL, + function_valid_from varchar(255) NULL, + "function" varchar(255) NULL, + manufacturer_name varchar(255) NULL, + van varchar(255) NULL, + semantic_model_id varchar(255) NULL, + catenax_site_id varchar(255) NULL, + CONSTRAINT assets_as_planned_pkey PRIMARY KEY (id) +); + + +-- public.assets_as_planned_alerts definition + +-- Drop table + +-- DROP TABLE public.assets_as_planned_alerts; + +CREATE TABLE public.assets_as_planned_alerts +( + alert_id int8 NOT NULL, + asset_id varchar(255) NOT NULL +); + + +-- public.assets_as_planned_childs definition + +-- Drop table + +-- DROP TABLE public.assets_as_planned_childs; + +CREATE TABLE public.assets_as_planned_childs +( + asset_as_planned_id varchar(255) NOT NULL, + id varchar(255) NULL, + id_short varchar(255) NULL +); + + +-- public.assets_as_planned_investigations definition + +-- Drop table + +-- DROP TABLE public.assets_as_planned_investigations; + +CREATE TABLE public.assets_as_planned_investigations +( + investigation_id int8 NOT NULL, + asset_id varchar(255) NOT NULL +); + + +-- public.assets_as_planned_notifications definition + +-- Drop table + +-- DROP TABLE public.assets_as_planned_notifications; + +CREATE TABLE public.assets_as_planned_notifications +( + notification_id varchar(255) NOT NULL, + asset_id varchar(255) NOT NULL +); + + +-- public.bpn_storage definition + +-- Drop table + +-- DROP TABLE public.bpn_storage; + +CREATE TABLE public.bpn_storage +( + manufacturer_id varchar(255) NOT NULL, + manufacturer_name varchar(255) NULL, + url varchar(255) NULL, + created timestamptz NULL, + updated timestamptz NULL, + CONSTRAINT bpn_storage_pkey PRIMARY KEY (manufacturer_id), + CONSTRAINT bpn_storage_url_key UNIQUE (url) +); + + +-- public.investigation definition + +-- Drop table + +-- DROP TABLE public.investigation; + +CREATE TABLE public.investigation +( + id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE), + bpn varchar(255) NULL, + close_reason varchar(1000) NULL, + created timestamp NULL, + description varchar(1000) NULL, + status varchar(50) NULL, + updated timestamp NULL, + side varchar(50) NULL, + accept_reason varchar(1000) NULL, + decline_reason varchar(1000) NULL, + error_message varchar(255) NULL, + CONSTRAINT investigation_pkey PRIMARY KEY (id) +); + + +-- public.shedlock definition + +-- Drop table + +-- DROP TABLE public.shedlock; + +CREATE TABLE public.shedlock +( + "name" varchar(64) NOT NULL, + lock_until timestamp NOT NULL, + locked_at timestamp NOT NULL, + locked_by varchar(255) NOT NULL, + CONSTRAINT shedlock_pkey PRIMARY KEY (name) +); + + +-- public.shell_descriptor definition + +-- Drop table + +-- DROP TABLE public.shell_descriptor; + +CREATE TABLE public.shell_descriptor +( + id serial4 NOT NULL, + created timestamptz NOT NULL, + updated timestamptz NOT NULL, + global_asset_id text NOT NULL, + CONSTRAINT shell_descriptor_global_asset_id_key UNIQUE (global_asset_id), + CONSTRAINT shell_descriptor_pkey PRIMARY KEY (id) +); + + +-- public.submodel definition + +-- Drop table + +-- DROP TABLE public.submodel; + +CREATE TABLE public.submodel +( + id varchar(255) NOT NULL, + submodel varchar NULL, + CONSTRAINT submodel_pkey PRIMARY KEY (id) +); + + +-- public.traction_battery_code_subcomponent definition + +-- Drop table + +-- DROP TABLE public.traction_battery_code_subcomponent; + +CREATE TABLE public.traction_battery_code_subcomponent +( + traction_battery_code varchar(255) NOT NULL, + subcomponent_traction_battery_code varchar(255) NOT NULL, + product_type varchar(255) NULL +); + + +-- public.alert_notification definition + +-- Drop table + +-- DROP TABLE public.alert_notification; + +CREATE TABLE public.alert_notification +( + id varchar(255) NOT NULL, + contract_agreement_id varchar(255) NULL, + edc_url varchar(255) NULL, + notification_reference_id varchar(255) NULL, + send_to varchar(255) NULL, + created_by varchar(255) NULL, + alert_id int8 NULL, + target_date timestamp NULL, + severity int4 NULL, + created_by_name varchar(255) NULL, + send_to_name varchar(255) NULL, + edc_notification_id varchar(255) NULL, + status varchar(255) NULL, + created timestamptz NULL, + updated timestamptz NULL, + message_id varchar(255) NULL, + is_initial bool NULL, + CONSTRAINT alert_notification_pkey PRIMARY KEY (id), + CONSTRAINT fk_alert FOREIGN KEY (alert_id) REFERENCES public.alert (id) +); + + +-- public.assets_as_built_alerts definition + +-- Drop table + +-- DROP TABLE public.assets_as_built_alerts; + +CREATE TABLE public.assets_as_built_alerts +( + alert_id int8 NOT NULL, + asset_id varchar(255) NOT NULL, + CONSTRAINT fk_alert FOREIGN KEY (alert_id) REFERENCES public.alert (id), + CONSTRAINT fk_asset_entity FOREIGN KEY (asset_id) REFERENCES public.assets_as_built (id) +); + + +-- public.assets_as_built_childs definition + +-- Drop table + +-- DROP TABLE public.assets_as_built_childs; + +CREATE TABLE public.assets_as_built_childs +( + asset_as_built_id varchar(255) NOT NULL, + id varchar(255) NULL, + id_short varchar(255) NULL, + CONSTRAINT fk_asset FOREIGN KEY (asset_as_built_id) REFERENCES public.assets_as_built (id) +); + + +-- public.assets_as_built_investigations definition + +-- Drop table + +-- DROP TABLE public.assets_as_built_investigations; + +CREATE TABLE public.assets_as_built_investigations +( + investigation_id int8 NOT NULL, + asset_id varchar(255) NOT NULL, + CONSTRAINT fk_asset_entity FOREIGN KEY (asset_id) REFERENCES public.assets_as_built (id), + CONSTRAINT fk_investigation FOREIGN KEY (investigation_id) REFERENCES public.investigation (id) +); + + +-- public.assets_as_built_parents definition + +-- Drop table + +-- DROP TABLE public.assets_as_built_parents; + +CREATE TABLE public.assets_as_built_parents +( + asset_as_built_id varchar(255) NOT NULL, + id varchar(255) NULL, + id_short varchar(255) NULL, + CONSTRAINT fk_asset FOREIGN KEY (asset_as_built_id) REFERENCES public.assets_as_built (id) +); + + +-- public.investigation_notification definition + +-- Drop table + +-- DROP TABLE public.investigation_notification; + +CREATE TABLE public.investigation_notification +( + id varchar(255) NOT NULL, + contract_agreement_id varchar(255) NULL, + edc_url varchar(255) NULL, + notification_reference_id varchar(255) NULL, + send_to varchar(255) NULL, + created_by varchar(255) NULL, + investigation_id int8 NULL, + target_date timestamp NULL, + severity int4 NULL, + created_by_name varchar(255) NULL, + send_to_name varchar(255) NULL, + edc_notification_id varchar(255) NULL, + status varchar(255) NULL, + created timestamptz NULL, + updated timestamptz NULL, + message_id varchar(255) NULL, + is_initial bool NULL, + CONSTRAINT notification_pkey PRIMARY KEY (id), + CONSTRAINT fk_investigation FOREIGN KEY (investigation_id) REFERENCES public.investigation (id) +); + + +-- public.assets_as_built_notifications definition + +-- Drop table + +-- DROP TABLE public.assets_as_built_notifications; + +CREATE TABLE public.assets_as_built_notifications +( + notification_id varchar(255) NOT NULL, + asset_id varchar(255) NOT NULL, + CONSTRAINT fk_notification FOREIGN KEY (notification_id) REFERENCES public.investigation_notification (id) +); diff --git a/tx-backend/src/main/resources/db/migration/V1__shedlock_table.sql b/tx-backend/src/main/resources/db/migration/V1__shedlock_table.sql deleted file mode 100644 index fc2d38d178..0000000000 --- a/tx-backend/src/main/resources/db/migration/V1__shedlock_table.sql +++ /dev/null @@ -1,8 +0,0 @@ -create table shedlock -( - name VARCHAR(64) NOT NULL, - lock_until TIMESTAMP NOT NULL, - locked_at TIMESTAMP NOT NULL, - locked_by VARCHAR(255) NOT NULL, - PRIMARY KEY (name) -); diff --git a/tx-backend/src/main/resources/db/migration/V20__alter_notification_name.sql b/tx-backend/src/main/resources/db/migration/V20__alter_notification_name.sql deleted file mode 100644 index 076077e5af..0000000000 --- a/tx-backend/src/main/resources/db/migration/V20__alter_notification_name.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE notification RENAME TO investigation_notification; diff --git a/tx-backend/src/main/resources/db/migration/V21__remove_testdata_assets.sql b/tx-backend/src/main/resources/db/migration/V21__remove_testdata_assets.sql deleted file mode 100644 index c6dcd79900..0000000000 --- a/tx-backend/src/main/resources/db/migration/V21__remove_testdata_assets.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE -FROM asset -WHERE id = 'urn:uuid:51ff7c73-34e9-45d4-816c-d92ownerbpnb'; -DELETE -FROM asset -WHERE id = 'urn:uuid:51ff7c73-34e9-45d4-816c-d92ownerbpna'; - diff --git a/tx-backend/src/main/resources/db/migration/V22__renaming_of_assets.sql b/tx-backend/src/main/resources/db/migration/V22__renaming_of_assets.sql deleted file mode 100644 index e12a8a7168..0000000000 --- a/tx-backend/src/main/resources/db/migration/V22__renaming_of_assets.sql +++ /dev/null @@ -1,15 +0,0 @@ -ALTER TABLE asset RENAME TO assets_as_built; -ALTER TABLE asset_child_descriptors RENAME TO assets_as_built_childs; -ALTER TABLE asset_parent_descriptors RENAME TO assets_as_built_parents; -ALTER TABLE assets_investigations RENAME TO assets_as_built_investigations; -ALTER TABLE assets_notifications RENAME TO assets_as_built_notifications; - -ALTER TABLE assets_as_built - ADD COLUMN active_alert boolean NOT NULL default (false); - -ALTER TABLE assets_as_built - ADD COLUMN semantic_model_id varchar(255); - -ALTER TABLE assets_as_built DROP COLUMN part_instance_id; - -ALTER TABLE assets_as_built DROP COLUMN batch_id; diff --git a/tx-backend/src/main/resources/db/migration/V23__renaming_of_child_parent_assets.sql b/tx-backend/src/main/resources/db/migration/V23__renaming_of_child_parent_assets.sql deleted file mode 100644 index 20c6cdcde7..0000000000 --- a/tx-backend/src/main/resources/db/migration/V23__renaming_of_child_parent_assets.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE assets_as_built_parents - RENAME COLUMN asset_entity_id TO asset_as_built_id; -ALTER TABLE assets_as_built_childs - RENAME COLUMN asset_entity_id TO asset_as_built_id; diff --git a/tx-backend/src/main/resources/db/migration/V24__add_semantic_data_model_to_assets.sql b/tx-backend/src/main/resources/db/migration/V24__add_semantic_data_model_to_assets.sql deleted file mode 100644 index 10e7b00ed1..0000000000 --- a/tx-backend/src/main/resources/db/migration/V24__add_semantic_data_model_to_assets.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE assets_as_built - add column semantic_data_model int4; diff --git a/tx-backend/src/main/resources/db/migration/V25__alert_tables.sql b/tx-backend/src/main/resources/db/migration/V25__alert_tables.sql deleted file mode 100644 index 2ee25f4399..0000000000 --- a/tx-backend/src/main/resources/db/migration/V25__alert_tables.sql +++ /dev/null @@ -1,58 +0,0 @@ -create table assets_as_built_alerts -( - alert_id int8 not null, - asset_id varchar(255) not null -); - -create table asset_as_built_alert_notifications -( - alert_notification_id varchar(255) not null, - asset_id varchar(255) not null -); - -create table if not exists alert -( - id int8 generated by default as identity, - bpn varchar(255), - close_reason varchar(1000), - created timestamp, - description varchar(1000), - status int4, - side int4, - accept_reason varchar(1000), - decline_reason varchar(1000), - updated timestamp, - primary key (id) -); - -create table alert_notification -( - id varchar(255) not null, - contract_agreement_id varchar(255), - edc_url varchar(255), - notification_reference_id varchar(255), - receiver_bpn_number varchar(255), - sender_bpn_number varchar(255), - alert_id int8, - target_date timestamp, - severity int4, - sender_manufacturer_name varchar(255), - receiver_manufacturer_name varchar(255), - edc_notification_id varchar(255), - status varchar(255), - created timestamp with time zone, - updated timestamp with time zone, - message_id varchar(255), - is_initial boolean, - primary key (id) -); - -alter table if exists assets_as_built_alerts - add constraint fk_asset_entity foreign key (asset_id) references assets_as_built; - -alter table if exists assets_as_built_alerts - add constraint fk_alert foreign key (alert_id) references alert; - -alter table if exists alert_notification - add constraint fk_alert foreign key (alert_id) references alert; - diff --git a/tx-backend/src/main/resources/db/migration/V26__bpn_edc_url_new_mappings.sql b/tx-backend/src/main/resources/db/migration/V26__bpn_edc_url_new_mappings.sql deleted file mode 100644 index cfb156ca59..0000000000 --- a/tx-backend/src/main/resources/db/migration/V26__bpn_edc_url_new_mappings.sql +++ /dev/null @@ -1,6 +0,0 @@ -delete -FROM public.bpn_edc_mappings; -insert into bpn_edc_mappings -values ('BPNL00000003CML1', 'https://tracex-consumer-controlplane.dev.demo.catena-x.net', current_timestamp, null); -insert into bpn_edc_mappings -values ('BPNL00000003CNKC', 'https://tracex-test-consumer-controlplane.dev.demo.catena-x.net', current_timestamp, null); diff --git a/tx-backend/src/main/resources/db/migration/V27__asset_as_planned_tables.sql b/tx-backend/src/main/resources/db/migration/V27__asset_as_planned_tables.sql deleted file mode 100644 index ebe45310b7..0000000000 --- a/tx-backend/src/main/resources/db/migration/V27__asset_as_planned_tables.sql +++ /dev/null @@ -1,55 +0,0 @@ -ALTER TABLE assets_as_built - add column classification varchar(255); - -create table assets_as_planned -( - id varchar(255) not null, - customer_part_id varchar(255), - id_short varchar(255), - manufacturer_part_id varchar(255), - name_at_customer varchar(255), - name_at_manufacturer varchar(255), - quality_type integer, - classification varchar(255), - owner integer, - semantic_data_model integer, - in_investigation boolean not null default (false), - active_alert boolean NOT NULL default (false), - primary key (id) -); - -create table assets_as_planned_childs -( - asset_as_planned_id varchar(255) not null, - id varchar(255), - id_short varchar(255) -); - -create table assets_as_planned_alerts -( - alert_id int8 not null, - asset_id varchar(255) not null -); - -create table assets_as_planned_investigations -( - investigation_id int8 not null, - asset_id varchar(255) not null -); - -create table asset_as_planned_alert_notifications -( - alert_notification_id varchar(255) not null, - asset_id varchar(255) not null -); - -create table assets_as_planned_notifications -( - notification_id varchar(255) not null, - asset_id varchar(255) not null -); - - - - - diff --git a/tx-backend/src/main/resources/db/migration/V28__adapt_investigation_and_alert.sql b/tx-backend/src/main/resources/db/migration/V28__adapt_investigation_and_alert.sql deleted file mode 100644 index 474ada2c4f..0000000000 --- a/tx-backend/src/main/resources/db/migration/V28__adapt_investigation_and_alert.sql +++ /dev/null @@ -1,5 +0,0 @@ -alter table if exists investigation - add column error_message varchar(255); - -alter table if exists alert - add column error_message varchar(255); diff --git a/tx-backend/src/main/resources/db/migration/V29__drop_registry_lookup_metrics.sql b/tx-backend/src/main/resources/db/migration/V29__drop_registry_lookup_metrics.sql deleted file mode 100644 index 10f249ebef..0000000000 --- a/tx-backend/src/main/resources/db/migration/V29__drop_registry_lookup_metrics.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE registry_lookup_metrics; diff --git a/tx-backend/src/main/resources/db/migration/V2__asset_tables.sql b/tx-backend/src/main/resources/db/migration/V2__asset_tables.sql deleted file mode 100644 index a82c434686..0000000000 --- a/tx-backend/src/main/resources/db/migration/V2__asset_tables.sql +++ /dev/null @@ -1,41 +0,0 @@ -create table asset -( - id varchar(255) not null, - customer_part_id varchar(255), - id_short varchar(255), - manufacturer_id varchar(255), - manufacturer_name varchar(255), - manufacturer_part_id varchar(255), - manufacturing_country varchar(255), - manufacturing_date timestamp, - name_at_customer varchar(255), - name_at_manufacturer varchar(255), - quality_type integer, - supplier_part boolean not null default (true), - batch_id varchar(255), - part_instance_id varchar(255), - primary key (id) -); - -create table asset_child_descriptors -( - asset_entity_id varchar(255) not null, - id varchar(255), - id_short varchar(255) -); - -alter table if exists asset_child_descriptors add constraint fk_asset foreign key (asset_entity_id) references asset; - -create table shell_descriptor -( - id int8 generated by default as identity, - created timestamptz not null, - updated timestamptz not null, - shell_descriptor_id text not null unique, - global_asset_id text not null unique, - batch_id VARCHAR(255), - id_short VARCHAR(255), - part_instance_id VARCHAR(255), - manufacturer_part_id VARCHAR(255), - manufacturer_id VARCHAR(255) -); diff --git a/tx-backend/src/main/resources/db/migration/V30__drop_and_reset_shell_descriptors.sql b/tx-backend/src/main/resources/db/migration/V30__drop_and_reset_shell_descriptors.sql deleted file mode 100644 index 2aeb24a449..0000000000 --- a/tx-backend/src/main/resources/db/migration/V30__drop_and_reset_shell_descriptors.sql +++ /dev/null @@ -1,9 +0,0 @@ -DROP TABLE shell_descriptor; - -CREATE TABLE shell_descriptor -( - id SERIAL PRIMARY KEY, - created TIMESTAMPTZ NOT NULL, - updated TIMESTAMPTZ NOT NULL, - global_asset_id TEXT NOT NULL UNIQUE -); diff --git a/tx-backend/src/main/resources/db/migration/V31__add_field_to_asset_as_planned.sql b/tx-backend/src/main/resources/db/migration/V31__add_field_to_asset_as_planned.sql deleted file mode 100644 index fbabfa337e..0000000000 --- a/tx-backend/src/main/resources/db/migration/V31__add_field_to_asset_as_planned.sql +++ /dev/null @@ -1,20 +0,0 @@ -alter table if exists assets_as_planned - add column validity_period_from varchar (255); - -alter table if exists assets_as_planned - add column validity_period_to varchar (255); - -alter table if exists assets_as_planned - add column function_valid_until varchar (255); - -alter table if exists assets_as_planned - add column function_valid_from varchar (255); - -alter table if exists assets_as_planned - add column function varchar (255); - -alter table if exists assets_as_planned - add column manufacturer_name varchar (255); - -alter table if exists assets_as_planned - add column van varchar (255); diff --git a/tx-backend/src/main/resources/db/migration/V32__add_field_to_asset_as_planned.sql b/tx-backend/src/main/resources/db/migration/V32__add_field_to_asset_as_planned.sql deleted file mode 100644 index 8101202ada..0000000000 --- a/tx-backend/src/main/resources/db/migration/V32__add_field_to_asset_as_planned.sql +++ /dev/null @@ -1,10 +0,0 @@ -alter table if exists assets_as_planned - add column semantic_model_id varchar (255); - -alter table if exists assets_as_planned -drop -column name_at_customer; - -alter table if exists assets_as_planned -drop -column customer_part_id; diff --git a/tx-backend/src/main/resources/db/migration/V33__change_asset_enums_to_be_varchar.sql b/tx-backend/src/main/resources/db/migration/V33__change_asset_enums_to_be_varchar.sql deleted file mode 100644 index e0d9b2c3e3..0000000000 --- a/tx-backend/src/main/resources/db/migration/V33__change_asset_enums_to_be_varchar.sql +++ /dev/null @@ -1,12 +0,0 @@ -ALTER TABLE assets_as_built - ALTER COLUMN owner SET DATA TYPE VARCHAR(50); -ALTER TABLE assets_as_built - ALTER COLUMN quality_type SET DATA TYPE VARCHAR(50); -ALTER TABLE assets_as_built - ALTER COLUMN semantic_data_model SET DATA TYPE VARCHAR(50); -ALTER TABLE assets_as_planned - ALTER COLUMN owner SET DATA TYPE VARCHAR(50); -ALTER TABLE assets_as_planned - ALTER COLUMN quality_type SET DATA TYPE VARCHAR(50); -ALTER TABLE assets_as_planned - ALTER COLUMN semantic_data_model SET DATA TYPE VARCHAR(50); diff --git a/tx-backend/src/main/resources/db/migration/V34__cleanup-bpn-mappings.sql b/tx-backend/src/main/resources/db/migration/V34__cleanup-bpn-mappings.sql deleted file mode 100644 index a7b3825ef8..0000000000 --- a/tx-backend/src/main/resources/db/migration/V34__cleanup-bpn-mappings.sql +++ /dev/null @@ -1,5 +0,0 @@ -DELETE FROM public.bpn_edc_mappings -WHERE bpn = 'BPNL00000003CML1'; - -DELETE FROM public.bpn_edc_mappings -WHERE bpn = 'BPNL00000003CNKC'; diff --git a/tx-backend/src/main/resources/db/migration/V35__change-notification-enums-to-be-varchar.sql b/tx-backend/src/main/resources/db/migration/V35__change-notification-enums-to-be-varchar.sql deleted file mode 100644 index 4f0d431929..0000000000 --- a/tx-backend/src/main/resources/db/migration/V35__change-notification-enums-to-be-varchar.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE alert - ALTER COLUMN side SET DATA TYPE VARCHAR(50); -ALTER TABLE alert - ALTER COLUMN status SET DATA TYPE VARCHAR(50); -ALTER TABLE investigation - ALTER COLUMN side SET DATA TYPE VARCHAR(50); -ALTER TABLE investigation - ALTER COLUMN status SET DATA TYPE VARCHAR(50); diff --git a/tx-backend/src/main/resources/db/migration/V36__remove-bpn-edc-mappings.sql b/tx-backend/src/main/resources/db/migration/V36__remove-bpn-edc-mappings.sql deleted file mode 100644 index bf290459f3..0000000000 --- a/tx-backend/src/main/resources/db/migration/V36__remove-bpn-edc-mappings.sql +++ /dev/null @@ -1,12 +0,0 @@ -DROP TABLE bpn_edc_mappings; -DROP TABLE bpn_storage; -CREATE TABLE bpn_storage -( - manufacturer_id VARCHAR(255) NOT NULL, - manufacturer_name VARCHAR(255), - url VARCHAR(255), - created timestamptz, - updated timestamptz, - PRIMARY KEY(manufacturer_id), - UNIQUE(url) -); diff --git a/tx-backend/src/main/resources/db/migration/V37__add_catenaxSiteId_to_assets_as_planned.sql b/tx-backend/src/main/resources/db/migration/V37__add_catenaxSiteId_to_assets_as_planned.sql deleted file mode 100644 index 59fa395eea..0000000000 --- a/tx-backend/src/main/resources/db/migration/V37__add_catenaxSiteId_to_assets_as_planned.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE assets_as_planned - ADD COLUMN catenax_site_id varchar(255); diff --git a/tx-backend/src/main/resources/db/migration/V38__add_traction_battery_code_subcomponent_table.sql b/tx-backend/src/main/resources/db/migration/V38__add_traction_battery_code_subcomponent_table.sql deleted file mode 100644 index 8a3e098d98..0000000000 --- a/tx-backend/src/main/resources/db/migration/V38__add_traction_battery_code_subcomponent_table.sql +++ /dev/null @@ -1,12 +0,0 @@ -create table traction_battery_code_subcomponent -( - traction_battery_code varchar(255) not null, - subcomponent_traction_battery_code varchar(255) not null, - product_type varchar(255) -); - -ALTER TABLE assets_as_built - add column product_type varchar(255); - -ALTER TABLE assets_as_built - add column traction_battery_code varchar(255); diff --git a/tx-backend/src/main/resources/db/migration/V39__rename_entity_to_suite_domain_model.sql b/tx-backend/src/main/resources/db/migration/V39__rename_entity_to_suite_domain_model.sql deleted file mode 100644 index a4d32dd993..0000000000 --- a/tx-backend/src/main/resources/db/migration/V39__rename_entity_to_suite_domain_model.sql +++ /dev/null @@ -1,20 +0,0 @@ -ALTER TABLE alert_notification - RENAME COLUMN sender_bpn_number TO created_by; -ALTER TABLE alert_notification - RENAME COLUMN sender_manufacturer_name TO created_by_name; -ALTER TABLE alert_notification - RENAME COLUMN receiver_bpn_number TO send_to; -ALTER TABLE alert_notification - RENAME COLUMN receiver_manufacturer_name TO send_to_name; - -ALTER TABLE investigation_notification - RENAME COLUMN sender_bpn_number TO created_by; -ALTER TABLE investigation_notification - RENAME COLUMN sender_manufacturer_name TO created_by_name; -ALTER TABLE investigation_notification - RENAME COLUMN receiver_bpn_number TO send_to; -ALTER TABLE investigation_notification - RENAME COLUMN receiver_manufacturer_name TO send_to_name; - - - diff --git a/tx-backend/src/main/resources/db/migration/V3__bpn_storage_table.sql b/tx-backend/src/main/resources/db/migration/V3__bpn_storage_table.sql deleted file mode 100644 index 04cb8e14ed..0000000000 --- a/tx-backend/src/main/resources/db/migration/V3__bpn_storage_table.sql +++ /dev/null @@ -1,16 +0,0 @@ -create table bpn_storage -( - manufacturer_id varchar(255) not null, - manufacturer_name varchar(255) not null, - primary key (manufacturer_id) -); - -insert into bpn_storage values('BPNL00000000BJTL', 'Sub Tier C'); -insert into bpn_storage values('BPNL00000003AXS3', 'Sub Tier B'); -insert into bpn_storage values('BPNL00000003AYRE', 'OEM A'); -insert into bpn_storage values('BPNL00000003AZQP', 'OEM C'); -insert into bpn_storage values('BPNL00000003B0Q0', 'N-Tier A'); -insert into bpn_storage values('BPNL00000003B2OM', 'Tier A'); -insert into bpn_storage values('BPNL00000003B3NX', 'Sub Tier A'); -insert into bpn_storage values('BPNL00000003B5MJ', 'Tier B'); -insert into bpn_storage values('BPNL00000003CSGV', 'Tier C'); diff --git a/tx-backend/src/main/resources/db/migration/V40__submodel_entity.sql b/tx-backend/src/main/resources/db/migration/V40__submodel_entity.sql deleted file mode 100644 index cf489be5b4..0000000000 --- a/tx-backend/src/main/resources/db/migration/V40__submodel_entity.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE submodel -( - id VARCHAR(255) NOT NULL, - submodel VARCHAR, - PRIMARY KEY (id) -); diff --git a/tx-backend/src/main/resources/db/migration/V4__registry_lookup_metrics_table.sql b/tx-backend/src/main/resources/db/migration/V4__registry_lookup_metrics_table.sql deleted file mode 100644 index cfe753abe8..0000000000 --- a/tx-backend/src/main/resources/db/migration/V4__registry_lookup_metrics_table.sql +++ /dev/null @@ -1,10 +0,0 @@ -create table registry_lookup_metrics -( - id int8 generated by default as identity, - status int4, - start_date timestamp, - end_date timestamp, - success_shell_descriptors_fetch_count int8, - failed_shell_descriptors_fetch_count int8, - primary key (id) -); diff --git a/tx-backend/src/main/resources/db/migration/V5__notification_tables.sql b/tx-backend/src/main/resources/db/migration/V5__notification_tables.sql deleted file mode 100644 index ae63c40dfc..0000000000 --- a/tx-backend/src/main/resources/db/migration/V5__notification_tables.sql +++ /dev/null @@ -1,47 +0,0 @@ -create table assets_investigations -( - investigation_id int8 not null, - asset_id varchar(255) not null -); - -create table assets_notifications -( - notification_id varchar(255) not null, - asset_id varchar(255) not null -); - -create table investigation -( - id int8 generated by default as identity, - bpn varchar(255), - close_reason varchar(255), - created timestamp, - description varchar(255), - status int4, - updated timestamp, - primary key (id) -); - -create table notification -( - id varchar(255) not null, - contract_agreement_id varchar(255), - edc_url varchar(255), - notification_reference_id varchar(255), - receiver_bpn_number varchar(255), - sender_bpn_number varchar(255), - investigation_id int8, - primary key (id) -); - -alter table if exists assets_investigations - add constraint fk_asset_entity foreign key (asset_id) references asset; - -alter table if exists assets_investigations - add constraint fk_investigation foreign key (investigation_id) references investigation; - -alter table if exists assets_notifications - add constraint fk_notification foreign key (notification_id) references notification; - -alter table if exists notification - add constraint fk_investigation foreign key (investigation_id) references investigation; diff --git a/tx-backend/src/main/resources/db/migration/V6__alter_investigation_table.sql b/tx-backend/src/main/resources/db/migration/V6__alter_investigation_table.sql deleted file mode 100644 index 9b13bfcc98..0000000000 --- a/tx-backend/src/main/resources/db/migration/V6__alter_investigation_table.sql +++ /dev/null @@ -1,8 +0,0 @@ -alter table if exists investigation - add column side int4; - -alter table if exists investigation - add column accept_reason varchar(255); - -alter table if exists investigation - add column decline_reason varchar(255); diff --git a/tx-backend/src/main/resources/db/migration/V7__alter_asset_table.sql b/tx-backend/src/main/resources/db/migration/V7__alter_asset_table.sql deleted file mode 100644 index 16227d3fde..0000000000 --- a/tx-backend/src/main/resources/db/migration/V7__alter_asset_table.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table if exists asset - add column van varchar(255); diff --git a/tx-backend/src/main/resources/db/migration/V8__alter_notification_table.sql b/tx-backend/src/main/resources/db/migration/V8__alter_notification_table.sql deleted file mode 100644 index ac314fc8c1..0000000000 --- a/tx-backend/src/main/resources/db/migration/V8__alter_notification_table.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table if exists notification - add column target_date timestamp; diff --git a/tx-backend/src/main/resources/db/migration/V9__alter_notification_table_add_severity.sql b/tx-backend/src/main/resources/db/migration/V9__alter_notification_table_add_severity.sql deleted file mode 100644 index db08b8d8db..0000000000 --- a/tx-backend/src/main/resources/db/migration/V9__alter_notification_table_add_severity.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table if exists notification - add column severity int4; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerFilteringIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerFilteringIT.java index 66b2294531..6b7d93be8e 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerFilteringIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerFilteringIT.java @@ -311,6 +311,6 @@ void givenSemanticDataModelAsMultipleValuesAndOwnerOR_whenCallFilteredEndpoint_t .then() .log().all() .statusCode(200) - .body("totalItems", equalTo(12)); + .body("totalItems", equalTo(12)).extract().response(); } }