Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
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 62bc311b
authored
Jun 06, 2013
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
paikkakooditulostus
1 parent
b2593292
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
9 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceMapBean.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/PlaceMapBeanLocal.java
code/MoyaWeb/WebContent/map/edit.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/map/MapManageView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
View file @
62bc311
...
@@ -82,14 +82,18 @@ public class BarcodeBean implements BarcodeBeanLocal {
...
@@ -82,14 +82,18 @@ public class BarcodeBean implements BarcodeBeanLocal {
sb
.
append
(
PLACE_PREFIX
);
sb
.
append
(
PLACE_PREFIX
);
String
idStr
=
place
.
getId
().
toString
();
String
idStr
=
place
.
getId
().
toString
();
for
(
int
i
=
12
-
idStr
.
length
()
-
sb
.
length
();
i
>
0
;
--
i
)
{
for
(
int
i
=
8
-
idStr
.
length
()
-
sb
.
length
();
i
>
0
;
--
i
)
{
sb
.
append
(
"0"
);
sb
.
append
(
"0"
);
}
}
sb
.
append
(
idStr
);
sb
.
append
(
idStr
);
String
barcode
=
sb
.
toString
();
String
barcode
=
sb
.
toString
();
String
hexcode
=
Integer
.
toHexString
(
Integer
.
parseInt
(
barcode
));
String
hexcode
=
Long
.
toHexString
(
Long
.
parseLong
(
barcode
));
String
checksum
=
Integer
.
toHexString
(
hexcode
.
hashCode
());
checksum
=
checksum
.
substring
(
checksum
.
length
()
-
3
);
hexcode
+=
checksum
;
logger
.
debug
(
"Geneating hexcode for place {} : {}"
,
place
.
getId
(),
hexcode
);
logger
.
debug
(
"Geneating hexcode for place {} : {}"
,
place
.
getId
(),
hexcode
);
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
62bc311
...
@@ -537,12 +537,12 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -537,12 +537,12 @@ public class PlaceBean implements PlaceBeanLocal {
font
.
setSize
(
font1
);
font
.
setSize
(
font1
);
TextLine
textLine
=
new
TextLine
(
font
);
TextLine
textLine
=
new
TextLine
(
font
);
textLine
.
setText
(
place
.
get
Cod
e
());
textLine
.
setText
(
place
.
get
Nam
e
());
textLine
.
setPosition
(
3
,
3
);
textLine
.
setPosition
(
5
,
15
);
textLine
.
setColor
(
new
double
[]
{
0
,
0
,
0
});
textLine
.
setColor
(
new
double
[]
{
0
,
0
,
0
});
textLine
.
drawOn
(
page
);
textLine
.
drawOn
(
page
);
double
currentX
=
font1
*
4
;
double
currentX
=
42
;
// nick
// nick
if
(
place
.
getPlaceReserver
()
!=
null
&&
place
.
getPlaceReserver
().
getUser
()
!=
null
)
{
if
(
place
.
getPlaceReserver
()
!=
null
&&
place
.
getPlaceReserver
().
getUser
()
!=
null
)
{
...
@@ -551,7 +551,7 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -551,7 +551,7 @@ public class PlaceBean implements PlaceBeanLocal {
textLine
=
new
TextLine
(
font
);
textLine
=
new
TextLine
(
font
);
textLine
.
setText
(
place
.
getPlaceReserver
().
getUser
().
getNick
());
textLine
.
setText
(
place
.
getPlaceReserver
().
getUser
().
getNick
());
textLine
.
setPosition
(
currentX
,
3
);
textLine
.
setPosition
(
currentX
,
15
);
textLine
.
setColor
(
new
double
[]
{
0
,
0
,
0
});
textLine
.
setColor
(
new
double
[]
{
0
,
0
,
0
});
textLine
.
drawOn
(
page
);
textLine
.
drawOn
(
page
);
}
}
...
@@ -562,7 +562,7 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -562,7 +562,7 @@ public class PlaceBean implements PlaceBeanLocal {
textLine
=
new
TextLine
(
font
);
textLine
=
new
TextLine
(
font
);
textLine
.
setText
(
barcodeBean
.
getPlaceHexcode
(
place
));
textLine
.
setText
(
barcodeBean
.
getPlaceHexcode
(
place
));
textLine
.
setPosition
(
currentX
,
(
height
/
2
)
);
textLine
.
setPosition
(
currentX
,
(
pagey
/
2
)+
font1
);
textLine
.
setColor
(
new
double
[]
{
0
,
0
,
0
});
textLine
.
setColor
(
new
double
[]
{
0
,
0
,
0
});
textLine
.
drawOn
(
page
);
textLine
.
drawOn
(
page
);
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PlaceMapBean.java
View file @
62bc311
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.ejb.Stateless
;
import
javax.ejb.Stateless
;
import
javax.imageio.ImageIO
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.pdfjet.CoreFont
;
import
com.pdfjet.Image
;
import
com.pdfjet.ImageType
;
import
com.pdfjet.PDF
;
import
com.pdfjet.Page
;
import
com.pdfjet.TextLine
;
import
fi.codecrew.moya.facade.EventMapFacade
;
import
fi.codecrew.moya.facade.EventMapFacade
;
import
fi.codecrew.moya.facade.PlaceFacade
;
import
fi.codecrew.moya.facade.PlaceFacade
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.model.CardTemplate
;
import
fi.codecrew.moya.beans.PlaceMapBeanLocal
;
import
fi.codecrew.moya.model.EventMap
;
import
fi.codecrew.moya.model.EventMap
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.Place
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.util.MassPrintResult
;
/**
/**
* Session Bean implementation class PlaceMapBean
* Session Bean implementation class PlaceMapBean
...
@@ -63,4 +78,51 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
...
@@ -63,4 +78,51 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
}
}
return
null
;
return
null
;
}
}
/*
wanha, poistoon
public byte[] placeCodesPdf(List<Place> places) {
// double[] pageSize = new double[] { cardBackground.getWidth(),
// cardBackground.getHeight() };
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PDF pdf;
try {
pdf = new PDF(outputStream);
pdf.setTitle("placecodes");
double pagex = 155.9;
double pagey = 48;
Page page = new Page(pdf, new double[] { pagex, pagey });
// Render texts
// Big font for nick
com.pdfjet.Font font = new com.pdfjet.Font(pdf, CoreFont.HELVETICA);
font.setSize(8.0);
TextLine line = new TextLine(font);
line.setText("testi");
line.setPosition(1, 1);
line.setColor(new double[] { 1.0, 1.0, 1.0 });
line.drawOn(page);
pdf.flush();
outputStream.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return outputStream.toByteArray();
}
*/
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/PlaceMapBeanLocal.java
View file @
62bc311
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.util.List
;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.EventMap
;
import
fi.codecrew.moya.model.EventMap
;
import
fi.codecrew.moya.model.Place
;
@Local
@Local
public
interface
PlaceMapBeanLocal
{
public
interface
PlaceMapBeanLocal
{
...
@@ -17,6 +20,9 @@ public interface PlaceMapBeanLocal {
...
@@ -17,6 +20,9 @@ public interface PlaceMapBeanLocal {
public
Long
availablePlaceCount
(
EventMap
activeMap
);
public
Long
availablePlaceCount
(
EventMap
activeMap
);
public
EventMap
getActiveMap
();
public
EventMap
getActiveMap
();
// wanha poistoon, see placebean
// public byte[] placeCodesPdf(List<Place> places);
// public List<Place> findSelectedPlaces(EventMap map);
// public List<Place> findSelectedPlaces(EventMap map);
...
...
code/MoyaWeb/WebContent/map/edit.xhtml
View file @
62bc311
...
@@ -28,6 +28,12 @@
...
@@ -28,6 +28,12 @@
<p:fileUpload
mode=
"simple"
value=
"#{mapManageView.bgFile}"
/>
<p:fileUpload
mode=
"simple"
value=
"#{mapManageView.bgFile}"
/>
<h:commandButton
action=
"#{mapManageView.submitBg}"
value=
"#{i18n['map.submitMap']}"
/>
<h:commandButton
action=
"#{mapManageView.submitBg}"
value=
"#{i18n['map.submitMap']}"
/>
</h:form>
</h:form>
<h:form>
<p:commandButton
id=
"downloadLink"
value=
"koodipdf"
ajax=
"false"
>
<p:fileDownload
value=
"#{mapManageView.streamedFile}"
/>
</p:commandButton>
</h:form>
</ui:define>
</ui:define>
</ui:composition>
</ui:composition>
</h:body>
</h:body>
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/map/MapManageView.java
View file @
62bc311
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
map
;
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
map
;
import
java.io.ByteArrayInputStream
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -10,6 +11,8 @@ import javax.faces.context.FacesContext;
...
@@ -10,6 +11,8 @@ import javax.faces.context.FacesContext;
import
javax.faces.event.ActionEvent
;
import
javax.faces.event.ActionEvent
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
org.primefaces.model.DefaultStreamedContent
;
import
org.primefaces.model.StreamedContent
;
import
org.primefaces.model.UploadedFile
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -71,6 +74,8 @@ public class MapManageView extends GenericCDIView {
...
@@ -71,6 +74,8 @@ public class MapManageView extends GenericCDIView {
private
String
namebase
;
private
String
namebase
;
private
Integer
mapId
;
private
Integer
mapId
;
private
List
<
Product
>
productlist
;
private
List
<
Product
>
productlist
;
private
StreamedContent
streamedFile
;
private
LanEvent
copyEvent
;
private
LanEvent
copyEvent
;
...
@@ -86,7 +91,10 @@ public class MapManageView extends GenericCDIView {
...
@@ -86,7 +91,10 @@ public class MapManageView extends GenericCDIView {
map
=
eventmapBean
.
find
(
getMapId
());
map
=
eventmapBean
.
find
(
getMapId
());
setProductlist
(
productbean
.
getProducts
());
setProductlist
(
productbean
.
getProducts
());
super
.
beginConversation
();
super
.
beginConversation
();
streamedFile
=
new
DefaultStreamedContent
(
new
ByteArrayInputStream
(
placebean
.
generatePlacesPdf
(
54
,
17
,
18
,
15
)),
"application/pdf"
,
"paikkakoodit"
);
}
}
}
}
...
@@ -340,4 +348,14 @@ public class MapManageView extends GenericCDIView {
...
@@ -340,4 +348,14 @@ public class MapManageView extends GenericCDIView {
public
void
setBgFile
(
UploadedFile
bgFile
)
{
public
void
setBgFile
(
UploadedFile
bgFile
)
{
this
.
bgFile
=
bgFile
;
this
.
bgFile
=
bgFile
;
}
}
//StreamedContent new DefaultStreamedContent(pdfstream)
public
StreamedContent
getStreamedFile
()
{
//DefaultStreamedContent(new ByteArrayInputStream(placebean.generatePlacesPdf(54, 17, 10, 6)));
return
streamedFile
;
}
}
}
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