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: 2.6.3                      ***
 *** Copyright (C) 2005 - 2010 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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionForward;
import net.anotheria.maf.action.ActionMapping;
import net.anotheria.maf.bean.FormBean;
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.asg.util.helper.cmsview.CMSViewHelperUtil;
import net.anotheria.asg.util.helper.cmsview.CMSViewHelperRegistry;
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 ActionForward anoDocExecute(ActionMapping mapping, FormBean af, 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");

		addFieldExplanations(req, pagetemplate);


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

	private void addFieldExplanations(HttpServletRequest req, PageTemplate pagetemplate) {
		if (!CMSViewHelperRegistry.getCMSViewHelpers("ASSiteData.PageTemplate").isEmpty()) {
			String fieldDescription = null;
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "name");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.name", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "mediaLinks");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.mediaLinks", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "scripts");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.scripts", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "c1first");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.c1first", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "c2first");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.c2first", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "c3first");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.c3first", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "c1last");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.c1last", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "c2last");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.c2last", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "c3last");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.c3last", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "meta");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.meta", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "header");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.header", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "footer");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.footer", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "localizations");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.localizations", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASSiteData.PageTemplate", pagetemplate, "description");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.description", fieldDescription);
		} //
	} //addFieldExplanations END


	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