net.anotheria.anosite.gen.aslayoutdata.action.EditPageLayoutAction Maven / Gradle / Ivy
/**
********************************************************************************
*** EditPageLayoutAction.java ***
*** generated by AnoSiteGenerator (ASG), Version: 3.2.2 ***
*** Copyright (C) 2005 - 2023 Anotheria.net, www.anotheria.net ***
*** All Rights Reserved. ***
********************************************************************************
*** Don't edit this code, if you aren't sure ***
*** that you do exactly know what you are doing! ***
*** It's better to invest time in the generator, as into the generated code. ***
********************************************************************************
*/
package net.anotheria.anosite.gen.aslayoutdata.action;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionCommand;
import net.anotheria.maf.action.ActionMapping;
import java.util.List;
import java.util.ArrayList;
import net.anotheria.anosite.gen.aslayoutdata.bean.EditPageLayoutFB;
import net.anotheria.anosite.gen.aslayoutdata.data.PageLayout;
import net.anotheria.webutils.bean.LabelValueBean;
import net.anotheria.anodoc.query2.QueryProperty;
import net.anotheria.asg.util.bean.LinkToMeBean;
import net.anotheria.anosite.gen.assitedata.data.PageTemplate;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.anosite.gen.aslayoutdata.data.PageStyle;
public class EditPageLayoutAction extends ShowPageLayoutsAction{
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEditAction
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEditActionMethod
public ActionCommand anoDocExecute(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
EditPageLayoutFB form = new EditPageLayoutFB() ;
PageLayout pagelayout = getASLayoutDataService().getPageLayout(id);
checkPageLayouts(pagelayout, req);
if(pagelayout instanceof LockableObject && !((LockableObject)pagelayout).isLocked() && isAutoLockingEnabled())
lockPageLayouts(pagelayout, req);
form.setId(pagelayout.getId());
form.setName(pagelayout.getName());
form.setLayoutpage(pagelayout.getLayoutpage());
form.setStyle(pagelayout.getStyle());
form.setDescription(pagelayout.getDescription());
form.setLocked(((LockableObject)pagelayout).isLocked());
form.setLockerId(((LockableObject)pagelayout).getLockerId());
form.setLockingTime(net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)pagelayout).getLockingTime()) + " automatic unlock expected AT : " + net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)pagelayout).getLockingTime() + getLockingTimeout()));
//link style to ASLayoutData.PageStyle
List pagestyles = getASLayoutDataService().getPageStyles();
List pagestylesValues = new ArrayList(pagestyles.size()+1);
pagestylesValues.add(new LabelValueBean("", "-----"));
for (net.anotheria.anosite.gen.aslayoutdata.data.PageStyle pagestyleTemp : pagestyles){
LabelValueBean bean = new LabelValueBean(pagestyleTemp.getId(), pagestyleTemp.getName() + " [" + pagestyleTemp.getId() + "]" );
pagestylesValues.add(bean);
}
form.setStyleCollection(pagestylesValues);
try{
form.setStyleCurrentValue(getASLayoutDataService().getPageStyle(pagelayout.getStyle()).getName());
}catch(Exception e){
form.setStyleCurrentValue("none");
form.setStyleIdOfCurrentValue("none");
}
addBeanToRequest(req, "objectId" , pagelayout.getId());
addBeanToRequest(req, "EditASLayoutDataPageLayoutForm" , form);
addBeanToRequest(req, "objectInfoString" , pagelayout.getObjectInfo().toString());
addBeanToRequest(req, "apply.label.prefix", "Apply");
addBeanToRequest(req, "save.label.prefix", "Save");
addBeanToRequest(req, "transfer.label.prefix", "Transfer");
addFieldExplanations(req, pagelayout);
// Generating back link handling...
List linksToMe = findLinksToCurrentDocument(pagelayout.getId());
if (linksToMe.size()>0)
req.setAttribute("linksToMe", linksToMe);
return mapping.success();
}
private List findLinksToCurrentDocument(String documentId){
List ret = new ArrayList();
try{
ret.addAll(findLinkToCurrentDocumentInASSiteDataPageTemplateLayout(documentId));
}catch(Exception ignored){
}
return ret;
}
private List findLinkToCurrentDocumentInASSiteDataPageTemplateLayout(String documentId) throws net.anotheria.anosite.gen.assitedata.service.ASSiteDataServiceException{
List ret = new ArrayList();
QueryProperty p = new QueryProperty(PageTemplate.LINK_PROP_LAYOUT, documentId);
// temporarly - replacy with query property
List list = getASSiteDataService().getPageTemplatesByProperty(p.getName(), p.getValue());
for (PageTemplate doc : list ){
ret.add(new LinkToMeBean(doc, "layout"));
}
return ret;
}
}