-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(chore):985 Fixed contractagreement view script.
- Loading branch information
1 parent
2ae3bf3
commit a3935fa
Showing
14 changed files
with
231 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...main/java/org/eclipse/tractusx/traceability/contracts/domain/model/ContractAgreement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2024 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.contracts.domain.model; | ||
|
||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.Id; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.eclipse.tractusx.traceability.contracts.infrastructure.model.ContractAgreementView; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
public class ContractAgreement { | ||
|
||
@Id | ||
private String id; | ||
private String contractAgreementId; | ||
@Enumerated(EnumType.STRING) | ||
private ContractType type; | ||
private Instant created; | ||
|
||
public static ContractAgreementView toEntity(ContractAgreement contractAgreement) { | ||
return ContractAgreementView.builder() | ||
.created(contractAgreement.getCreated()) | ||
.id(contractAgreement.getId()) | ||
.contractAgreementId(contractAgreement.getContractAgreementId()) | ||
.type(contractAgreement.getType()) | ||
.build(); | ||
} | ||
|
||
public static List<ContractAgreementView> toEntityList(List<ContractAgreement> contractAgreementList) { | ||
return contractAgreementList.stream().map(ContractAgreement::toEntity).toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 9 additions & 20 deletions
29
tx-backend/src/main/resources/db/migration/R__create_contract_agreement_view.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,10 @@ | ||
-- Drop the view if it exists | ||
DROP VIEW IF EXISTS contract_agreement_view; | ||
|
||
ALTER VIEW contract_agreement_view RENAME COLUMN asset_type TO type; | ||
|
||
CREATE OR REPLACE VIEW contract_agreement_view (id, contract_agreement_id, type, created) AS | ||
SELECT * | ||
FROM ( | ||
(SELECT assets_as_built.id, | ||
contract_agreement_id, | ||
'ASSET_AS_BUILT' AS type, | ||
created | ||
FROM assets_as_built | ||
WHERE contract_agreement_id IS NOT NULL) | ||
UNION ALL | ||
(SELECT assets_as_planned.id, | ||
contract_agreement_id, | ||
'ASSET_AS_PLANNED' AS type, | ||
created | ||
FROM assets_as_planned | ||
WHERE contract_agreement_id IS NOT NULL) | ||
) results | ||
ORDER BY created DESC; | ||
-- Create the table | ||
CREATE TABLE contract_agreement ( | ||
id varchar(255) PRIMARY KEY, | ||
contract_agreement_id varchar(255), | ||
type VARCHAR(255), | ||
created TIMESTAMP | ||
); |
Oops, something went wrong.