Skip to content

Commit

Permalink
Merge pull request #26 from catenax-ng/feature/DCMFOSS-67-copy2
Browse files Browse the repository at this point in the history
Statuses service for the Material Demand and Capacity Groups - 67
  • Loading branch information
carslen authored Oct 10, 2023
2 parents 84b1a45 + c9ba278 commit 7307473
Show file tree
Hide file tree
Showing 87 changed files with 5,467 additions and 1,094 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ target/

.idea/*

demand-capacity-mgmt-backend/.mvn/wrapper/maven-wrapper.jar
demand-capacity-mgmt-backend/.mvn/wrapper/maven-wrapper.jar
.env
keycloak/generate-secret.sh
keycloak/init-db.sql
keycloak/realm-export.json
2 changes: 1 addition & 1 deletion DEPENDENCIES_FRONTEND
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ npm/npmjs/-/flatted/3.2.7, ISC AND (ISC AND MIT), approved, #2430
npm/npmjs/-/flow-enums-runtime/0.0.5, MIT, approved, clearlydefined
npm/npmjs/-/flow-parser/0.206.0, MIT, approved, clearlydefined
npm/npmjs/-/flow-parser/0.209.0, MIT, approved, clearlydefined
npm/npmjs/-/follow-redirects/1.15.2, MIT, approved, clearlydefined
npm/npmjs/-/follow-redirects/1.15.2, MIT, approved, #10782
npm/npmjs/-/for-each/0.3.3, MIT, approved, clearlydefined
npm/npmjs/-/for-in/1.0.2, MIT, approved, clearlydefined
npm/npmjs/-/fork-ts-checker-webpack-plugin/6.5.3, MIT, approved, #7487
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* ******************************************************************************
* Copyright (c) 2023 BMW 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.demandcapacitymgmt.demandcapacitymgmtbackend.controllers;

import eclipse.tractusx.demand_capacity_mgmt_specification.api.CapacityGroupApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.CapacityGroupService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
public class CapacityGroupsController implements CapacityGroupApi {

private CapacityGroupService service;

@Override
public ResponseEntity<List<CapacityGroupDefaultViewResponse>> getCapacityGroups() {
List<CapacityGroupDefaultViewResponse> capacityGroupDefaultViewResponses = service.getAll();
return ResponseEntity.status(HttpStatus.OK).body(capacityGroupDefaultViewResponses);
}

@Override
public ResponseEntity<CapacityGroupResponse> getCapacityGroupById(String capacityGroupId) {
CapacityGroupResponse capacityGroupResponse = service.getCapacityGroupById(capacityGroupId);
return ResponseEntity.status(HttpStatus.OK).body(capacityGroupResponse);
}

@Override
public ResponseEntity<CapacityGroupResponse> postCapacityGroup(CapacityGroupRequest capacityGroupRequest) {
CapacityGroupResponse capacityGroupResponse = service.createCapacityGroup(capacityGroupRequest);
return ResponseEntity.status(HttpStatus.OK).body(capacityGroupResponse);
}

@Override
public ResponseEntity<Void> postLinkedCapacityGroupDemand(LinkCGDSRequest linkCGDSRequest) throws Exception {
service.linkCapacityGroupToMaterialDemand(linkCGDSRequest);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.controllers;

import eclipse.tractusx.demand_capacity_mgmt_specification.api.DemandApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.MaterialDemandRequest;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.MaterialDemandResponse;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.DemandService;
Expand Down Expand Up @@ -56,6 +55,23 @@ public ResponseEntity<List<MaterialDemandResponse>> getDemandsByProjectID() {
return ResponseEntity.status(HttpStatus.OK).body(demandResponseDtos);
}

@Override
public ResponseEntity<DemandSeriesCompositeResponse> getLinkedDemandSeriesByCompositeKeyID(
DemandSeriesCompositeRequest demandSeriesCompositeRequest
) throws Exception {
DemandSeriesCompositeResponse response = demandService.getAllDemandsByCompositeKey(
demandSeriesCompositeRequest
);
return ResponseEntity.status(HttpStatus.OK).body(response);
}

@Override
public ResponseEntity<Void> unlinkedDemandSeriesComposites(DemandSeriesUnlinkRequest demandSeriesUnlinkRequest)
throws Exception {
demandService.unlinkComposites(demandSeriesUnlinkRequest);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

@Override
public ResponseEntity<MaterialDemandResponse> postDemand(MaterialDemandRequest materialDemandRequest) {
MaterialDemandResponse responseDto = demandService.createDemand(materialDemandRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,36 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.controllers;

import eclipse.tractusx.demand_capacity_mgmt_specification.api.CapacityGroupApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.CapacityGroupDefaultViewResponse;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.CapacityGroupRequest;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.CapacityGroupResponse;
import eclipse.tractusx.demand_capacity_mgmt_specification.api.StatusesApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.StatusRequest;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.StatusesResponse;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.CapacityGroupService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.DemandService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.StatusesService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
public class CapacityGroupController implements CapacityGroupApi {
public class StatusesController implements StatusesApi {

private final CapacityGroupService capacityGroupService;
private final StatusesService statusesService;

@Override
public ResponseEntity<List<CapacityGroupDefaultViewResponse>> getCapacityGroup() {
List<CapacityGroupDefaultViewResponse> capacityGroupDefaultViewResponseList = capacityGroupService.getAll();
return ResponseEntity.status(HttpStatus.OK).body(capacityGroupDefaultViewResponseList);
public ResponseEntity<StatusesResponse> getStatuses() {
return ResponseEntity.status(HttpStatus.OK).body(statusesService.getAllStatuses());
}

@Override
public ResponseEntity<CapacityGroupResponse> getCapacityGroupById(String capacityGroupId) {
CapacityGroupResponse responseDto = capacityGroupService.getCapacityGroupById(capacityGroupId);
return ResponseEntity.status(HttpStatus.OK).body(responseDto);
public ResponseEntity<StatusesResponse> postStatus(StatusRequest statusRequest) {
StatusesResponse responseDto = statusesService.postStatuses(statusRequest);
return ResponseEntity.status(HttpStatus.CREATED).body(responseDto);
}

@Override
public ResponseEntity<CapacityGroupResponse> postCapacityGroup(CapacityGroupRequest capacityGroupRequest) {
CapacityGroupResponse capacityGroupResponse = capacityGroupService.createCapacityGroup(capacityGroupRequest);
return ResponseEntity.status(HttpStatus.OK).body(capacityGroupResponse);
public ResponseEntity<StatusesResponse> updateStatusesById(String statusId, StatusRequest statusRequest) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.controllers;

import eclipse.tractusx.demand_capacity_mgmt_specification.api.WeekBasedCapacityGroupApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupRequest;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.WeekBasedCapacityGroupService;
Expand All @@ -37,11 +37,29 @@ public class WeekBasedCapacityGroupController implements WeekBasedCapacityGroupA

private final WeekBasedCapacityGroupService weekBasedCapacityGroupService;

@Override
public ResponseEntity<List<WeekBasedCapacityGroupDtoResponse>> getWeekBasedCapacityGroup() {
List<WeekBasedCapacityGroupDtoResponse> capacityGroupDefaultViewResponseList = weekBasedCapacityGroupService.getWeekBasedCapacityGroups();
return ResponseEntity.status(HttpStatus.OK).body(capacityGroupDefaultViewResponseList);
}

@Override
public ResponseEntity<Void> postWeekBasedCapacityGroup(
List<WeekBasedCapacityGroupRequest> weekBasedCapacityGroupRequest
List<WeekBasedCapacityGroupDtoRequest> weekBasedCapacityGroupRequest
) {
weekBasedCapacityGroupService.createWeekBasedCapacityGroup(weekBasedCapacityGroupRequest);
return ResponseEntity.status(HttpStatus.OK).build();
}

@Override
public ResponseEntity<WeekBasedCapacityGroupDtoResponse> updateWeekBasedCapacityGroupById(
String weekBasedCapacityId,
WeekBasedCapacityGroupDtoRequest weekBasedCapacityGroupRequest
) {
WeekBasedCapacityGroupDtoResponse responseDto = weekBasedCapacityGroupService.updateWeekBasedCapacityGroup(
weekBasedCapacityId,
weekBasedCapacityGroupRequest
);
return ResponseEntity.status(HttpStatus.OK).body(responseDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import eclipse.tractusx.demand_capacity_mgmt_specification.api.WeekBasedMaterialDemandApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedMaterialDemandRequestDto;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedMaterialDemandResponseDto;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.WeekBasedMaterialService;
Expand All @@ -37,11 +38,29 @@ public class WeekBasedMaterialController implements WeekBasedMaterialDemandApi {

private final WeekBasedMaterialService weekBasedMaterialService;

@Override
public ResponseEntity<List<WeekBasedMaterialDemandResponseDto>> getWeekBasedMaterialDemand() {
List<WeekBasedMaterialDemandResponseDto> capacityGroupDefaultViewResponseList = weekBasedMaterialService.getWeekBasedMaterialDemands();
return ResponseEntity.status(HttpStatus.OK).body(capacityGroupDefaultViewResponseList);
}

@Override
public ResponseEntity<Void> postWeekBasedMaterialDemand(
List<WeekBasedMaterialDemandRequestDto> weekBasedMaterialDemandRequestDto
) {
weekBasedMaterialService.createWeekBasedMaterial(weekBasedMaterialDemandRequestDto);
return ResponseEntity.status(HttpStatus.OK).build();
}

@Override
public ResponseEntity<WeekBasedMaterialDemandResponseDto> updateWeekBasedMaterialDemandById(
String demandId,
WeekBasedMaterialDemandRequestDto weekBasedMaterialDemandRequestDto
) {
WeekBasedMaterialDemandResponseDto responseDto = weekBasedMaterialService.updateWeekBasedMaterial(
demandId,
weekBasedMaterialDemandRequestDto
);
return ResponseEntity.status(HttpStatus.OK).body(responseDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,16 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import lombok.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.converters.ListToStringConverter;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.CapacityGroupStatus;
import javax.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "capacity_group")
Expand All @@ -54,49 +46,26 @@ public class CapacityGroupEntity {
@Column(columnDefinition = "uuid", updatable = false, name = "id")
private UUID id;

@Column(columnDefinition = "uuid", updatable = false, name = "capacity_group_id")
private UUID capacityGroupId;
@Column(name = "capacity_group_name")
private String capacityGroupName;

@Column(name = "material_description_customer")
private String materialDescriptionCustomer;
@Column(name = "defaultactualcapacity")
private float defaultActualCapacity;

@Column(name = "material_number_customer")
private String materialNumberCustomer;
@Column(name = "defaultmaximumcapacity")
private float defaultMaximumCapacity;

@Column(name = "material_number_supplier")
private String materialNumberSupplier;
@Column(name = "start_date", nullable = false)
private LocalDate startDate;

@Column(name = "changed_at", nullable = false)
private LocalDateTime changedAt;
@Column(name = "end_date", nullable = false)
private LocalDate endDate;

@OneToOne
@JoinColumn(name = "customer_id", referencedColumnName = "ID")
private CompanyEntity customerId;
@JoinColumn(name = "customer", referencedColumnName = "ID")
private CompanyEntity customer;

@OneToOne
@JoinColumn(name = "supplier_id", referencedColumnName = "ID")
private CompanyEntity supplierId;

@OneToOne
@JoinColumn(name = "unity_of_measure_id", referencedColumnName = "ID")
private UnitMeasureEntity unitMeasure;

@OneToMany(mappedBy = "capacityGroupEntity", cascade = CascadeType.ALL)
@ToString.Exclude
private List<CapacityTimeSeries> capacityTimeSeries;

@OneToMany(mappedBy = "capacityGroupEntity", cascade = CascadeType.ALL)
@ToString.Exclude
private List<LinkedDemandSeries> linkedDemandSeries;

@Column(name = "supplier_locations")
@Convert(converter = ListToStringConverter.class)
private List<String> supplierLocation;

@Column(name = "name")
private String name;

@Column(name = "status")
@Enumerated(EnumType.STRING)
private CapacityGroupStatus status;
@JoinColumn(name = "supplier", referencedColumnName = "ID")
private CompanyEntity supplier;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,12 @@

package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import java.util.List;
import java.util.UUID;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import lombok.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.converters.ListToStringConverter;

@Entity
Expand All @@ -48,6 +36,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class DemandSeries {

@Id
Expand All @@ -74,6 +63,8 @@ public class DemandSeries {
@JoinColumn(name = "demand_series_id")
private List<DemandSeriesValues> demandSeriesValues;

@ToString.Exclude
@EqualsAndHashCode.Exclude
@ManyToOne(fetch = FetchType.LAZY)
private MaterialDemandEntity materialDemand;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
public class FavoriteEntity {

@Id
@GeneratedValue
@Column(columnDefinition = "uuid", updatable = false, name = "user_id")
private UUID id;

Expand Down
Loading

0 comments on commit 7307473

Please sign in to comment.