Skip to content

Commit e875ab4

Browse files
committed
IPTE-165: Code Refatoring include getUser
(cherry picked from commit c96359b)
1 parent 1dcf40d commit e875ab4

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

src/main/java/de/doubleslash/keeptime/model/Model.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.util.Comparator;
2020

21+
import de.doubleslash.keeptime.model.repos.UserRepository;
2122
import org.springframework.beans.factory.annotation.Autowired;
2223
import org.springframework.context.ConfigurableApplicationContext;
2324
import org.springframework.stereotype.Component;

src/main/java/de/doubleslash/keeptime/model/User.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public void setEnabled(final boolean enabled) {
3131
}
3232

3333
public String getUserName() {
34-
return userName;
34+
if (userName != null) {
35+
return userName;
36+
} else {
37+
return "No username set";
38+
}
3539
}
3640
}

src/main/java/de/doubleslash/keeptime/model/repos/UserRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
@Repository
88
public interface UserRepository extends JpaRepository<User, String> {
99
User findByUserName(String username);
10+
1011
}

src/main/java/de/doubleslash/keeptime/view/SettingsController.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.sql.SQLException;
2626
import java.util.Comparator;
2727
import java.util.HashMap;
28+
import java.util.List;
2829
import java.util.Map;
2930
import java.util.Properties;
3031

@@ -63,6 +64,8 @@
6364
import javafx.stage.FileChooser.ExtensionFilter;
6465
import javafx.stage.Stage;
6566

67+
import javax.print.attribute.standard.PrinterURI;
68+
6669
@Component
6770
public class SettingsController {
6871

@@ -212,17 +215,27 @@ public class SettingsController {
212215
@FXML
213216
private Label labelUsername;
214217

215-
User user = new User();
218+
User user;
216219

217220
@Autowired
218221
ViewController mainscreen;
219222

220223
@Autowired
221224
public SettingsController(final Model model, final Controller controller,
222-
ApplicationProperties applicationProperties) {
225+
ApplicationProperties applicationProperties, final UserRepository userRepository) {
223226
this.model = model;
224227
this.controller = controller;
225228
this.applicationProperties = applicationProperties;
229+
this.userRepository = userRepository;
230+
this.YYY();
231+
232+
}
233+
234+
private void YYY() {
235+
final List<User> users = userRepository.findAll();
236+
if (!users.isEmpty()) {
237+
user = users.get(0);
238+
}
226239
}
227240

228241
@FXML
@@ -267,9 +280,7 @@ private void initialize() {
267280
radioApiOn.setSelected(true);
268281
radioApiOff.setSelected(false);
269282
String port = properties.getProperty("server.port");
270-
// String username = properties.getProperty(user.getUserName());
271-
// System.err.println("'"+user.getUserName()+"'");
272-
String username = properties.getProperty("authUsername");
283+
authName.setText(user.getUserName());
273284
if (port != null) {
274285
authPort.setText(port);
275286
}
@@ -285,7 +296,6 @@ private void initialize() {
285296
e.printStackTrace();
286297
}
287298

288-
289299
LOG.debug("saveButton.setOnAction");
290300

291301
saveButton.setOnAction(ae -> {
@@ -602,8 +612,16 @@ public ObservableList<LicenseTableRow> loadLicenseRows() {
602612
licenseRows.add(new LicenseTableRow("h2", Licenses.EPLV1));
603613
licenseRows.add(new LicenseTableRow("Font Awesome Icons", Licenses.CC_4_0));
604614
licenseRows.add(new LicenseTableRow("mapstruct", Licenses.APACHEV2));
615+
licenseRows.add(new LicenseTableRow("mapstruct-processor", Licenses.APACHEV2));
605616
licenseRows.add(new LicenseTableRow("jackson-databind", Licenses.APACHEV2));
606617
licenseRows.add(new LicenseTableRow("javax.xml.bind", Licenses.APACHEV2));
618+
licenseRows.add(new LicenseTableRow("spring-boot-starter-web", Licenses.APACHEV2));//gleich
619+
licenseRows.add(new LicenseTableRow("spring-boot-starter-validation", Licenses.APACHEV2));//gleich
620+
licenseRows.add(new LicenseTableRow("spring-boot-starter-security", Licenses.APACHEV2));//gleich
621+
// licenseRows.add(new LicenseTableRow("org.springframework.boot", Licenses.APACHEV2));
622+
// licenseRows.add(new LicenseTableRow("jaxb-api", Licenses.);//CDDL 1.1
623+
licenseRows.add(new LicenseTableRow("jacoco-maven-plugin", Licenses.EPLV1));//EPL 2.0
624+
licenseRows.add(new LicenseTableRow("maven-compiler-plugin", Licenses.APACHEV2));
607625

608626
licenseRows.sort(Comparator.comparing(LicenseTableRow::getName));
609627

src/main/java/de/doubleslash/keeptime/view/ViewController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ private void initialize() {
301301
.bind(Bindings.createStringBinding(
302302
() -> DateFormatter.secondsToHHMMSS(activeWorkSecondsProperty.get()),
303303
activeWorkSecondsProperty));
304-
305304
// update ui each second
306305
new Interval(1).registerCallBack(() -> {
307306
final LocalDateTime now = LocalDateTime.now();

0 commit comments

Comments
 (0)