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 9c133387
authored
Oct 17, 2012
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Automatic product for Reader
1 parent
dfe5e1e0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
12 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/ReaderBean.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Reader.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/organisation/EventPropertyView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/ReaderBean.java
View file @
9c13338
...
...
@@ -40,6 +40,8 @@ public class ReaderBean implements ReaderBeanLocal {
private
UserBeanLocal
userbean
;
@EJB
private
CardTemplateBean
cardTemplateBean
;
@EJB
private
ProductPBean
productPBean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ReaderBean
.
class
);
...
...
@@ -62,10 +64,11 @@ public class ReaderBean implements ReaderBeanLocal {
Reader
reader
=
readerfacade
.
findOrCreateByIdent
(
readerIdent
);
logger
.
info
(
"reader {}, card {}"
,
reader
,
card
);
// RfidEvent revent = reventcontainer.foundTag(reader, tag);
List
<
ReaderEvent
>
lastevents
=
readerEventFacade
.
findLastEvents
(
reader
,
1
);
ReaderEvent
ret
=
null
;
if
(!
lastevents
.
isEmpty
())
if
(!
lastevents
.
isEmpty
()
&&
!
reader
.
isAutoproduct
()
)
{
ReaderEvent
lastevent
=
lastevents
.
get
(
0
);
if
(
card
==
null
)
...
...
@@ -84,6 +87,12 @@ public class ReaderBean implements ReaderBeanLocal {
if
(
ret
==
null
)
{
ret
=
createReaderEvent
(
reader
,
card
);
if
(
ret
!=
null
&&
card
!=
null
&&
reader
.
isAutoproduct
())
{
productPBean
.
createAccountEvent
(
reader
.
getAutomaticProduct
(),
reader
.
getAutomaticProductCount
(),
card
.
getUser
(),
Calendar
.
getInstance
());
ret
.
setNotes
(
"Created automatic account event from reader."
);
}
}
else
{
ret
.
setUpdatetime
(
Calendar
.
getInstance
());
}
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Reader.java
View file @
9c13338
...
...
@@ -9,6 +9,7 @@ import static javax.persistence.CascadeType.MERGE;
import
static
javax
.
persistence
.
CascadeType
.
PERSIST
;
import
static
javax
.
persistence
.
CascadeType
.
REFRESH
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -53,7 +54,7 @@ public class Reader extends GenericEntity {
@Column
(
nullable
=
false
,
name
=
"type"
)
@Enumerated
(
EnumType
.
STRING
)
private
ReaderType
type
;
private
ReaderType
type
=
ReaderType
.
RFID
;
public
static
final
String
EVENT_ID_COLUMN
=
"event_id"
;
@ManyToOne
()
...
...
@@ -68,9 +69,13 @@ public class Reader extends GenericEntity {
@OneToOne
(
mappedBy
=
"reader"
)
private
SalesEntity
salesEntity
;
/**
*
*/
@ManyToOne
@JoinColumn
(
name
=
"automatic_product_id"
)
private
Product
automaticProduct
;
@Column
(
precision
=
25
,
scale
=
4
,
name
=
"automatic_product_count"
)
private
BigDecimal
automaticProductCount
;
private
static
final
long
serialVersionUID
=
616803985117256035L
;
@Column
(
name
=
"reader_ident"
)
...
...
@@ -204,4 +209,33 @@ public class Reader extends GenericEntity {
public
void
setSalesEntity
(
SalesEntity
salesEntity
)
{
this
.
salesEntity
=
salesEntity
;
}
public
boolean
isAutoproduct
()
{
return
(
automaticProduct
!=
null
&&
automaticProductCount
!=
null
);
}
public
ReaderType
getType
()
{
return
type
;
}
public
void
setType
(
ReaderType
type
)
{
this
.
type
=
type
;
}
public
Product
getAutomaticProduct
()
{
return
automaticProduct
;
}
public
void
setAutomaticProduct
(
Product
automaticProduct
)
{
this
.
automaticProduct
=
automaticProduct
;
}
public
BigDecimal
getAutomaticProductCount
()
{
return
automaticProductCount
;
}
public
void
setAutomaticProductCount
(
BigDecimal
automaticProductCount
)
{
this
.
automaticProductCount
=
automaticProductCount
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/organisation/EventPropertyView.java
View file @
9c13338
...
...
@@ -62,24 +62,22 @@ public class EventPropertyView extends GenericCDIView {
public
List
<
LanEventPrivatePropertyKey
>
getAvailablePrivatePropertyKeys
()
{
List
<
LanEventPrivatePropertyKey
>
ret
=
null
;
if
(
isPrivatePropertyPermission
())
if
(
isPrivatePropertyPermission
()
&&
eventbean
.
getCurrentEvent
().
equals
(
eventorgview
.
getEvent
())
)
{
ret
=
new
ArrayList
<
LanEventPrivatePropertyKey
>(
Arrays
.
asList
(
LanEventPrivatePropertyKey
.
values
()));
if
(
createPrivateKey
!=
null
)
{
ret
.
remove
(
createPrivateKey
);
}
if
(
eventorgview
.
getEvent
()
!=
null
)
{
for
(
LanEventPrivateProperty
p
:
eventbean
.
getPrivateProperties
())
{
ret
.
remove
(
p
.
getKey
());
}
for
(
LanEventPrivateProperty
p
:
eventbean
.
getPrivateProperties
())
{
ret
.
remove
(
p
.
getKey
());
}
}
return
ret
;
}
public
boolean
isPrivatePropertyPermission
()
{
return
super
.
hasPermission
(
EventPermission
.
MANAGE_PRIVATE_PROPERTIES
);
return
super
.
hasPermission
(
EventPermission
.
MANAGE_PRIVATE_PROPERTIES
)
&&
eventbean
.
getCurrentEvent
().
equals
(
eventorgview
.
getEvent
())
;
}
public
String
editProperty
()
...
...
@@ -182,7 +180,7 @@ public class EventPropertyView extends GenericCDIView {
}
public
ListDataModel
<
LanEventPrivateProperty
>
getPrivateProperties
()
{
if
(
privateProperties
==
null
&&
eventorgview
!=
null
&&
event
orgview
.
getEvent
()
!=
null
)
if
(
privateProperties
==
null
&&
eventorgview
!=
null
&&
event
bean
.
getCurrentEvent
().
equals
(
eventorgview
.
getEvent
())
)
{
privateProperties
=
new
ListDataModel
<
LanEventPrivateProperty
>(
eventbean
.
getPrivateProperties
());
}
...
...
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