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

Add factories #64

Merged
merged 5 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -312,7 +312,7 @@ private void setUpTableToolbarListeners() {
}
});
tableToolbarController.getDeleteSelectedRowsButton().setOnAction(e -> openConfirmDeleteDialog(selectedRowsIndices));
tableToolbarController.getCreateNewOrderButton().setOnAction(e -> addNewOrder());
tableToolbarController.getCreateNewShipmentButton().setOnAction(e -> addNewOrder());
}

private void setUpConfirmDialogListeners() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private void setUpTableToolbarListeners() {
}
});
tableToolbarController.getDeleteSelectedRowsButton().setOnAction(e -> openConfirmDeleteDialog(selectedRowsIndices));;
tableToolbarController.getCreateNewOrderButton().setOnAction(e -> addNewOrder());
tableToolbarController.getCreateNewShipmentButton().setOnAction(e -> addNewOrder());
}

private void setUpConfirmDialogListeners() {
Expand Down Expand Up @@ -569,6 +569,7 @@ private void handleUpdateOrders(List<FactoryInventoryItem> FactoryInventoryItems

private UpdateFactoryInventoryItemDTO getUpdateFactoryInventoryItemDTO(FactoryInventoryItem item) {
UpdateFactoryInventoryItemDTO updateFactoryInventoryItemDTO = new UpdateFactoryInventoryItemDTO();
updateFactoryInventoryItemDTO.setOrganizationId(factory.getOrganizationId());
updateFactoryInventoryItemDTO.setId(item.getId());
updateFactoryInventoryItemDTO.setComponentId(item.getComponent().getId());
updateFactoryInventoryItemDTO.setProductId(item.getProduct().getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class UpdateFactoryInventoryItemDTO {

private Integer id;
private Integer organizationId;
private Integer factoryId;
private Integer productId;
private Integer componentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private void setUpTableToolbarListeners() {
}
});
tableToolbarController.getDeleteSelectedRowsButton().setOnAction(e -> openConfirmDeleteDialog(selectedRowsIndices));
tableToolbarController.getCreateNewOrderButton().setOnAction(e -> addNewOrder());
tableToolbarController.getCreateNewShipmentButton().setOnAction(e -> addNewOrder());
}

private void setUpConfirmDialogListeners() {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
package org.chainoptim.desktop.features.supplier.dto;

import org.chainoptim.desktop.shared.enums.ShipmentStatus;
import org.chainoptim.desktop.shared.features.location.model.Location;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.chainoptim.desktop.shared.features.location.model.Location;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CreateSupplierShipmentDTO {

private Integer organizationId;
private Integer supplierId;
private Integer supplierOrderId;
private String companyId;
private Integer componentId;
private String componentName;
private Float quantity;
private Float deliveredQuantity;
private LocalDateTime shipmentStartingDate;
private LocalDateTime estimatedArrivalDate;
private LocalDateTime arrivalDate;
private ShipmentStatus status;
private Integer sourceLocationId;
private Integer destinationLocationId;
private Location sourceLocation;
private Location destinationLocation;
private Float currentLocationLatitude;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
package org.chainoptim.desktop.features.supplier.dto;

<<<<<<< HEAD
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

=======
import org.chainoptim.desktop.shared.enums.ShipmentStatus;
import org.chainoptim.desktop.shared.features.location.model.Location;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpdateSupplierShipmentDTO {
<<<<<<< HEAD

=======
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af
private Integer id;
private Integer organizationId;
private Integer supplierOrderId;
private Float quantity;
private LocalDateTime shipmentStartingDate;
private LocalDateTime estimatedArrivalDate;
private LocalDateTime arrivalDate;
<<<<<<< HEAD
private String status;
private Integer sourceLocationId;
private Integer destinationLocationId;
=======
private ShipmentStatus status;
private Location sourceLocation;
private Location destinationLocation;
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af
private Float currentLocationLatitude;
private Float currentLocationLongitude;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

import org.chainoptim.desktop.shared.enums.ShipmentStatus;
import org.chainoptim.desktop.shared.features.location.model.Location;
<<<<<<< HEAD
import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SupplierShipment {

private Integer id;
private Integer supplierOrderId;
private String companyId;
private Integer componentId;
private String componentName;
private Float quantity;
private Float deliveredQuantity;
=======
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -30,6 +50,7 @@ public SupplierShipment(SupplierShipment data) {
private Integer id;
private Integer supplierOrderId;
private Float quantity;
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af
private LocalDateTime shipmentStartingDate;
private LocalDateTime estimatedArrivalDate;
private LocalDateTime arrivalDate;
Expand All @@ -39,4 +60,33 @@ public SupplierShipment(SupplierShipment data) {
private Location destinationLocation;
private Float currentLocationLatitude;
private Float currentLocationLongitude;
}
<<<<<<< HEAD
private Integer organizationId;
private Integer supplierId;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;

public SupplierShipment deepCopy() {
return SupplierShipment.builder()
// .id(this.id)
.createdAt(this.createdAt)
.updatedAt(this.updatedAt)
.supplierOrderId(this.supplierOrderId)
.quantity(this.quantity)
.shipmentStartingDate(this.shipmentStartingDate)
.estimatedArrivalDate(this.estimatedArrivalDate)
.arrivalDate(this.arrivalDate)
.transporterType(this.transporterType)
.status(this.status)
.sourceLocation(this.sourceLocation)
.destinationLocation(this.destinationLocation)
.currentLocationLatitude(this.currentLocationLatitude)
.currentLocationLongitude(this.currentLocationLongitude)
.organizationId(this.organizationId)
.supplierId(this.supplierId)
.build();
}
}
=======
}
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public CompletableFuture<Result<PaginatedResults<SupplierShipment>>> getSupplier
String rootAddress = "http://localhost:8080/api/v1/";
String cacheKey = CacheKeyBuilder.buildAdvancedSearchKey(
"supplier-shipments",
searchMode == SearchMode.ORGANIZATION ? "organization" : "order", entityId.toString(),
searchMode == SearchMode.ORGANIZATION ? "organization" : "supplier", entityId.toString(),
searchParams);
String routeAddress = rootAddress + cacheKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.chainoptim.desktop.shared.search.model.PaginatedResults;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.inject.Inject;

import java.net.HttpURLConnection;
import java.net.http.HttpRequest;
import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -71,10 +73,13 @@ public CompletableFuture<Result<List<Integer>>> deleteSupplierShipmentInBulk(Lis
String routeAddress = "http://localhost:8080/api/v1/supplier-shipments/delete/bulk";

HttpRequest request = requestBuilder.buildWriteRequest(
HttpMethod.DELETE, routeAddress, tokenManager.getToken(), shipmentIds);
HttpMethod.PUT, routeAddress, tokenManager.getToken(), shipmentIds);

requestHandler.sendRequest(request, new TypeReference<>() {}, ids ->
cachingService.clear() // Invalidate cache
);

return CompletableFuture.completedFuture(new Result<>(shipmentIds, null, HttpURLConnection.HTTP_OK));

return requestHandler.sendRequest(request, new TypeReference<List<Integer>>() {}, ids -> {
cachingService.clear(); // Invalidate cache
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private void setUpTableToolbarListeners() {
}
});
tableToolbarController.getDeleteSelectedRowsButton().setOnAction(e -> openConfirmDeleteDialog(selectedRowsIndices));;
tableToolbarController.getCreateNewOrderButton().setOnAction(e -> addNewOrder());
tableToolbarController.getCreateNewShipmentButton().setOnAction(e -> addNewOrder());
}

private void setUpConfirmDialogListeners() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package org.chainoptim.desktop.shared.enums;

<<<<<<< HEAD
import org.chainoptim.desktop.shared.util.ShipmentStatusDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

@JsonDeserialize(using = ShipmentStatusDeserializer.class)
=======
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af
public enum ShipmentStatus {
INITIATED,
NEGOTIATED,
Expand All @@ -12,6 +19,10 @@ public String toString() {
return this.name().charAt(0) + this.name().substring(1).toLowerCase();
}

<<<<<<< HEAD

=======
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af
public static ShipmentStatus fromString(String statusStr) {
for (ShipmentStatus status : values()) {
if (status.name().equalsIgnoreCase(statusStr)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.chainoptim.desktop.shared.enums.Feature;
import org.chainoptim.desktop.shared.enums.SearchMode;
import org.chainoptim.desktop.shared.search.filters.FilterBar;
import org.chainoptim.desktop.shared.search.filters.FilterOption;
import org.chainoptim.desktop.shared.search.model.ListHeaderParams;
import org.chainoptim.desktop.shared.search.model.SearchParams;

Expand All @@ -17,7 +16,6 @@
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.util.Duration;

import lombok.Getter;
Expand Down Expand Up @@ -62,7 +60,7 @@ public class TableToolbarController {
@FXML @Getter
private Button saveChangesButton;
@FXML @Getter
private Button createNewOrderButton;
private Button createNewShipmentButton;

// Icons
private Image sortUpIcon;
Expand Down Expand Up @@ -94,7 +92,7 @@ public void initialize(ListHeaderParams headerParams) {
setDeleteSelectedRowsButton();
setEditSelectedRowsButton();
setSaveChangesButton();
setCreateNewOrderButton();
setCreateNewShipmentButton();

toggleButtonVisibilityOnCancel();
}
Expand Down Expand Up @@ -190,13 +188,13 @@ private void setSaveChangesButton() {
toggleButtonVisibility(saveChangesButton, false);
}

private void setCreateNewOrderButton() {
private void setCreateNewShipmentButton() {
ImageView plusImageView = createImageView(plusIcon, 14, 14);
ColorAdjust colorAdjust = new ColorAdjust();
colorAdjust.setBrightness(1);
plusImageView.setEffect(colorAdjust);
createNewOrderButton.setGraphic(plusImageView);
createNewOrderButton.setContentDisplay(ContentDisplay.LEFT);
createNewShipmentButton.setGraphic(plusImageView);
createNewShipmentButton.setContentDisplay(ContentDisplay.LEFT);
}

public void toggleButtonVisibilityOnSelection(boolean isSelection) {
Expand All @@ -212,7 +210,7 @@ public void toggleButtonVisibilityOnEdit(boolean isEditing) {
}

public void toggleButtonVisibilityOnCreate(boolean isNewOrderMode) {
toggleButtonVisibility(createNewOrderButton, isNewOrderMode);
toggleButtonVisibility(createNewShipmentButton, isNewOrderMode);
toggleButtonVisibility(saveChangesButton, isNewOrderMode);
toggleButtonVisibility(cancelRowSelectionButton, isNewOrderMode);
toggleButtonVisibility(deleteSelectedRowsButton, !isNewOrderMode);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.chainoptim.desktop.shared.util;

import org.chainoptim.desktop.shared.enums.ShipmentStatus;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;

public class ShipmentStatusDeserializer extends JsonDeserializer<ShipmentStatus> {
@Override
public ShipmentStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String statusStr = p.getText();
return ShipmentStatus.fromString(statusStr);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
<<<<<<< HEAD
fx:controller="org.chainoptim.desktop.features.supplier.controller.SupplierShipmentsController" >
=======
fx:controller="org.chainoptim.desktop.features.supplier.controller.SupplierShipmentsController">
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af

<!-- Header -->
<StackPane fx:id="tableToolbarContainer"/>
Expand All @@ -21,6 +22,17 @@
<columns>
<TableColumn fx:id="selectRowColumn" prefWidth="50"/>
<TableColumn text="Shipment ID" fx:id="shipmentIdColumn" minWidth="120"/>
<<<<<<< HEAD
<TableColumn text="Company ID" fx:id="companyIdColumn" minWidth="150"/>
<TableColumn text="Supplier" fx:id="supplierNameColumn" minWidth="150"/>
<TableColumn text="Component" fx:id="componentNameColumn" minWidth="150"/>
<TableColumn text="Quantity" fx:id="quantityColumn" minWidth="150"/>
<TableColumn text="Delivered Quantity" fx:id="deliveredQuantityColumn" minWidth="150"/>
<TableColumn text="Status" fx:id="statusColumn" minWidth="150"/>
<TableColumn text="Starting Date" fx:id="shipmentStartingDateColumn" minWidth="200"/>
<TableColumn text="Arrival Date" fx:id="arrivalDateColumn" minWidth="150"/>
<TableColumn text="Estimated Arrival Date" fx:id="estimatedArrivalDateColumn" minWidth="200"/>
=======
<TableColumn text="Supplier Order ID" fx:id="supplierOrderIdColumn" minWidth="150"/>
<TableColumn text="Quantity" fx:id="quantityColumn" minWidth="150"/>
<TableColumn text="Shipment Starting Date" fx:id="shipmentStartingDateColumn" minWidth="200"/>
Expand All @@ -32,6 +44,7 @@
<TableColumn text="Destination Location" fx:id="destinationLocationColumn" minWidth="200"/>
<TableColumn text="Current Location Latitude" fx:id="currentLocationLatitudeColumn" minWidth="220"/>
<TableColumn text="Current Location Longitude" fx:id="currentLocationLongitudeColumn" minWidth="220"/>
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af
</columns>
</TableView>
<StackPane fx:id="pageSelectorContainer" style="-fx-background-color: yellow;"/>
Expand All @@ -45,5 +58,9 @@
<StackPane fx:id="confirmDeleteDialogContainer" style="-fx-padding: 64px;"/>
<StackPane fx:id="confirmCreateDialogContainer" style="-fx-padding: 64px;"/>
</StackPane>
<<<<<<< HEAD
</VBox>
=======

</VBox>
>>>>>>> 7134550b09d6001d5ce347aaf8ec256d3aec77af
Loading
Loading