Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
9d4f79f1ae | |||
4f574dbb18 | |||
55c85931a4 | |||
ce0ea8903e | |||
1240c7ec90 | |||
84bcd7d64c | |||
689b85bf12 | |||
5576f9e59e | |||
bbdcd30900 | |||
|
67a097458c | ||
8946fad520 | |||
9655a84025 | |||
|
444e67736e | ||
3136b75b1b | |||
|
4264287804 | ||
ad838b891b |
5
.gitignore
vendored
5
.gitignore
vendored
@ -87,3 +87,8 @@ dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
/frontend/node_modules/
|
||||
/.idea/
|
||||
/.gradle/
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +1,2 @@
|
||||
#Thu Feb 10 13:21:42 GMT+04:00 2022
|
||||
#Tue Mar 21 10:03:06 GMT+04:00 2023
|
||||
gradle.version=7.3.3
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
.gradle/workspace-id.txt
Normal file
BIN
.gradle/workspace-id.txt
Normal file
Binary file not shown.
BIN
.gradle/workspace-id.txt.lock
Normal file
BIN
.gradle/workspace-id.txt.lock
Normal file
Binary file not shown.
3
.idea/.gitignore
vendored
3
.idea/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
1
.idea/.name
Normal file
1
.idea/.name
Normal file
@ -0,0 +1 @@
|
||||
sbapp
|
6
.idea/encodings.xml
Normal file
6
.idea/encodings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/data.mv.db" charset="windows-1251" />
|
||||
</component>
|
||||
</project>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
</project>
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
11
build.gradle
11
build.gradle
@ -14,9 +14,18 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'com.h2database:h2:2.1.214'
|
||||
implementation 'junit:junit:4.13.2'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-devtools'
|
||||
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
|
||||
implementation 'org.springdoc:springdoc-openapi-ui:1.6.5'
|
||||
implementation 'org.hibernate.validator:hibernate-validator'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
}
|
||||
|
||||
|
||||
tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
BIN
data.mv.db
Normal file
BIN
data.mv.db
Normal file
Binary file not shown.
894
data.trace.db
Normal file
894
data.trace.db
Normal file
@ -0,0 +1,894 @@
|
||||
2023-05-24 22:46:14 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "GENRE" not found; SQL statement:
|
||||
select genre0_.id as id1_2_, genre0_.name as name2_2_ from genre genre0_ where genre0_.name like genre [42122-214]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
|
||||
at org.h2.message.DbException.get(DbException.java:223)
|
||||
at org.h2.message.DbException.get(DbException.java:199)
|
||||
at org.h2.expression.ExpressionColumn.getColumnException(ExpressionColumn.java:244)
|
||||
at org.h2.expression.ExpressionColumn.optimizeOther(ExpressionColumn.java:226)
|
||||
at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:213)
|
||||
at org.h2.expression.condition.CompareLike.optimize(CompareLike.java:150)
|
||||
at org.h2.expression.Expression.optimizeCondition(Expression.java:148)
|
||||
at org.h2.command.query.Select.prepareExpressions(Select.java:1177)
|
||||
at org.h2.command.query.Query.prepare(Query.java:218)
|
||||
at org.h2.command.Parser.prepareCommand(Parser.java:575)
|
||||
at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631)
|
||||
at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:554)
|
||||
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116)
|
||||
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:92)
|
||||
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:288)
|
||||
at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:337)
|
||||
at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
|
||||
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)
|
||||
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176)
|
||||
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151)
|
||||
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2122)
|
||||
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2059)
|
||||
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037)
|
||||
at org.hibernate.loader.Loader.doQuery(Loader.java:956)
|
||||
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)
|
||||
at org.hibernate.loader.Loader.doList(Loader.java:2868)
|
||||
at org.hibernate.loader.Loader.doList(Loader.java:2850)
|
||||
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682)
|
||||
at org.hibernate.loader.Loader.list(Loader.java:2677)
|
||||
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:540)
|
||||
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400)
|
||||
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
|
||||
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1454)
|
||||
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1649)
|
||||
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
|
||||
at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1665)
|
||||
at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:198)
|
||||
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:90)
|
||||
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:155)
|
||||
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:143)
|
||||
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
|
||||
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
|
||||
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159)
|
||||
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
|
||||
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
|
||||
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:145)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
|
||||
at jdk.proxy2/jdk.proxy2.$Proxy118.findByName(Unknown Source)
|
||||
at ru.ulstu.is.sbapp.Movie.Service.MovieService.fillRepo(MovieService.java:194)
|
||||
at ru.ulstu.is.sbapp.Movie.Service.MovieService$$FastClassBySpringCGLIB$$bb620b80.invoke(<generated>)
|
||||
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
|
||||
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
|
||||
at ru.ulstu.is.sbapp.Movie.Service.MovieService$$EnhancerBySpringCGLIB$$7d3e602e.fillRepo(<generated>)
|
||||
at ru.ulstu.is.sbapp.Movie.Controller.MovieController.insertMovies(MovieController.java:65)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
|
||||
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
|
||||
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
|
||||
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
|
||||
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
|
||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
|
||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
|
||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
|
||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
|
||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)
|
||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||
2023-05-24 23:03:06 jdbc[4]: exception
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "GENRE" not found; SQL statement:
|
||||
select genre0_.id as id1_2_, genre0_.name as name2_2_ from genre genre0_ where genre0_.name like genre [42122-214]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
|
||||
at org.h2.message.DbException.get(DbException.java:223)
|
||||
at org.h2.message.DbException.get(DbException.java:199)
|
||||
at org.h2.expression.ExpressionColumn.getColumnException(ExpressionColumn.java:244)
|
||||
at org.h2.expression.ExpressionColumn.optimizeOther(ExpressionColumn.java:226)
|
||||
at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:213)
|
||||
at org.h2.expression.condition.CompareLike.optimize(CompareLike.java:150)
|
||||
at org.h2.expression.Expression.optimizeCondition(Expression.java:148)
|
||||
at org.h2.command.query.Select.prepareExpressions(Select.java:1177)
|
||||
at org.h2.command.query.Query.prepare(Query.java:218)
|
||||
at org.h2.command.Parser.prepareCommand(Parser.java:575)
|
||||
at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631)
|
||||
at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:554)
|
||||
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116)
|
||||
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:92)
|
||||
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:288)
|
||||
at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:337)
|
||||
at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
|
||||
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)
|
||||
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176)
|
||||
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151)
|
||||
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2122)
|
||||
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2059)
|
||||
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037)
|
||||
at org.hibernate.loader.Loader.doQuery(Loader.java:956)
|
||||
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)
|
||||
at org.hibernate.loader.Loader.doList(Loader.java:2868)
|
||||
at org.hibernate.loader.Loader.doList(Loader.java:2850)
|
||||
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682)
|
||||
at org.hibernate.loader.Loader.list(Loader.java:2677)
|
||||
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:540)
|
||||
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400)
|
||||
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
|
||||
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1454)
|
||||
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1649)
|
||||
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
|
||||
at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1665)
|
||||
at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:198)
|
||||
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:90)
|
||||
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:155)
|
||||
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:143)
|
||||
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
|
||||
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
|
||||
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159)
|
||||
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
|
||||
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
|
||||
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:145)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
|
||||
at jdk.proxy2/jdk.proxy2.$Proxy118.findByName(Unknown Source)
|
||||
at ru.ulstu.is.sbapp.Movie.Service.MovieService.fillRepo(MovieService.java:194)
|
||||
at ru.ulstu.is.sbapp.Movie.Service.MovieService$$FastClassBySpringCGLIB$$bb620b80.invoke(<generated>)
|
||||
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
|
||||
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
|
||||
at ru.ulstu.is.sbapp.Movie.Service.MovieService$$EnhancerBySpringCGLIB$$e0f68ee9.fillRepo(<generated>)
|
||||
at ru.ulstu.is.sbapp.Movie.Controller.MovieController.insertMovies(MovieController.java:65)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
|
||||
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
|
||||
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
|
||||
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
|
||||
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
|
||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
|
||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
|
||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
|
||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
|
||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)
|
||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||
2023-05-24 23:20:24 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "GENRE" not found; SQL statement:
|
||||
select genre0_.id as id1_2_, genre0_.name as name2_2_ from genre genre0_ where genre0_.name like genre [42122-214]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
|
||||
at org.h2.message.DbException.get(DbException.java:223)
|
||||
at org.h2.message.DbException.get(DbException.java:199)
|
||||
at org.h2.expression.ExpressionColumn.getColumnException(ExpressionColumn.java:244)
|
||||
at org.h2.expression.ExpressionColumn.optimizeOther(ExpressionColumn.java:226)
|
||||
at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:213)
|
||||
at org.h2.expression.condition.CompareLike.optimize(CompareLike.java:150)
|
||||
at org.h2.expression.Expression.optimizeCondition(Expression.java:148)
|
||||
at org.h2.command.query.Select.prepareExpressions(Select.java:1177)
|
||||
at org.h2.command.query.Query.prepare(Query.java:218)
|
||||
at org.h2.command.Parser.prepareCommand(Parser.java:575)
|
||||
at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631)
|
||||
at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:554)
|
||||
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116)
|
||||
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:92)
|
||||
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:288)
|
||||
at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:337)
|
||||
at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
|
||||
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)
|
||||
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176)
|
||||
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151)
|
||||
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2122)
|
||||
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2059)
|
||||
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037)
|
||||
at org.hibernate.loader.Loader.doQuery(Loader.java:956)
|
||||
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)
|
||||
at org.hibernate.loader.Loader.doList(Loader.java:2868)
|
||||
at org.hibernate.loader.Loader.doList(Loader.java:2850)
|
||||
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682)
|
||||
at org.hibernate.loader.Loader.list(Loader.java:2677)
|
||||
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:540)
|
||||
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400)
|
||||
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
|
||||
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1454)
|
||||
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1649)
|
||||
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
|
||||
at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1665)
|
||||
at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:198)
|
||||
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:90)
|
||||
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:155)
|
||||
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:143)
|
||||
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
|
||||
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
|
||||
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159)
|
||||
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
|
||||
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
|
||||
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:145)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
|
||||
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
|
||||
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
|
||||
at jdk.proxy2/jdk.proxy2.$Proxy118.findByName(Unknown Source)
|
||||
at ru.ulstu.is.sbapp.Movie.Service.MovieService.fillRepo(MovieService.java:194)
|
||||
at ru.ulstu.is.sbapp.Movie.Service.MovieService$$FastClassBySpringCGLIB$$bb620b80.invoke(<generated>)
|
||||
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
|
||||
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
|
||||
at ru.ulstu.is.sbapp.Movie.Service.MovieService$$EnhancerBySpringCGLIB$$f55ccaf0.fillRepo(<generated>)
|
||||
at ru.ulstu.is.sbapp.Movie.Controller.MovieController.insertMovies(MovieController.java:66)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
|
||||
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
|
||||
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
|
||||
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
|
||||
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
|
||||
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
|
||||
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
|
||||
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
|
||||
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
|
||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
|
||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
|
||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
|
||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
|
||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
|
||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)
|
||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||
2023-06-15 17:40:19 database: flush
|
||||
org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:395)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:125)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:3318)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:593)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:469)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:136)
|
||||
at org.h2.engine.Database.<init>(Database.java:324)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.lambda$logDataSources$0(H2ConsoleAutoConfiguration.java:77)
|
||||
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
|
||||
at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
|
||||
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
|
||||
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
|
||||
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.logDataSources(H2ConsoleAutoConfiguration.java:83)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.h2Console(H2ConsoleAutoConfiguration.java:70)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:212)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:203)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:97)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:86)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:260)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53)
|
||||
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5219)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
|
||||
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
|
||||
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:478)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
|
||||
at ru.ulstu.is.sbapp.SbappApplication.main(SbappApplication.java:13)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
|
||||
... 99 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:178)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:128)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:452)
|
||||
... 93 more
|
||||
2023-06-15 17:40:21 database: flush
|
||||
org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:395)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:125)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:3318)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:593)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:469)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:136)
|
||||
at org.h2.engine.Database.<init>(Database.java:324)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
|
||||
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
|
||||
at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
|
||||
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173)
|
||||
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494)
|
||||
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
|
||||
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
|
||||
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
|
||||
at ru.ulstu.is.sbapp.SbappApplication.main(SbappApplication.java:13)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
|
||||
... 66 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:178)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:128)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:452)
|
||||
... 60 more
|
||||
2023-06-15 17:40:23 database: flush
|
||||
org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:395)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:125)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:3318)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:593)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:469)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:136)
|
||||
at org.h2.engine.Database.<init>(Database.java:324)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181)
|
||||
at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:44)
|
||||
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.jdbcStatement(GenerationTargetToDatabase.java:77)
|
||||
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:53)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:387)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:371)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:246)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:156)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:128)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:114)
|
||||
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:153)
|
||||
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:81)
|
||||
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:335)
|
||||
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1498)
|
||||
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
|
||||
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
|
||||
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
|
||||
at ru.ulstu.is.sbapp.SbappApplication.main(SbappApplication.java:13)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
|
||||
... 66 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:178)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:128)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:452)
|
||||
... 60 more
|
||||
2023-06-15 17:48:12 database: flush
|
||||
org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:395)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:125)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:3318)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:593)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:469)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:136)
|
||||
at org.h2.engine.Database.<init>(Database.java:324)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.lambda$logDataSources$0(H2ConsoleAutoConfiguration.java:77)
|
||||
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
|
||||
at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
|
||||
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
|
||||
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
|
||||
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.logDataSources(H2ConsoleAutoConfiguration.java:83)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.h2Console(H2ConsoleAutoConfiguration.java:70)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:212)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:203)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:97)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:86)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:260)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53)
|
||||
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5219)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
|
||||
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
|
||||
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
|
||||
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:478)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
|
||||
at ru.ulstu.is.sbapp.SbappApplication.main(SbappApplication.java:13)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
|
||||
... 99 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:178)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:128)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:452)
|
||||
... 93 more
|
||||
2023-06-15 17:48:14 database: flush
|
||||
org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:395)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:125)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:3318)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:593)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:469)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:136)
|
||||
at org.h2.engine.Database.<init>(Database.java:324)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
|
||||
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
|
||||
at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
|
||||
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173)
|
||||
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494)
|
||||
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
|
||||
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
|
||||
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
|
||||
at ru.ulstu.is.sbapp.SbappApplication.main(SbappApplication.java:13)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
|
||||
... 66 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:178)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:128)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:452)
|
||||
... 60 more
|
||||
2023-06-15 17:48:15 database: flush
|
||||
org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:395)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:125)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:3318)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:593)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:469)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4082)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:136)
|
||||
at org.h2.engine.Database.<init>(Database.java:324)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181)
|
||||
at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:44)
|
||||
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.jdbcStatement(GenerationTargetToDatabase.java:77)
|
||||
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:53)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:387)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:371)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:246)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:156)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:128)
|
||||
at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:114)
|
||||
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:153)
|
||||
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:81)
|
||||
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:335)
|
||||
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1498)
|
||||
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
|
||||
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
|
||||
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
|
||||
at ru.ulstu.is.sbapp.SbappApplication.main(SbappApplication.java:13)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]" [50000-214]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
|
||||
... 66 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: E:/University/InternetProgramming/data.mv.db [2.1.214/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:178)
|
||||
at org.h2.mvstore.FileStore.open(FileStore.java:128)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:452)
|
||||
... 60 more
|
17598
frontend/package-lock.json
generated
Normal file
17598
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
42
frontend/package.json
Normal file
42
frontend/package.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
"@testing-library/react": "^13.4.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"axios": "^1.4.0",
|
||||
"bootstrap": "^5.2.3",
|
||||
"react": "^18.2.0",
|
||||
"react-bootstrap": "^2.7.4",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "^6.11.2",
|
||||
"react-scripts": "5.0.1",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
BIN
frontend/public/favicon.ico
Normal file
BIN
frontend/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
43
frontend/public/index.html
Normal file
43
frontend/public/index.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
BIN
frontend/public/logo192.png
Normal file
BIN
frontend/public/logo192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
BIN
frontend/public/logo512.png
Normal file
BIN
frontend/public/logo512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
25
frontend/public/manifest.json
Normal file
25
frontend/public/manifest.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
3
frontend/public/robots.txt
Normal file
3
frontend/public/robots.txt
Normal file
@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
38
frontend/src/App.css
Normal file
38
frontend/src/App.css
Normal file
@ -0,0 +1,38 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
28
frontend/src/App.js
Normal file
28
frontend/src/App.js
Normal file
@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import './style.css';
|
||||
import 'bootstrap/dist/css/bootstrap.css';
|
||||
import MainPage from './Pages/Mainpage'
|
||||
import SearchPage from './Pages/Searchpage'
|
||||
import LibPage from './Pages/Librarypage'
|
||||
import RegPage from './Pages/Regpage'
|
||||
import FilmInfo from './Pages/Filmpage'
|
||||
import Loginpage from './Pages/Loginpage';
|
||||
import { BrowserRouter as Router,Routes,Route} from 'react-router-dom';
|
||||
export default function App() {
|
||||
return (
|
||||
<div>
|
||||
<Router>
|
||||
<Routes>
|
||||
<Route path='/movie/:customerId' element={<MainPage/>} />
|
||||
<Route path='/genre/:customerId' element={<SearchPage/>} />
|
||||
<Route path='/library/:customerId' element={<LibPage/>} />
|
||||
<Route path='*' element={<RegPage/>} />
|
||||
<Route path='/movie/:customerId/:movieId' element={<FilmInfo/>} />
|
||||
<Route path='/login' element={<Loginpage/>} />
|
||||
</Routes>
|
||||
</Router>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
8
frontend/src/App.test.js
Normal file
8
frontend/src/App.test.js
Normal file
@ -0,0 +1,8 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
107
frontend/src/Components/DataService.js
Normal file
107
frontend/src/Components/DataService.js
Normal file
@ -0,0 +1,107 @@
|
||||
import axios from 'axios';
|
||||
|
||||
|
||||
const host = "http://localhost:8080";
|
||||
|
||||
export async function registerUser(fullName,password)
|
||||
{
|
||||
console.log(fullName);
|
||||
console.log(password);
|
||||
const response = await axios.post(`${host}/customer?fullName=${fullName}&password=${password}`);
|
||||
|
||||
if (response.status === 200) {
|
||||
const customerDTO = response.data;
|
||||
console.log(customerDTO);
|
||||
return customerDTO;}
|
||||
|
||||
}
|
||||
|
||||
export async function getMovies()
|
||||
{
|
||||
const response = await axios.get(`${host}/movie`);
|
||||
if (response.status === 200) {
|
||||
const moviesData = response.data;
|
||||
return moviesData;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getMovie(movieId)
|
||||
{
|
||||
const response = await axios.get(`${host}/movie/${movieId}`);
|
||||
|
||||
if (response.status === 200) {
|
||||
const movieDTO = response.data;
|
||||
return movieDTO;}
|
||||
}
|
||||
export async function getCustomerMovies(customerId)
|
||||
{
|
||||
const response = await axios.get(`${host}/customer/movies/${customerId}`);
|
||||
if (response.status === 200) {
|
||||
const customerMovies = response.data;
|
||||
return customerMovies;}
|
||||
}
|
||||
|
||||
export async function acquireMovie(movieId,customerId)
|
||||
{
|
||||
const response = await axios.post(`${host}/movie/${customerId}/${movieId}`);
|
||||
if (response.status === 200) {
|
||||
const movieDTO= response.data;
|
||||
return movieDTO;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getMoviesByGenre(genre)
|
||||
{
|
||||
console.log(genre);
|
||||
const response = await axios.get(`${host}/movie/movies/${genre}`);
|
||||
console.log(response.data);
|
||||
if (response.status === 200) {
|
||||
const moviesData= response.data;
|
||||
return moviesData;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getCustomers()
|
||||
{
|
||||
const response = await axios.get(`${host}/customer`);
|
||||
if (response.status === 200) {
|
||||
const customers= response.data;
|
||||
console.log(customers);
|
||||
return customers;
|
||||
}
|
||||
}
|
||||
|
||||
export async function fillRepos()
|
||||
{
|
||||
console.log("here");
|
||||
const response1 = await axios.post(`${host}/genre/fill`);
|
||||
console.log(response1.data);
|
||||
if(response1.status === 200)
|
||||
{
|
||||
|
||||
const response2 = await axios.post(`${host}/movie/fill`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export async function getGenres()
|
||||
{
|
||||
const response = await axios.get(`${host}/genre`);
|
||||
if (response.status === 200) {
|
||||
const genres= response.data;
|
||||
console.log(genres);
|
||||
return genres;
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateMovie(movieId, modalData)
|
||||
{
|
||||
console.log(movieId);
|
||||
console.log(modalData);
|
||||
const response = await axios.put(`${host}/movie/${movieId}?title=${modalData["title"]}&length=${modalData["length"]}&score=${modalData["score"]}`);
|
||||
}
|
||||
|
||||
export async function removeCustomerMovie(movieId,customerId)
|
||||
{
|
||||
const response = await axios.delete(`${host}/movie/${customerId}/${movieId}`);
|
||||
}
|
24
frontend/src/Components/Film.js
Normal file
24
frontend/src/Components/Film.js
Normal file
@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import { Link, useParams } from 'react-router-dom';
|
||||
|
||||
function Film({customerId,movieId,title, acquire,main,search})
|
||||
{
|
||||
const handleAcquireClick = () => {
|
||||
acquire();
|
||||
};
|
||||
return (
|
||||
<div className="flex-containerB" style={{flexDirection: "column", display: "flex", width: "250px",height:"350px",gap:"40px",alignItems:"center"}}>
|
||||
<div className="flex-item1">
|
||||
<img src="https://www.seekpng.com/png/detail/8-84931_question-mark-question-mark-white-background.png" alt = "cover" width="100%" height="300px"/>
|
||||
</div>
|
||||
<div className="flex-item12 text-center" style={{ color:"white",fontSize: " 32px",fontWeight: "bold"}}><Link style={{color: "white", textDecoration: "none"}} to={`/movie/${customerId}/${movieId}`}>{title}</Link></div>
|
||||
|
||||
{main ? (
|
||||
<button style= {{width:"50px"}}onClick={handleAcquireClick}>Add</button>
|
||||
) : (main == null ? (<div></div>):(<button style= {{width:"90px"}}onClick={handleAcquireClick}>Remove</button>))}
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Film;
|
5
frontend/src/Components/Footer.html
Normal file
5
frontend/src/Components/Footer.html
Normal file
@ -0,0 +1,5 @@
|
||||
<footer class="flex-item6">
|
||||
<div class="text-center text-light p-2" style="font-size: 30px; font-weight: bold;">
|
||||
@2022 Copyright: BLSJY.com
|
||||
</div>
|
||||
</footer>
|
13
frontend/src/Components/LibraryExtraBar.js
Normal file
13
frontend/src/Components/LibraryExtraBar.js
Normal file
@ -0,0 +1,13 @@
|
||||
const LibraryExtraBar = () =>{
|
||||
return(
|
||||
<div className="flex-container justify-content-center" id="filterbar" style={{display: "flex" , flex:"1" , flexDirection: "column", gap: "10px", textAlign: "center"}}>
|
||||
<div className="flex-item-profile sidebar rounded-4 align-self-center">
|
||||
<button className="button" style={{height: "110px", width:"160px", fontSize: "25px", opacity: "0.6"}} disabled="true">REVIEWED</button>
|
||||
</div>
|
||||
<div className="flex-item-search sidebar rounded-4 align-self-center">
|
||||
<button className="button" style={{height: "110px", width:"160px", fontSize: "25px"}}>WATCHED</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default LibraryExtraBar;
|
25
frontend/src/Components/ModalWindow.js
Normal file
25
frontend/src/Components/ModalWindow.js
Normal file
@ -0,0 +1,25 @@
|
||||
import React from "react";
|
||||
const ModalWindow = () => {
|
||||
return (
|
||||
<div className="modal fade" id="myModal" role="dialog">
|
||||
<div className="modal-dialog">
|
||||
<div className="modal-content">
|
||||
<div className="modal-header">
|
||||
<button className="close" type="button" data-bs-dismiss="modal">×</button>
|
||||
<h4 className="modal-title">Do you want to change or delete?</h4>
|
||||
</div>
|
||||
<div className="modal-body">
|
||||
<input className="form-control" id="inputFilmName" type="name" value="" placeholder="Enter film name"/>
|
||||
<input className="form-control" id="inputPic" type="url-pic" value="" placeholder="Enter url of film cover"/>
|
||||
</div>
|
||||
<div className="modal-footer">
|
||||
<button className="btn btn-default" type="button" data-bs-dismiss="modal" onclick="changeMovie()">Change
|
||||
<button className="btn btn-default" type="button" data-bs-dismiss="modal" onclick="deleteRequest()">Delete</button>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default ModalWindow;
|
24
frontend/src/Components/Navbar.html
Normal file
24
frontend/src/Components/Navbar.html
Normal file
@ -0,0 +1,24 @@
|
||||
<nav class="navbar navbar-expand-lg navbar-light">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" th:href="@{/movie/{customerId}(customerId=${customerId})}">
|
||||
Main Page
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" th:href="@{/genre/{customerId}(customerId=${customerId})}">
|
||||
Search Page
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" th:href="@{/library/{customerId}(customerId=${customerId})}">
|
||||
Library Page
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" th:href="@{/customer}">
|
||||
Registration Page
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
30
frontend/src/Components/SearchSuggestions.js
Normal file
30
frontend/src/Components/SearchSuggestions.js
Normal file
@ -0,0 +1,30 @@
|
||||
import React from "react";
|
||||
let imgs = ['https://cdn-l-cyberpunk.cdprojektred.com/edgerunners/Cyberpunk-Edgerunners-S1-Poster-en.jpg',
|
||||
'https://upload.wikimedia.org/wikipedia/ru/thumb/f/f2/%D0%90%D1%80%D0%BA%D0%B5%D0%B9%D0%BD_%28%D0%BC%D1%83%D0%BB%D1%8C%D1%82%D1%81%D0%B5%D1%80%D0%B8%D0%B0%D0%BB%29.jpg/800px-%D0%90%D1%80%D0%BA%D0%B5%D0%B9%D0%BD_%28%D0%BC%D1%83%D0%BB%D1%8C%D1%82%D1%81%D0%B5%D1%80%D0%B8%D0%B0%D0%BB%29.jpg',
|
||||
'https://cdn.shopify.com/s/files/1/0106/3708/2686/collections/Collection_Image_2_600x600_crop_center.jpg?v=1643983621'
|
||||
];
|
||||
const SearchSuggestions = () =>
|
||||
{
|
||||
return (
|
||||
<div className="flex-container" style={{display: "flex", flexDirection: "column", flex:"1" }}>
|
||||
<header className="flex-item" style={{display: "flex", height: "90px"}}>
|
||||
<div className="flex-itemB2 text-center align-self-center" style={{flex: "1", color: "white", fontSize: "32px", fontWeight: "bold"}}>You might like this</div>
|
||||
</header>
|
||||
<main style={{display: "flex", flex: "1", gap: "20px"}}>
|
||||
<div className="flex-containerB3" style={{flex: "1", flexDirection: "column", display: "flex", marginLeft: "20px"}}>
|
||||
<div className="flex-itemB31" style={{flex: "10"}}><img src={imgs[0]} alt = "cover1" width="100%" height="100%"/></div>
|
||||
<div className="flex-itemB32 text-center" style={{flex: "1", color:"white",fontSize: " 32px",fontWeight: "bold"}}>Cyberpunk: Edgerunners</div>
|
||||
</div>
|
||||
<div className="flex-containerB4" style={{flex: "1", flexDirection: "column", display: "flex"}}>
|
||||
<div className="flex-itemB41" style={{flex: "10"}}><img src={imgs[1]} alt="cover2" width="100%" height="100%"/></div>
|
||||
<div className="flex-itemB42 text-center" style={{flex: "1", color:"white",fontSize: " 32px",fontWeight: "bold"}}>Arcane</div>
|
||||
</div>
|
||||
<div className="flex-containerB5" style={{flex: "1", flexDirection: "column", display: "flex", marginRight: "20px"}}>
|
||||
<div className="flex-itemB51" style={{flex: "10"}}><img src={imgs[2]} alt = "cover3" width="100%" height="100%"/></div>
|
||||
<div className="flex-itemB52 text-center" style={{flex: "1", color:"white",fontSize: " 32px",fontWeight: "bold"}}>Stranger Things</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default SearchSuggestions;
|
112
frontend/src/Pages/Filmpage.js
Normal file
112
frontend/src/Pages/Filmpage.js
Normal file
@ -0,0 +1,112 @@
|
||||
import React,{useEffect,useState} from "react";
|
||||
import { useParams } from 'react-router-dom';
|
||||
import gradientImg from '../Assets/background.png';
|
||||
import Navbar from '../Components/Navbar';
|
||||
import Footer from '../Components/Footer';
|
||||
import { getMovie } from "../Components/DataService";
|
||||
import { Button, Modal } from "react-bootstrap";
|
||||
import { updateMovie } from "../Components/DataService";
|
||||
function Filmpage()
|
||||
{
|
||||
const { customerId, movieId } = useParams();
|
||||
const [movie, setMovie] = useState(null);
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const [modalData, setModalData] = useState({
|
||||
title: "",
|
||||
score: "",
|
||||
length: "",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
fetchMovie();
|
||||
}, []);
|
||||
|
||||
const fetchMovie = async () => {
|
||||
const movieData = await getMovie(movieId);
|
||||
setMovie(movieData);
|
||||
};
|
||||
|
||||
const handleModalOpen = () => {
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
const handleModalClose = () => {
|
||||
setShowModal(false);
|
||||
setModalData({
|
||||
title: "",
|
||||
score: "",
|
||||
length: "",
|
||||
});
|
||||
};
|
||||
|
||||
const handleModalInputChange = (event) => {
|
||||
const { name, value } = event.target;
|
||||
setModalData((prevData) => ({
|
||||
...prevData,
|
||||
[name]: value,
|
||||
}));
|
||||
};
|
||||
|
||||
const handleModalSubmit = async () => {
|
||||
|
||||
await updateMovie(movieId, modalData);
|
||||
|
||||
fetchMovie();
|
||||
|
||||
handleModalClose();
|
||||
|
||||
};
|
||||
|
||||
if (!movie) {
|
||||
return <p>Loading movie...</p>;
|
||||
}
|
||||
|
||||
return(
|
||||
<body>
|
||||
<div className="flex-container" style={{flexDirection:"column",display: "flex",backgroundImage: `url(${gradientImg})`}}>
|
||||
<Navbar customerId={customerId}/>
|
||||
<div className="flex-container min-vh-100" style={{flexDirection: "column", display: "flex"}}>
|
||||
<main style={{display: "flex", flex: "1", gap:"100px"}}>
|
||||
|
||||
<div className="flex-container" style={{display: "inline-flex", flex:"1" , flexWrap:" wrap", gap: "40px"}}>
|
||||
<div className="flex-item1 align-self-center" style={{ flex:"1"}}>
|
||||
<img src="https://www.seekpng.com/png/detail/8-84931_question-mark-question-mark-white-background.png" width="400px" height="600px"/></div>
|
||||
<div className="flex-container align-self-center" style={{flex: "3"}}>
|
||||
<div className="flex-item1 text-light" style={{fontSize: "50px"}}><a>{movie.title}</a></div>
|
||||
<div className="flex-item3 text-light" style={{fontSize: "35px"}}>Average score: {movie.score}</div>
|
||||
<div className="flex-item3 text-light" style={{fontSize: "35px"}}>Length: {movie.length}</div>
|
||||
<div className="flex-item3 text-light" style={{fontSize: "35px"}}>Genre: {movie.genreName}</div>
|
||||
<button className="primary" onClick={handleModalOpen}>Edit Movie</button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<Footer/>
|
||||
<Modal show={showModal} onHide={handleModalClose}>
|
||||
<Modal.Header closeButton>
|
||||
<Modal.Title>Edit Movie</Modal.Title>
|
||||
</Modal.Header>
|
||||
<Modal.Body>
|
||||
<div className="form-group">
|
||||
<label>Title:</label>
|
||||
<input type="text" className="form-control" name="title" value={modalData.title} onChange={handleModalInputChange} />
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>Score:</label>
|
||||
<input type="text" className="form-control" name="score" value={modalData.score} onChange={handleModalInputChange} />
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>Length:</label>
|
||||
<input type="text" className="form-control" name="length" value={modalData.length} onChange={handleModalInputChange} />
|
||||
</div>
|
||||
</Modal.Body>
|
||||
<Modal.Footer>
|
||||
<Button variant="secondary" onClick={handleModalClose}>Close</Button>
|
||||
<Button variant="primary" onClick={handleModalSubmit}>Save Changes</Button>
|
||||
</Modal.Footer>
|
||||
</Modal>
|
||||
</div>
|
||||
</body>
|
||||
)
|
||||
}
|
||||
export default Filmpage;
|
61
frontend/src/Pages/Librarypage.js
Normal file
61
frontend/src/Pages/Librarypage.js
Normal file
@ -0,0 +1,61 @@
|
||||
import React,{useEffect,useState} from "react";
|
||||
import gradientImg from '../Assets/background.png';
|
||||
import Footer from '../Components/Footer';
|
||||
import Navbar from '../Components/Navbar';
|
||||
import Film from "../Components/Film";
|
||||
import { useParams} from 'react-router-dom';
|
||||
import { getCustomerMovies } from "../Components/DataService";
|
||||
import { removeCustomerMovie } from "../Components/DataService";
|
||||
function Librarypage()
|
||||
{
|
||||
const [movies, setMovies] = useState([]);
|
||||
const { customerId } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
fetchMovies();
|
||||
}, []);
|
||||
|
||||
const fetchMovies = async () => {
|
||||
const moviesData = await getCustomerMovies(customerId);
|
||||
console.log(moviesData);
|
||||
setMovies(moviesData);
|
||||
};
|
||||
|
||||
const handleDeleteMovie = async (movieId) => {
|
||||
await removeCustomerMovie(movieId,customerId);
|
||||
fetchMovies();
|
||||
}
|
||||
return(
|
||||
<div style={{backgroundImage: `url(${gradientImg})`}}>
|
||||
<Navbar customerId={customerId}/>
|
||||
|
||||
<div className="flex-container min-vh-100" style={{display: "flex", marginLeft:"20px",marginTop:"50px"}}>
|
||||
|
||||
{movies.length > 0 ? (
|
||||
<div style={{flexDirection: "row", display:"flex",flexWrap: "wrap",gap:"30px"}}>
|
||||
{movies.map((movie) => (
|
||||
<Film key={movie.id}
|
||||
title={movie.title}
|
||||
main={false}
|
||||
acquire={() => handleDeleteMovie(movie.id)}
|
||||
movieId = {movie.id}
|
||||
customerId={customerId}
|
||||
/>
|
||||
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<h1 style={{color:"white"}}>No movies available</h1>
|
||||
)}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<Footer/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
)
|
||||
}
|
||||
export default Librarypage;
|
61
frontend/src/Pages/Loginpage.js
Normal file
61
frontend/src/Pages/Loginpage.js
Normal file
@ -0,0 +1,61 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import gradientImg from '../Assets/background.png';
|
||||
import { getCustomers } from '../Components/DataService';
|
||||
import { fillRepos } from '../Components/DataService';
|
||||
function Loginpage() {
|
||||
|
||||
const [users, setUsers] = useState([]);
|
||||
const [selectedUser, setSelectedUser] = useState('');
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
fetchUsers();
|
||||
}, []);
|
||||
|
||||
|
||||
const fetchUsers = async () => {
|
||||
fillRepos();
|
||||
const usersData = await getCustomers();
|
||||
setUsers(usersData);
|
||||
|
||||
}
|
||||
|
||||
const handleUserChange = (event) => {
|
||||
setSelectedUser(event.target.value);
|
||||
};
|
||||
|
||||
const handleLogin = () => {
|
||||
|
||||
if (selectedUser || users.length === 1) {
|
||||
const userId = selectedUser || users[0].id;
|
||||
navigate(`/movie/${userId}`);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
|
||||
<div className="flex-container" style={{flexDirection:"column",display: "flex",backgroundImage: `url(${gradientImg})`}}>
|
||||
<div className="flex-container min-vh-100" style={{flexDirection: "column", display: "flex", alignItems: "center", justifyContent: "center", gap: "20px"}}>
|
||||
<h1 htmlFor="userSelect" style={{color: "white"}}>Select User:</h1>
|
||||
<select id="userSelect" value={selectedUser} onChange={handleUserChange} style={{width: "100px"}}>
|
||||
{
|
||||
users.map((user) => (
|
||||
<option key={user.id} value={user.id}>
|
||||
{`${user.username}`}
|
||||
</option>
|
||||
))
|
||||
}
|
||||
</select>
|
||||
<button style={{marginTop: "50px"}}onClick={handleLogin}>Login</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
export default Loginpage;
|
66
frontend/src/Pages/Mainpage.js
Normal file
66
frontend/src/Pages/Mainpage.js
Normal file
@ -0,0 +1,66 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import gradientImg from '../Assets/background.png';
|
||||
import Footer from '../Components/Footer';
|
||||
import { getMovies } from '../Components/DataService';
|
||||
import { acquireMovie } from '../Components/DataService';
|
||||
import { useParams} from 'react-router-dom';
|
||||
import Navbar from '../Components/Navbar';
|
||||
import Film from '../Components/Film';
|
||||
function MainPage() {
|
||||
const [movies, setMovies] = useState([]);
|
||||
const { customerId } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
fetchMovies();
|
||||
}, []);
|
||||
|
||||
const fetchMovies = async () => {
|
||||
const moviesData = await getMovies();
|
||||
console.log(moviesData);
|
||||
setMovies(moviesData);
|
||||
};
|
||||
|
||||
const handleAcquireMovie = async (movieId) => {
|
||||
await acquireMovie(movieId,customerId);
|
||||
const updatedMovies = movies.map((movie) => {
|
||||
return movie;
|
||||
});
|
||||
|
||||
setMovies(updatedMovies);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
<div style={{backgroundImage: `url(${gradientImg})`}}>
|
||||
<Navbar customerId={customerId}/>
|
||||
|
||||
<div className="flex-container min-vh-100" style={{flexDirection: "row", display: "flex", marginLeft:"20px",marginTop:"50px"}}>
|
||||
|
||||
{movies.length > 0 ? (
|
||||
<div style={{flexDirection: "row", display:"flex",flexWrap: "wrap",justifyContent:"space-between"}}>
|
||||
{movies.map((movie) => (
|
||||
<Film key={movie.id}
|
||||
title={movie.title}
|
||||
acquire={() => handleAcquireMovie(movie.id)}
|
||||
main = {true}
|
||||
movieId = {movie.id}
|
||||
customerId={customerId}
|
||||
/>
|
||||
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<h1 style={{color: "white"}}>No movies available</h1>
|
||||
)}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<Footer/>
|
||||
</div>
|
||||
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
export default MainPage;
|
71
frontend/src/Pages/Regpage.js
Normal file
71
frontend/src/Pages/Regpage.js
Normal file
@ -0,0 +1,71 @@
|
||||
import React,{useState} from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { registerUser } from '../Components/DataService.js';
|
||||
import gradientImg from '../Assets/background.png';
|
||||
import CoverImg from '../Assets/cover.png'
|
||||
import Footer from '../Components/Footer';
|
||||
function Regpage()
|
||||
{
|
||||
|
||||
const [inputUsername, setUsername] = useState('');
|
||||
const [inputPassword,setPassword] = useState('');
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleInputChange = (e) => {
|
||||
const {id , value} = e.target;
|
||||
if(id === "inputUsername"){
|
||||
setUsername(value);
|
||||
}
|
||||
if(id === "inputPassword"){
|
||||
setPassword(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const handleSubmit = async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const customerDTO = await registerUser(inputUsername, inputPassword);
|
||||
setUsername ('');
|
||||
setPassword ('');
|
||||
navigate(`/login`);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return(
|
||||
|
||||
<div className="flex-container" style={{flexDirection:"column",display: "flex",backgroundImage: `url(${gradientImg})`}}>
|
||||
<div className="flex-container min-vh-100" style={{flexDirection: "column", display: "flex"}}>
|
||||
<main style={{display: "flex", flex: "1"}}>
|
||||
<aside className="flex-item2" style={{flex: "2"}}></aside>
|
||||
<div className="flex-item3 align-self-center" style={{flex: "3"}}><img src={CoverImg} alt = "cover" width="100%" height="600px"/></div>
|
||||
<section className="flex-container align-self-center" style={{height:"660px", flex: "4", backgroundColor: "#ffd79d", flexDirection: "column", display: "flex"}}>
|
||||
<form>
|
||||
<section className="flex-itemR1" style={{color: "#320D3E",fontSize: "50px",fontWeight: "bold", paddingLeft: "30px",paddingTop: "10px"}}>SIGN UP</section>
|
||||
<section className="flex-itemR2" style={{color: "#320D3E",fontSize: "35px",fontWeight: "bold", paddingLeft: "30px",paddingTop: "10px"}}>
|
||||
<label style={{color: "#320D3E",fontSize: "32px",fontWeight: "bold"}}>USERNAME</label>
|
||||
</section>
|
||||
<section className="flex-itemR3" style={{display: "flex", width: "320px", paddingLeft: "30px"}}>
|
||||
<input className="form-control" id="inputUsername" type="string" value={inputUsername} onChange = {(e) => handleInputChange(e)} placeholder="Enter username"/>
|
||||
</section>
|
||||
<section className="flex-itemR6" style={{color: "#320D3E",fontSize: "35px",fontWeight: "bold", paddingLeft: "30px",paddingTop: "10px"}}>
|
||||
<label style={{color: "#320D3E",fontSize: "32px",fontWeight: "bold"}}>PASSWORD</label>
|
||||
</section>
|
||||
<section className="flex-itemR7" style={{display: "flex", width: "320px", paddingLeft: "30px"}}>
|
||||
<input className="form-control" id="inputPassword" type="password" value={inputPassword} onChange = {(e) => handleInputChange(e)} placeholder="Enter password"/>
|
||||
</section>
|
||||
<button className="btn btn-primary" type="submit" id="register" style={{fontSize: "20px", marginLeft: "30px", marginTop: "15px", width: "150px", backgroundColor: "#320D3E", color:"white", fontWeight: "bold"}} onClick={(e)=>handleSubmit(e)} >Register</button>
|
||||
<a href="/login">Sign in</a>
|
||||
</form>
|
||||
</section>
|
||||
<aside className="flex-item5" style={{flex: "2"}}></aside>
|
||||
</main>
|
||||
</div>
|
||||
<Footer/>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
export default Regpage;
|
85
frontend/src/Pages/Searchpage.js
Normal file
85
frontend/src/Pages/Searchpage.js
Normal file
@ -0,0 +1,85 @@
|
||||
import React,{useState,useEffect} from "react";
|
||||
import gradientImg from '../Assets/background.png'
|
||||
import Navbar from '../Components/Navbar';
|
||||
import Footer from '../Components/Footer'
|
||||
import Film from '../Components/Film';
|
||||
import { getMoviesByGenre } from "../Components/DataService";
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { getGenres } from "../Components/DataService";
|
||||
function Searchpage()
|
||||
{
|
||||
|
||||
const { customerId } = useParams();
|
||||
const [genres, setGenres] = useState([]);
|
||||
const [movies, setMovies] = useState([]);
|
||||
const [selectedGenre, setSelectedGenre] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
fetchGenres();
|
||||
}, []);
|
||||
|
||||
const fetchGenres = async() =>{
|
||||
const response = await getGenres();
|
||||
setGenres(response);
|
||||
}
|
||||
|
||||
const handleGenreChange = (event) => {
|
||||
setSelectedGenre(event.target.value);
|
||||
};
|
||||
|
||||
const handleSearch = async () => {
|
||||
setLoading(true);
|
||||
|
||||
const response = await getMoviesByGenre(selectedGenre);
|
||||
setLoading(false);
|
||||
setMovies(response);
|
||||
}
|
||||
return (
|
||||
|
||||
|
||||
<div className="flex-container" style={{ flexDirection: "column", display: "flex", backgroundImage: `url(${gradientImg})` }}>
|
||||
<Navbar customerId={customerId} />
|
||||
|
||||
<div className="flex-container min-vh-100" style={{ flexDirection: "column", display: "flex", flex: "1", alignItems: "center", justifyContent: "flex-start", marginTop: "20px" }}>
|
||||
<div>
|
||||
<select id="genre-select" value={selectedGenre} onChange={handleGenreChange}>
|
||||
<option value="all">All Genres</option>
|
||||
{genres.map((genre) => (
|
||||
<option key={genre.id} value={genre.name}>
|
||||
{genre.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<button type="button" onClick={handleSearch}>Search</button>
|
||||
</div>
|
||||
<div className="flex-container min-vh-100" style={{flexDirection: "row", display: "flex", marginLeft:"20px",marginTop:"50px"}}>
|
||||
{loading ? (
|
||||
<p>Loading movies...</p>
|
||||
) : (
|
||||
<div style={{flexDirection: "row", display:"flex",flexWrap: "wrap",gap:"30px"}}>
|
||||
{movies.length > 0 ? (
|
||||
movies.map((movie) => (
|
||||
<Film
|
||||
key={movie.id}
|
||||
title={movie.title}
|
||||
movieId={movie.id}
|
||||
customerId={customerId}
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
<h1 style={{color:"white"}}>No movies found</h1>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Footer/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
export default Searchpage;
|
13
frontend/src/Templates/Error.html
Normal file
13
frontend/src/Templates/Error.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div><span th:text="${error}"></span></div>
|
||||
<a href="/">Return to registration</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
85
frontend/src/Templates/Filmpage.html
Normal file
85
frontend/src/Templates/Filmpage.html
Normal file
@ -0,0 +1,85 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div class="flex-container" style="flex-direction: column; display: flex; background-image: url('background.png');">
|
||||
<div class="flex-container min-vh-100" style="flex-direction: column; display: flex;">
|
||||
<main style="display: flex; flex: 1; gap: 100px;">
|
||||
<div class="flex-container" style="display: inline-flex; flex: 1; flex-wrap: wrap; gap: 40px;">
|
||||
<div class="flex-item1 align-self-center" style="flex: 1;">
|
||||
<img src="https://www.seekpng.com/png/detail/8-84931_question-mark-question-mark-white-background.png" width="400px" height="600px"/>
|
||||
</div>
|
||||
<div class="flex-container align-self-center" style="flex: 3;">
|
||||
<div class="flex-item1 text-light" style="font-size: 50px;"><a th:text="${movie.title}"></a></div>
|
||||
<div class="flex-item3 text-light" style="font-size: 35px;">Average score: <span th:text="${movie.score}"></span></div>
|
||||
<div class="flex-item3 text-light" style="font-size: 35px;">Length: <span th:text="${movie.length}"></span></div>
|
||||
<div class="flex-item3 text-light" style="font-size: 35px;">Genre: <span th:text="${movie.genreName}"></span></div>
|
||||
<button class="primary" onclick="handleModalOpen()">Edit Movie</button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<div id="modal" class="modal" th:classappend="${showModal} ? 'show' : ''">
|
||||
<div class="modal-content">
|
||||
<span class="close" onclick="handleModalClose()">×</span>
|
||||
<h2>Edit Movie</h2>
|
||||
<div class="form-group">
|
||||
<label>Title:</label>
|
||||
<input type="text" class="form-control" name="title" th:value="${modalData.title}"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Score:</label>
|
||||
<input type="text" class="form-control" name="score" th:value="${modalData.score}"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Length:</label>
|
||||
<input type="text" class="form-control" name="length" th:value="${modalData.length}"/>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-secondary" onclick="handleModalClose()">Close</button>
|
||||
<button class="btn btn-primary" onclick="handleModalSubmit()">Save Changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
|
||||
function handleModalOpen() {
|
||||
var modal = document.getElementById("modal");
|
||||
modal.classList.add("show");
|
||||
}
|
||||
|
||||
function handleModalClose() {
|
||||
var modal = document.getElementById("modal");
|
||||
modal.classList.remove("show");
|
||||
|
||||
titleInput.value = "";
|
||||
scoreInput.value = "";
|
||||
lengthInput.value = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
function handleModalSubmit() {
|
||||
var titleInput = document.getElementsByName("title")[0];
|
||||
var scoreInput = document.getElementsByName("score")[0];
|
||||
var lengthInput = document.getElementsByName("length")[0];
|
||||
|
||||
var modalData = {
|
||||
title: titleInput.value,
|
||||
score: scoreInput.value,
|
||||
length: lengthInput.value
|
||||
};
|
||||
|
||||
const movieId = "${param.movieId}";
|
||||
modal.classList.remove("show");
|
||||
window.location.href = `/movies/movie/update/${movieId}?title=${modalData["title"]}&length=${modalData["length"]}&score=${modalData["score"]}`
|
||||
}
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
36
frontend/src/Templates/Librarypage.html
Normal file
36
frontend/src/Templates/Librarypage.html
Normal file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
|
||||
|
||||
<div class="flex-container min-vh-100" style="display: flex; margin-left: 20px; margin-top: 50px">
|
||||
|
||||
<th:block th:if="${movies.size() > 0}">
|
||||
<div style="flex-direction: row; display: flex; flex-wrap: wrap; gap: 30px">
|
||||
<th:block th:each="movie : ${movies}">
|
||||
<div>
|
||||
<h3 th:text="${movie.title}"></h3>
|
||||
<form th:action="@{/movies/{customerId}/delete/{movieId}(customerId=${customerId}, movieId=${movie.id})}" method="post">
|
||||
<button type="submit">Remove</button>
|
||||
</form>
|
||||
</div>
|
||||
</th:block>
|
||||
</div>
|
||||
</th:block>
|
||||
<h1 th:unless="${movies.size() > 0}" style="color: white">No movies available</h1>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
|
||||
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
32
frontend/src/Templates/Login.html
Normal file
32
frontend/src/Templates/Login.html
Normal file
@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div class="flex-container" style="flex-direction: column; display: flex; ">
|
||||
<div class="flex-container min-vh-100" style="flex-direction: column; display: flex; align-items: center; justify-content: center; gap: 20px;">
|
||||
<h1 for="userSelect" style="color: white;">Select User:</h1>
|
||||
<select id="userSelect" onchange="handleUserChange(event)" style="width: 100px;">
|
||||
<option th:each="customer : ${customers}" th:value="${customer.id}" th:text="${customer.username}"></option>
|
||||
</select>
|
||||
<button style="margin-top: 50px;" onclick="handleLogin()">Login</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
|
||||
function handleUserChange(event) {
|
||||
var selectedUserId = event.target.value;
|
||||
}
|
||||
|
||||
function handleLogin() {
|
||||
var selectedUserId = document.getElementById("userSelect").value;
|
||||
document.cookie = "userID=" + selectedUserId;
|
||||
window.location.href = "/genre/fill";
|
||||
}
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
38
frontend/src/Templates/Mainpage.html
Normal file
38
frontend/src/Templates/Mainpage.html
Normal file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
|
||||
|
||||
<div class="flex-container min-vh-100" style="flex-direction: row; display: flex; margin-left: 20px; margin-top: 50px;">
|
||||
<div th:if="${movies.length > 0}" style="flex-direction: row; display: flex; flex-wrap: wrap; justify-content: space-between;">
|
||||
<div th:each="movie : ${movies}" style="margin-bottom: 20px;">
|
||||
<div>
|
||||
<h3><a th:href="@{/movies/movie/{movieId}, movieId=${movie.id}}"
|
||||
th:text="${movie.title}"></a></h3>
|
||||
<button type="button" th:attr="data-movie-id=${movie.id}" onclick="handleAcquireMovie(event)">Acquire</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1 th:unless="${movies.length > 0}" style="color: white;">No movies available</h1>
|
||||
</div>
|
||||
|
||||
<div th:replace="fragments/footer :: footer"></div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
<script th:inline="javascript">
|
||||
|
||||
function handleAcquireMovie(movieId) {
|
||||
var movieId = event.target.getAttribute("data-movie-id");
|
||||
var customerID = /*[[${userId}]]*/ null;
|
||||
var url = "/movies/" + customerId + "/" + movieId;
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
37
frontend/src/Templates/Registration.html
Normal file
37
frontend/src/Templates/Registration.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div class="flex-container" style="flex-direction: column; display: flex;">
|
||||
<div class="flex-container min-vh-100" style="flex-direction: column; display: flex;">
|
||||
<main style="display: flex; flex: 1;">
|
||||
<aside class="flex-item2" style="flex: 2;"></aside>
|
||||
<div class="flex-item3 align-self-center" style="flex: 3;"><img src="cover.png" alt="cover" width="100%" height="600px"/></div>
|
||||
<section class="flex-container align-self-center" style="height: 660px; flex: 4; background-color: #ffd79d; flex-direction: column; display: flex;">
|
||||
<form action="#" th:action="@{/customer}" method="post">
|
||||
<section class="flex-itemR1" style="color: #320D3E; font-size: 50px; font-weight: bold; padding-left: 30px; padding-top: 10px;">SIGN UP</section>
|
||||
<section class="flex-itemR2" style="color: #320D3E; font-size: 35px; font-weight: bold; padding-left: 30px; padding-top: 10px;">
|
||||
<label style="color: #320D3E; font-size: 32px; font-weight: bold;">USERNAME</label>
|
||||
</section>
|
||||
<section class="flex-itemR3" style="display: flex; width: 320px; padding-left: 30px;">
|
||||
<input class="form-control" id="inputUsername" type="string" name="fullName" placeholder="Enter username" th:value="${inputUsername}"/>
|
||||
</section>
|
||||
<section class="flex-itemR6" style="color: #320D3E; font-size: 35px; font-weight: bold; padding-left: 30px; padding-top: 10px;">
|
||||
<label style="color: #320D3E; font-size: 32px; font-weight: bold;">PASSWORD</label>
|
||||
</section>
|
||||
<section class="flex-itemR7" style="display: flex; width: 320px; padding-left: 30px;">
|
||||
<input class="form-control" id="inputPassword" type="password" name="password" placeholder="Enter password" th:value="${inputPassword}"/>
|
||||
</section>
|
||||
<button class="btn btn-primary" type="submit" id="register" style="font-size: 20px; margin-left: 30px; margin-top: 15px; width: 150px; background-color: #320D3E; color: white; font-weight: bold;">Register</button>
|
||||
<a href="/login">Sign in</a>
|
||||
</form>
|
||||
</section>
|
||||
<aside class="flex-item5" style="flex: 2;"></aside>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
70
frontend/src/Templates/Searchpage.html
Normal file
70
frontend/src/Templates/Searchpage.html
Normal file
@ -0,0 +1,70 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div class="flex-container" style="flex-direction: column; display: flex;">
|
||||
<div class="flex-container min-vh-100" style="flex-direction: column; display: flex; flex: 1; align-items: center; justify-content: flex-start; margin-top: 20px">
|
||||
<div>
|
||||
<select id="genre-select">
|
||||
<option value="all">All Genres</option>
|
||||
<option th:each="genre : ${genres}" th:value="${genre.name}" th:text="${genre.name}"></option>
|
||||
</select>
|
||||
<button type="button" onclick="handleSearch()">Search</button>
|
||||
</div>
|
||||
<div class="flex-container min-vh-100" style="flex-direction: row; display: flex; margin-left: 20px; margin-top: 50px">
|
||||
<div style="flex-direction: row; display: flex; flex-wrap: wrap; gap: 30px">
|
||||
<div th:if="${movies.length > 0}" th:each="movie : ${movies}" style="margin-bottom: 20px;">
|
||||
<div>
|
||||
<h3><a th:href="@{/movies/movie/{movieId}, movieId=${movie.id}}"
|
||||
th:text="${movie.title}"></a></h3>
|
||||
</div>
|
||||
</div>
|
||||
<h1 th:if="${movies.length == 0}" style="color: white">No movies found</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
function handleSearch() {
|
||||
const genreSelect = document.getElementById("genre-select");
|
||||
const selectedGenre = genreSelect.value;
|
||||
|
||||
fetch(`/movies/${selectedGenre}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
// Update the movies array in the Thymeleaf model
|
||||
const moviesContainer = document.querySelector(".flex-container.min-vh-100 > div:last-child");
|
||||
moviesContainer.innerHTML = ""; // Clear previous movie elements
|
||||
|
||||
if (data.length > 0) {
|
||||
data.forEach(movie => {
|
||||
const movieElement = document.createElement("div");
|
||||
movieElement.innerHTML = `
|
||||
<div>
|
||||
<h3><a th:href="@{/movies/movie/{movieId}, movieId=${movie.id}}"
|
||||
th:text="${movie.title}"></a></h3>
|
||||
</div>
|
||||
`;
|
||||
moviesContainer.appendChild(movieElement);
|
||||
});
|
||||
} else {
|
||||
const noMoviesElement = document.createElement("h1");
|
||||
noMoviesElement.style.color = "white";
|
||||
noMoviesElement.textContent = "No movies found";
|
||||
moviesContainer.appendChild(noMoviesElement);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error fetching movies:", error);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
43
frontend/src/Templates/Template.html
Normal file
43
frontend/src/Templates/Template.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||
|
||||
<div style="background-image: url(background.png);">
|
||||
<nav class="navbar navbar-expand-lg navbar-light">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="/movies" th:classappend="${#strings.equals(activeLink, '/movies')} ? 'active' : ''">
|
||||
Main Page
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="/genre" th:classappend="${#strings.equals(activeLink, '/genre')} ? 'active' : ''">
|
||||
Search Page
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" th:href="@{/customer/movies/{customerId}(customerId=${param.customerId})}">
|
||||
Library Page
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="/" th:classappend="${#strings.equals(activeLink, '/')} ? 'active' : ''">
|
||||
Registration Page
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div layout:fragment="content">
|
||||
|
||||
</div>
|
||||
<footer class="flex-item6">
|
||||
<div class="text-center text-light p-2" style="font-size: 30px; font-weight: bold;">
|
||||
@2022 Copyright: BLSJY.com
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
<th:block layout:fragment="scripts">
|
||||
</th:block>
|
||||
</html>
|
BIN
frontend/src/Templates/background.png
Normal file
BIN
frontend/src/Templates/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
frontend/src/Templates/cover.png
Normal file
BIN
frontend/src/Templates/cover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
13
frontend/src/index.css
Normal file
13
frontend/src/index.css
Normal file
@ -0,0 +1,13 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
17
frontend/src/index.js
Normal file
17
frontend/src/index.js
Normal file
@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
|
||||
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||
root.render(
|
||||
<App />
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
13
frontend/src/reportWebVitals.js
Normal file
13
frontend/src/reportWebVitals.js
Normal file
@ -0,0 +1,13 @@
|
||||
const reportWebVitals = onPerfEntry => {
|
||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||
getCLS(onPerfEntry);
|
||||
getFID(onPerfEntry);
|
||||
getFCP(onPerfEntry);
|
||||
getLCP(onPerfEntry);
|
||||
getTTFB(onPerfEntry);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default reportWebVitals;
|
5
frontend/src/setupTests.js
Normal file
5
frontend/src/setupTests.js
Normal file
@ -0,0 +1,5 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom';
|
23
frontend/src/style.css
Normal file
23
frontend/src/style.css
Normal file
@ -0,0 +1,23 @@
|
||||
@media screen and (max-width: 768px) {
|
||||
|
||||
main
|
||||
{
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
header
|
||||
{
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
.button:hover
|
||||
{
|
||||
background-color: #ffd79d;
|
||||
color:black;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
package ru.ulstu.is.sbapp.Customer.Controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.Customer.Service.CustomerService;
|
||||
import ru.ulstu.is.sbapp.Movie.Controller.MovieDTO;
|
||||
import ru.ulstu.is.sbapp.WebConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(WebConfiguration.REST_API + "/customer")
|
||||
@ControllerAdvice(annotations = RestController.class)
|
||||
public class CustomerController {
|
||||
private final CustomerService customerService;
|
||||
|
||||
public CustomerController(CustomerService customerService)
|
||||
{
|
||||
this.customerService = customerService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public CustomerDTO getCustomer(@PathVariable Long id) {
|
||||
return new CustomerDTO(customerService.findCustomer(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<CustomerDTO> getCustomers() {
|
||||
return customerService.findAllCustomers().stream().map(CustomerDTO::new).toList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public CustomerDTO createCustomer(@RequestParam("fullName") String fullName, @RequestParam("password") String password ) {
|
||||
return new CustomerDTO(customerService.addCustomer(fullName,password));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public CustomerDTO updateCustomer(@PathVariable Long id, @RequestParam("fullName") String fullName) {
|
||||
return new CustomerDTO(customerService.updateCustomer(id,fullName));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public CustomerDTO deleteCustomer(@PathVariable Long id) {
|
||||
return new CustomerDTO(customerService.deleteCustomer(id));
|
||||
}
|
||||
|
||||
@GetMapping("/movies/{customerId}")
|
||||
public List<MovieDTO> getCustomerMovies(@PathVariable("customerId") Long customerId) {
|
||||
return customerService.findCustomerMovies(customerId).stream()
|
||||
.map(MovieDTO::new)
|
||||
.toList();
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package ru.ulstu.is.sbapp.Customer.Controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import ru.ulstu.is.sbapp.Customer.Model.Customer;
|
||||
import ru.ulstu.is.sbapp.Movie.Controller.MovieDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CustomerDTO {
|
||||
private final long id;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final List<MovieDTO> movies;
|
||||
public CustomerDTO(Customer customer) {
|
||||
this.id = customer.getId();
|
||||
this.username = customer.getUsername();
|
||||
this.password = customer.getPassword();
|
||||
this.movies = customer.getMovies().stream().map(MovieDTO::new).toList();
|
||||
}
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
public long getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public List<MovieDTO> getMovies() {
|
||||
return movies;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.Customer.Exception;
|
||||
|
||||
public class CustomerNotFoundException extends RuntimeException{
|
||||
public CustomerNotFoundException(Long id){
|
||||
super(String.format("Customer with id [%s] is not found", id));
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package ru.ulstu.is.sbapp.Customer.MVC;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.Customer.Controller.CustomerDTO;
|
||||
import ru.ulstu.is.sbapp.Customer.Service.CustomerService;
|
||||
import ru.ulstu.is.sbapp.Movie.Controller.MovieDTO;
|
||||
import ru.ulstu.is.sbapp.Utilities.CookiesManagement;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/customer")
|
||||
public class CustomerMVC {
|
||||
private final CustomerService customerService;
|
||||
private final CookiesManagement cookiesManagement;
|
||||
|
||||
public CustomerMVC(CustomerService customerService)
|
||||
{
|
||||
this.customerService = customerService;
|
||||
this.cookiesManagement = new CookiesManagement();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public String getCustomer(@PathVariable Long id, Model model) {
|
||||
model.addAttribute("customer",new CustomerDTO(customerService.findCustomer(id)));
|
||||
return "customer-details";
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String getCustomers(Model model) {
|
||||
model.addAttribute("customers", customerService.findAllCustomers().stream().map(CustomerDTO::new).toList());
|
||||
return "Login";
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public String createCustomer(@RequestParam("fullName") String fullName, @RequestParam("password") String password ) {
|
||||
customerService.addCustomer(fullName,password);
|
||||
return "redirect:/customer";
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public String updateCustomer(@PathVariable Long id, @RequestParam("fullName") String fullName) {
|
||||
return "redirect:/customer/" + new CustomerDTO(customerService.updateCustomer(id,fullName)).getID();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public String deleteCustomer(@PathVariable Long id) {
|
||||
customerService.deleteCustomer(id);
|
||||
return "redirect:/customer";
|
||||
}
|
||||
|
||||
@GetMapping("/movies")
|
||||
public String getCustomerMovies(HttpServletRequest request, Model model) {
|
||||
|
||||
Long userId = Long.parseLong(cookiesManagement.GetUserID(request));
|
||||
model.addAttribute("movies", customerService.findCustomerMovies(userId).stream()
|
||||
.map(MovieDTO::new)
|
||||
.toList());
|
||||
model.addAttribute("customerId",userId);
|
||||
return "Librarypage";
|
||||
}
|
||||
|
||||
}
|
74
src/main/java/ru/ulstu/is/sbapp/Customer/Model/Customer.java
Normal file
74
src/main/java/ru/ulstu/is/sbapp/Customer/Model/Customer.java
Normal file
@ -0,0 +1,74 @@
|
||||
package ru.ulstu.is.sbapp.Customer.Model;
|
||||
|
||||
|
||||
import ru.ulstu.is.sbapp.Movie.Model.Movie;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Entity
|
||||
public class Customer
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
@Column
|
||||
@NotBlank(message = "Username can't be null or empty")
|
||||
private String username;
|
||||
@Column
|
||||
@NotBlank(message = "Password can't be empty")
|
||||
private String password;
|
||||
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
|
||||
private List<Movie> movies;
|
||||
|
||||
|
||||
public Customer()
|
||||
{
|
||||
|
||||
}
|
||||
public Customer(String username,String password)
|
||||
{
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
|
||||
this.movies = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public String getPassword() {return password;}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username)
|
||||
{
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public List<Movie> getMovies()
|
||||
{
|
||||
return movies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Customer customer = (Customer) o;
|
||||
return Objects.equals(id, customer.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Customer: " + "ID: " + id + " | Username: " + username;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.Customer.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import ru.ulstu.is.sbapp.Customer.Model.Customer;
|
||||
|
||||
public interface CustomerRepository extends JpaRepository<Customer, Long> {
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package ru.ulstu.is.sbapp.Customer.Service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.ulstu.is.sbapp.Customer.Exception.CustomerNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Customer.Model.Customer;
|
||||
import ru.ulstu.is.sbapp.Customer.Repository.CustomerRepository;
|
||||
import ru.ulstu.is.sbapp.Movie.Model.Movie;
|
||||
import ru.ulstu.is.sbapp.Utilities.validation.ValidatorUtil;
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class CustomerService
|
||||
{
|
||||
private final CustomerRepository customerRepository;
|
||||
private final ValidatorUtil validatorUtil;
|
||||
|
||||
public CustomerService(CustomerRepository customerRepository, ValidatorUtil validatorUtil) {
|
||||
this.customerRepository = customerRepository;
|
||||
this.validatorUtil = validatorUtil;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Customer addCustomer(String fullName,String password)
|
||||
{
|
||||
if(!StringUtils.hasText(fullName))
|
||||
{
|
||||
throw new IllegalArgumentException("Customer's name or surname is missing");
|
||||
}
|
||||
|
||||
if(!StringUtils.hasText(password))
|
||||
{
|
||||
throw new IllegalArgumentException("Customer's name or surname is missing");
|
||||
}
|
||||
|
||||
final Customer customer = new Customer(fullName,password);
|
||||
validatorUtil.validate(customer);
|
||||
return customerRepository.save(customer);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Customer findCustomer(Long id)
|
||||
{
|
||||
final Optional<Customer> student = customerRepository.findById(id);
|
||||
return student.orElseThrow(() -> new CustomerNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Customer> findAllCustomers()
|
||||
{
|
||||
return customerRepository.findAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Customer updateCustomer(Long id, String fullName)
|
||||
{
|
||||
if(!StringUtils.hasText(fullName))
|
||||
{
|
||||
throw new IllegalArgumentException("Customer's name or surname is missing");
|
||||
}
|
||||
final Optional<Customer> customer = customerRepository.findById(id);
|
||||
if(customer.isEmpty())
|
||||
{
|
||||
throw new CustomerNotFoundException(id);
|
||||
}
|
||||
final Customer specificCustomer = customer.get();
|
||||
specificCustomer.setUsername(fullName);
|
||||
|
||||
validatorUtil.validate(specificCustomer);
|
||||
|
||||
return customerRepository.save(specificCustomer);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Customer deleteCustomer(Long id)
|
||||
{
|
||||
final Optional<Customer> customer = customerRepository.findById(id);
|
||||
if(customer.isEmpty())
|
||||
{
|
||||
throw new CustomerNotFoundException(id);
|
||||
}
|
||||
final Customer specificCustomer = customer.get();
|
||||
|
||||
customerRepository.delete(specificCustomer);
|
||||
return specificCustomer;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllCustomers()
|
||||
{
|
||||
customerRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Movie> findCustomerMovies(Long customerId){
|
||||
|
||||
final Optional<Customer> customer = customerRepository.findById(customerId);
|
||||
return customer.get().getMovies();
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package ru.ulstu.is.sbapp.Genre.Controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.Genre.Service.GenreService;
|
||||
import ru.ulstu.is.sbapp.WebConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping(WebConfiguration.REST_API + "/genre")
|
||||
@ControllerAdvice(annotations = RestController.class)
|
||||
public class GenreController {
|
||||
private final GenreService genreService;
|
||||
|
||||
public GenreController(GenreService genreService) {
|
||||
this.genreService = genreService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public GenreDTO getGenre(@PathVariable Long id) {
|
||||
return new GenreDTO(genreService.findGenre(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<GenreDTO> getGenres() {
|
||||
return genreService.findAllGenres().stream()
|
||||
.map(GenreDTO::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public GenreDTO createGenre(@RequestParam("name") String name) {
|
||||
return new GenreDTO(genreService.addGenre(name));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public GenreDTO updateGenre(@PathVariable Long id,
|
||||
@RequestParam("name") String name) {
|
||||
return new GenreDTO(genreService.updateGenre(id,name));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public GenreDTO deleteGenre(@PathVariable Long id) {
|
||||
return new GenreDTO(genreService.deleteGenre(id));
|
||||
}
|
||||
|
||||
@PostMapping("/fill")
|
||||
public boolean insertGenres() { return genreService.fillRepo();}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package ru.ulstu.is.sbapp.Genre.Controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
import ru.ulstu.is.sbapp.Movie.Controller.MovieDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GenreDTO {
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final List<MovieDTO> movies;
|
||||
|
||||
public GenreDTO(Genre genre) {
|
||||
this.id = genre.getId();
|
||||
this.name = genre.getName();
|
||||
this.movies = genre.getMovies().stream().map(MovieDTO::new).toList();
|
||||
}
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
public long getID() {
|
||||
return id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<MovieDTO> getMovies() {
|
||||
return movies;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package ru.ulstu.is.sbapp.Genre.Exception;
|
||||
|
||||
public class GenreNotFoundException extends RuntimeException{
|
||||
public GenreNotFoundException(Long id){
|
||||
super(String.format("Genre with id [%s] is not found", id));
|
||||
}
|
||||
|
||||
public GenreNotFoundException(String name){
|
||||
super(String.format("Genre with name [%s] is not found", name));
|
||||
}
|
||||
}
|
56
src/main/java/ru/ulstu/is/sbapp/Genre/MVC/GenreMVC.java
Normal file
56
src/main/java/ru/ulstu/is/sbapp/Genre/MVC/GenreMVC.java
Normal file
@ -0,0 +1,56 @@
|
||||
package ru.ulstu.is.sbapp.Genre.MVC;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.Genre.Controller.GenreDTO;
|
||||
import ru.ulstu.is.sbapp.Genre.Service.GenreService;
|
||||
import java.util.List;
|
||||
@Controller
|
||||
@RequestMapping("/genre")
|
||||
public class GenreMVC {
|
||||
private final GenreService genreService;
|
||||
|
||||
public GenreMVC(GenreService genreService) {
|
||||
this.genreService = genreService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public String getGenre(@PathVariable Long id, Model model) {
|
||||
model.addAttribute("genre",new GenreDTO(genreService.findGenre(id)));
|
||||
return "genre-details";
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String getGenres(Model model) {
|
||||
model.addAttribute("genres",genreService.findAllGenres().stream()
|
||||
.map(GenreDTO::new)
|
||||
.toList());
|
||||
return "Searchpage";
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public String createGenre(@RequestParam("name") String name) {
|
||||
|
||||
return "redirect:/genre/" + new GenreDTO(genreService.addGenre(name)).getID();
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public String updateGenre(@PathVariable Long id,
|
||||
@RequestParam("name") String name) {
|
||||
return "redirect:/genre/" + new GenreDTO(genreService.updateGenre(id,name)).getID();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public String deleteGenre(@PathVariable Long id) {
|
||||
|
||||
genreService.deleteGenre(id);
|
||||
return "redirect:/genre";
|
||||
}
|
||||
|
||||
@GetMapping("/fill")
|
||||
public String insertGenres() {
|
||||
genreService.fillRepo();
|
||||
return "redirect:/movies/fill";
|
||||
}
|
||||
}
|
66
src/main/java/ru/ulstu/is/sbapp/Genre/Model/Genre.java
Normal file
66
src/main/java/ru/ulstu/is/sbapp/Genre/Model/Genre.java
Normal file
@ -0,0 +1,66 @@
|
||||
package ru.ulstu.is.sbapp.Genre.Model;
|
||||
|
||||
import ru.ulstu.is.sbapp.Movie.Model.Movie;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
public class Genre
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
@Column
|
||||
@NotBlank(message = "Genre's can't be null or empty")
|
||||
private String name;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "genre", cascade = CascadeType.ALL)
|
||||
private List<Movie> movies;
|
||||
|
||||
public Genre()
|
||||
{
|
||||
|
||||
}
|
||||
public Genre(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.movies = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Movie> getMovies()
|
||||
{
|
||||
return movies;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Genre genre = (Genre) o;
|
||||
return Objects.equals(id, genre.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Genre: " + " ID: " + id + " | Name: " + name;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package ru.ulstu.is.sbapp.Genre.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
import ru.ulstu.is.sbapp.Movie.Model.Movie;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface GenreRepository extends JpaRepository<Genre,Long> {
|
||||
|
||||
Optional<Genre> findByNameLike(String genreName);
|
||||
}
|
120
src/main/java/ru/ulstu/is/sbapp/Genre/Service/GenreService.java
Normal file
120
src/main/java/ru/ulstu/is/sbapp/Genre/Service/GenreService.java
Normal file
@ -0,0 +1,120 @@
|
||||
package ru.ulstu.is.sbapp.Genre.Service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.ulstu.is.sbapp.Customer.Repository.CustomerRepository;
|
||||
import ru.ulstu.is.sbapp.Genre.Exception.GenreNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
import ru.ulstu.is.sbapp.Genre.Repository.GenreRepository;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import ru.ulstu.is.sbapp.Utilities.validation.ValidatorUtil;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class GenreService
|
||||
{
|
||||
private final GenreRepository genreRepository;
|
||||
private final ValidatorUtil validatorUtil;
|
||||
|
||||
public GenreService(GenreRepository genreRepository, ValidatorUtil validatorUtil) {
|
||||
this.genreRepository = genreRepository;
|
||||
this.validatorUtil = validatorUtil;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Genre addGenre(String name) {
|
||||
if(!StringUtils.hasText(name))
|
||||
{
|
||||
throw new IllegalArgumentException("Genre's name is missing");
|
||||
}
|
||||
final Genre genre = new Genre(name);
|
||||
validatorUtil.validate(genre);
|
||||
|
||||
return genreRepository.save(genre);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Genre findGenre(Long id) {
|
||||
final Optional<Genre> genre = genreRepository.findById(id);
|
||||
return genre.orElseThrow(() -> new GenreNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Genre findGenreByName(String name)
|
||||
{
|
||||
final Optional<Genre> genre = genreRepository.findByNameLike(name);
|
||||
return genre.orElseThrow(() -> new GenreNotFoundException(name));
|
||||
}
|
||||
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Genre> findAllGenres()
|
||||
{
|
||||
return genreRepository.findAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Genre updateGenre(Long id, String name) {
|
||||
if(!StringUtils.hasText(name))
|
||||
{
|
||||
throw new IllegalArgumentException("Genre's name is missing");
|
||||
}
|
||||
final Optional<Genre> genre = genreRepository.findById(id);
|
||||
if(genre.isEmpty())
|
||||
{
|
||||
throw new GenreNotFoundException(id);
|
||||
}
|
||||
Genre specificGenre = genre.get();
|
||||
specificGenre.setName(name);
|
||||
|
||||
validatorUtil.validate(genre);
|
||||
|
||||
return genreRepository.save(specificGenre);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Genre deleteGenre(Long id) {
|
||||
final Optional<Genre> genre = genreRepository.findById(id);
|
||||
if(genre.isEmpty())
|
||||
{
|
||||
throw new GenreNotFoundException(id);
|
||||
}
|
||||
Genre specificGenre = genre.get();
|
||||
specificGenre.getMovies().clear();
|
||||
genreRepository.delete(specificGenre);
|
||||
|
||||
return specificGenre;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllGenres() {
|
||||
genreRepository.deleteAll();
|
||||
}
|
||||
|
||||
public boolean fillRepo()
|
||||
{
|
||||
if(genreRepository.count() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Genre genreSciFi = addGenre("Sci-Fi");
|
||||
|
||||
Genre genreAdventure = addGenre("Adventure");
|
||||
|
||||
|
||||
Genre genreAction = addGenre("Action");
|
||||
|
||||
|
||||
Genre genreComedy = addGenre("Comedy");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package ru.ulstu.is.sbapp.Movie.Controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.Movie.Service.MovieService;
|
||||
import ru.ulstu.is.sbapp.WebConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping(WebConfiguration.REST_API + "/movie")
|
||||
@ControllerAdvice(annotations = RestController.class)
|
||||
public class MovieController {
|
||||
private final MovieService movieService;
|
||||
|
||||
public MovieController(MovieService movieService) {
|
||||
this.movieService = movieService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public MovieDTO getMovie(@PathVariable Long id) {
|
||||
return new MovieDTO(movieService.findMovie(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<MovieDTO> getMovies() {
|
||||
return movieService.findAllMovies().stream()
|
||||
.map(MovieDTO::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/movies/{genre}")
|
||||
public List<MovieDTO> getSpecificMovies(@PathVariable("genre") String genre) {
|
||||
return movieService.findAllSpecificMovies(genre).stream()
|
||||
.map(MovieDTO::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public MovieDTO createMovie(@RequestParam("title") String title, @RequestParam("length") int length, @RequestParam("score") double score, @RequestParam("genre") Long genreId) {
|
||||
return new MovieDTO(movieService.addMovie(title,length,score,genreId));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public MovieDTO updateMovie(@PathVariable("id") Long id,
|
||||
@RequestParam("title") String title,@RequestParam("length") int length,@RequestParam("score") double score ) {
|
||||
return new MovieDTO(movieService.updateMovie(id,title,length,score));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public MovieDTO deleteMovie(@PathVariable("id") Long id)
|
||||
{
|
||||
return new MovieDTO(movieService.deleteMovie(id));
|
||||
}
|
||||
|
||||
@PostMapping("/{customerId}/{id}")
|
||||
public MovieDTO assignMovie(@PathVariable("customerId") Long customerId, @PathVariable("id") Long id)
|
||||
{
|
||||
return new MovieDTO(movieService.assignMovie(customerId,id));
|
||||
}
|
||||
@DeleteMapping("/{customerId}/{id}")
|
||||
public MovieDTO deleteMovieCustomer(@PathVariable("customerId") Long customerId,@PathVariable("id") Long id) {
|
||||
return new MovieDTO(movieService.deleteMovieCustomer(id,customerId));
|
||||
}
|
||||
|
||||
@PostMapping("/fill")
|
||||
public boolean insertMovies()
|
||||
{
|
||||
return movieService.fillRepo();
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package ru.ulstu.is.sbapp.Movie.Controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
import ru.ulstu.is.sbapp.Movie.Model.Movie;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MovieDTO {
|
||||
|
||||
private final Long id;
|
||||
private final String title;
|
||||
private final int length;
|
||||
private final double score;
|
||||
private final String genreName;
|
||||
|
||||
public MovieDTO(Movie movie) {
|
||||
this.id = movie.getId();
|
||||
this.title = movie.getTitle();
|
||||
this.length = movie.getLength();
|
||||
this.score = movie.getScore();
|
||||
this.genreName = movie.getGenre().getName();
|
||||
}
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
public long getID() {
|
||||
return id;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public int getLength() {
|
||||
return length;
|
||||
}
|
||||
public double getScore() {
|
||||
return score;
|
||||
}
|
||||
public String getGenreName() {return genreName;}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.is.sbapp.Movie.Exception;
|
||||
|
||||
public class MovieNotFoundException extends RuntimeException{
|
||||
public MovieNotFoundException(Long id){
|
||||
super(String.format("Movie with id [%s] is not found", id));
|
||||
}
|
||||
}
|
113
src/main/java/ru/ulstu/is/sbapp/Movie/MVC/MovieMVC.java
Normal file
113
src/main/java/ru/ulstu/is/sbapp/Movie/MVC/MovieMVC.java
Normal file
@ -0,0 +1,113 @@
|
||||
package ru.ulstu.is.sbapp.Movie.MVC;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.sbapp.Genre.Controller.GenreDTO;
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
import ru.ulstu.is.sbapp.Genre.Service.GenreService;
|
||||
import ru.ulstu.is.sbapp.Movie.Controller.MovieDTO;
|
||||
import ru.ulstu.is.sbapp.Movie.Model.Movie;
|
||||
import ru.ulstu.is.sbapp.Movie.Service.MovieService;
|
||||
import ru.ulstu.is.sbapp.Utilities.CookiesManagement;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/movies")
|
||||
public class MovieMVC {
|
||||
private final MovieService movieService;
|
||||
private final GenreService genreService;
|
||||
private final CookiesManagement cookiesManagement;
|
||||
public MovieMVC(MovieService movieService, GenreService genreService)
|
||||
{
|
||||
this.movieService = movieService;
|
||||
this.genreService = genreService;
|
||||
this.cookiesManagement = new CookiesManagement();
|
||||
}
|
||||
|
||||
@GetMapping("/movie/{id}")
|
||||
public String getMovie(@PathVariable Long id, Model model) {
|
||||
model.addAttribute("movie", new MovieDTO(movieService.findMovie(id)));
|
||||
return "Filmpage";
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String getMovies(HttpServletRequest request, Model model) {
|
||||
|
||||
String userId = null;
|
||||
userId = cookiesManagement.GetUserID(request);
|
||||
|
||||
|
||||
model.addAttribute("movies", movieService.findAllMovies().stream()
|
||||
.map(MovieDTO::new)
|
||||
.toList());
|
||||
model.addAttribute("userId", userId);
|
||||
return "Mainpage";
|
||||
}
|
||||
|
||||
@GetMapping("/{genre}")
|
||||
public String getSpecificMovies(@PathVariable("genre") String genre, Model model) {
|
||||
if(!Objects.equals(genre, "null") && !Objects.equals(genre,"all"))
|
||||
{
|
||||
model.addAttribute("movies", movieService.findAllSpecificMovies(genre).stream()
|
||||
.map(MovieDTO::new)
|
||||
.toList());
|
||||
}
|
||||
else
|
||||
{
|
||||
model.addAttribute("movies", movieService.findAllMovies().stream()
|
||||
.map(MovieDTO::new)
|
||||
.toList());
|
||||
}
|
||||
model.addAttribute("genres",genreService.findAllGenres().stream().map(GenreDTO::new).toList());
|
||||
return "Searchpage";
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public String createMovie(@RequestParam("title") String title,
|
||||
@RequestParam("length") int length,
|
||||
@RequestParam("score") double score,
|
||||
@RequestParam("genre") Long genreId) {
|
||||
|
||||
return "redirect:/movie" + new MovieDTO(movieService.addMovie(title, length, score, genreId)).getID();
|
||||
}
|
||||
|
||||
@PostMapping("/movie/update/{id}")
|
||||
public String updateMovie(@PathVariable("id") Long id,
|
||||
@RequestParam("title") String title,
|
||||
@RequestParam("length") int length,
|
||||
@RequestParam("score") double score) {
|
||||
movieService.updateMovie(id, title, length, score);
|
||||
return "redirect:/movies/movie/" + id;
|
||||
}
|
||||
|
||||
@PostMapping("/movie/delete/{id}")
|
||||
public String deleteMovie(@PathVariable("id") Long id) {
|
||||
movieService.deleteMovie(id);
|
||||
return "redirect:/movie";
|
||||
}
|
||||
|
||||
@PostMapping("/customer/{id}")
|
||||
public String assignMovie(HttpServletRequest request,@PathVariable("id") Long id) {
|
||||
|
||||
Long customerId = Long.parseLong(cookiesManagement.GetUserID(request));
|
||||
movieService.assignMovie(customerId, id);
|
||||
return "redirect:/movies";
|
||||
}
|
||||
|
||||
@PostMapping("/customer/delete/{id}")
|
||||
public String deleteMovieCustomer(HttpServletRequest request, @PathVariable("id") Long id) {
|
||||
Long customerId = Long.parseLong(cookiesManagement.GetUserID(request));
|
||||
movieService.deleteMovieCustomer(id, customerId);
|
||||
return "redirect:/customer/movies";
|
||||
}
|
||||
|
||||
@GetMapping("/fill")
|
||||
public String insertMovies() {
|
||||
movieService.fillRepo();
|
||||
return "redirect:/movies";
|
||||
}
|
||||
}
|
100
src/main/java/ru/ulstu/is/sbapp/Movie/Model/Movie.java
Normal file
100
src/main/java/ru/ulstu/is/sbapp/Movie/Model/Movie.java
Normal file
@ -0,0 +1,100 @@
|
||||
package ru.ulstu.is.sbapp.Movie.Model;
|
||||
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
public class Movie
|
||||
{
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
@Column
|
||||
@NotBlank(message = "Movie's title can't be null or empty")
|
||||
private String title;
|
||||
@Column
|
||||
@NotNull(message = "Movie's length can't be null or empty")
|
||||
private int length;
|
||||
@Column
|
||||
@NotNull(message = "Movie's score can't be null or empty")
|
||||
private double score;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "genre_fk")
|
||||
private Genre genre;
|
||||
|
||||
|
||||
public Movie()
|
||||
{
|
||||
|
||||
}
|
||||
public Movie(String title, int length, double score, Genre genre)
|
||||
{
|
||||
this.title = title;
|
||||
this.length = length;
|
||||
this.score = score;
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(int length)
|
||||
{
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public double getScore()
|
||||
{
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(Double score)
|
||||
{
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Genre getGenre()
|
||||
{
|
||||
return genre;
|
||||
}
|
||||
|
||||
public void setGenre(Genre genre)
|
||||
{
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Movie movie = (Movie) o;
|
||||
return Objects.equals(id, movie.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Movie: " + " ID: " + id + " | Title: " + title + " | Length: " + length + " | Score: " + score;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package ru.ulstu.is.sbapp.Movie.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
import ru.ulstu.is.sbapp.Movie.Model.Movie;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MovieRepository extends JpaRepository<Movie,Long> {
|
||||
@Query("SELECT m FROM Movie m WHERE m.genre = :specGenre")
|
||||
List<Movie> findByGenre(@Param("specGenre") Genre genre);
|
||||
}
|
214
src/main/java/ru/ulstu/is/sbapp/Movie/Service/MovieService.java
Normal file
214
src/main/java/ru/ulstu/is/sbapp/Movie/Service/MovieService.java
Normal file
@ -0,0 +1,214 @@
|
||||
package ru.ulstu.is.sbapp.Movie.Service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.ulstu.is.sbapp.Customer.Exception.CustomerNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Customer.Model.Customer;
|
||||
import ru.ulstu.is.sbapp.Customer.Repository.CustomerRepository;
|
||||
import ru.ulstu.is.sbapp.Genre.Exception.GenreNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Genre.Model.Genre;
|
||||
import ru.ulstu.is.sbapp.Genre.Repository.GenreRepository;
|
||||
import ru.ulstu.is.sbapp.Movie.Controller.MovieDTO;
|
||||
import ru.ulstu.is.sbapp.Movie.Exception.MovieNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Movie.Model.Movie;
|
||||
import ru.ulstu.is.sbapp.Movie.Repository.MovieRepository;
|
||||
import ru.ulstu.is.sbapp.Utilities.validation.ValidatorUtil;
|
||||
|
||||
import javax.swing.text.html.Option;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MovieService
|
||||
{
|
||||
private final MovieRepository movieRepository;
|
||||
private final GenreRepository genreRepository;
|
||||
private final CustomerRepository customerRepository;
|
||||
private final ValidatorUtil validatorUtil;
|
||||
|
||||
public MovieService(MovieRepository movieRepository, GenreRepository genreRepository, CustomerRepository customerRepository, ValidatorUtil validatorUtil) {
|
||||
this.movieRepository = movieRepository;
|
||||
this.validatorUtil = validatorUtil;
|
||||
this.genreRepository = genreRepository;
|
||||
this.customerRepository = customerRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Movie addMovie(String title, int length, double score, Long genre)
|
||||
{
|
||||
if(!StringUtils.hasText(title) || length == 0 || score == 0 || genre == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("Some of the movie's properties are incorrect.");
|
||||
}
|
||||
final Optional<Genre> specGenre = genreRepository.findById(genre);
|
||||
|
||||
|
||||
if(specGenre.isEmpty())
|
||||
{
|
||||
throw new GenreNotFoundException(genre);
|
||||
}
|
||||
|
||||
final Movie movie = new Movie(title,length,score,specGenre.get());
|
||||
validatorUtil.validate(movie);
|
||||
|
||||
specGenre.get().getMovies().add(movie);
|
||||
|
||||
|
||||
return movieRepository.save(movie);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Movie assignMovie(Long customerId, Long movieId)
|
||||
{
|
||||
if(customerId == 0 || movieId == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("Some of the properties are incorrect.");
|
||||
}
|
||||
final Optional<Customer> specCustomer = customerRepository.findById(customerId);
|
||||
final Optional<Movie> specMovie = movieRepository.findById(movieId);
|
||||
|
||||
if(specCustomer.get().getMovies().contains(specMovie.get()))
|
||||
{
|
||||
throw new IllegalArgumentException("You already have this movie");
|
||||
}
|
||||
specCustomer.get().getMovies().add(specMovie.get());
|
||||
|
||||
return specMovie.get();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Movie findMovie(Long id)
|
||||
{
|
||||
final Optional<Movie> movie = movieRepository.findById(id);
|
||||
return movie.orElseThrow(() -> new MovieNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Movie> findAllMovies()
|
||||
{
|
||||
return movieRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public Movie updateMovie(Long id, String title, int length, double score)
|
||||
{
|
||||
if(!StringUtils.hasText(title) && length == 0 && score == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("Nothing to change.");
|
||||
}
|
||||
final Optional<Movie> movie = movieRepository.findById(id);
|
||||
if(movie.isEmpty())
|
||||
{
|
||||
throw new MovieNotFoundException(id);
|
||||
}
|
||||
|
||||
Movie specificMovie = movie.get();
|
||||
Genre specificGenre = movie.get().getGenre();
|
||||
|
||||
if(length != 0)
|
||||
{
|
||||
specificMovie.setLength(length);
|
||||
}
|
||||
if(StringUtils.hasText(title))
|
||||
{
|
||||
specificMovie.setTitle(title);
|
||||
}
|
||||
if(score != 0)
|
||||
{
|
||||
specificMovie.setScore(score);
|
||||
}
|
||||
|
||||
specificMovie.setGenre(specificGenre);
|
||||
|
||||
return movieRepository.save(specificMovie);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Movie deleteMovieCustomer(Long id, Long customerId)
|
||||
{
|
||||
final Optional<Movie> movie = movieRepository.findById(id);
|
||||
if(movie.isEmpty())
|
||||
{
|
||||
throw new MovieNotFoundException(id);
|
||||
}
|
||||
Movie specificMovie = movie.get();
|
||||
|
||||
specificMovie.getGenre().getMovies().remove(specificMovie);
|
||||
|
||||
final Optional<Customer> customer = customerRepository.findById(customerId);
|
||||
if(customer.isEmpty())
|
||||
{
|
||||
throw new CustomerNotFoundException(id);
|
||||
}
|
||||
|
||||
customer.get().getMovies().remove(specificMovie);
|
||||
|
||||
|
||||
return specificMovie;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Movie deleteMovie(Long id)
|
||||
{
|
||||
final Optional<Movie> movie = movieRepository.findById(id);
|
||||
if(movie.isEmpty())
|
||||
{
|
||||
throw new MovieNotFoundException(id);
|
||||
}
|
||||
Movie specificMovie = movie.get();
|
||||
|
||||
specificMovie.getGenre().getMovies().remove(specificMovie);
|
||||
|
||||
final List<Customer> customers = customerRepository.findAll();
|
||||
|
||||
customers.forEach(customer -> {
|
||||
customer.getMovies().remove(specificMovie);
|
||||
});
|
||||
|
||||
return specificMovie;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Movie> findAllSpecificMovies(String genreName)
|
||||
{
|
||||
return movieRepository.findByGenre(genreRepository.findByNameLike(genreName).get());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllMovies()
|
||||
{
|
||||
movieRepository.deleteAll();
|
||||
}
|
||||
|
||||
public boolean fillRepo()
|
||||
{
|
||||
if(movieRepository.count() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<Genre> genreSciFi = genreRepository.findByNameLike("Sci-Fi");
|
||||
Optional<Genre> genreAdventure = genreRepository.findByNameLike("Adventure");
|
||||
Optional<Genre> genreAction = genreRepository.findByNameLike("Action");
|
||||
Optional<Genre> genreComedy = genreRepository.findByNameLike("Comedy");
|
||||
|
||||
|
||||
|
||||
Movie interstellar = addMovie("Interstellar",12,4.5,genreSciFi.get().getId());
|
||||
Movie passengers = addMovie("Passengers",5,5.0,genreSciFi.get().getId());
|
||||
|
||||
Movie indianaJones = addMovie("Indiana Jones",9,4.3,genreAdventure.get().getId());
|
||||
Movie jumandji = addMovie("Djumandji",2,3.1,genreAdventure.get().getId());
|
||||
|
||||
Movie fastFurious = addMovie("Fast and Furious 2",4,4.1,genreAction.get().getId());
|
||||
Movie idk = addMovie("IDK",1,2.1,genreAction.get().getId());
|
||||
|
||||
Movie misterBean = addMovie("Mister bean in London",3,4.4,genreComedy.get().getId());
|
||||
Movie ted = addMovie("TED",5,5.0,genreComedy.get().getId());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,8 +2,7 @@ package ru.ulstu.is.sbapp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@SpringBootApplication
|
||||
@ -13,9 +12,4 @@ public class SbappApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SbappApplication.class, args);
|
||||
}
|
||||
|
||||
@GetMapping("/hello")
|
||||
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
|
||||
return String.format("Hello %s!", name);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package ru.ulstu.is.sbapp.Utilities;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class CookiesManagement {
|
||||
|
||||
public String GetUserID(HttpServletRequest request)
|
||||
{
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if (cookies != null) {
|
||||
for (Cookie cookie : cookies) {
|
||||
if ("userID".equals(cookie.getName())) {
|
||||
return cookie.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package ru.ulstu.is.sbapp.Utilities.error;
|
||||
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import ru.ulstu.is.sbapp.Customer.Exception.CustomerNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Genre.Exception.GenreNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Movie.Exception.MovieNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Utilities.validation.ValidationException;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ControllerAdvice
|
||||
public class AdviceController {
|
||||
@ExceptionHandler({
|
||||
MovieNotFoundException.class,
|
||||
GenreNotFoundException.class,
|
||||
CustomerNotFoundException.class,
|
||||
ValidationException.class
|
||||
})
|
||||
public ResponseEntity<Object> handleException(Throwable e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseEntity<Object> handleBindException(MethodArgumentNotValidException e) {
|
||||
final ValidationException validationException = new ValidationException(
|
||||
e.getBindingResult().getAllErrors().stream()
|
||||
.map(DefaultMessageSourceResolvable::getDefaultMessage)
|
||||
.collect(Collectors.toSet()));
|
||||
return handleException(validationException);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<Object> handleUnknownException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package ru.ulstu.is.sbapp.Utilities.validation;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ValidationException extends RuntimeException {
|
||||
public ValidationException(Set<String> errors) {
|
||||
super(String.join("\n", errors));
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package ru.ulstu.is.sbapp.Utilities.validation;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
import javax.validation.ValidatorFactory;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class ValidatorUtil {
|
||||
private final Validator validator;
|
||||
|
||||
public ValidatorUtil() {
|
||||
try (ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) {
|
||||
this.validator = factory.getValidator();
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void validate(T object) {
|
||||
final Set<ConstraintViolation<T>> errors = validator.validate(object);
|
||||
if (!errors.isEmpty()) {
|
||||
throw new ValidationException(errors.stream()
|
||||
.map(ConstraintViolation::getMessage)
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
}
|
14
src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java
Normal file
14
src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java
Normal file
@ -0,0 +1,14 @@
|
||||
package ru.ulstu.is.sbapp;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfiguration implements WebMvcConfigurer {
|
||||
public static final String REST_API = "/api";
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedMethods("*");
|
||||
}
|
||||
}
|
@ -1 +1,11 @@
|
||||
|
||||
spring.main.banner-mode=off
|
||||
#server.port=8080
|
||||
spring.datasource.url=jdbc:h2:file:./data
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=password
|
||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.settings.trace=false
|
||||
spring.h2.console.settings.web-allow-others=false
|
||||
|
13
src/main/resources/templates/Error.html
Normal file
13
src/main/resources/templates/Error.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div><span th:text="${error}"></span></div>
|
||||
<a href="/">Return to registration</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
81
src/main/resources/templates/Filmpage.html
Normal file
81
src/main/resources/templates/Filmpage.html
Normal file
@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<div layout:fragment="content">
|
||||
<div class="flex-container" style="flex-direction: column; display: flex;">
|
||||
<div class="flex-container min-vh-100" style="flex-direction: column; display: flex;">
|
||||
<main style="display: flex; flex: 1; gap: 100px;">
|
||||
<div class="flex-container" style="display: inline-flex; flex: 1; flex-wrap: wrap; gap: 40px;">
|
||||
<div class="flex-item1 align-self-center" style="flex: 1;">
|
||||
<img src="https://www.seekpng.com/png/detail/8-84931_question-mark-question-mark-white-background.png" width="400px" height="600px"/>
|
||||
</div>
|
||||
<div id="movieCard" th:attr="data-movie-id=${movie.getID()}"class="flex-container align-self-center" style="flex: 3;">
|
||||
<div class="flex-item1 text-light" style="font-size: 50px;"><a th:text="${movie.title}"></a></div>
|
||||
<div class="flex-item3 text-light" style="font-size: 35px;">Average score: <span th:text="${movie.score}"></span></div>
|
||||
<div class="flex-item3 text-light" style="font-size: 35px;">Length: <span th:text="${movie.length}"></span></div>
|
||||
<div class="flex-item3 text-light" style="font-size: 35px;">Genre: <span th:text="${movie.genreName}"></span></div>
|
||||
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modal">Edit Movie</button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<div id="modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<span class="close" onclick="handleModalClose()">×</span>
|
||||
<h2>Edit Movie</h2>
|
||||
<div class="form-group">
|
||||
<label>Title:</label>
|
||||
<input type="text" class="form-control" name="title" th:value="${movie.title}"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Score:</label>
|
||||
<input type="text" class="form-control" name="score" th:value="${movie.score}"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Length:</label>
|
||||
<input type="text" class="form-control" name="length" th:value="${movie.length}"/>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-secondary" onclick="handleModalClose()">Close</button>
|
||||
<button class="btn btn-primary" onclick="handleModalSubmit()">Save Changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
function handleModalClose()
|
||||
{
|
||||
const modalElement = document.getElementById('modal');
|
||||
console.log("html modals sucks");
|
||||
// Use Bootstrap's Modal API to close the modal
|
||||
const modal = new bootstrap.Modal(modalElement);
|
||||
modal.hide();
|
||||
}
|
||||
function handleModalSubmit() {
|
||||
var titleInput = document.getElementsByName("title")[0];
|
||||
var scoreInput = document.getElementsByName("score")[0];
|
||||
var lengthInput = document.getElementsByName("length")[0];
|
||||
|
||||
var modalData = {
|
||||
title: titleInput.value,
|
||||
score: scoreInput.value,
|
||||
length: lengthInput.value
|
||||
};
|
||||
|
||||
const movieId = document.getElementById('movieCard').getAttribute('data-movie-id');
|
||||
console.log(movieId);
|
||||
fetch(`/movies/movie/update/${movieId}?title=${modalData["title"]}&length=${modalData["length"]}&score=${modalData["score"]}`,{
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
window.location.href = "/movies";
|
||||
location.reload();
|
||||
}
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
37
src/main/resources/templates/Librarypage.html
Normal file
37
src/main/resources/templates/Librarypage.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<div layout:fragment="content">
|
||||
|
||||
|
||||
<div class="flex-container min-vh-100" style="display: flex; margin-left: 20px; margin-top: 50px">
|
||||
|
||||
<th:block th:if="${not #lists.isEmpty(movies)}">
|
||||
<div style="flex-direction: row; display: flex; flex-wrap: wrap; gap: 30px">
|
||||
<th:block th:each="movie : ${movies}">
|
||||
<div className="flex-containerB" style="flex-direction: column; display: flex; width: 250px; height: 350px; gap:40px; align-items:center; color:aliceblue">
|
||||
<img src="https://www.seekpng.com/png/detail/8-84931_question-mark-question-mark-white-background.png" alt = "cover" width="100%" height="300px"/>
|
||||
<h3 th:text="${movie.title}"></h3>
|
||||
<form th:action="@{/movies/customer/delete/{movieId}(movieId=${movie.getID()})}" method="post">
|
||||
<button type="submit">Remove</button>
|
||||
</form>
|
||||
</div>
|
||||
</th:block>
|
||||
</div>
|
||||
</th:block>
|
||||
<h1 th:unless="${not #lists.isEmpty(movies)}" style="color: white">No movies available</h1>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
|
||||
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
31
src/main/resources/templates/Login.html
Normal file
31
src/main/resources/templates/Login.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<div layout:fragment="content">
|
||||
<div class="flex-container" style="flex-direction: column; display: flex; ">
|
||||
<div class="flex-container min-vh-100" style="flex-direction: column; display: flex; align-items: center; justify-content: center; gap: 20px;">
|
||||
<h1 for="userSelect" style="color: white;">Select User:</h1>
|
||||
<select id="userSelect" style="width: 100px;">
|
||||
<option th:each="customer : ${customers}" th:value="${customer.getID()}" th:text="${customer.username}"></option>
|
||||
</select>
|
||||
<button style="margin-top: 50px;" onclick="handleLogin()">Login</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
function handleLogin() {
|
||||
localStorage.clear();
|
||||
var selectedUserId = document.getElementById("userSelect").value;
|
||||
document.cookie = "userID=" + selectedUserId;
|
||||
window.location.href = "/genre/fill";
|
||||
}
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
39
src/main/resources/templates/Mainpage.html
Normal file
39
src/main/resources/templates/Mainpage.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<div layout:fragment="content">
|
||||
|
||||
|
||||
<div class="flex-container min-vh-100" style="flex-direction: row; display: flex; margin-left: 20px; margin-top: 50px;">
|
||||
<div th:if="${not #lists.isEmpty(movies)}" style="flex-direction: row; display: flex; flex-wrap: wrap; justify-content: space-between;">
|
||||
<div th:each="movie : ${movies}" style="margin-bottom: 20px;">
|
||||
<div className="flex-containerB" style="flex-direction: column; display: flex; width: 250px; height: 350px; gap:40px; align-items:center;">
|
||||
<img src="https://www.seekpng.com/png/detail/8-84931_question-mark-question-mark-white-background.png" alt = "cover" width="100%" height="300px"/>
|
||||
<h3><a th:href="@{/movies/movie/{movieId}(movieId=${movie.getID()})}"
|
||||
th:text="${movie.title}" style="text-decoration: none; color: white;"></a></h3>
|
||||
<button type="button" th:attr="data-movie-id=${movie.getID()}" onclick="handleAcquireMovie(event)">Acquire</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1 th:unless="${not #lists.isEmpty(movies)}" style="color: white;">No movies available</h1>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<th:block layout:fragment="scripts">
|
||||
<script th:inline="javascript">
|
||||
|
||||
function handleAcquireMovie(movieId) {
|
||||
var movieId = event.target.getAttribute("data-movie-id");
|
||||
var url = "/movies/customer/" + movieId;
|
||||
fetch(url,{
|
||||
method: "POST",
|
||||
}) ;
|
||||
}
|
||||
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
56
src/main/resources/templates/Searchpage.html
Normal file
56
src/main/resources/templates/Searchpage.html
Normal file
@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<div layout:fragment="content">
|
||||
<div class="flex-container" style="flex-direction: column; display: flex;">
|
||||
<div class="flex-container min-vh-100" style="flex-direction: column; display: flex; flex: 1; align-items: center; justify-content: flex-start; margin-top: 20px">
|
||||
<div>
|
||||
<select id="genre-select">
|
||||
<option value="all">All Genres</option>
|
||||
<option th:each="genre : ${genres}" th:value="${genre.name}" th:text="${genre.name}"></option>
|
||||
</select>
|
||||
<button type="button" onclick="handleSearch()">Search</button>
|
||||
</div>
|
||||
<div class="flex-container min-vh-100" style="flex-direction: row; display: flex; margin-left: 20px; margin-top: 50px">
|
||||
<div style="flex-direction: row; display: flex; flex-wrap: wrap; gap: 30px">
|
||||
<div th:if="${not #lists.isEmpty(movies)}" th:each="movie : ${movies}" style="margin-bottom: 20px;">
|
||||
<div className="flex-containerB" style="flex-direction: column; display: flex; width: 250px; height: 350px; gap:40px; align-items:center; color:aliceblue">
|
||||
<img src="https://www.seekpng.com/png/detail/8-84931_question-mark-question-mark-white-background.png" alt = "cover" width="100%" height="300px"/>
|
||||
<h3><a th:href="@{/movies/movie/{movieId}(movieId=${movie.getID()})}"
|
||||
th:text="${movie.title}" style="text-decoration: none; color: white;"></a></h3>
|
||||
</div>
|
||||
</div>
|
||||
<h1 th:if="${#lists.isEmpty(movies)}" style="color: white">No movies found</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
window.onload = function()
|
||||
{
|
||||
var storedOptionValue = localStorage.getItem('genre');
|
||||
if(storedOptionValue !== null)
|
||||
{
|
||||
var selectElement = document.getElementById('genre-select');
|
||||
selectElement.value = storedOptionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
const genreSelect = document.getElementById("genre-select");
|
||||
const selectedGenre = genreSelect.value;
|
||||
localStorage.setItem('genre',selectedGenre);
|
||||
window.location.href = `/movies/${selectedGenre}`;
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
50
src/main/resources/templates/Template.html
Normal file
50
src/main/resources/templates/Template.html
Normal file
@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>I'M TIRED OF IP</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
<div style="background-image: url('https://img.freepik.com/premium-vector/grainy-gradient-background-using-different-colors_606954-9.jpg');">
|
||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="/movies" th:classappend="${#strings.equals(activeLink, '/movies')} ? 'active' : ''">
|
||||
Main Page
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="/movies/null" th:classappend="${#strings.equals(activeLink, '/genre')} ? 'active' : ''">
|
||||
Search Page
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" th:href="@{/customer/movies}">
|
||||
Library Page
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="/" th:classappend="${#strings.equals(activeLink, '/')} ? 'active' : ''">
|
||||
Registration Page
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div layout:fragment="content">
|
||||
|
||||
</div>
|
||||
<footer class="flex-item6">
|
||||
<div class="text-center text-light p-2" style="font-size: 30px; font-weight: bold;">
|
||||
@2022 Copyright: BLSJY.com
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
<th:block layout:fragment="scripts">
|
||||
</th:block>
|
||||
</html>
|
37
src/main/resources/templates/index.html
Normal file
37
src/main/resources/templates/index.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{Template}">
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<div layout:fragment="content">
|
||||
<div class="flex-container" style="flex-direction: column; display: flex;">
|
||||
<div class="flex-container min-vh-100" style="flex-direction: column; display: flex;">
|
||||
<main style="display: flex; flex: 1;">
|
||||
<aside class="flex-item2" style="flex: 2;"></aside>
|
||||
<div class="flex-item3 align-self-center" style="flex: 3;"><img src="https://i.pinimg.com/736x/57/ee/6a/57ee6a23a455b12eff3aa13d63f104cd.jpg" alt="cover" width="100%" height="600px"/></div>
|
||||
<section class="flex-container align-self-center" style="height: 660px; flex: 4; background-color: #ffd79d; flex-direction: column; display: flex;">
|
||||
<form action="#" th:action="@{/customer}" method="post">
|
||||
<section class="flex-itemR1" style="color: #320D3E; font-size: 50px; font-weight: bold; padding-left: 30px; padding-top: 10px;">SIGN UP</section>
|
||||
<section class="flex-itemR2" style="color: #320D3E; font-size: 35px; font-weight: bold; padding-left: 30px; padding-top: 10px;">
|
||||
<label style="color: #320D3E; font-size: 32px; font-weight: bold;">USERNAME</label>
|
||||
</section>
|
||||
<section class="flex-itemR3" style="display: flex; width: 320px; padding-left: 30px;">
|
||||
<input class="form-control" id="inputUsername" type="string" name="fullName" placeholder="Enter username" th:value="${inputUsername}"/>
|
||||
</section>
|
||||
<section class="flex-itemR6" style="color: #320D3E; font-size: 35px; font-weight: bold; padding-left: 30px; padding-top: 10px;">
|
||||
<label style="color: #320D3E; font-size: 32px; font-weight: bold;">PASSWORD</label>
|
||||
</section>
|
||||
<section class="flex-itemR7" style="display: flex; width: 320px; padding-left: 30px;">
|
||||
<input class="form-control" id="inputPassword" type="password" name="password" placeholder="Enter password" th:value="${inputPassword}"/>
|
||||
</section>
|
||||
<button class="btn btn-primary" type="submit" id="register" style="font-size: 20px; margin-left: 30px; margin-top: 15px; width: 150px; background-color: #320D3E; color: white; font-weight: bold;">Register</button>
|
||||
<a href="/customer">Sign in</a>
|
||||
</form>
|
||||
</section>
|
||||
<aside class="flex-item5" style="flex: 2;"></aside>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</html>
|
92
src/test/java/ru/ulstu/is/sbapp/JpaCustomerTests.java
Normal file
92
src/test/java/ru/ulstu/is/sbapp/JpaCustomerTests.java
Normal file
@ -0,0 +1,92 @@
|
||||
package ru.ulstu.is.sbapp;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import ru.ulstu.is.sbapp.Customer.Exception.CustomerNotFoundException;
|
||||
import ru.ulstu.is.sbapp.Customer.Model.Customer;
|
||||
import ru.ulstu.is.sbapp.Customer.Service.CustomerService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
public class JpaCustomerTests
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(JpaCustomerTests.class);
|
||||
|
||||
@Autowired
|
||||
private CustomerService customerService;
|
||||
|
||||
@Test
|
||||
void testCustomerCreate()
|
||||
{
|
||||
customerService.deleteAllCustomers();
|
||||
final Customer customer = customerService.addCustomer("Nikita Lisov","1234");
|
||||
log.info(customer.toString());
|
||||
Assertions.assertNotNull(customer.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomerRead()
|
||||
{
|
||||
customerService.deleteAllCustomers();
|
||||
final Customer customer = customerService.addCustomer("Nikita Lisov","1234");
|
||||
log.info(customer.toString());
|
||||
final Customer findCustomer = customerService.findCustomer(customer.getId());
|
||||
log.info(findCustomer.toString());
|
||||
Assertions.assertEquals(customer, findCustomer);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomerReadNotFound()
|
||||
{
|
||||
customerService.deleteAllCustomers();
|
||||
Assertions.assertThrows(CustomerNotFoundException.class, () -> customerService.findCustomer(-1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomerReadAll()
|
||||
{
|
||||
customerService.deleteAllCustomers();
|
||||
customerService.addCustomer("Nikita Lisov","1234");
|
||||
customerService.addCustomer("Evelina Aust Sergeevna","12345");
|
||||
final List<Customer> customers = customerService.findAllCustomers();
|
||||
log.info(customers.toString());
|
||||
Assertions.assertEquals(customers.size(), 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomerReadAllEmpty()
|
||||
{
|
||||
customerService.deleteAllCustomers();
|
||||
final List<Customer> customers = customerService.findAllCustomers();
|
||||
log.info(customers.toString());
|
||||
Assertions.assertEquals(customers.size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomerChanges()
|
||||
{
|
||||
customerService.deleteAllCustomers();
|
||||
final Customer customer = customerService.addCustomer("Nikita Lisov","1234");
|
||||
log.info(customer.toString());
|
||||
final Customer changedCustomer = customerService.updateCustomer(customer.getId(),"Evelina Potter");
|
||||
log.info(changedCustomer.toString());
|
||||
Assertions.assertEquals("Evelina",changedCustomer.getFirst_name());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteSpecificCustomer()
|
||||
{
|
||||
customerService.deleteAllCustomers();
|
||||
|
||||
final Customer customer1 = customerService.addCustomer("Nikita Lisov","1234");
|
||||
final Customer customer2 = customerService.addCustomer("Evelina Potter","12345");
|
||||
customerService.deleteCustomer(customer1.getId());
|
||||
Assertions.assertThrows(CustomerNotFoundException.class, () -> customerService.findCustomer(customer1.getId()));
|
||||
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user