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 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;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.sun.xml.bind.v2.model.core.ID
;
import
fi.codecrew.moya.facade.PrintedCardFacade
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.utilities.BarcodeUtils
;
/**
...
...
@@ -23,11 +23,17 @@ import fi.codecrew.moya.utilities.BarcodeUtils;
@LocalBean
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
);
@EJB
PrintedCardFacade
printedCardFacade
;
@EJB
UserBeanLocal
userBean
;
/**
* Default constructor.
...
...
@@ -35,6 +41,21 @@ public class BarcodeBean implements BarcodeBeanLocal {
public
BarcodeBean
()
{
// 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
{
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -69,4 +90,22 @@ public class BarcodeBean implements BarcodeBeanLocal {
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;
import
com.pdfjet.Page
;
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.GroupMembershipFacade
;
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.GroupMembership
;
import
fi.codecrew.moya.model.LanEventProperty
;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.PlaceGroup
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.utilities.BarcodeUtils
;
import
fi.codecrew.moya.utilities.I18n
;
/**
* Session Bean implementation class PlaceGroupBean
...
...
@@ -48,6 +46,9 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
private
static
final
int
YSTART
=
30
;
@EJB
private
EventBeanLocal
eventbean
;
@EJB
private
BarcodeBeanLocal
barcodeBean
;
@EJB
private
GroupMembershipFacade
gmemfacade
;
...
...
@@ -134,6 +135,22 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
@RolesAllowed
(
SpecialPermission
.
S_USER
)
public
void
getGroupMembershipPdf
(
EventUser
usr
,
OutputStream
ostream
)
{
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
{
PDF
pdf
=
new
PDF
(
ostream
);
Font
font
=
new
Font
(
pdf
,
CoreFont
.
TIMES_ROMAN
);
...
...
@@ -148,16 +165,36 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
page
=
new
Page
(
pdf
,
A4
.
PORTRAIT
);
y
=
YSTART
;
}
if
(
printOnlyOwn
&&
(
membership
.
getUser
()
==
null
||
!
membership
.
getUser
().
equals
(
usr
)))
{
continue
;
}
//
// PNGImage jpeg = new
// PNGImage(BarcodeBean.getBarcode(membership.getInviteToken()));
// logger.debug("Jpeg: " + jpeg.getWidth() + " h. " +
// jpeg.getHeight());
Image
image
=
new
Image
(
pdf
,
BarcodeUtils
.
getBarcode
(
membership
.
getInviteToken
()),
ImageType
.
PNG
);
image
.
scaleBy
(
0.8
);
image
.
setPosition
(
50
,
y
);
image
.
drawOn
(
page
);
if
(
placecodeFromUser
)
{
if
(
membership
.
getUser
()
!=
null
)
{
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
();
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;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.PrintedCard
;
@Local
public
interface
BarcodeBeanLocal
{
public
PrintedCard
getPrintedCard
(
String
barcode
)
;
public
EventUser
getUser
(
String
barcode
);
public
InputStream
getUserBarcode
(
EventUser
user
)
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 {
PORTAL_EMAIL_NAME
(
Type
.
TEXT
,
"Streamparty intranet"
),
ADMIN_MAIL
(
Type
.
TEXT
,
"intra@streamparty.org"
),
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
{
TEXT
,
DATE
,
DATA
,
BOOL
};
...
...
@@ -29,14 +32,14 @@ public enum LanEventPropertyKey {
}
public
boolean
isBoolean
()
{
return
Type
.
DATA
.
equals
(
type
);
return
Type
.
BOOL
.
equals
(
type
);
}
private
LanEventPropertyKey
(
Type
t
,
String
def
)
{
this
.
type
=
t
;
defaultvalue
=
def
;
}
}
public
String
getDefaultvalue
()
{
return
defaultvalue
;
...
...
code/MoyaWeb/WebContent/eventorg/editEvent.xhtml
View file @
c8e39a5
...
...
@@ -77,6 +77,8 @@
<h:column>
<f:facet
name=
"header"
>
#{i18n['lanEventProperty.value']}
</f:facet>
<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}"
>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
...
...
@@ -123,6 +125,10 @@
<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}"
/>
<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: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;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
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