Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
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 c8e39a5c
authored
Feb 23, 2013
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
settings for placecode printing (print only own and use userid instead of placec…
…ode), fixed boolean eventsetting
1 parent
4d3b6587
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
17 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceGroupBean.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/BarcodeBeanLocal.java
code/MoyaDatabase/src/fi/codecrew/moya/model/LanEventPropertyKey.java
code/MoyaWeb/WebContent/eventorg/editEvent.xhtml
code/MoyaWeb/src/fi/codecrew/moya/servlet/PlaceGroupPdf.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
View file @
c8e39a5
...
@@ -10,10 +10,10 @@ import javax.ejb.Stateless;
...
@@ -10,10 +10,10 @@ import javax.ejb.Stateless;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.sun.xml.bind.v2.model.core.ID
;
import
fi.codecrew.moya.facade.PrintedCardFacade
;
import
fi.codecrew.moya.facade.PrintedCardFacade
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.utilities.BarcodeUtils
;
import
fi.codecrew.moya.utilities.BarcodeUtils
;
/**
/**
...
@@ -23,11 +23,17 @@ import fi.codecrew.moya.utilities.BarcodeUtils;
...
@@ -23,11 +23,17 @@ import fi.codecrew.moya.utilities.BarcodeUtils;
@LocalBean
@LocalBean
public
class
BarcodeBean
implements
BarcodeBeanLocal
{
public
class
BarcodeBean
implements
BarcodeBeanLocal
{
private
static
final
String
PRINTED_CARD_PREFIX
=
"277"
;
private
static
final
String
PRINTED_CARD_PREFIX
=
"277"
;
//2M
private
static
final
String
EVENTUSER_PREFIX
=
"279"
;
//2O
//private static final String NEXT_PREFIX = "289"; //2Y
//private static final String NEXT_PREFIX = "265"; //2A
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BarcodeBean
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BarcodeBean
.
class
);
@EJB
@EJB
PrintedCardFacade
printedCardFacade
;
PrintedCardFacade
printedCardFacade
;
@EJB
UserBeanLocal
userBean
;
/**
/**
* Default constructor.
* Default constructor.
...
@@ -35,6 +41,21 @@ public class BarcodeBean implements BarcodeBeanLocal {
...
@@ -35,6 +41,21 @@ public class BarcodeBean implements BarcodeBeanLocal {
public
BarcodeBean
()
{
public
BarcodeBean
()
{
// TODO Auto-generated constructor stub
// TODO Auto-generated constructor stub
}
}
public
InputStream
getUserBarcode
(
EventUser
user
)
throws
IOException
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
EVENTUSER_PREFIX
);
String
idStr
=
user
.
getId
().
toString
();
for
(
int
i
=
12
-
idStr
.
length
()
-
sb
.
length
();
i
>
0
;
--
i
)
{
sb
.
append
(
"0"
);
}
sb
.
append
(
idStr
);
String
barcode
=
sb
.
toString
();
logger
.
debug
(
"Geneating barcode for user {} : {}"
,
user
,
barcode
);
return
BarcodeUtils
.
getBarcodeEAN
(
barcode
);
}
public
InputStream
getCardBarcode
(
PrintedCard
printedCard
)
throws
IOException
{
public
InputStream
getCardBarcode
(
PrintedCard
printedCard
)
throws
IOException
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
...
@@ -69,4 +90,22 @@ public class BarcodeBean implements BarcodeBeanLocal {
...
@@ -69,4 +90,22 @@ public class BarcodeBean implements BarcodeBeanLocal {
return
printedCardFacade
.
findByBarcode
(
barcode
);
return
printedCardFacade
.
findByBarcode
(
barcode
);
}
}
public
EventUser
getUser
(
String
barcode
)
{
if
(
barcode
==
null
||
barcode
.
isEmpty
())
return
null
;
// it's our special front barcode
try
{
if
(
barcode
.
startsWith
(
EVENTUSER_PREFIX
))
{
int
id
=
Integer
.
parseInt
(
barcode
.
substring
(
3
));
EventUser
user
=
userBean
.
findByEventUserId
(
id
);
return
user
;
}
}
catch
(
NumberFormatException
x
)
{
}
return
null
;
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceGroupBean.java
View file @
c8e39a5
...
@@ -21,21 +21,19 @@ import com.pdfjet.PDF;
...
@@ -21,21 +21,19 @@ import com.pdfjet.PDF;
import
com.pdfjet.Page
;
import
com.pdfjet.Page
;
import
com.pdfjet.TextLine
;
import
com.pdfjet.TextLine
;
import
fi.codecrew.moya.enums.apps.MapPermission
;
import
fi.codecrew.moya.enums.apps.SpecialPermission
;
import
fi.codecrew.moya.facade.EventUserFacade
;
import
fi.codecrew.moya.facade.EventUserFacade
;
import
fi.codecrew.moya.facade.GroupMembershipFacade
;
import
fi.codecrew.moya.facade.GroupMembershipFacade
;
import
fi.codecrew.moya.facade.PlaceGroupFacade
;
import
fi.codecrew.moya.facade.PlaceGroupFacade
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.LoggingBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PlaceGroupBeanLocal
;
import
fi.codecrew.moya.beans.SecurityLogType
;
import
fi.codecrew.moya.enums.apps.MapPermission
;
import
fi.codecrew.moya.enums.apps.SpecialPermission
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.GroupMembership
;
import
fi.codecrew.moya.model.GroupMembership
;
import
fi.codecrew.moya.model.LanEventProperty
;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.PlaceGroup
;
import
fi.codecrew.moya.model.PlaceGroup
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.utilities.BarcodeUtils
;
import
fi.codecrew.moya.utilities.BarcodeUtils
;
import
fi.codecrew.moya.utilities.I18n
;
/**
/**
* Session Bean implementation class PlaceGroupBean
* Session Bean implementation class PlaceGroupBean
...
@@ -48,6 +46,9 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
...
@@ -48,6 +46,9 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
private
static
final
int
YSTART
=
30
;
private
static
final
int
YSTART
=
30
;
@EJB
@EJB
private
EventBeanLocal
eventbean
;
private
EventBeanLocal
eventbean
;
@EJB
private
BarcodeBeanLocal
barcodeBean
;
@EJB
@EJB
private
GroupMembershipFacade
gmemfacade
;
private
GroupMembershipFacade
gmemfacade
;
...
@@ -134,6 +135,22 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
...
@@ -134,6 +135,22 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
@RolesAllowed
(
SpecialPermission
.
S_USER
)
@RolesAllowed
(
SpecialPermission
.
S_USER
)
public
void
getGroupMembershipPdf
(
EventUser
usr
,
OutputStream
ostream
)
{
public
void
getGroupMembershipPdf
(
EventUser
usr
,
OutputStream
ostream
)
{
List
<
GroupMembership
>
memberships
=
getMembershipsAndCreations
(
usr
);
List
<
GroupMembership
>
memberships
=
getMembershipsAndCreations
(
usr
);
LanEventProperty
tmpProperty
=
eventbean
.
getProperty
(
LanEventPropertyKey
.
PLACECODE_FROM_USER
);
boolean
placecodeFromUser
=
false
;
if
(
tmpProperty
!=
null
&&
tmpProperty
.
isBooleanValue
())
{
placecodeFromUser
=
true
;
}
tmpProperty
=
eventbean
.
getProperty
(
LanEventPropertyKey
.
PLACECODE_PRINT_ONLY_OWN
);
boolean
printOnlyOwn
=
false
;
if
(
tmpProperty
!=
null
&&
tmpProperty
.
isBooleanValue
())
{
printOnlyOwn
=
true
;
}
try
{
try
{
PDF
pdf
=
new
PDF
(
ostream
);
PDF
pdf
=
new
PDF
(
ostream
);
Font
font
=
new
Font
(
pdf
,
CoreFont
.
TIMES_ROMAN
);
Font
font
=
new
Font
(
pdf
,
CoreFont
.
TIMES_ROMAN
);
...
@@ -148,16 +165,36 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
...
@@ -148,16 +165,36 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
page
=
new
Page
(
pdf
,
A4
.
PORTRAIT
);
page
=
new
Page
(
pdf
,
A4
.
PORTRAIT
);
y
=
YSTART
;
y
=
YSTART
;
}
}
if
(
printOnlyOwn
&&
(
membership
.
getUser
()
==
null
||
!
membership
.
getUser
().
equals
(
usr
)))
{
continue
;
}
//
//
// PNGImage jpeg = new
// PNGImage jpeg = new
// PNGImage(BarcodeBean.getBarcode(membership.getInviteToken()));
// PNGImage(BarcodeBean.getBarcode(membership.getInviteToken()));
// logger.debug("Jpeg: " + jpeg.getWidth() + " h. " +
// logger.debug("Jpeg: " + jpeg.getWidth() + " h. " +
// jpeg.getHeight());
// jpeg.getHeight());
Image
image
=
new
Image
(
pdf
,
BarcodeUtils
.
getBarcode
(
membership
.
getInviteToken
()),
ImageType
.
PNG
);
image
.
scaleBy
(
0.8
);
if
(
placecodeFromUser
)
{
image
.
setPosition
(
50
,
y
);
if
(
membership
.
getUser
()
!=
null
)
{
image
.
drawOn
(
page
);
Image
image
=
new
Image
(
pdf
,
barcodeBean
.
getUserBarcode
(
membership
.
getUser
()),
ImageType
.
PNG
);
image
.
scaleBy
(
0.8
);
image
.
setPosition
(
50
,
y
);
image
.
drawOn
(
page
);
}
else
{
TextLine
nouser
=
new
TextLine
(
bigfont
,
"EMPTY PLACE"
);
nouser
.
setPosition
(
85
,
y
+
10
);
nouser
.
drawOn
(
page
);
}
}
else
{
Image
image
=
new
Image
(
pdf
,
BarcodeUtils
.
getBarcode
(
membership
.
getInviteToken
()),
ImageType
.
PNG
);
image
.
scaleBy
(
0.8
);
image
.
setPosition
(
50
,
y
);
image
.
drawOn
(
page
);
}
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
if
(
membership
.
getPlaceReservation
().
getName
()
!=
null
)
if
(
membership
.
getPlaceReservation
().
getName
()
!=
null
)
...
...
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/BarcodeBeanLocal.java
View file @
c8e39a5
...
@@ -5,12 +5,16 @@ import java.io.InputStream;
...
@@ -5,12 +5,16 @@ import java.io.InputStream;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.PrintedCard
;
@Local
@Local
public
interface
BarcodeBeanLocal
{
public
interface
BarcodeBeanLocal
{
public
PrintedCard
getPrintedCard
(
String
barcode
)
;
public
PrintedCard
getPrintedCard
(
String
barcode
)
;
public
EventUser
getUser
(
String
barcode
);
public
InputStream
getUserBarcode
(
EventUser
user
)
throws
IOException
;
public
InputStream
getCardBarcode
(
PrintedCard
printedCard
)
throws
IOException
;
public
InputStream
getCardBarcode
(
PrintedCard
printedCard
)
throws
IOException
;
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/LanEventPropertyKey.java
View file @
c8e39a5
...
@@ -8,7 +8,10 @@ public enum LanEventPropertyKey {
...
@@ -8,7 +8,10 @@ public enum LanEventPropertyKey {
PORTAL_EMAIL_NAME
(
Type
.
TEXT
,
"Streamparty intranet"
),
PORTAL_EMAIL_NAME
(
Type
.
TEXT
,
"Streamparty intranet"
),
ADMIN_MAIL
(
Type
.
TEXT
,
"intra@streamparty.org"
),
ADMIN_MAIL
(
Type
.
TEXT
,
"intra@streamparty.org"
),
EVENT_LAYOUT
(
Type
.
TEXT
,
"template1"
),
EVENT_LAYOUT
(
Type
.
TEXT
,
"template1"
),
SHOP_DEFAULT_CASH
(
Type
.
BOOL
,
null
),
;
SHOP_DEFAULT_CASH
(
Type
.
BOOL
,
null
),
PLACECODE_FROM_USER
(
Type
.
BOOL
,
null
),
PLACECODE_PRINT_ONLY_OWN
(
Type
.
BOOL
,
null
),
;
private
enum
Type
{
private
enum
Type
{
TEXT
,
DATE
,
DATA
,
BOOL
TEXT
,
DATE
,
DATA
,
BOOL
};
};
...
@@ -29,14 +32,14 @@ public enum LanEventPropertyKey {
...
@@ -29,14 +32,14 @@ public enum LanEventPropertyKey {
}
}
public
boolean
isBoolean
()
{
public
boolean
isBoolean
()
{
return
Type
.
DATA
.
equals
(
type
);
return
Type
.
BOOL
.
equals
(
type
);
}
}
private
LanEventPropertyKey
(
Type
t
,
String
def
)
private
LanEventPropertyKey
(
Type
t
,
String
def
)
{
{
this
.
type
=
t
;
this
.
type
=
t
;
defaultvalue
=
def
;
defaultvalue
=
def
;
}
}
public
String
getDefaultvalue
()
{
public
String
getDefaultvalue
()
{
return
defaultvalue
;
return
defaultvalue
;
...
...
code/MoyaWeb/WebContent/eventorg/editEvent.xhtml
View file @
c8e39a5
...
@@ -77,6 +77,8 @@
...
@@ -77,6 +77,8 @@
<h:column>
<h:column>
<f:facet
name=
"header"
>
#{i18n['lanEventProperty.value']}
</f:facet>
<f:facet
name=
"header"
>
#{i18n['lanEventProperty.value']}
</f:facet>
<h:outputText
rendered=
"#{prop.key.text}"
value=
"#{prop.textvalue}"
/>
<h:outputText
rendered=
"#{prop.key.text}"
value=
"#{prop.textvalue}"
/>
<h:outputText
rendered=
"#{prop.key.boolean and prop.booleanValue}"
value=
"true"
/>
<h:outputText
rendered=
"#{prop.key.boolean and not prop.booleanValue}"
value=
"false"
/>
<h:outputText
rendered=
"#{prop.key.date}"
value=
"#{prop.dateValue}"
>
<h:outputText
rendered=
"#{prop.key.date}"
value=
"#{prop.dateValue}"
>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
</h:outputText>
...
@@ -123,6 +125,10 @@
...
@@ -123,6 +125,10 @@
<h:outputLabel
rendered=
"#{eventPropertyView.property.key.date}"
for=
"textval"
value=
"#{i18n['lanEventProperty.textValue']}"
/>
<h:outputLabel
rendered=
"#{eventPropertyView.property.key.date}"
for=
"textval"
value=
"#{i18n['lanEventProperty.textValue']}"
/>
<p:calendar
rendered=
"#{eventPropertyView.property.key.date}"
value=
"#{eventPropertyView.property.dateValue}"
pattern=
"#{sessionHandler.datetimeFormat}"
/>
<p:calendar
rendered=
"#{eventPropertyView.property.key.date}"
value=
"#{eventPropertyView.property.dateValue}"
pattern=
"#{sessionHandler.datetimeFormat}"
/>
<h:message
rendered=
"#{eventPropertyView.property.key.date}"
for=
"textval"
/>
<h:message
rendered=
"#{eventPropertyView.property.key.date}"
for=
"textval"
/>
<h:outputLabel
rendered=
"#{eventPropertyView.property.key.boolean}"
for=
"booleanval"
value=
"#{i18n['lanEventProperty.booleanValue']}"
/>
<h:selectBooleanCheckbox
rendered=
"#{eventPropertyView.property.key.boolean}"
id=
"booleanval"
value=
"#{eventPropertyView.property.booleanValue}"
/>
<h:message
rendered=
"#{eventPropertyView.property.key.boolean}"
for=
"booleanval"
/>
</h:panelGrid>
</h:panelGrid>
<h:commandButton
action=
"#{eventPropertyView.saveProperty}"
value=
"#{i18n['lanEventProperty.save']}"
/>
<h:commandButton
action=
"#{eventPropertyView.saveProperty}"
value=
"#{i18n['lanEventProperty.save']}"
/>
...
...
code/MoyaWeb/src/fi/codecrew/moya/servlet/PlaceGroupPdf.java
View file @
c8e39a5
...
@@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PlaceGroupBeanLocal
;
import
fi.codecrew.moya.beans.PlaceGroupBeanLocal
;
...
...
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