Skip to content

Commit 5325373

Browse files
phasenraum2010phasenraum2010
authored andcommitted
changed propeterties
1 parent af0ff79 commit 5325373

29 files changed

+826
-349
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<organization>
2323
<name>Thomas Woehlke</name>
24-
<url>https://twitter.com/ThomasWoehlke</url>
24+
<url>https://github.com/phasenraum2010</url>
2525
</organization>
2626

2727
<inceptionYear>2018</inceptionYear>
@@ -37,7 +37,7 @@
3737
<developer>
3838
<name>Thomas Wöhlke</name>
3939
<email>thomas@woehlke.org</email>
40-
<url>https://github.com/phasenraum2010</url>
40+
<url>https://about.me/ThomasWoehlke</url>
4141
</developer>
4242
</developers>
4343

@@ -50,7 +50,7 @@
5050

5151
<issueManagement>
5252
<system>GitHub</system>
53-
<url>https://github.com/phasenraum2010/btw17kandidaten/issues</url>
53+
<url>https://github.com/phasenraum2010/learn-neo4j/issues</url>
5454
</issueManagement>
5555

5656
<distributionManagement>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package org.woehlke.learn.learnneo4j.configuration;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
import org.springframework.stereotype.Component;
5+
import org.springframework.validation.annotation.Validated;
6+
7+
import javax.validation.constraints.NotNull;
8+
import java.util.List;
9+
10+
11+
@Component
12+
@Validated
13+
@ConfigurationProperties(prefix = "org.woehlke.learn.learnneo4j")
14+
public class MyApplicationProperties {
15+
16+
@NotNull
17+
private String filesystemWorkdir;
18+
19+
@NotNull
20+
private String loginUsername;
21+
22+
@NotNull
23+
private String loginPassword;
24+
25+
@NotNull
26+
private List<String> webSecurityConfigPublicPaths;
27+
28+
@NotNull
29+
private Boolean createTestDataAtStartup;
30+
31+
public String[] getWebSecurityConfigPublicPathsAsArray() {
32+
int size = webSecurityConfigPublicPaths.size();
33+
String[] myArray = new String[size];
34+
for (int i = 0; i < size; i++) {
35+
myArray[i] = webSecurityConfigPublicPaths.get(i);
36+
}
37+
return myArray;
38+
}
39+
40+
public String getFilesystemWorkdir() {
41+
return filesystemWorkdir;
42+
}
43+
44+
public void setFilesystemWorkdir(String filesystemWorkdir) {
45+
this.filesystemWorkdir = filesystemWorkdir;
46+
}
47+
48+
public String getLoginUsername() {
49+
return loginUsername;
50+
}
51+
52+
public void setLoginUsername(String loginUsername) {
53+
this.loginUsername = loginUsername;
54+
}
55+
56+
public String getLoginPassword() {
57+
return loginPassword;
58+
}
59+
60+
public void setLoginPassword(String loginPassword) {
61+
this.loginPassword = loginPassword;
62+
}
63+
64+
public List<String> getWebSecurityConfigPublicPaths() {
65+
return webSecurityConfigPublicPaths;
66+
}
67+
68+
public void setWebSecurityConfigPublicPaths(List<String> webSecurityConfigPublicPaths) {
69+
this.webSecurityConfigPublicPaths = webSecurityConfigPublicPaths;
70+
}
71+
72+
public Boolean getCreateTestDataAtStartup() {
73+
return createTestDataAtStartup;
74+
}
75+
76+
public void setCreateTestDataAtStartup(Boolean createTestDataAtStartup) {
77+
this.createTestDataAtStartup = createTestDataAtStartup;
78+
}
79+
80+
@Override
81+
public String toString() {
82+
return "PortinfoProperties{" +
83+
"loginUsername='" + loginUsername + '\'' +
84+
", loginPassword='" + loginPassword + '\'' +
85+
", webSecurityConfigPublicPaths=" + webSecurityConfigPublicPaths +
86+
'}';
87+
}
88+
}

src/main/java/org/woehlke/learn/learnneo4j/configuration/StartupListener.java

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import org.springframework.context.ApplicationListener;
77
import org.springframework.context.event.ContextRefreshedEvent;
88
import org.springframework.stereotype.Component;
9-
import org.woehlke.learn.learnneo4j.configuration.properties.MyAppProperties;
10-
import org.woehlke.learn.learnneo4j.configuration.properties.OtherAppProperties;
11-
import org.woehlke.learn.learnneo4j.configuration.properties.SpringAppProperties;
9+
import org.woehlke.learn.learnneo4j.configuration.properties.*;
1210
import org.woehlke.learn.learnneo4j.model.graph.Category;
1311
import org.woehlke.learn.learnneo4j.model.graph.category.CategoryRepository;
12+
import org.woehlke.learn.learnneo4j.model.graph.category.CategoryService;
13+
import org.woehlke.learn.learnneo4j.model.orm.portinfo.PortinfoService;
1414

1515
@Component
1616
public class StartupListener implements ApplicationListener<ContextRefreshedEvent> {
@@ -19,46 +19,72 @@ public class StartupListener implements ApplicationListener<ContextRefreshedEven
1919

2020
private final CategoryRepository categoryRepository;
2121

22-
private final MyAppProperties myAppProperties;
22+
private final CategoryService categoryService;
2323

24-
private final OtherAppProperties otherAppProperties;
24+
private final PortinfoService portinfoService;
2525

26-
private final SpringAppProperties springAppProperties;
26+
private final MyApplicationProperties myApplicationProperties;
27+
28+
private final MyHibernateProperties myHibernateProperties;
29+
30+
private final MyInfoProperties myInfoProperties;
31+
32+
private final MyManagementProperties myManagementProperties;
33+
34+
private final MyServerProperties myServerProperties;
35+
36+
private final MySpringBootProperties mySpringBootProperties;
2737

2838
@Autowired
29-
public StartupListener(CategoryRepository categoryRepository, MyAppProperties myAppProperties, OtherAppProperties otherAppProperties, SpringAppProperties springAppProperties) {
39+
public StartupListener(CategoryRepository categoryRepository, CategoryService categoryService, PortinfoService portinfoService, MyApplicationProperties myApplicationProperties, MyHibernateProperties myHibernateProperties, MyInfoProperties myInfoProperties, MyManagementProperties myManagementProperties, MyServerProperties myServerProperties, MySpringBootProperties mySpringBootProperties) {
3040
this.categoryRepository = categoryRepository;
31-
this.myAppProperties = myAppProperties;
32-
this.otherAppProperties = otherAppProperties;
33-
this.springAppProperties = springAppProperties;
41+
this.categoryService = categoryService;
42+
this.portinfoService = portinfoService;
43+
this.myApplicationProperties = myApplicationProperties;
44+
this.myHibernateProperties = myHibernateProperties;
45+
this.myInfoProperties = myInfoProperties;
46+
this.myManagementProperties = myManagementProperties;
47+
this.myServerProperties = myServerProperties;
48+
this.mySpringBootProperties = mySpringBootProperties;
3449
}
3550

3651
@Override
3752
public void onApplicationEvent(ContextRefreshedEvent event) {
38-
log.info(" =========================== ");
39-
log.info(" === Application Started === ");
40-
log.info(" =========================== ");
41-
this.categoryRepository.deleteAll();
42-
this.categoryRepository.save(new Category("www"));
43-
this.categoryRepository.save(new Category("qt4"));
44-
this.categoryRepository.save(new Category("qt5"));
45-
// fetch all Categories
46-
log.info("Categories found with findAll():");
47-
log.info("--------------------------------");
48-
for (Category category : this.categoryRepository.findAll()) {
49-
log.info(category.toString());
53+
log.info(" ================================ ");
54+
log.info(" ===== Application Started ====== ");
55+
log.info(" ================================ ");
56+
if( this.myApplicationProperties.getCreateTestDataAtStartup()){
57+
this.categoryRepository.deleteAll();
58+
this.categoryRepository.save(new Category("www"));
59+
this.categoryRepository.save(new Category("qt4"));
60+
this.categoryRepository.save(new Category("qt5"));
61+
// fetch all Categories
62+
log.info(" Categories found with findAll(): ");
63+
log.info(" -------------------------------- ");
64+
for (Category category : this.categoryService.findAll()) {
65+
log.info(" category : "+category.toString());
66+
}
67+
log.info(" -------------------------------- ");
68+
log.info(" fetch an individual Category: ");
69+
log.info(" findByCategory('www'): ");
70+
log.info(" -------------------------------- ");
71+
log.info(this.categoryService.findByName("www").toString());
72+
log.info(" ================================ ");
5073
}
51-
System.out.println();
52-
log.info("fetch an individual Category: ");
53-
log.info("Category found with findByCategory('www'):");
54-
log.info("--------------------------------");
55-
log.info(this.categoryRepository.findByName("www").toString());
56-
log.info("--------------------------------");
57-
log.info(myAppProperties.toString());
58-
log.info("--------------------------------");
59-
log.info(otherAppProperties.toString());
60-
log.info("--------------------------------");
61-
log.info(springAppProperties.toString());
62-
log.info("--------------------------------");
74+
log.info(" -------------------------------- ");
75+
log.info(" Properties ");
76+
log.info(" -------------------------------- ");
77+
log.info(this.myApplicationProperties.toString());
78+
log.info(" -------------------------------- ");
79+
log.info(this.myInfoProperties.toString());
80+
log.info(" -------------------------------- ");
81+
log.info(this.myManagementProperties.toString());
82+
log.info(" -------------------------------- ");
83+
log.info(this.myServerProperties.toString());
84+
log.info(" -------------------------------- ");
85+
log.info(this.myHibernateProperties.toString());
86+
log.info(" -------------------------------- ");
87+
log.info(this.mySpringBootProperties.toString());
88+
log.info(" -------------------------------- ");
6389
}
6490
}

src/main/java/org/woehlke/learn/learnneo4j/configuration/properties/MyAppProperties.java

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.woehlke.learn.learnneo4j.configuration.properties;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
import org.springframework.stereotype.Component;
5+
import org.springframework.validation.annotation.Validated;
6+
7+
import javax.validation.constraints.NotNull;
8+
9+
@Component
10+
@Validated
11+
@ConfigurationProperties(prefix = "hibernate")
12+
public class MyHibernateProperties {
13+
14+
@NotNull
15+
private String dialect;
16+
17+
public String getDialect() {
18+
return dialect;
19+
}
20+
21+
public void setDialect(String dialect) {
22+
this.dialect = dialect;
23+
}
24+
25+
@Override
26+
public String toString() {
27+
return "MyHibernateProperties{" +
28+
"dialect='" + dialect + '\'' +
29+
'}';
30+
}
31+
}

0 commit comments

Comments
 (0)