Skip to content

Commit f172f3c

Browse files
AB-xdevJohannesRabauerMoritz Mitlmeier
committed
Add initial code
Co-Authored-By: Johannes Rabauer <8188460+JohannesRabauer@users.noreply.github.com> Co-Authored-By: Moritz Mitlmeier <99164988+MMitlmeier@users.noreply.github.com>
1 parent 59758ff commit f172f3c

168 files changed

Lines changed: 13126 additions & 27 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

spring-data-eclipse-store-demo/pom.xml

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<version>1.0.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

12-
<inceptionYear>2022</inceptionYear>
12+
<inceptionYear>2023</inceptionYear>
1313

1414
<organization>
1515
<name>XDEV Software</name>
@@ -24,14 +24,41 @@
2424
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2525

2626
<mainClass>software.xdev.Application</mainClass>
27+
28+
<org.springframework.boot.version>3.2.2</org.springframework.boot.version>
2729
</properties>
2830

31+
<dependencyManagement>
32+
<dependencies>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-dependencies</artifactId>
36+
<version>${org.springframework.boot.version}</version>
37+
<type>pom</type>
38+
<scope>import</scope>
39+
</dependency>
40+
</dependencies>
41+
</dependencyManagement>
42+
2943
<dependencies>
3044
<dependency>
3145
<groupId>software.xdev</groupId>
3246
<artifactId>spring-data-eclipse-store</artifactId>
3347
<version>${project.version}</version>
3448
</dependency>
49+
50+
<dependency>
51+
<groupId>org.apache.logging.log4j</groupId>
52+
<artifactId>log4j-core</artifactId>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.apache.logging.log4j</groupId>
56+
<artifactId>log4j-slf4j2-impl</artifactId>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-autoconfigure</artifactId>
61+
</dependency>
3562
</dependencies>
3663

3764
<build>
@@ -50,32 +77,9 @@
5077
</configuration>
5178
</plugin>
5279
<plugin>
53-
<groupId>org.apache.maven.plugins</groupId>
54-
<artifactId>maven-assembly-plugin</artifactId>
55-
<version>3.6.0</version>
56-
<configuration>
57-
<archive>
58-
<manifest>
59-
<mainClass>${mainClass}</mainClass>
60-
</manifest>
61-
<manifestEntries>
62-
<Multi-Release>true</Multi-Release>
63-
</manifestEntries>
64-
</archive>
65-
<descriptorRefs>
66-
<descriptorRef>jar-with-dependencies</descriptorRef>
67-
</descriptorRefs>
68-
<appendAssemblyId>false</appendAssemblyId>
69-
</configuration>
70-
<executions>
71-
<execution>
72-
<id>make-assembly</id> <!-- this is used for inheritance merges -->
73-
<phase>package</phase> <!-- bind to the packaging phase -->
74-
<goals>
75-
<goal>single</goal>
76-
</goals>
77-
</execution>
78-
</executions>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-maven-plugin</artifactId>
82+
<version>${org.springframework.boot.version}</version>
7983
</plugin>
8084
</plugins>
8185
</build>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package software.xdev.spring.data.eclipse.store.demo.complex;
18+
19+
import java.time.LocalDate;
20+
import java.time.temporal.ChronoUnit;
21+
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
24+
import org.springframework.boot.CommandLineRunner;
25+
import org.springframework.boot.SpringApplication;
26+
import org.springframework.boot.autoconfigure.SpringBootApplication;
27+
import org.springframework.context.ConfigurableApplicationContext;
28+
import org.springframework.data.domain.Pageable;
29+
30+
import software.xdev.spring.data.eclipse.store.demo.complex.owner.Owner;
31+
import software.xdev.spring.data.eclipse.store.demo.complex.owner.OwnerRepository;
32+
import software.xdev.spring.data.eclipse.store.demo.complex.owner.Pet;
33+
import software.xdev.spring.data.eclipse.store.demo.complex.owner.PetType;
34+
import software.xdev.spring.data.eclipse.store.demo.complex.owner.Visit;
35+
import software.xdev.spring.data.eclipse.store.demo.complex.vet.Specialty;
36+
import software.xdev.spring.data.eclipse.store.demo.complex.vet.Vet;
37+
import software.xdev.spring.data.eclipse.store.demo.complex.vet.VetRepository;
38+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
39+
40+
41+
@SpringBootApplication
42+
@EnableEclipseStoreRepositories
43+
public class ComplexDemoApplication implements CommandLineRunner
44+
{
45+
private static final Logger LOG = LoggerFactory.getLogger(ComplexDemoApplication.class);
46+
private final OwnerRepository ownerRepository;
47+
private final VetRepository vetRepository;
48+
49+
public ComplexDemoApplication(final OwnerRepository ownerRepository, final VetRepository vetRepository)
50+
{
51+
this.ownerRepository = ownerRepository;
52+
this.vetRepository = vetRepository;
53+
}
54+
55+
public static void main(final String[] args)
56+
{
57+
final ConfigurableApplicationContext run = SpringApplication.run(ComplexDemoApplication.class, args);
58+
run.close();
59+
}
60+
61+
@Override
62+
public void run(final String... args)
63+
{
64+
LOG.info("----Vets-BeforeDeleteAll----");
65+
this.vetRepository.findAll().forEach(i -> LOG.info(i.toString()));
66+
this.vetRepository.deleteAll();
67+
68+
LOG.info("----Vets-AfterDeleteAll----");
69+
this.vetRepository.findAll().forEach(i -> LOG.info(i.toString()));
70+
71+
final Vet vet = createVet();
72+
this.vetRepository.save(vet);
73+
74+
LOG.info("----Vets-AfterSave----");
75+
this.vetRepository.findAll().forEach(i -> LOG.info(i.toString()));
76+
77+
LOG.info("----Owner-BeforeDeleteAll----");
78+
this.ownerRepository.findAll(Pageable.unpaged()).forEach(i -> LOG.info(i.toString()));
79+
this.ownerRepository.deleteAll();
80+
81+
LOG.info("----Owner-AfterDeleteAll----");
82+
this.ownerRepository.findAll(Pageable.unpaged()).forEach(i -> LOG.info(i.toString()));
83+
84+
final Owner owner = createOwner();
85+
this.ownerRepository.save(owner);
86+
87+
LOG.info("----Owner-AfterSave----");
88+
this.ownerRepository.findAll(Pageable.unpaged()).forEach(i -> LOG.info(i.toString()));
89+
90+
final Visit visit = createVisit();
91+
owner.addVisit("Peter", visit);
92+
this.ownerRepository.save(owner);
93+
94+
LOG.info("----Owner-AfterVisit----");
95+
this.ownerRepository
96+
.findByLastName("Nicks", Pageable.unpaged())
97+
.forEach(i ->
98+
{
99+
LOG.info(i.toString());
100+
i.getPets().forEach(p -> {
101+
LOG.info(p.toString());
102+
p.getVisits().forEach(v -> LOG.info(v.toString()));
103+
}
104+
);
105+
}
106+
);
107+
}
108+
109+
private static Visit createVisit()
110+
{
111+
final Visit visit = new Visit();
112+
visit.setDate(LocalDate.now());
113+
visit.setDescription("Peter got his first parvovirus vaccine");
114+
return visit;
115+
}
116+
117+
private static Vet createVet()
118+
{
119+
final Vet vet = new Vet();
120+
vet.setFirstName("Mick");
121+
vet.setLastName("Fleetwood");
122+
final Specialty specialty = new Specialty();
123+
specialty.setName("Vaccination");
124+
vet.addSpecialty(specialty);
125+
return vet;
126+
}
127+
128+
private static Owner createOwner()
129+
{
130+
final Owner owner = new Owner();
131+
owner.setFirstName("Stevie");
132+
owner.setLastName("Nicks");
133+
final Pet pet = new Pet();
134+
pet.setBirthDate(LocalDate.now().minus(6, ChronoUnit.WEEKS));
135+
pet.setName("Peter");
136+
final PetType petType = new PetType();
137+
petType.setName("Dog");
138+
pet.setType(petType);
139+
owner.addPet(pet);
140+
return owner;
141+
}
142+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.demo.complex.model;
17+
18+
import java.io.Serializable;
19+
20+
import org.springframework.data.annotation.Id;
21+
22+
import jakarta.persistence.GeneratedValue;
23+
import jakarta.persistence.GenerationType;
24+
25+
26+
public class BaseEntity implements Serializable
27+
{
28+
@Id
29+
@GeneratedValue(strategy = GenerationType.AUTO)
30+
private Integer id;
31+
32+
public Integer getId()
33+
{
34+
return this.id;
35+
}
36+
37+
public boolean isNew()
38+
{
39+
return this.id == null;
40+
}
41+
42+
@Override
43+
public String toString()
44+
{
45+
return "BaseEntity{" +
46+
"id=" + this.id +
47+
'}';
48+
}
49+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.demo.complex.model;
17+
18+
public class NamedEntity extends BaseEntity
19+
{
20+
private String name;
21+
22+
public String getName()
23+
{
24+
return this.name;
25+
}
26+
27+
public void setName(final String name)
28+
{
29+
this.name = name;
30+
}
31+
32+
@Override
33+
public String toString()
34+
{
35+
return this.getName();
36+
}
37+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.demo.complex.model;
17+
18+
public class Person extends BaseEntity
19+
{
20+
private String firstName;
21+
22+
private String lastName;
23+
24+
public String getFirstName()
25+
{
26+
return this.firstName;
27+
}
28+
29+
public void setFirstName(final String firstName)
30+
{
31+
this.firstName = firstName;
32+
}
33+
34+
public String getLastName()
35+
{
36+
return this.lastName;
37+
}
38+
39+
public void setLastName(final String lastName)
40+
{
41+
this.lastName = lastName;
42+
}
43+
44+
@Override
45+
public String toString()
46+
{
47+
return "Person{" +
48+
"firstName='" + this.firstName + '\'' +
49+
", lastName='" + this.lastName + '\'' +
50+
'}';
51+
}
52+
}

0 commit comments

Comments
 (0)