Skip to content

Commit

Permalink
refactor code intellij code anlyses and recommended fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandar Zivkovic <[email protected]>
  • Loading branch information
anywaywayany committed Feb 27, 2024
1 parent cf4ce86 commit f332d51
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 81 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/samic/samic/components/form/CPEForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public class CPEForm extends FormLayout {
private final TextField trackingNumber = new TextField("Sendungsnummer");
private final BeanValidationBinder<StorageObject> binderStorageObject = new BeanValidationBinder<>(
StorageObject.class, true);
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 =
private final ComboBox<ObjectType> deviceType = new ComboBox<>("Gerätetyp");
private final TextField macAdress = new TextField("MAC Adresse");
private final TextField serialnumber = new TextField("Seriennummer");
private final TextField remark = new TextField("Anmerkung");
private final HorizontalLayout projectEquipmentContainer =
UIFactory.childContainer(
FlexComponent.JustifyContentMode.START, connectionNumber, trackingNumber);

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/samic/samic/components/form/SFPForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

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 @@ -30,9 +28,9 @@ public class SFPForm extends FormLayout {
private final TextField wavelength = new TextField("Wellenlänge");
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 final ComboBox<ObjectType> deviceType = new ComboBox<>("Gerätetyp");
private final TextField serialnumber = new TextField("Seriennummer");
private HorizontalLayout projectEquipmentContainer =
private final HorizontalLayout projectEquipmentContainer =
UIFactory.childContainer(
FlexComponent.JustifyContentMode.START, connectionNumber, trackingNumber);
private final TextField remark = new TextField("Anmerkung");
Expand Down
89 changes: 43 additions & 46 deletions src/main/java/com/samic/samic/views/MainLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@
*/
public class MainLayout extends AppLayout {

private final AccessAnnotationChecker accessChecker;
private final AuthenticatedUser authenticatedUser;
private H2 viewTitle;

private AuthenticatedUser authenticatedUser;
private AccessAnnotationChecker accessChecker;

public MainLayout(AuthenticatedUser authenticatedUser, AccessAnnotationChecker accessChecker) {
this.authenticatedUser = authenticatedUser;
this.accessChecker = accessChecker;
Expand Down Expand Up @@ -92,46 +91,46 @@ private SideNav createNavigation() {
LagerobjektErfassenView.class,
LineAwesomeIcon.DASHCUBE.create()));
}
if (accessChecker.hasAccess(LagerobjektAufnehmenView.class)) {
nav.addItem(
new SideNavItem(
"Lagerobjekt aufnehmen",
LagerobjektAufnehmenView.class,
LineAwesomeIcon.CART_ARROW_DOWN_SOLID.create()));
}
if (accessChecker.hasAccess(FreieLagerobjekteView.class)) {
nav.addItem(
new SideNavItem(
"Freie Lagerobjekte",
FreieLagerobjekteView.class,
LineAwesomeIcon.SEARCH_SOLID.create()));
}
if (accessChecker.hasAccess(MeineHardwareView.class)) {
nav.addItem(
new SideNavItem(
"Meine Hardware",
MeineHardwareView.class,
LineAwesomeIcon.STRIPE.create()));
}

if (accessChecker.hasAccess(AbfragenView.class)) {
nav.addItem(
new SideNavItem(
"Abfragen",
AbfragenView.class,
LineAwesomeIcon.QUESTION_CIRCLE_SOLID.create()
)
);
}
if (accessChecker.hasAccess(AdministrationView.class)) {
nav.addItem(
new SideNavItem(
"Administration",
AdministrationView.class,
LineAwesomeIcon.COG_SOLID.create()
)
);
}
if (accessChecker.hasAccess(LagerobjektAufnehmenView.class)) {
nav.addItem(
new SideNavItem(
"Lagerobjekt aufnehmen",
LagerobjektAufnehmenView.class,
LineAwesomeIcon.CART_ARROW_DOWN_SOLID.create()));
}
if (accessChecker.hasAccess(FreieLagerobjekteView.class)) {
nav.addItem(
new SideNavItem(
"Freie Lagerobjekte",
FreieLagerobjekteView.class,
LineAwesomeIcon.SEARCH_SOLID.create()));
}
if (accessChecker.hasAccess(MeineHardwareView.class)) {
nav.addItem(
new SideNavItem(
"Meine Hardware",
MeineHardwareView.class,
LineAwesomeIcon.STRIPE.create()));
}

if (accessChecker.hasAccess(AbfragenView.class)) {
nav.addItem(
new SideNavItem(
"Abfragen",
AbfragenView.class,
LineAwesomeIcon.QUESTION_CIRCLE_SOLID.create()
)
);
}
if (accessChecker.hasAccess(AdministrationView.class)) {
nav.addItem(
new SideNavItem(
"Administration",
AdministrationView.class,
LineAwesomeIcon.COG_SOLID.create()
)
);
}

return nav;
}
Expand Down Expand Up @@ -159,9 +158,7 @@ private Footer createFooter() {
.getSubMenu()
.addItem(
"Sign out",
e -> {
authenticatedUser.logout();
});
e -> authenticatedUser.logout());

layout.add(userMenu);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
public class UserManagement extends VerticalLayout {

private static final String DATE_PATTERN = "dd.MM.yyyy";
final VirtualList<User> virtualList = new VirtualList<>();
private final ServiceUser userService;
private final UserForm userForm;
private final UserForm userFormDialog;
VirtualList<User> virtualList = new VirtualList<>();
private ComponentRenderer<com.vaadin.flow.component.Component, User> userComponentRenderer;

public UserManagement(ServiceUser userService, UserForm userForm,
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/com/samic/samic/views/dashboard/DashboardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import jakarta.annotation.security.PermitAll;
import java.util.concurrent.atomic.AtomicInteger;

;

@PageTitle("Dashboard")
@Route(value = "dashboard", layout = MainLayout.class)
Expand All @@ -68,7 +67,6 @@ public class DashboardView extends VerticalLayout implements BeforeEnterObserver
private final ComboBox<Storage> storageComboBox = new ComboBox<>("Lager");
private final ComboBox<Producer> producerComboBox = new ComboBox<>("Hersteller");


private final ReservationGrid reservationGrid;
private final StorageObjectGrid hardwareGrid;
private final ServiceStorage storageService;
Expand All @@ -77,11 +75,10 @@ public class DashboardView extends VerticalLayout implements BeforeEnterObserver

public DashboardView(ServiceReservation reservationService,
ServiceStorageObject storageObjectService, AuthenticatedUser authenticatedUser,
ServiceProducer producerService, ServiceStorageObject storageObjectService1,
ServiceObjectType serviceObjectType,
ServiceProducer producerService, ServiceObjectType serviceObjectType,
CPEForm cpeForm, SFPForm sfpForm, SupplyForm supplyForm, UserForm userForm,
ServiceObjectType objectTypeService, ServiceStorage stoageService,
ServiceProducer producerService1, StorageForm storageForm, ReservationGrid reservationGrid,
ServiceObjectType objectTypeService, ServiceStorage stoageService, StorageForm storageForm,
ReservationGrid reservationGrid,
StorageObjectGrid hardwareGrid, ServiceStorage storageService, ServiceUser userService) {
this.reservationService = reservationService;
this.storageObjectService = storageObjectService;
Expand All @@ -93,12 +90,12 @@ public DashboardView(ServiceReservation reservationService,
this.userForm = userForm;
this.objectTypeService = objectTypeService;
this.stoageService = stoageService;
this.producerService = producerService1;
this.storageForm = storageForm;
this.reservationGrid = reservationGrid;
this.hardwareGrid = hardwareGrid;
this.storageService = storageService;
this.userService = userService;
this.producerService = producerService;

initUI();
}
Expand Down Expand Up @@ -151,7 +148,7 @@ private void initQuickAccess() {
menuBar.addItem("Lager hinzufügen", onClick -> {
Dialog dialog = new Dialog();
dialog.add(storageForm);
supplyForm.setSupplyBeans(StorageObject.builder().supply(Supply.builder().build()).build());
storageForm.setBean(Storage.builder().build());
dialog.add(UIFactory.btnPrimary("Speichern", e -> {
dialog.close();
onSave(storageForm.isValid() ? storageForm.saveBean() : null);
Expand Down Expand Up @@ -211,6 +208,7 @@ private Dialog createDialog(SupplyForm supplyForm) {
Dialog dialog = new Dialog();

dialog.setCloseOnOutsideClick(false);
dialog.add(storageComboBox);
dialog.add(supplyForm);

dialog.add(UIFactory.btnPrimary("Speichern", e -> {
Expand Down Expand Up @@ -317,7 +315,6 @@ private void onSave(StorageObject storageObject) {
UIFactory.notificationInfoNoDuration("LagerID: " + persisted.getId().toString()).open();
UIFactory.notificationSuccess("Lagerobjekt erfolgreich gespeichert").open();
}
hardwareGrid.getDataProvider().refreshAll();
}

private void initHardware() {
Expand Down
23 changes: 7 additions & 16 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,53 +1,44 @@
spring.profiles.active= @profileActive@
spring.profiles.active=@profileActive@
server.port=${PORT:8080}
logging.level.org.atmosphere = warn
spring.mustache.check-template-location = false

logging.level.org.atmosphere=warn
spring.mustache.check-template-location=false
# Launch the default browser when starting the application in development mode
vaadin.launch-browser=true
# To improve the performance during development.
# For more information https://vaadin.com/docs/flow/spring/tutorial-spring-configuration.html#special-configuration-parameters
vaadin.whitelisted-packages = com.vaadin,org.vaadin,dev.hilla,com.example.application
spring.jpa.defer-datasource-initialization = true
spring.sql.init.mode = always



vaadin.whitelisted-packages=com.vaadin,org.vaadin,dev.hilla,com.example.application
spring.jpa.defer-datasource-initialization=true
spring.sql.init.mode=always
#Database
#jdbc:tc:oracle:21-slim-faststart:///databasename
spring.datasource.url=jdbc:tc:oracle:thin:@//localhost:1521/XEPDB1
#spring.datasource.username=system
#spring.datasource.password=oracle
#spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

#spring.datasource.hikari.minimumIdle=5
#spring.datasource.hikari.maximumPoolSize=20
#spring.datasource.hikari.idleTimeout=30000
#spring.datasource.hikari.maxLifetime=2000000
#spring.datasource.hikari.connectionTimeout=30000
#spring.datasource.hikari.poolName=HikariPoolBooks

#spring.datasource.url=jdbc:tc:oracle:21-slim-faststart:///databasename
#spring.jpa.database=oracle
#spring.jpa.database-platform=org.hibernate.dialect.OracleDialect
#spring.jpa.hibernate.ddl-auto=create-drop

#spring.datasource.url=jdbc:oracle:thin:@//database:1521/XEPDB1
spring.datasource.username=system
spring.datasource.password=oracle
#spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect
spring.jpa.hibernate.ddl-auto=create-drop

#logging.file.name=test.log
#logging.level.com.zaxxer.hikari.HikariConfig=trace
vaadin.frontend.hotdeploy=true

spring.test.database.replace=none
#spring.main.allow-bean-definition-overriding=true
#spring.datasource.hikari.initialization-fail-timeout=0
############################################################################################
Logging
##Logging
logging.file.name="log_data_samic.log"
#logging.file.path=
#logging.level.root=warn
Expand Down

0 comments on commit f332d51

Please sign in to comment.