All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anosite.gen.assitedata.action.EditPageTemplateAction Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** EditPageTemplateAction.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.assitedata.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.assitedata.bean.EditPageTemplateFB;
import net.anotheria.anosite.gen.assitedata.data.PageTemplate;
import net.anotheria.webutils.bean.LabelValueBean;
import net.anotheria.anodoc.query2.QueryProperty;
import net.anotheria.asg.util.bean.LinkToMeBean;
import net.anotheria.anosite.gen.aswebdata.data.Pagex;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.anosite.gen.aslayoutdata.data.PageLayout;
import net.anotheria.anosite.gen.assitedata.data.Site;

public class EditPageTemplateAction extends ShowPageTemplatesAction{

// 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);
		EditPageTemplateFB form = new EditPageTemplateFB() ;
		PageTemplate pagetemplate = getASSiteDataService().getPageTemplate(id);
		checkPageTemplates(pagetemplate, req);
		if(pagetemplate instanceof LockableObject && !((LockableObject)pagetemplate).isLocked() && isAutoLockingEnabled())
			lockPageTemplates(pagetemplate, req);
		form.setId(pagetemplate.getId());
		form.setName(pagetemplate.getName());
		form.setLayout(pagetemplate.getLayout());
		form.setLayoutlink("aslayoutdataPageLayoutEdit?pId="+pagetemplate.getLayout());
		form.setSite(pagetemplate.getSite());
		// mediaLinks is a table, storing size only
		form.setMediaLinks(pagetemplate.getMediaLinksSize());
		// scripts is a table, storing size only
		form.setScripts(pagetemplate.getScriptsSize());
		// localizations is a table, storing size only
		form.setLocalizations(pagetemplate.getLocalizationsSize());
		// c1first is a table, storing size only
		form.setC1first(pagetemplate.getC1firstSize());
		// c2first is a table, storing size only
		form.setC2first(pagetemplate.getC2firstSize());
		// c3first is a table, storing size only
		form.setC3first(pagetemplate.getC3firstSize());
		// c1last is a table, storing size only
		form.setC1last(pagetemplate.getC1lastSize());
		// c2last is a table, storing size only
		form.setC2last(pagetemplate.getC2lastSize());
		// c3last is a table, storing size only
		form.setC3last(pagetemplate.getC3lastSize());
		// meta is a table, storing size only
		form.setMeta(pagetemplate.getMetaSize());
		// header is a table, storing size only
		form.setHeader(pagetemplate.getHeaderSize());
		// footer is a table, storing size only
		form.setFooter(pagetemplate.getFooterSize());
		form.setDescription(pagetemplate.getDescription());
		form.setLocked(((LockableObject)pagetemplate).isLocked());
		form.setLockerId(((LockableObject)pagetemplate).getLockerId());
		form.setLockingTime(net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)pagetemplate).getLockingTime()) + " automatic unlock expected AT : " + net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)pagetemplate).getLockingTime() + getLockingTimeout()));


		//link layout to ASLayoutData.PageLayout
		List pagelayouts = getASLayoutDataService().getPageLayouts();
		List pagelayoutsValues = new ArrayList(pagelayouts.size()+1);
		pagelayoutsValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.aslayoutdata.data.PageLayout pagelayoutTemp : pagelayouts){
			LabelValueBean bean = new LabelValueBean(pagelayoutTemp.getId(), pagelayoutTemp.getName() + " [" + pagelayoutTemp.getId() + "]" );
			pagelayoutsValues.add(bean);
		}
		form.setLayoutCollection(pagelayoutsValues);
		try{
			form.setLayoutCurrentValue(getASLayoutDataService().getPageLayout(pagetemplate.getLayout()).getName());
		}catch(Exception e){
			form.setLayoutCurrentValue("none");
			form.setLayoutIdOfCurrentValue("none");
		}

		//link site to ASSiteData.Site
		List sites = getASSiteDataService().getSites();
		List sitesValues = new ArrayList(sites.size()+1);
		sitesValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.assitedata.data.Site siteTemp : sites){
			LabelValueBean bean = new LabelValueBean(siteTemp.getId(), siteTemp.getName() + " [" + siteTemp.getId() + "]" );
			sitesValues.add(bean);
		}
		form.setSiteCollection(sitesValues);
		try{
			form.setSiteCurrentValue(getASSiteDataService().getSite(pagetemplate.getSite()).getName());
		}catch(Exception e){
			form.setSiteCurrentValue("none");
			form.setSiteIdOfCurrentValue("none");
		}
		addBeanToRequest(req, "objectId" , pagetemplate.getId());
		addBeanToRequest(req, "EditASSiteDataPageTemplateForm" , form);
		addBeanToRequest(req, "objectInfoString" , pagetemplate.getObjectInfo().toString());
		addBeanToRequest(req, "apply.label.prefix", "Apply");
		addBeanToRequest(req, "save.label.prefix", "Save");
		addBeanToRequest(req, "transfer.label.prefix", "Transfer");

		addFieldExplanations(req, pagetemplate);


		// Generating back link handling...
		List linksToMe = findLinksToCurrentDocument(pagetemplate.getId());
		if (linksToMe.size()>0)
			req.setAttribute("linksToMe", linksToMe);
		return mapping.success();
	}

	private List findLinksToCurrentDocument(String documentId){
		List ret = new ArrayList();
		try{
			ret.addAll(findLinkToCurrentDocumentInASWebDataPagexTemplate(documentId));
		}catch(Exception ignored){
		}
		return ret;
	}
	private List findLinkToCurrentDocumentInASWebDataPagexTemplate(String documentId) throws net.anotheria.anosite.gen.aswebdata.service.ASWebDataServiceException{
		List ret = new ArrayList();
		QueryProperty p = new QueryProperty(Pagex.LINK_PROP_TEMPLATE, documentId);
		// temporarly - replacy with query property
		List list = getASWebDataService().getPagexsByProperty(p.getName(), p.getValue());
		for (Pagex doc : list ){
			ret.add(new LinkToMeBean(doc, "template"));
		}
		return ret;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy