Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/itemstock #108

Merged
merged 36 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7279d5a
feat: initial commit
eschrewe Nov 29, 2023
b991afc
Merge branch 'refactor/merge_0.5.x_with_security_feat_branch' into fe…
eschrewe Nov 29, 2023
b21077d
feat: added itemstocktest
eschrewe Dec 1, 2023
e7d73d7
Merge branch 'refactor/migrate_to_edc_0.5.x' into feat/itemstock
eschrewe Dec 1, 2023
be348f6
fix: some fixes
eschrewe Dec 4, 2023
11840a1
fix: fixed itemstockservicetest
eschrewe Dec 4, 2023
825ac78
feat: added itemstocksamm and tests
eschrewe Dec 5, 2023
5ceb429
chore: added license headers
eschrewe Dec 5, 2023
0dea5e0
Merge branch 'main' into feat/itemstock
eschrewe Dec 5, 2023
65144e1
chore: edited commandlinerunner
eschrewe Dec 5, 2023
9f2147f
chore: updated dependencies
eschrewe Dec 5, 2023
76eaff8
chore: updated dependencies
eschrewe Dec 5, 2023
6074394
fix: removed esmf dependencies
eschrewe Dec 6, 2023
d9fd0a8
Merge branch 'main' into feat/itemstock
eschrewe Dec 6, 2023
36f19d5
Merge branch 'feat/itemstock' into feat/unittest_for_itemstock
eschrewe Dec 6, 2023
0046fa1
fix: some cleanup
eschrewe Dec 6, 2023
246346a
Merge branch 'feat/itemstock' into feat/unittest_for_itemstock
eschrewe Dec 6, 2023
7b7b561
fix: removed jsoncreator
eschrewe Dec 6, 2023
9d5e58d
Merge branch 'feat/itemstock' into feat/unittest_for_itemstock
eschrewe Dec 6, 2023
e75617c
chore: removed tests
eschrewe Dec 6, 2023
4028672
Merge branch 'feat/itemstock' into feat/unittest_for_itemstock
eschrewe Dec 6, 2023
dcc7e4b
feat: added tests
eschrewe Dec 6, 2023
3f44f45
chore: updated dependencies
eschrewe Dec 6, 2023
e6d7156
fix: itemstock now contains partner and material
eschrewe Dec 6, 2023
d177469
fix: edited license headers as ordered
eschrewe Dec 6, 2023
726d28f
fix: validation check generates more verbose output
eschrewe Dec 6, 2023
5a2fd2e
feat: current working status
eschrewe Dec 13, 2023
23c66ed
refactor: refactored itemstock and its variants
eschrewe Dec 18, 2023
82842ea
Merge branch 'main' into feat/itemstock
eschrewe Dec 19, 2023
44d819b
refactor: itemstock and its variants
eschrewe Dec 19, 2023
847ac7b
chore: added license headers
eschrewe Dec 19, 2023
06ab397
chore: merge main
eschrewe Dec 19, 2023
d64008e
feat: added regex check for bpns/bpna
eschrewe Dec 19, 2023
3ddc489
feat: added itemstocksamm mapper
eschrewe Dec 19, 2023
903b2a9
fix: fixed material identification logic and minor other fixes
eschrewe Dec 19, 2023
7299ab9
Merge branch 'main' into feat/itemstock
tom-rm-meyer-ISST Dec 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@
import org.eclipse.tractusx.puris.backend.stock.domain.model.*;
import org.eclipse.tractusx.puris.backend.stock.domain.model.measurement.MeasurementUnit;
import org.eclipse.tractusx.puris.backend.stock.logic.adapter.ProductStockSammMapper;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm.ItemUnitEnumeration;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.LocationIdTypeEnum;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.ProductStockSammDto;
import org.eclipse.tractusx.puris.backend.stock.logic.service.MaterialStockService;
import org.eclipse.tractusx.puris.backend.stock.logic.service.PartnerProductStockService;
import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockRequestService;
import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockService;
import org.eclipse.tractusx.puris.backend.stock.logic.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -70,6 +68,11 @@
@Autowired
private ProductStockService productStockService;

@Autowired
private MaterialItemStockService materialItemStockService;
@Autowired
private ReportedMaterialItemStockService reportedMaterialItemStockService;

@Autowired
private PartnerProductStockService partnerProductStockService;

Expand Down Expand Up @@ -113,7 +116,7 @@
*/
private void createOwnPartnerEntity() {
Partner mySelf;
if(variablesService.getOwnDefaultBpns()!= null && variablesService.getOwnDefaultBpns().length()!=0) {
if (variablesService.getOwnDefaultBpns() != null && variablesService.getOwnDefaultBpns().length() != 0) {
mySelf = new Partner(variablesService.getOwnName(),
variablesService.getEdcProtocolUrl(),
variablesService.getOwnBpnl(),
Expand All @@ -134,8 +137,8 @@
);
}
mySelf = partnerService.create(mySelf);
log.info("Successfully created own Partner Entity: " + (partnerService.findByBpnl(mySelf.getBpnl()) != null));

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
mySelf
may be null at this access as suggested by
this
null guard.
if(mySelf != null) {
if (mySelf != null) {
log.info(mySelf.toString());
}
}
Expand Down Expand Up @@ -219,6 +222,34 @@
log.info("SAMM-DTO:\n" + objectMapper.writeValueAsString(productStockSammDto));

log.info("Own Street and Number: " + variablesService.getOwnDefaultStreetAndNumber());
Partner mySelf = partnerService.getOwnPartnerEntity();
var builder = MaterialItemStock.builder();
var materialItemStock = builder.partner(supplierPartner)
.material(semiconductorMaterial)
.lastUpdatedOnDateTime(new Date())
.locationBpna(mySelf.getSites().first().getAddresses().first().getBpna())
.locationBpns(mySelf.getSites().first().getBpns())
.measurementUnit(ItemUnitEnumeration.UNIT_PIECE)
.quantity(20)
.build();
var createdMaterialItemStock = materialItemStockService.create(materialItemStock);
log.info("Created MaterialItemStock: \n" + createdMaterialItemStock.toString());

var builder2 = ReportedMaterialItemStock.builder();
var reportedMaterialItemStock =
builder2
.material(semiconductorMaterial)
.partner(supplierPartner)
.lastUpdatedOnDateTime(new Date())
.locationBpns(supplierPartner.getSites().first().getBpns())
.locationBpna(supplierPartner.getSites().first().getAddresses().first().getBpna())
.measurementUnit(ItemUnitEnumeration.UNIT_PIECE)
.quantity(50)
.build();

var createdReportedMaterialItemStock = reportedMaterialItemStockService.create(reportedMaterialItemStock);
log.info("Created ReportedMaterialItemStock: \n" + createdReportedMaterialItemStock);

}

/**
Expand Down Expand Up @@ -266,7 +297,6 @@
"bpnl: %s", foundProductStocks));
}


/**
* creates a new customer Partner entity, stores it to
* the database and returns this entity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
@ToString
public class Address implements Comparable<Address> {

public static final String BPNA_REGEX = "^BPNA[0-9a-zA-Z]{12}$";
/**
* The BPNA of this Address.
*/
@Pattern(regexp = "^BPNA[0-9a-zA-Z]{12}$")
@Pattern(regexp = BPNA_REGEX)
private String bpna;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
@Setter
@ToString
public class Site implements Comparable<Site> {

public static final String BPNS_REGEX = "^BPNS[0-9a-zA-Z]{12}$";
@Id
@NotNull
/**
* The BPNS of this Site.
*/
@Pattern(regexp = "^BPNS[0-9a-zA-Z]{12}$")
@Pattern(regexp = BPNS_REGEX)
private String bpns;
/**
* A human-readable, distinctive name of this site.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2023 Volkswagen AG
* 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.puris.backend.stock.domain.model;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Address;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Site;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm.ItemUnitEnumeration;

import java.util.Date;
import java.util.UUID;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@SuperBuilder
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Entity
@ToString
public abstract class ItemStock {

static final String ORDER_ID_REGEX = "^[a-zA-Z0-9\\-\\.]{1,255}$";

@Id
@GeneratedValue
protected UUID uuid;

@ManyToOne()
@JoinColumn(name = "partner_uuid")
@ToString.Exclude
@NotNull
protected Partner partner;
@ManyToOne()
@JoinColumn(name = "material_ownMaterialNumber")
@ToString.Exclude
@NotNull
protected Material material;

protected double quantity;
@NotNull
protected ItemUnitEnumeration measurementUnit;
@NotNull
@Pattern(regexp = Address.BPNA_REGEX)
protected String locationBpna;
@NotNull
@Pattern(regexp = Site.BPNS_REGEX)
protected String locationBpns;
@NotNull
protected Date lastUpdatedOnDateTime;

protected boolean isBlocked;
@Pattern(regexp = ORDER_ID_REGEX)
protected String supplierOrderId;
@Pattern(regexp = ORDER_ID_REGEX)
protected String customerOrderId;
@Pattern(regexp = ORDER_ID_REGEX)
protected String customerOrderPositionId;

@ToString.Include
private String material_ownMaterialNumber(){
return material.getOwnMaterialNumber();
}

@ToString.Include
private String partner_partnerBpnl(){
return partner.getBpnl();
}

}



Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2023 Volkswagen AG
* 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.puris.backend.stock.domain.model;

import jakarta.persistence.Entity;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

@Entity
@SuperBuilder
@NoArgsConstructor
@ToString(callSuper = true)
public class MaterialItemStock extends ItemStock {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2023 Volkswagen AG
* 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.puris.backend.stock.domain.model;

import jakarta.persistence.Entity;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

@Entity
@SuperBuilder
@NoArgsConstructor
@ToString(callSuper = true)
public class ProductItemStock extends ItemStock {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2023 Volkswagen AG
* 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.puris.backend.stock.domain.model;

import jakarta.persistence.Entity;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

@Entity
@SuperBuilder
@NoArgsConstructor
@ToString(callSuper = true)
public class ReportedMaterialItemStock extends ItemStock {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2023 Volkswagen AG
* 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.puris.backend.stock.domain.model;

import jakarta.persistence.Entity;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

@Entity
@SuperBuilder
@NoArgsConstructor
@ToString(callSuper = true)
public class ReportedProductItemStock extends ItemStock {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2023 Volkswagen AG
* 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.puris.backend.stock.domain.repository;

import org.eclipse.tractusx.puris.backend.stock.domain.model.MaterialItemStock;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.UUID;
@Repository
public interface MaterialItemStockRepository extends JpaRepository<MaterialItemStock, UUID> {
}
Loading
Loading