Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
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 0b7ab654
authored
Oct 21, 2010
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ja lisätään vielä ne fileetkin.
1 parent
4b574c9a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
280 additions
and
0 deletions
code/LanBortalWeb/WebContent/shop/listReaders.xhtml
code/LanBortalWeb/WebContent/shop/showReaderEvents.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/view/ReaderView.java
code/LanBortalWeb/src/fi/insomnia/bortal/view/RfidContainer.java
code/LanBortalWeb/WebContent/shop/listReaders.xhtml
0 → 100644
View file @
0b7ab65
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:users=
"http://java.sun.com/jsf/composite/tools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:param
name=
"thispage"
value=
"page.eventorg.list"
/>
<ui:define
name=
"content"
>
<h:form>
<h:dataTable
border=
"1"
id=
"reader"
value=
"#{readerView.readers}"
var=
"reader"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['reader.name']}"
/>
</f:facet>
<h:outputText
value=
"#{reader}"
/>
</h:column>
<h:column
>
<h:commandButton
action=
"#{readerView.selectReader()}"
value=
"#{i18n['reader.select']}"
/>
</h:column>
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/WebContent/shop/showReaderEvents.xhtml
0 → 100644
View file @
0b7ab65
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:users=
"http://java.sun.com/jsf/composite/tools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:param
name=
"thispage"
value=
"page.eventorg.list"
/>
<ui:define
name=
"content"
>
<h1>
#{readerView.readername}
</h1>
<h:form>
<h:dataTable
border=
"1"
id=
"event"
value=
"#{readerView.readerEvents}"
var=
"event"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['reader.tag']}"
/>
</f:facet>
<h:outputText
id=
"tag"
value=
"#{event.tag}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['reader.tag']}"
/>
</f:facet>
<h:outputText
id=
"eventtime"
value=
"#{event.time.time}"
>
<f:convertDateTime
/>
</h:outputText>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['reader.tag']}"
/>
</f:facet>
<h:outputText
rendered=
"#{!empty event.event}"
value=
"#{event.event.printedCard.user.wholeName} (#{event.event.printedCard.user.nick})"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['reader.tag']}"
/>
</f:facet>
<h:dataTable
value=
"#{event.actions}"
var=
"action"
>
<h:column>
<h:outputText
value=
"#{action}"
/>
</h:column>
</h:dataTable>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['readerevent.seenSince']}"
/>
</f:facet>
<h:outputText
value=
"#{event.seenSince}"
/>
</h:column>
<h:column>
<h:commandButton
action=
"#{readerView.selectReader()}"
value=
"#{i18n['reader.select']}"
/>
</h:column>
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/src/fi/insomnia/bortal/view/ReaderView.java
0 → 100644
View file @
0b7ab65
package
fi
.
insomnia
.
bortal
.
view
;
import
java.util.ArrayList
;
import
java.util.Set
;
import
javax.faces.bean.ManagedBean
;
import
javax.faces.bean.ManagedProperty
;
import
javax.faces.bean.RequestScoped
;
import
javax.faces.bean.SessionScoped
;
import
javax.faces.model.ListDataModel
;
import
fi.insomnia.bortal.view.RfidContainer.RfidEvent
;
@ManagedBean
(
name
=
"readerView"
)
@SessionScoped
public
class
ReaderView
{
@ManagedProperty
(
value
=
"#{rfidContainer}"
)
private
RfidContainer
container
;
private
ListDataModel
<
String
>
readerlist
;
private
String
readername
;
private
ListDataModel
<
RfidEvent
>
readerevents
;
public
ListDataModel
<
String
>
getReaders
()
{
Set
<
String
>
keyset
=
getContainer
().
getReaders
().
keySet
();
readerlist
=
new
ListDataModel
<
String
>(
new
ArrayList
<
String
>(
keyset
));
return
readerlist
;
}
public
String
selectReader
()
{
setReadername
(
readerlist
.
getRowData
());
return
"showReaderEvents"
;
}
public
ListDataModel
<
RfidEvent
>
getReaderEvents
()
{
readerevents
=
new
ListDataModel
<
RfidEvent
>(
getContainer
().
getReaderEvents
(
getReadername
()));
return
readerevents
;
}
public
void
setContainer
(
RfidContainer
container
)
{
this
.
container
=
container
;
}
public
RfidContainer
getContainer
()
{
return
container
;
}
public
void
setReadername
(
String
readername
)
{
this
.
readername
=
readername
;
}
public
String
getReadername
()
{
return
readername
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/view/RfidContainer.java
0 → 100644
View file @
0b7ab65
package
fi
.
insomnia
.
bortal
.
view
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
javax.faces.bean.ApplicationScoped
;
import
javax.faces.bean.ManagedBean
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.model.ReaderEvent
;
@ApplicationScoped
@ManagedBean
public
class
RfidContainer
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RfidContainer
.
class
);
private
Map
<
String
,
List
<
RfidEvent
>>
events
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
List
<
RfidEvent
>>());
public
synchronized
void
foundTag
(
String
reader
,
String
tag
,
ReaderEvent
revent
)
{
if
(!
events
.
containsKey
(
reader
))
{
events
.
put
(
reader
,
Collections
.
synchronizedList
(
new
LinkedList
<
RfidEvent
>()));
}
List
<
RfidEvent
>
readerevents
=
events
.
get
(
reader
);
while
(
readerevents
.
size
()
>
20
)
{
readerevents
.
remove
(
readerevents
.
size
()
-
1
);
logger
.
debug
(
"Cleaning readerevents fro reader {}"
,
reader
);
}
if
(
readerevents
.
size
()
>
0
&&
readerevents
.
get
(
0
).
getTag
().
equals
(
tag
))
{
readerevents
.
get
(
0
).
seen
();
}
else
{
readerevents
.
add
(
0
,
new
RfidEvent
(
reader
,
tag
,
revent
));
logger
.
debug
(
"Readerevents size {}"
,
readerevents
.
size
());
}
}
public
List
<
RfidEvent
>
getReaderEvents
(
String
reader
)
{
return
events
.
get
(
reader
);
}
public
Map
<
String
,
List
<
RfidEvent
>>
getReaders
()
{
return
events
;
}
public
class
RfidEvent
{
RfidEvent
(
String
reader
,
String
tag
,
ReaderEvent
revent
)
{
this
.
reader
=
reader
;
this
.
tag
=
tag
;
this
.
event
=
revent
;
}
public
void
seen
()
{
time
=
Calendar
.
getInstance
();
}
public
String
getSeenSince
()
{
long
diffSec
=
(
Calendar
.
getInstance
().
getTimeInMillis
()
-
time
.
getTimeInMillis
())
/
1000
;
long
secs
=
diffSec
%
60
;
long
diffMin
=
diffSec
/
60
;
long
mins
=
diffMin
%
60
;
long
hours
=
diffMin
/
60
;
StringBuilder
ret
=
new
StringBuilder
();
if
(
hours
>
0
)
{
ret
.
append
(
hours
).
append
(
" h "
);
}
if
(
hours
>
0
||
mins
>
0
)
{
ret
.
append
(
mins
).
append
(
" min "
);
}
ret
.
append
(
secs
).
append
(
" sec"
);
return
ret
.
toString
();
}
private
Calendar
time
=
Calendar
.
getInstance
();
private
String
reader
;
private
String
tag
;
private
ReaderEvent
event
;
private
List
<
String
>
actions
=
new
ArrayList
<
String
>();
public
Calendar
getTime
()
{
return
time
;
}
public
void
setTime
(
Calendar
time
)
{
this
.
time
=
time
;
}
public
String
getReader
()
{
return
reader
;
}
public
void
setReader
(
String
reader
)
{
this
.
reader
=
reader
;
}
public
String
getTag
()
{
return
tag
;
}
public
void
setTag
(
String
tag
)
{
this
.
tag
=
tag
;
}
public
ReaderEvent
getEvent
()
{
return
event
;
}
public
void
setEvent
(
ReaderEvent
event
)
{
this
.
event
=
event
;
}
public
List
<
String
>
getActions
()
{
return
actions
;
}
public
void
setActions
(
List
<
String
>
actions
)
{
this
.
actions
=
actions
;
}
}
}
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