Commit 2b755c5c by Tuukka Kivilahti

Merge branch 'sitecopy' into 'master'

Site copy from old event

Copy site contents from old event

See merge request !267
2 parents 2aa5c263 d9dfe43e
......@@ -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);
}
......@@ -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);
}
}
}
......@@ -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), eventbean.getCurrentEvent())
cb.equal(root.get(SitePage_.event), event)
);
return getEm().createQuery(cq).getResultList();
......
<?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>
......
......@@ -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;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!