Skip to content

Commit

Permalink
minor fixes to LagerobjektErfassen & Forms, FreieLagerobjekte
Browse files Browse the repository at this point in the history
add trackingNo, remark field

FreieLagerobjekte: make Grid use full height.

Signed-off-by: Aleksandar Zivkovic <[email protected]>
  • Loading branch information
Aleksandar committed Feb 22, 2024
1 parent d168b8d commit a390758
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 147 deletions.
15 changes: 11 additions & 4 deletions src/main/java/com/samic/samic/components/form/CPEForm.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.samic.samic.components.form;

import com.samic.samic.components.UIFactory;
import com.samic.samic.data.entity.Customer;
import com.samic.samic.data.constants.ConstantsDomain;
import com.samic.samic.data.entity.ObjectType;
import com.samic.samic.data.entity.StorageObject;
import com.vaadin.flow.component.checkbox.Checkbox;
Expand All @@ -11,6 +11,7 @@
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.BeanValidationBinder;
import com.vaadin.flow.data.validator.StringLengthValidator;
import jakarta.annotation.PostConstruct;
import java.util.List;
import org.springframework.context.annotation.Scope;
Expand All @@ -28,14 +29,15 @@ public class CPEForm extends FormLayout {
private ComboBox<ObjectType> deviceType = new ComboBox<>("Gerätetyp");
private TextField macAdress = new TextField("MAC Adresse");
private TextField serialnumber = new TextField("Seriennummer");
private TextField remark = new TextField("Anmerkung");
private HorizontalLayout projectEquipmentContainer =
UIFactory.childContainer(
FlexComponent.JustifyContentMode.START, connectionNumber, trackingNumber);

@PostConstruct
private void initUI() {
macAdress.setRequired(true);
add(deviceType, macAdress, serialnumber, isProjectEquipment);
add(deviceType, macAdress, serialnumber, remark, isProjectEquipment);

isProjectEquipment.addValueChangeListener(
event -> {
Expand Down Expand Up @@ -73,6 +75,11 @@ private void initBinder() {
binderStorageObject.forField(isProjectEquipment)
.bind(StorageObject::getProjectDevice, StorageObject::setProjectDevice);

binderStorageObject.forField(remark)
.withValidator(new StringLengthValidator("Anmerkung zu lang! (max 55 Zeichen)", 0,
ConstantsDomain.DEFAULT_LENGTH))
.bind(StorageObject::getRemark, StorageObject::setRemark);

//TODO bind connectionNumber and trackingNumber
binderStorageObject.forField(connectionNumber)
.withNullRepresentation("")
Expand All @@ -81,8 +88,8 @@ private void initBinder() {
*/
.bind(StorageObject::getVerbindungsnummer, StorageObject::setVerbindungsnummer);

// binderStorageObject.forField(trackingNumber)
// .bind(StorageObject::getTrackingNumber, StorageObject::setTrackingNumber);
binderStorageObject.forField(trackingNumber)
.bind(StorageObject::getTrackingNo, StorageObject::setTrackingNo);

}

Expand Down
16 changes: 12 additions & 4 deletions src/main/java/com/samic/samic/components/form/SFPForm.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.samic.samic.components.form;

import com.samic.samic.components.UIFactory;
import com.samic.samic.data.constants.ConstantsDomain;
import com.samic.samic.data.entity.Customer;
import com.samic.samic.data.entity.ObjectType;
import com.samic.samic.data.entity.StorageObject;
import com.vaadin.flow.component.HasValue;
import com.vaadin.flow.component.checkbox.Checkbox;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
Expand All @@ -12,6 +14,7 @@
import com.vaadin.flow.component.textfield.IntegerField;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.validator.StringLengthValidator;
import jakarta.annotation.PostConstruct;
import java.util.List;
import org.springframework.context.annotation.Scope;
Expand All @@ -28,10 +31,11 @@ public class SFPForm extends FormLayout {
private final IntegerField nicSpeed = new IntegerField("NIC Speed Gbps");
private final Binder<StorageObject> binderStorageObject = new Binder<>(StorageObject.class, true);
private ComboBox<ObjectType> deviceType = new ComboBox<>("Gerätetyp");
private TextField serialnumber = new TextField("Seriennummer");
private final TextField serialnumber = new TextField("Seriennummer");
private HorizontalLayout projectEquipmentContainer =
UIFactory.childContainer(
FlexComponent.JustifyContentMode.START, connectionNumber, trackingNumber);
private final TextField remark = new TextField("Anmerkung");

@PostConstruct
private void initUI() {
Expand All @@ -41,6 +45,7 @@ private void initUI() {
serialnumber,
wavelength,
nicSpeed,
remark,
isProjectEquipment);

isProjectEquipment.addValueChangeListener(
Expand Down Expand Up @@ -82,10 +87,13 @@ private void initBinder() {
*/
.bind(StorageObject::getVerbindungsnummer, StorageObject::setVerbindungsnummer);

/*
binderStorageObject.forField(trackingNumber)
.bind(StorageObject::getTrackingNumber, StorageObject::setTrackingNumber);
*/
.bind(StorageObject::getTrackingNo, StorageObject::setTrackingNo);

binderStorageObject.forField(remark)
.withValidator(new StringLengthValidator("Anmerkung zu lang! (max 55 Zeichen)", 0,
ConstantsDomain.DEFAULT_LENGTH))
.bind(StorageObject::getRemark, StorageObject::setRemark);
}

public void setSFPBeans(List<ObjectType> objectTypes, StorageObject storageObject) {
Expand Down
276 changes: 140 additions & 136 deletions src/main/java/com/samic/samic/data/entity/StorageObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,144 +15,148 @@
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table(name = "storage_objects")
public class StorageObject extends AbstractIdentityClass<Long>{

/*
relations
*/
@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE})
@JoinColumn(name = "fk_object_type",
foreignKey = @ForeignKey(name = "fk_objectType_2_storageObject"))
private ObjectType objectTypeName;

@OneToOne(fetch = FetchType.EAGER,
cascade = CascadeType.PERSIST,
orphanRemoval = false) //Shared Primary Key
@JoinColumn(name = "fk_reservation"
/*, referencedColumnName = "id"*/,
foreignKey = @ForeignKey(name = "fk_reservation_2_storageObject")) //foreignKey should be named only reservation
private Reservation reservation;

@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@JoinColumn(name = "fk_CPE",
foreignKey = @ForeignKey(name = "fk_cpe_2_storageObject"))
private CPE cpe;

@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@JoinColumn(name = "fk_SFP",
foreignKey = @ForeignKey(name = "fk_sfp_2_storageObject"))
private SFP sfp;

@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@JoinColumn(name = "fk_supply",
foreignKey = @ForeignKey(name = "fk_supply_2_storageObject"))
private Supply supply;

@OneToMany(mappedBy = "storageObject",
fetch = FetchType.LAZY,
cascade = {CascadeType.PERSIST})
private List<StorageObjectHistory> storageObjectHistory = new ArrayList<>();


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


@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE})
@JoinColumn(name = "fk_storaed_at_user",
foreignKey = @ForeignKey(name = "fk_User_2_storageObject"))
private User storedAtUser;

//Einseitige Beziehung
@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE})
@JoinColumn(name = "fk_storage",
foreignKey = @ForeignKey(name = "fk_storage_2_storageObject"))
private Storage storage;

/*
attributes
*/
@Column(name = "remark",
length = ConstantsDomain.DEFAULT_LENGTH)
// @NotBlank
private String remark;

@Enumerated(EnumType.STRING)
@Column(name = "status"
/*, length = 1*/
/*,columnDefinition = "CHAR(1)CHECK (Status IN ('C','R','M','P','A'))"*/)
private Status status;

// @Column(name = "object_name", length = ConstantsDomain.DEFAULT_LENGTH)
// private @NotBlank String name;

@Column(name = "project_device")
private Boolean projectDevice;

@Column(name = "processed")
private Boolean processed;

// public void setReservation(Reservation reservation){
// if(reservation != null){
// if(this.getReservation() == null){
// this.reservation = reservation;
// }else{
// throw new SamicException("Reservation has already been set!");
// }
// }else{
// throw new SamicException("Given Reservation is null!");
// }
// }
//
// public void setStorage(Storage storage){
// if(storage != null){
// this.storage = storage;
// }
// }
//
// public void setCpe(CPE cpe){
// if(cpe != null){
// if(this.getSfp() == null){
// this.cpe = cpe;
// }
// }
// }
//
// public void setSfp(SFP sfp){
// if(sfp != null){
// if(this.getCpe() == null){
// this.sfp = sfp;
// }
// }
// }
//
// public void setSupply(Supply supply){
// if(supply != null){
// if(this.supply == null){
// this.supply = supply;
// }
// }
// }


@Override
public int hashCode() {
if (getId() != null) {
return getId().hashCode();
}
return super.hashCode();
public class StorageObject extends AbstractIdentityClass<Long> {

/*
relations
*/
@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE})
@JoinColumn(name = "fk_object_type",
foreignKey = @ForeignKey(name = "fk_objectType_2_storageObject"))
private ObjectType objectTypeName;

@OneToOne(fetch = FetchType.EAGER,
cascade = CascadeType.PERSIST,
orphanRemoval = false) //Shared Primary Key
@JoinColumn(name = "fk_reservation"
/*, referencedColumnName = "id"*/,
foreignKey = @ForeignKey(name = "fk_reservation_2_storageObject"))
//foreignKey should be named only reservation
private Reservation reservation;

@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@JoinColumn(name = "fk_CPE",
foreignKey = @ForeignKey(name = "fk_cpe_2_storageObject"))
private CPE cpe;

@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@JoinColumn(name = "fk_SFP",
foreignKey = @ForeignKey(name = "fk_sfp_2_storageObject"))
private SFP sfp;

@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE, CascadeType.PERSIST})
@JoinColumn(name = "fk_supply",
foreignKey = @ForeignKey(name = "fk_supply_2_storageObject"))
private Supply supply;

@OneToMany(mappedBy = "storageObject",
fetch = FetchType.LAZY,
cascade = {CascadeType.PERSIST})
private List<StorageObjectHistory> storageObjectHistory = new ArrayList<>();


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


@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE})
@JoinColumn(name = "fk_storaed_at_user",
foreignKey = @ForeignKey(name = "fk_User_2_storageObject"))
private User storedAtUser;

//Einseitige Beziehung
@ManyToOne(fetch = FetchType.EAGER,
cascade = {CascadeType.MERGE})
@JoinColumn(name = "fk_storage",
foreignKey = @ForeignKey(name = "fk_storage_2_storageObject"))
private Storage storage;

/*
attributes
*/
@Column(name = "remark",
length = ConstantsDomain.DEFAULT_LENGTH)
// @NotBlank
private String remark;

@Enumerated(EnumType.STRING)
@Column(name = "status"
/*, length = 1*/
/*,columnDefinition = "CHAR(1)CHECK (Status IN ('C','R','M','P','A'))"*/)
private Status status;

// @Column(name = "object_name", length = ConstantsDomain.DEFAULT_LENGTH)
// private @NotBlank String name;

@Column(name = "project_device")
private Boolean projectDevice;

@Column(name = "processed")
private Boolean processed;

@Column
private String trackingNo;

// public void setReservation(Reservation reservation){
// if(reservation != null){
// if(this.getReservation() == null){
// this.reservation = reservation;
// }else{
// throw new SamicException("Reservation has already been set!");
// }
// }else{
// throw new SamicException("Given Reservation is null!");
// }
// }
//
// public void setStorage(Storage storage){
// if(storage != null){
// this.storage = storage;
// }
// }
//
// public void setCpe(CPE cpe){
// if(cpe != null){
// if(this.getSfp() == null){
// this.cpe = cpe;
// }
// }
// }
//
// public void setSfp(SFP sfp){
// if(sfp != null){
// if(this.getCpe() == null){
// this.sfp = sfp;
// }
// }
// }
//
// public void setSupply(Supply supply){
// if(supply != null){
// if(this.supply == null){
// this.supply = supply;
// }
// }
// }


@Override
public int hashCode() {
if (getId() != null) {
return getId().hashCode();
}
return super.hashCode();
}


@Override
public String toString(){
return "StorageObject{"+"remark='"+remark+"\n"+'}';
}
@Override
public String toString() {
return "StorageObject{" + "remark='" + remark + "\n" + '}';
}
}

Loading

0 comments on commit a390758

Please sign in to comment.