Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f3ac6075
authored
Mar 12, 2023
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'liv-devel' into 'master'
Reservable boolean to place See merge request
!442
2 parents
3b053f40
bd1eccb2
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
5 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/auth/AuthHelperBean.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/map/v1/PlacePojo.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/MapAdminView.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/PojoUtils.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/apiapp/v1/ApiAppRestViewV1.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/PlacemapRestViewV1.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
View file @
f3ac607
...
...
@@ -670,6 +670,11 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE bill_lines ADD COLUMN discount_source_id INTEGER"
,
"ALTER TABLE bill_lines ADD CONSTRAINT FK_bill_lines_discount_source_id FOREIGN KEY (discount_source_id) REFERENCES bill_lines (id)"
});
dbUpdates
.
add
(
new
String
[]
{
"ALTER TABLE places ADD COLUMN reservable BOOLEAN NOT NULL default true"
});
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/auth/AuthHelperBean.java
View file @
f3ac607
...
...
@@ -14,6 +14,8 @@ import javax.ejb.Stateless;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.http.HttpHeaders
;
import
java.nio.charset.StandardCharsets
;
import
java.security.Principal
;
import
java.util.Base64
;
...
...
@@ -32,7 +34,7 @@ public class AuthHelperBean implements AuthHelperBeanLocal {
@Override
public
String
parseHostname
(
HttpServletRequest
httpRequest
)
{
StringBuffer
url
=
httpRequest
.
getRequestURL
();
String
requestHostHeader
=
httpRequest
.
getHeader
(
"host"
);
String
requestHostHeader
=
httpRequest
.
getHeader
(
HttpHeaders
.
HOST
);
String
hostname
=
"localhost"
;
if
(
requestHostHeader
!=
null
)
{
hostname
=
requestHostHeader
.
split
(
":"
)[
0
];
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
View file @
f3ac607
...
...
@@ -63,9 +63,15 @@ public class Place extends GenericEntity implements Comparable<Place> {
@BatchFetch
(
BatchFetchType
.
EXISTS
)
private
GroupMembership
placeReserver
;
// define that user can buy place
@Column
(
name
=
"buyable"
,
nullable
=
false
)
private
boolean
buyable
=
true
;
// define that user can reserve place from map (does not affect to buyable)
@Column
(
name
=
"reservable"
,
nullable
=
false
)
private
boolean
reservable
=
true
;
// define that user can see place at map (disabled places are not buyable)
@Column
(
nullable
=
false
)
private
boolean
disabled
=
false
;
/**
...
...
@@ -112,8 +118,8 @@ public class Place extends GenericEntity implements Comparable<Place> {
if
(
isDisabled
())
{
ret
=
PlaceState
.
DISABLED
;
}
else
{
if
(!
isBuy
able
())
{
// lock place at map if it is not buyable or if it is not reservable.
if
(!
isBuyable
()
||
!
isReserv
able
())
{
ret
=
PlaceState
.
LOCKED
;
}
if
(
isTaken
())
{
...
...
@@ -304,6 +310,10 @@ public class Place extends GenericEntity implements Comparable<Place> {
return
buyable
;
}
public
boolean
isReservable
()
{
return
reservable
;
}
/**
* NOTE: you can newer be sure that this is up to date
*
...
...
@@ -333,6 +343,10 @@ public class Place extends GenericEntity implements Comparable<Place> {
this
.
disabled
=
disabled
;
}
public
void
setReservable
(
boolean
reservable
)
{
this
.
reservable
=
reservable
;
}
/**
* Note: this class has a natural ordering that is inconsistent with equals.
*/
...
...
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/map/v1/PlacePojo.java
View file @
f3ac607
...
...
@@ -46,6 +46,15 @@ public class PlacePojo {
private
String
description
;
private
Integer
reserverId
;
private
Integer
eventuserId
;
private
Boolean
reservable
;
public
Boolean
getReservable
()
{
return
reservable
;
}
public
void
setReservable
(
Boolean
reservable
)
{
this
.
reservable
=
reservable
;
}
public
String
getName
()
{
return
name
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/MapAdminView.java
View file @
f3ac607
...
...
@@ -263,6 +263,8 @@ public class MapAdminView {
place
.
setBuyable
(
update
.
getBuyable
());
if
(
update
.
getDisabled
()
!=
null
)
place
.
setDisabled
(
update
.
getDisabled
());
if
(
update
.
getReservable
()
!=
null
)
place
.
setReservable
(
update
.
getReservable
());
if
(
update
.
getProductId
()
!=
null
)
{
Product
product
=
productbean
.
findById
(
update
.
getProductId
());
if
(
product
!=
null
)
{
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/PojoUtils.java
View file @
f3ac607
...
...
@@ -93,6 +93,7 @@ public class PojoUtils {
ret
.
setTaken
(
place
.
isTaken
());
ret
.
setBuyable
(
place
.
isBuyable
());
ret
.
setDisabled
(
place
.
isDisabled
());
ret
.
setReservable
(
place
.
isReservable
());
// I cannot change REST -api without making new version, so let's simulate this ReleaseTime -feature from reserveTime
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/apiapp/v1/ApiAppRestViewV1.java
View file @
f3ac607
...
...
@@ -6,6 +6,7 @@ import fi.codecrew.moya.model.ApiApplicationInstance;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.ApiApplicationInstancePojo
;
import
io.swagger.v3.oas.annotations.OpenAPIDefinition
;
import
io.swagger.v3.oas.annotations.info.Info
;
import
org.apache.http.HttpHeaders
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -52,7 +53,7 @@ public class ApiAppRestViewV1 {
principal
=
null
;
}
servletRequest
.
getSession
(
true
);
String
domain
=
servletRequest
.
getHeader
(
"host"
);
String
domain
=
servletRequest
.
getHeader
(
HttpHeaders
.
HOST
);
String
authHeader
=
servletRequest
.
getHeader
(
AUTH_HEADER
);
logger
.
info
(
"Got auth header {}"
,
authHeader
);
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/PlacemapRestViewV1.java
View file @
f3ac607
...
...
@@ -226,7 +226,7 @@ public class PlacemapRestViewV1 {
boolean
success
=
false
;
if
(
p
.
isReservedFor
(
user
))
{
success
=
placebean
.
userReleasePlace
(
p
);
}
else
if
(
p
.
isBuyable
()
&&
!
p
.
isTaken
())
{
}
else
if
(
p
.
isBuyable
()
&&
!
p
.
isTaken
()
&&
p
.
isReservable
()
)
{
logger
.
info
(
"Rest Reserving place for place {}"
,
p
);
success
=
placebean
.
reservePlace
(
p
,
user
);
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment