Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9a876f0a
authored
Apr 01, 2018
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into feature/i18n-for-angular
2 parents
73882464
b1f00ba6
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
503 additions
and
13 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/ReaderBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ReaderBean.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/reader/v3/ReaderEventRestPojoV3.java
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/userinfo/v3/CardCodePojoV3.java
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/userinfo/v3/PrintedCardRestPojoV3.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/PrinterRestView.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/PojoFactoryV2.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/UserRestViewV2.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v3/PojoFactoryV3.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v3/UserRestViewV3.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/ReaderBeanLocal.java
View file @
9a876f0
...
...
@@ -30,10 +30,6 @@ import fi.codecrew.moya.model.User;
@Local
public
interface
ReaderBeanLocal
{
// WAT!
// ReaderEvent assocTagToPlacecode(String tag, String readerIdent, String
// placecode) throws BortalCatchableException, PermissionDeniedException;
ReaderEvent
assocCodeToCard
(
ReaderEvent
readerEvent
,
PrintedCard
card
);
List
<
Reader
>
getReaders
();
...
...
@@ -73,6 +69,16 @@ public interface ReaderBeanLocal {
*/
ReaderEvent
checkCode
(
String
readerIdent
,
String
code
);
/**
* Check and brogress barcode from some external reader which is only named
* @param readerIdent
* @param code
* @param ignoreRepeating Normally, readerevent ignores if same code comes again in 30s period, set this to true to turn this thingy off
* @return
*/
ReaderEvent
checkCode
(
Reader
readerIdent
,
String
code
,
boolean
ignoreRepeating
);
/**
* Check and progress barcode from some specific reader
*
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ReaderBean.java
View file @
9a876f0
...
...
@@ -91,10 +91,15 @@ public class ReaderBean implements ReaderBeanLocal {
}
@Override
public
ReaderEvent
checkCode
(
Reader
reader
,
String
code
)
{
return
checkCode
(
reader
,
code
,
false
);
}
@Override
/**
* check reader code, and add it to the database
*/
public
ReaderEvent
checkCode
(
Reader
reader
,
String
code
)
{
public
ReaderEvent
checkCode
(
Reader
reader
,
String
code
,
boolean
ignoreRepeating
)
{
if
(
reader
==
null
||
code
==
null
||
code
.
isEmpty
())
{
return
null
;
...
...
@@ -132,7 +137,7 @@ public class ReaderBean implements ReaderBeanLocal {
// probably bcause user want's to read it again
List
<
ReaderEvent
>
lastevents
=
readerEventFacade
.
findLastEvents
(
reader
,
1
);
if
(!
lastevents
.
isEmpty
()
&&
!
reader
.
isAutoproduct
())
if
(!
lastevents
.
isEmpty
()
&&
!
reader
.
isAutoproduct
()
&&
!
ignoreRepeating
)
{
ReaderEvent
lastevent
=
lastevents
.
get
(
0
);
...
...
@@ -212,7 +217,7 @@ public class ReaderBean implements ReaderBeanLocal {
card
.
getCardCodes
().
add
(
code
);
cardCodeFacade
.
flush
();
return
checkCode
(
readerEvent
.
getReader
(),
readerEvent
.
getValue
());
return
checkCode
(
readerEvent
.
getReader
(),
readerEvent
.
getValue
()
,
true
);
}
@Override
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
View file @
9a876f0
...
...
@@ -80,7 +80,7 @@ public class Place extends GenericEntity implements Comparable<Place> {
private
Role
providesRole
;
@JoinColumn
(
name
=
"map_id"
,
referencedColumnName
=
EventMap
.
ID_COLUMN
,
nullable
=
true
)
@ManyToOne
(
optional
=
true
,
cascade
=
CascadeType
.
ALL
)
@ManyToOne
(
optional
=
true
)
private
EventMap
map
;
/**
* Which ticket type is this place sold as
...
...
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/reader/v3/ReaderEventRestPojoV3.java
0 → 100644
View file @
9a876f0
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
reader
.
v3
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo
;
import
fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3
;
import
io.swagger.annotations.ApiModel
;
import
javax.xml.bind.annotation.XmlElement
;
import
java.util.Date
;
@ApiModel
public
class
ReaderEventRestPojoV3
{
private
EventUserRestPojo
eventUser
;
private
PrintedCardRestPojoV3
printedCard
;
private
Integer
readerEventId
;
private
Date
readerEventTime
;
private
Integer
readerId
;
private
Integer
printedCardId
;
private
String
printedCardState
;
public
ReaderEventRestPojoV3
()
{
}
@XmlElement
(
name
=
"eventuser"
,
nillable
=
true
)
public
EventUserRestPojo
getEventuser
()
{
return
eventUser
;
}
@XmlElement
(
name
=
"readerEventId"
,
nillable
=
false
)
public
Integer
getEventId
()
{
return
readerEventId
;
}
@XmlElement
(
name
=
"readerEventTime"
,
nillable
=
true
)
public
Date
getReaderEventTime
()
{
return
readerEventTime
;
}
@XmlElement
(
name
=
"readerId"
,
nillable
=
false
)
public
Integer
getReaderId
()
{
return
readerId
;
}
@XmlElement
(
name
=
"printedCardId"
,
nillable
=
true
)
public
Integer
getPrintedCardId
()
{
return
printedCardId
;
}
@XmlElement
(
name
=
"printedCardState"
,
nillable
=
true
)
public
String
getPrintedCardState
()
{
return
printedCardState
;
}
public
PrintedCardRestPojoV3
getPrintedCard
()
{
return
printedCard
;
}
public
void
setPrintedCard
(
PrintedCardRestPojoV3
printedCard
)
{
this
.
printedCard
=
printedCard
;
}
public
EventUserRestPojo
getEventUser
()
{
return
eventUser
;
}
public
void
setEventUser
(
EventUserRestPojo
eventUser
)
{
this
.
eventUser
=
eventUser
;
}
public
Integer
getReaderEventId
()
{
return
readerEventId
;
}
public
void
setReaderEventId
(
Integer
readerEventId
)
{
this
.
readerEventId
=
readerEventId
;
}
public
void
setReaderEventTime
(
Date
readerEventTime
)
{
this
.
readerEventTime
=
readerEventTime
;
}
public
void
setReaderId
(
Integer
readerId
)
{
this
.
readerId
=
readerId
;
}
public
void
setPrintedCardId
(
Integer
printedCardId
)
{
this
.
printedCardId
=
printedCardId
;
}
public
void
setPrintedCardState
(
String
printedCardState
)
{
this
.
printedCardState
=
printedCardState
;
}
}
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/userinfo/v3/CardCodePojoV3.java
0 → 100644
View file @
9a876f0
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
userinfo
.
v3
;
import
io.swagger.annotations.ApiModel
;
import
javax.xml.bind.annotation.XmlElement
;
@ApiModel
public
class
CardCodePojoV3
{
private
String
readerType
;
private
String
code
;
private
Integer
printedCardId
;
private
Integer
id
;
@XmlElement
()
public
String
getReaderType
()
{
return
readerType
;
}
@XmlElement
()
public
String
getCode
()
{
return
code
;
}
@XmlElement
()
public
Integer
getPrintedCardId
()
{
return
printedCardId
;
}
@XmlElement
()
public
Integer
getId
()
{
return
id
;
}
public
void
setReaderType
(
String
readerType
)
{
this
.
readerType
=
readerType
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
void
setPrintedCardId
(
Integer
printedCardId
)
{
this
.
printedCardId
=
printedCardId
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
}
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/userinfo/v3/PrintedCardRestPojoV3.java
0 → 100644
View file @
9a876f0
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
userinfo
.
v3
;
import
io.swagger.annotations.ApiModel
;
import
javax.xml.bind.annotation.XmlElement
;
import
java.util.Date
;
import
java.util.List
;
@ApiModel
public
class
PrintedCardRestPojoV3
{
private
Integer
eventuserId
;
private
Integer
id
;
private
String
template
;
private
String
username
;
private
String
wholeName
;
private
String
state
;
private
Date
printTime
;
private
List
<
CardCodePojoV3
>
codes
;
public
PrintedCardRestPojoV3
()
{
super
();
}
@XmlElement
()
public
Integer
getEventuserId
()
{
return
eventuserId
;
}
@XmlElement
()
public
Integer
getId
()
{
return
id
;
}
@XmlElement
()
public
String
getTemplate
()
{
return
template
;
}
@XmlElement
()
public
String
getUsername
()
{
return
username
;
}
@XmlElement
()
public
String
getWholeName
()
{
return
wholeName
;
}
/**
* Possible values: ( from CardState )
*
* <ul>
* <li>DATA_MISSING,
* <li>PENDING_VALIDATION,
* <li>REJECTED,
* <li>VALIDATED,
* <li>PRINTING_IN_PROGRESS,
* <li>PRINTED,
* <li>DELIVERED;
* </ul>
*/
@XmlElement
()
public
String
getState
()
{
return
state
;
}
@XmlElement
()
public
Date
getPrintTime
()
{
return
printTime
;
}
@XmlElement
()
public
List
<
CardCodePojoV3
>
getCodes
()
{
return
codes
;
}
public
void
setEventuserId
(
Integer
eventuserId
)
{
this
.
eventuserId
=
eventuserId
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
void
setTemplate
(
String
template
)
{
this
.
template
=
template
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
void
setWholeName
(
String
wholeName
)
{
this
.
wholeName
=
wholeName
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
void
setPrintTime
(
Date
printTime
)
{
this
.
printTime
=
printTime
;
}
public
void
setCodes
(
List
<
CardCodePojoV3
>
codes
)
{
this
.
codes
=
codes
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/PrinterRestView.java
View file @
9a876f0
...
...
@@ -80,11 +80,6 @@ public class PrinterRestView {
@Path
(
"/Printed/{id}/"
)
public
PrintedCardRestPojo
setCardPrinted
(
@PathParam
(
"id"
)
int
cardId
,
@QueryParam
(
"key"
)
String
hash
)
throws
Exception
{
return
PojoUtils
.
initPrintedCardRestPojo
(
cardbean
.
setCardState
(
cardId
,
CardState
.
PRINTED
));
// PrintedCard card = cardbean.findCard(cardId);
// card.setCardState(CardState.PRINTED);
// card.setPrintCount(card.getPrintCount() + 1);
// card = cardbean.saveCard(card);
// return new PrintedCardRestPojo(card);
}
@GET
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/PojoFactoryV2.java
View file @
9a876f0
package
fi
.
codecrew
.
moya
.
rest
.
v2
;
import
fi.codecrew.moya.enums.Gender
;
import
fi.codecrew.moya.model.CardCode
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.rest.pojo.userinfo.v3.CardCodePojoV3
;
import
fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3
;
import
fi.codecrew.moya.rest.v2.pojo.UserPojo
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
/**
* Created by jkj on 2015-05-31.
...
...
@@ -40,4 +45,5 @@ public class PojoFactoryV2 implements Serializable {
pojo
.
postOffice
=
user
.
getTown
();
return
pojo
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/UserRestViewV2.java
View file @
9a876f0
...
...
@@ -6,6 +6,7 @@ import fi.codecrew.moya.enums.apps.UserPermission;
import
fi.codecrew.moya.model.*
;
import
fi.codecrew.moya.rest.PojoUtils
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo
;
import
fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardUpdateCodePojo
;
import
fi.codecrew.moya.rest.v2.pojo.UserPojo
;
import
io.swagger.annotations.Api
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/v3/PojoFactoryV3.java
0 → 100644
View file @
9a876f0
package
fi
.
codecrew
.
moya
.
rest
.
v3
;
import
fi.codecrew.moya.model.CardCode
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.ReaderEvent
;
import
fi.codecrew.moya.rest.PojoUtils
;
import
fi.codecrew.moya.rest.pojo.reader.v3.ReaderEventRestPojoV3
;
import
fi.codecrew.moya.rest.pojo.userinfo.v3.CardCodePojoV3
;
import
fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
public
class
PojoFactoryV3
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
public
static
ReaderEventRestPojoV3
createReaderEventRestPojo
(
ReaderEvent
event
)
{
ReaderEventRestPojoV3
readerEvent
=
new
ReaderEventRestPojoV3
();
if
(
event
.
getPrintedCard
()
!=
null
)
{
if
(
event
.
getPrintedCard
().
getUser
()
!=
null
)
{
readerEvent
.
setEventUser
(
PojoUtils
.
initEventUserRestPojo
(
event
.
getPrintedCard
().
getUser
()));
}
}
else
if
(
event
.
getUser
()
!=
null
)
{
readerEvent
.
setEventUser
(
PojoUtils
.
initEventUserRestPojo
(
event
.
getUser
()));
}
readerEvent
.
setReaderEventId
(
event
.
getId
());
readerEvent
.
setReaderEventTime
(
event
.
getUpdatetime
());
readerEvent
.
setReaderId
(
event
.
getReader
().
getId
());
if
(
event
.
getPrintedCard
()
!=
null
)
{
readerEvent
.
setPrintedCardId
(
event
.
getPrintedCard
().
getId
());
readerEvent
.
setPrintedCardState
(
event
.
getPrintedCard
().
getCardState
().
name
());
readerEvent
.
setPrintedCard
(
createPrintedCardPojo
(
event
.
getPrintedCard
()));
}
return
readerEvent
;
}
public
static
PrintedCardRestPojoV3
createPrintedCardPojo
(
PrintedCard
card
)
{
PrintedCardRestPojoV3
cardPojo
=
new
PrintedCardRestPojoV3
();
cardPojo
.
setEventuserId
(
card
.
getUser
().
getId
());
cardPojo
.
setId
(
card
.
getId
());
if
(
card
.
getTemplate
()
!=
null
)
cardPojo
.
setTemplate
(
card
.
getTemplate
().
getName
());
cardPojo
.
setUsername
(
card
.
getUser
().
getNick
());
cardPojo
.
setWholeName
(
card
.
getUser
().
getWholeName
());
cardPojo
.
setState
(
card
.
getCardState
().
toString
());
if
(
card
.
getPrintTime
()
!=
null
)
cardPojo
.
setPrintTime
(
card
.
getPrintTime
().
getTime
());
if
(
card
.
getCardCodes
()
!=
null
)
{
cardPojo
.
setCodes
(
new
ArrayList
<>());
for
(
CardCode
code
:
card
.
getCardCodes
())
{
CardCodePojoV3
codePojo
=
new
CardCodePojoV3
();
codePojo
.
setId
(
code
.
getId
());
codePojo
.
setPrintedCardId
(
card
.
getId
());
codePojo
.
setCode
(
code
.
getCode
());
cardPojo
.
getCodes
().
add
(
codePojo
);
}
}
return
cardPojo
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/v3/UserRestViewV3.java
0 → 100644
View file @
9a876f0
package
fi
.
codecrew
.
moya
.
rest
.
v3
;
import
fi.codecrew.moya.beans.*
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.ReaderEvent
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardUpdateCodePojo
;
import
fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.PUT
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.core.Response
;
@RequestScoped
@Path
(
"/v3/user"
)
@Api
(
value
=
"/v3/user"
,
description
=
"User operations"
)
public
class
UserRestViewV3
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserRestViewV3
.
class
);
@EJB
private
EventBeanLocal
eventBean
;
@EJB
private
PermissionBeanLocal
permissionBean
;
@EJB
private
UserBeanLocal
userBean
;
@EJB
private
ReaderBeanLocal
readerbean
;
@EJB
private
CardTemplateBeanLocal
cardBean
;
@PUT
@ApiOperation
(
value
=
"Update code "
)
@Path
(
"/{userid}/cardcode"
)
public
Response
updateUserCard
(
PrintedCardUpdateCodePojo
codepojo
,
@PathParam
(
"userid"
)
Integer
userid
)
{
ReaderEvent
event
=
readerbean
.
checkCode
(
codepojo
.
getReaderName
(),
codepojo
.
getCode
());
// If tag is not associated, try to add it to the user.
if
(
event
.
getPrintedCard
()
==
null
)
{
PrintedCard
card
=
cardBean
.
checkPrintedCard
(
userBean
.
findByUserId
(
userid
,
false
));
logger
.
info
(
"Updating card {} to event {} "
,
card
,
event
);
if
(
card
!=
null
)
{
event
=
readerbean
.
assocCodeToCard
(
event
,
card
);
return
Response
.
ok
(
PojoFactoryV3
.
createReaderEventRestPojo
(
event
)).
build
();
}
}
Response
.
Status
status
=
Response
.
Status
.
CONFLICT
;
if
(
event
.
getPrintedCard
()
!=
null
&&
event
.
getUser
().
getEvent
().
equals
(
eventBean
.
getCurrentEvent
())
&&
event
.
getUser
().
getUser
().
getId
().
equals
(
userid
))
{
status
=
Response
.
Status
.
OK
;
}
return
Response
.
status
(
status
).
entity
(
PojoFactoryV3
.
createReaderEventRestPojo
(
event
)).
build
();
}
@GET
@Path
(
"/card/{eventuserId}"
)
@ApiOperation
(
value
=
"Get PrintedCard for EventUser"
,
response
=
PrintedCardRestPojoV3
.
class
)
public
PrintedCardRestPojoV3
getUsersCard
(
@ApiParam
(
"EventUser entity ID"
)
@PathParam
(
"eventuserId"
)
Integer
eventuserid
)
{
EventUser
user
=
userBean
.
findByEventUserId
(
eventuserid
);
logger
.
warn
(
"users card for user: {}"
,
user
);
PrintedCard
card
=
cardBean
.
checkPrintedCard
(
user
);
if
(
card
==
null
)
{
return
null
;
}
return
PojoFactoryV3
.
createPrintedCardPojo
(
card
);
}
}
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