Skip to content

Commit d0e1540

Browse files
author
amigoscode
committed
Initial commit
0 parents  commit d0e1540

Some content is hidden

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

51 files changed

+30816
-0
lines changed

Diff for: .gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
HELP.md
2+
/target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
.sts4-cache
13+
14+
### IntelliJ IDEA ###
15+
.idea
16+
*.iws
17+
*.iml
18+
*.ipr
19+
20+
### NetBeans ###
21+
/nbproject/private/
22+
/nbbuild/
23+
/dist/
24+
/nbdist/
25+
/.nb-gradle/
26+
/build/
27+
28+
### VS Code ###
29+
.vscode/
30+
31+
src/js/node/
32+
src/js/node_modules/
33+
src/js/build/
34+

Diff for: .mvn/wrapper/MavenWrapperDownloader.java

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
20+
import java.io.File;
21+
import java.io.FileInputStream;
22+
import java.io.FileOutputStream;
23+
import java.io.IOException;
24+
import java.net.URL;
25+
import java.nio.channels.Channels;
26+
import java.nio.channels.ReadableByteChannel;
27+
import java.util.Properties;
28+
29+
public class MavenWrapperDownloader {
30+
31+
/**
32+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
33+
*/
34+
private static final String DEFAULT_DOWNLOAD_URL =
35+
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
36+
37+
/**
38+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
39+
* use instead of the default one.
40+
*/
41+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
42+
".mvn/wrapper/maven-wrapper.properties";
43+
44+
/**
45+
* Path where the maven-wrapper.jar will be saved to.
46+
*/
47+
private static final String MAVEN_WRAPPER_JAR_PATH =
48+
".mvn/wrapper/maven-wrapper.jar";
49+
50+
/**
51+
* Name of the property which should be used to override the default download url for the wrapper.
52+
*/
53+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
54+
55+
public static void main(String args[]) {
56+
System.out.println("- Downloader started");
57+
File baseDirectory = new File(args[0]);
58+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
59+
60+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
61+
// wrapperUrl parameter.
62+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
63+
String url = DEFAULT_DOWNLOAD_URL;
64+
if(mavenWrapperPropertyFile.exists()) {
65+
FileInputStream mavenWrapperPropertyFileInputStream = null;
66+
try {
67+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
68+
Properties mavenWrapperProperties = new Properties();
69+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
70+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
71+
} catch (IOException e) {
72+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
73+
} finally {
74+
try {
75+
if(mavenWrapperPropertyFileInputStream != null) {
76+
mavenWrapperPropertyFileInputStream.close();
77+
}
78+
} catch (IOException e) {
79+
// Ignore ...
80+
}
81+
}
82+
}
83+
System.out.println("- Downloading from: : " + url);
84+
85+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
86+
if(!outputFile.getParentFile().exists()) {
87+
if(!outputFile.getParentFile().mkdirs()) {
88+
System.out.println(
89+
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
90+
}
91+
}
92+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
93+
try {
94+
downloadFileFromURL(url, outputFile);
95+
System.out.println("Done");
96+
System.exit(0);
97+
} catch (Throwable e) {
98+
System.out.println("- Error downloading");
99+
e.printStackTrace();
100+
System.exit(1);
101+
}
102+
}
103+
104+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
105+
URL website = new URL(urlString);
106+
ReadableByteChannel rbc;
107+
rbc = Channels.newChannel(website.openStream());
108+
FileOutputStream fos = new FileOutputStream(destination);
109+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
110+
fos.close();
111+
rbc.close();
112+
}
113+
114+
}

Diff for: .mvn/wrapper/maven-wrapper.jar

47.2 KB
Binary file not shown.

Diff for: .mvn/wrapper/maven-wrapper.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# fullstack-spring-boot-and-react

Diff for: course-files/Joins and Link Tables/Exercise Solution

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// 1.
2+
@GetMapping(path = "{studentId}/courses")
3+
public List<StudentCourse> getAllCoursesForStudent(
4+
@PathVariable("studentId") UUID studentId) {
5+
return studentService.getAllCoursesForStudent(studentId);
6+
}
7+
8+
// 2.
9+
List<StudentCourse> getAllCoursesForStudent(UUID studentId) {
10+
return studentDataAccessService.selectAllStudentCourses(studentId);
11+
}
12+
13+
// 3.
14+
15+
private RowMapper<StudentCourse> mapStudentCourseFromDb() {
16+
return (resultSet, i) ->
17+
new StudentCourse(
18+
UUID.fromString(resultSet.getString("student_id")),
19+
UUID.fromString(resultSet.getString("course_id")),
20+
resultSet.getString("name"),
21+
resultSet.getString("description"),
22+
resultSet.getString("department"),
23+
resultSet.getString("teacher_name"),
24+
resultSet.getDate("start_date").toLocalDate(),
25+
resultSet.getDate("end_date").toLocalDate(),
26+
Optional.ofNullable(resultSet.getString("grade"))
27+
.map(Integer::parseInt)
28+
.orElse(null)
29+
);
30+
}
31+
32+
List<StudentCourse> selectAllStudentCourses(UUID studentId) {
33+
String sql = "" +
34+
"SELECT " +
35+
" student.student_id, " +
36+
" course.course_id, " +
37+
" course.name, " +
38+
" course.description," +
39+
" course.department," +
40+
" course.teacher_name," +
41+
" student_course.start_date, " +
42+
" student_course.end_date, " +
43+
" student_course.grade " +
44+
"FROM student " +
45+
"JOIN student_course USING (student_id) " +
46+
"JOIN course USING (course_id) " +
47+
"WHERE student.student_id = ?";
48+
return jdbcTemplate.query(
49+
sql,
50+
new Object[]{studentId},
51+
mapStudentCourseFromDb()
52+
);
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
INSERT INTO student_course (
2+
student_id,
3+
course_id,
4+
start_date,
5+
end_date,
6+
grade
7+
)
8+
VALUES (
9+
'e7e40436-b931-441d-85e0-d86b6039fdfa',
10+
'7321b9a6-29f7-49e0-9330-6d079c792608',
11+
(NOW() - INTERVAL '1 YEAR')::DATE,
12+
NOW()::DATE,
13+
90
14+
);

Diff for: course-files/profiles.txt

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
1.
2+
<frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
3+
<node.version>v10.13.0</node.version>
4+
<yarn.version>v1.12.1</yarn.version>
5+
6+
2.
7+
<profiles>
8+
<profile>
9+
<id>test</id>
10+
<activation>
11+
<activeByDefault>true</activeByDefault>
12+
</activation>
13+
<properties>
14+
<spring.profiles.active>dev</spring.profiles.active>
15+
</properties>
16+
</profile>
17+
<profile>
18+
<id>demo</id>
19+
<build>
20+
<plugins>
21+
<plugin>
22+
<artifactId>maven-resources-plugin</artifactId>
23+
<executions>
24+
<execution>
25+
<id>copy-resources</id>
26+
<phase>process-classes</phase>
27+
<goals>
28+
<goal>copy-resources</goal>
29+
</goals>
30+
<configuration>
31+
<outputDirectory>${basedir}/target/classes/static</outputDirectory>
32+
<resources>
33+
<resource>
34+
<directory>src/js/build</directory>
35+
</resource>
36+
</resources>
37+
</configuration>
38+
</execution>
39+
</executions>
40+
</plugin>
41+
<plugin>
42+
<groupId>com.github.eirslett</groupId>
43+
<artifactId>frontend-maven-plugin</artifactId>
44+
<version>${frontend-maven-plugin.version}</version>
45+
<configuration>
46+
<workingDirectory>src/js</workingDirectory>
47+
</configuration>
48+
<executions>
49+
<execution>
50+
<id>install node</id>
51+
<goals>
52+
<goal>install-node-and-yarn</goal>
53+
</goals>
54+
<configuration>
55+
<nodeVersion>${node.version}</nodeVersion>
56+
<yarnVersion>${yarn.version}</yarnVersion>
57+
</configuration>
58+
</execution>
59+
<execution>
60+
<id>yarn install</id>
61+
<goals>
62+
<goal>yarn</goal>
63+
</goals>
64+
<phase>generate-resources</phase>
65+
</execution>
66+
<execution>
67+
<id>yarn test</id>
68+
<goals>
69+
<goal>yarn</goal>
70+
</goals>
71+
<phase>test</phase>
72+
<configuration>
73+
<arguments>test</arguments>
74+
<environmentVariables>
75+
<CI>true</CI>
76+
</environmentVariables>
77+
</configuration>
78+
</execution>
79+
<execution>
80+
<id>yarn build</id>
81+
<goals>
82+
<goal>yarn</goal>
83+
</goals>
84+
<phase>compile</phase>
85+
<configuration>
86+
<arguments>build</arguments>
87+
</configuration>
88+
</execution>
89+
</executions>
90+
</plugin>
91+
</plugins>
92+
</build>
93+
</profile>
94+
</profiles>

Diff for: course-files/student.sql

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
insert into student (student_id, first_name, last_name, email, gender) values ('e7e40436-b931-441d-85e0-d86b6039fdfa', 'Leshia', 'Aikin', '[email protected]', 'FEMALE');
2+
insert into student (student_id, first_name, last_name, email, gender) values ('13ba8584-99f5-4e7a-87b8-c2d16b39ce49', 'Idalia', 'Lentsch', '[email protected]', 'FEMALE');
3+
insert into student (student_id, first_name, last_name, email, gender) values ('a75c1b78-0802-4888-8e8c-f8e76e34b617', 'Winny', 'Forster', '[email protected]', 'MALE');
4+
insert into student (student_id, first_name, last_name, email, gender) values ('020bb0e0-7681-4eae-90f5-1218b649e917', 'Christel', 'Comolli', '[email protected]', 'FEMALE');
5+
insert into student (student_id, first_name, last_name, email, gender) values ('5ea017f7-b4f7-4bbd-800f-940253380b15', 'Minta', 'Autie', '[email protected]', 'FEMALE');
6+
insert into student (student_id, first_name, last_name, email, gender) values ('953b52d8-a089-48a4-bbf8-e21008c72f0e', 'Jacqui', 'Rigate', '[email protected]', 'FEMALE');
7+
insert into student (student_id, first_name, last_name, email, gender) values ('7492d4b0-1217-48af-9757-9611a9d4af55', 'Jacquelynn', 'McAnellye', '[email protected]', 'FEMALE');
8+
insert into student (student_id, first_name, last_name, email, gender) values ('bc5bc1a9-1da7-4b1f-931a-4f5c3f7dc992', 'Perry', 'Vamplew', '[email protected]', 'MALE');
9+
insert into student (student_id, first_name, last_name, email, gender) values ('6c20ac51-23d0-4d46-bd50-82dab6611e66', 'Rodger', 'Corradeschi', '[email protected]', 'MALE');
10+
insert into student (student_id, first_name, last_name, email, gender) values ('eb8c6b33-8a73-4482-90d4-6f89e800b947', 'Brice', 'Farfull', '[email protected]', 'MALE');
11+
insert into student (student_id, first_name, last_name, email, gender) values ('ce82e722-1310-4d00-9f17-2bb0d45719f0', 'Denney', 'Chittem', '[email protected]', 'MALE');
12+
insert into student (student_id, first_name, last_name, email, gender) values ('d40668fa-432e-4649-88cc-871fa46a0396', 'Derron', 'Allix', '[email protected]', 'MALE');
13+
insert into student (student_id, first_name, last_name, email, gender) values ('5f5d877e-0649-4ec8-9991-793dfc068f75', 'Sergio', 'Stapley', '[email protected]', 'MALE');
14+
insert into student (student_id, first_name, last_name, email, gender) values ('fbdebde6-58c7-41e3-b51b-343e032b3b3b', 'Halsy', 'Obell', '[email protected]', 'MALE');
15+
insert into student (student_id, first_name, last_name, email, gender) values ('a81ae551-6411-405b-ba89-6fe4699a7293', 'Merrick', 'Fewkes', '[email protected]', 'MALE');
16+
insert into student (student_id, first_name, last_name, email, gender) values ('fb5941db-1f2b-4eac-b9d5-f90927cb0621', 'Andee', 'Poultney', '[email protected]', 'FEMALE');
17+
insert into student (student_id, first_name, last_name, email, gender) values ('6673241a-9e55-4cd3-b724-fff6fbe073c5', 'Saxe', 'Prettyjohns', '[email protected]', 'MALE');
18+
insert into student (student_id, first_name, last_name, email, gender) values ('12aca1c6-48a7-4a2e-8d0b-040556f83dc5', 'Zuzana', 'McDonagh', '[email protected]', 'FEMALE');
19+
insert into student (student_id, first_name, last_name, email, gender) values ('583db972-bb74-4f63-94a8-7b1efa8ae4bc', 'Christin', 'Cortese', '[email protected]', 'FEMALE');
20+
insert into student (student_id, first_name, last_name, email, gender) values ('9c42106d-04f2-4b29-a17f-28e61203b230', 'Edy', 'Shakshaft', '[email protected]', 'FEMALE');

0 commit comments

Comments
 (0)