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 d9dfe43e
authored
Apr 01, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Site content copying from existing event
1 parent
9914e624
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
48 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/SitePageBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/SitePageBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/SitePageFacade.java
code/moya-web/WebContent/resources/cditools/role/edit.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/organisation/EventOrgView.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/SitePageBeanLocal.java
View file @
d9dfe43
...
...
@@ -23,6 +23,7 @@ import java.util.Locale;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.PageContent
;
import
fi.codecrew.moya.model.SitePage
;
...
...
@@ -49,4 +50,6 @@ public interface SitePageBeanLocal {
SitePage
findSitename
(
String
managedPage
);
void
copySites
(
LanEvent
copyParty
,
LanEvent
event
);
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/SitePageBean.java
View file @
d9dfe43
...
...
@@ -35,10 +35,13 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.enums.apps.ContentPermission
;
import
fi.codecrew.moya.facade.LanEventFacade
;
import
fi.codecrew.moya.facade.SitePageFacade
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.PageContent
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.SitePage
;
import
fi.codecrew.moya.utilities.jpa.GenericFacade
;
/**
* Session Bean implementation class SitePageBean
...
...
@@ -74,6 +77,9 @@ public class SitePageBean implements SitePageBeanLocal {
@SuppressWarnings
(
"unused"
)
private
Logger
logger
=
LoggerFactory
.
getLogger
(
SitePageBean
.
class
);
@EJB
private
LanEventFacade
eventFacade
;
@Override
@RolesAllowed
(
ContentPermission
.
S_MANAGE_PAGES
)
public
void
create
(
SitePage
sitepage
)
{
...
...
@@ -159,4 +165,33 @@ public class SitePageBean implements SitePageBeanLocal {
return
sitepagefacade
.
find
(
managedPage
);
}
@Override
@RolesAllowed
(
ContentPermission
.
S_MANAGE_PAGES
)
public
void
copySites
(
LanEvent
copyParty
,
LanEvent
event
)
{
event
=
eventFacade
.
reload
(
event
);
List
<
SitePage
>
sites
=
sitepagefacade
.
findAll
(
copyParty
);
for
(
SitePage
s
:
sites
)
{
SitePage
oldsite
=
findSitename
(
s
.
getName
());
if
(
oldsite
!=
null
)
{
continue
;
}
SitePage
nsite
=
new
SitePage
();
nsite
.
setName
(
s
.
getName
());
nsite
.
setContents
(
new
ArrayList
<>());
nsite
.
setEvent
(
event
);
for
(
PageContent
cont
:
s
.
getContents
())
{
PageContent
ncont
=
new
PageContent
();
ncont
.
setContent
(
cont
.
getContent
());
ncont
.
setExpire
(
cont
.
getExpire
());
ncont
.
setLocale
(
cont
.
getLocale
());
ncont
.
setPublish
(
cont
.
getPublish
());
ncont
.
setSort
(
cont
.
getSort
());
ncont
.
setSitepage
(
nsite
);
nsite
.
getContents
().
add
(
ncont
);
}
sitepagefacade
.
create
(
nsite
);
}
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/SitePageFacade.java
View file @
d9dfe43
...
...
@@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.PageContent
;
import
fi.codecrew.moya.model.PageContent_
;
import
fi.codecrew.moya.model.Role
;
...
...
@@ -98,7 +99,11 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> {
}
public
List
<
SitePage
>
findAll
()
public
List
<
SitePage
>
findAll
()
{
return
findAll
(
eventbean
.
getCurrentEvent
());
}
public
List
<
SitePage
>
findAll
(
LanEvent
event
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
SitePage
>
cq
=
cb
.
createQuery
(
SitePage
.
class
);
...
...
@@ -106,7 +111,7 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> {
cq
.
where
(
cb
.
isNull
(
root
.
get
(
SitePage_
.
parent
)),
cb
.
equal
(
root
.
get
(
SitePage_
.
event
),
event
bean
.
getCurrentEvent
()
)
cb
.
equal
(
root
.
get
(
SitePage_
.
event
),
event
)
);
return
getEm
().
createQuery
(
cq
).
getResultList
();
...
...
code/moya-web/WebContent/resources/cditools/role/edit.xhtml
View file @
d9dfe43
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
xmlns:role=
"http://java.sun.com/jsf/composite/tools/role"
>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:
c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
xmlns:
role=
"http://java.sun.com/jsf/composite/tools/role"
>
<composite:interface>
...
...
@@ -29,58 +29,53 @@
</p:autoComplete>
</h:form>
<p:fieldset
legend=
"#{i18n['roleView.members']}"
collapsed=
"true"
>
<h:dataTable
id=
"memberlist"
value=
"#{roleView.role.users}"
var=
"usr"
>
<h:column>
<p:fieldset
id=
"userfield"
legend=
"#{i18n['roleView.members']}"
toggleable=
"true"
collapsed=
"true"
>
<p:dataTable
id=
"memberlist"
value=
"#{roleView.role.users}"
var=
"usr"
>
<p:column>
<h:outputText
value=
"#{usr.login}"
/>
</
h
:column>
<
h
:column>
</
p
:column>
<
p
:column>
<h:outputText
value=
"#{usr.nick}"
/>
</
h
:column>
<
h
:column>
</
p
:column>
<
p
:column>
<h:outputText
value=
"#{usr.wholeName}"
/>
</
h
:column>
<
h
:column>
</
p
:column>
<
p
:column>
<h:outputText
value=
"#{usr.email}"
/>
</h:column>
</h:dataTable>
</p:column>
</p:dataTable>
</p:fieldset>
<p:fieldset
legend=
"#{i18n['role.permissionheader']}"
toggleable=
"true"
collapsed=
"true"
>
<h:form
id=
"permissionform"
>
<h:commandButton
id=
"save1"
value=
"#{i18n['role.savePermissions']}"
action=
"#{roleView.savePermissions}"
/>
<h:dataTable
border=
"1"
id=
"bortalApps"
value=
"#{roleView.rolePermissions}"
var=
"bapp"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['applicationPermission.name']}"
/>
</f:facet>
<h:outputText
value=
"#{bapp.name}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['applicationPermission.description']}"
/>
</f:facet>
<h:outputText
value=
"#{i18n[bapp.key]}"
/>
</h:column>
<h:column>
<h:selectManyCheckbox
id=
"permissions"
layout=
"pageDirection"
value=
"#{bapp.selected}"
>
<f:selectItems
value=
"#{bapp.permissions}"
var=
"per"
itemLabel=
"#{i18n[per.i18nKey]}"
/>
</h:selectManyCheckbox>
</h:column>
</h:dataTable>
<h:commandButton
id=
"save2"
value=
"#{i18n['role.savePermissions']}"
action=
"#{roleView.savePermissions}"
/>
<button
id=
"roledisplayer"
onclick=
'$("#roleeditor").show(); $(this).hide();'
>
#{i18n['roleView.showPermissioneditor']}
</button>
<div
id=
"roleeditor"
style=
"display: none"
>
<button
onclick=
'$("#roleeditor").hide(); $("#roledisplayer").show();'
>
#{i18n['roleView.hidePermissioneditor']}
</button>
<h2>
#{i18n['role.permissionheader']}
</h2>
<p>
<h:form
id=
"permissionform"
>
<h:commandButton
id=
"save1"
value=
"#{i18n['role.savePermissions']}"
action=
"#{roleView.savePermissions}"
/>
<h:dataTable
border=
"1"
id=
"bortalApps"
value=
"#{roleView.rolePermissions}"
var=
"bapp"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['applicationPermission.name']}"
/>
</f:facet>
<h:outputText
value=
"#{bapp.name}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['applicationPermission.description']}"
/>
</f:facet>
<h:outputText
value=
"#{i18n[bapp.key]}"
/>
</h:column>
<h:column>
<h:selectManyCheckbox
id=
"permissions"
layout=
"pageDirection"
value=
"#{bapp.selected}"
>
<f:selectItems
value=
"#{bapp.permissions}"
var=
"per"
itemLabel=
"#{i18n[per.i18nKey]}"
/>
</h:selectManyCheckbox>
</h:column>
</h:dataTable>
<h:commandButton
id=
"save2"
value=
"#{i18n['role.savePermissions']}"
action=
"#{roleView.savePermissions}"
/>
</h:form>
</p>
</div>
</h:form>
</p:fieldset>
</composite:implementation>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/organisation/EventOrgView.java
View file @
d9dfe43
...
...
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.EventOrganiserBeanLocal
;
import
fi.codecrew.moya.beans.SitePageBeanLocal
;
import
fi.codecrew.moya.enums.apps.EventPermission
;
import
fi.codecrew.moya.model.EventOrganiser
;
import
fi.codecrew.moya.model.EventUser
;
...
...
@@ -55,6 +56,9 @@ public class EventOrgView extends GenericCDIView {
@EJB
private
transient
EventBeanLocal
eventbean
;
@EJB
private
SitePageBeanLocal
sitepagebean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EventOrgView
.
class
);
@LoggedIn
...
...
@@ -74,6 +78,8 @@ public class EventOrgView extends GenericCDIView {
private
String
newdomain
;
private
LanEvent
copyParty
;
private
transient
ListDataModel
<
LanEventDomain
>
eventdomains
;
ScheduleModel
eventsCalendar
=
null
;
...
...
@@ -286,4 +292,18 @@ public class EventOrgView extends GenericCDIView {
return
eventsCalendar
;
}
public
String
copySiteContent
()
{
sitepagebean
.
copySites
(
copyParty
,
event
);
return
null
;
}
public
LanEvent
getCopyParty
()
{
return
copyParty
;
}
public
void
setCopyParty
(
LanEvent
copyParty
)
{
this
.
copyParty
=
copyParty
;
}
}
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