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

net.anotheria.anosite.gen.aswebdata.action.EditBoxAction Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** EditBoxAction.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.aswebdata.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.aswebdata.bean.EditBoxFB;
import net.anotheria.anosite.gen.aswebdata.data.Box;
import net.anotheria.asg.util.helper.cmsview.CMSViewHelperUtil;
import net.anotheria.asg.util.helper.cmsview.CMSViewHelperRegistry;
import net.anotheria.asg.data.MultilingualObject;
import net.anotheria.webutils.bean.LabelValueBean;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.anosite.gen.asfederateddata.data.BoxType;
import net.anotheria.anosite.gen.asfederateddata.data.BoxHandlerDef;
import net.anotheria.anosite.gen.anoaccessconfiguration.data.AccessOperation;
import net.anotheria.anosite.gen.asfeature.data.Feature;


public class EditBoxAction extends ShowBoxsAction{

// 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);
		EditBoxFB form = new EditBoxFB() ;
		Box box = getASWebDataService().getBox(id);
		checkBoxs(box, req);
		if(box instanceof LockableObject && !((LockableObject)box).isLocked() && isAutoLockingEnabled())
			lockBoxs(box, req);
		form.setId(box.getId());
		form.setName(box.getName());
		form.setType(box.getType());
		form.setHandler(box.getHandler());
		// mediaLinks is a table, storing size only
		form.setMediaLinks(box.getMediaLinksSize());
		// scripts is a table, storing size only
		form.setScripts(box.getScriptsSize());
		// localizations is a table, storing size only
		form.setLocalizations(box.getLocalizationsSize());
		// subboxes is a table, storing size only
		form.setSubboxes(box.getSubboxesSize());
		form.setCssClass(box.getCssClass());
		form.setContentEN(box.getContentEN());
		form.setContentDE(box.getContentDE());
		form.setParameter1(box.getParameter1());
		form.setParameter2(box.getParameter2());
		form.setParameter3(box.getParameter3());
		form.setParameter4(box.getParameter4());
		form.setParameter5(box.getParameter5());
		form.setParameter6(box.getParameter6());
		form.setParameter7(box.getParameter7());
		form.setParameter8(box.getParameter8());
		form.setParameter9(box.getParameter9());
		form.setParameter10(box.getParameter10());
		// guards is a table, storing size only
		form.setGuards(box.getGuardsSize());
		// attributes is a table, storing size only
		form.setAttributes(box.getAttributesSize());
		form.setAccessOperation(box.getAccessOperation());
		form.setFeature(box.getFeature());
		form.setMultilingualInstanceDisabled(((MultilingualObject)box).isMultilingualDisabledInstance());
		form.setLocked(((LockableObject)box).isLocked());
		form.setLockerId(((LockableObject)box).getLockerId());
		form.setLockingTime(net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)box).getLockingTime()) + " automatic unlock expected AT : " + net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)box).getLockingTime() + getLockingTimeout()));


		//link type to ASFederatedData.BoxType
		List boxtypes = getASFederatedDataService().getBoxTypes();
		List boxtypesValues = new ArrayList(boxtypes.size()+1);
		boxtypesValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.asfederateddata.data.BoxType boxtypeTemp : boxtypes){
			LabelValueBean bean = new LabelValueBean(boxtypeTemp.getId(), boxtypeTemp.getName() + " [" + boxtypeTemp.getId() + "]" );
			boxtypesValues.add(bean);
		}
		form.setTypeCollection(boxtypesValues);
		try{
			if ( getASFederatedDataService().getBoxType(box.getType()) instanceof BoxType ) {
				String typeId = (String)getASFederatedDataService().getBoxType(box.getType()).getId();
				int index = typeId.indexOf("C-");
				if ( index != -1 ) {
					form.setTypeIdOfCurrentValue( typeId.substring(index+2) );
				} else {
					form.setTypeIdOfCurrentValue( "none" );
				}
			}
			form.setTypeCurrentValue(getASFederatedDataService().getBoxType(box.getType()).getName());
		}catch(Exception e){
			form.setTypeCurrentValue("none");
			form.setTypeIdOfCurrentValue("none");
		}

		//link handler to ASFederatedData.BoxHandlerDef
		List boxhandlerdefs = getASFederatedDataService().getBoxHandlerDefs();
		List boxhandlerdefsValues = new ArrayList(boxhandlerdefs.size()+1);
		boxhandlerdefsValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.asfederateddata.data.BoxHandlerDef boxhandlerdefTemp : boxhandlerdefs){
			LabelValueBean bean = new LabelValueBean(boxhandlerdefTemp.getId(), boxhandlerdefTemp.getName() + " [" + boxhandlerdefTemp.getId() + "]" );
			boxhandlerdefsValues.add(bean);
		}
		form.setHandlerCollection(boxhandlerdefsValues);
		try{
			if ( getASFederatedDataService().getBoxHandlerDef(box.getHandler()) instanceof BoxHandlerDef ) {
				String handlerId = (String)getASFederatedDataService().getBoxHandlerDef(box.getHandler()).getId();
				int index = handlerId.indexOf("C-");
				if ( index != -1 ) {
					form.setHandlerIdOfCurrentValue( handlerId.substring(index+2) );
				} else {
					form.setHandlerIdOfCurrentValue( "none" );
				}
			}
			form.setHandlerCurrentValue(getASFederatedDataService().getBoxHandlerDef(box.getHandler()).getName());
		}catch(Exception e){
			form.setHandlerCurrentValue("none");
			form.setHandlerIdOfCurrentValue("none");
		}

		//link accessOperation to AnoAccessConfiguration.AccessOperation
		List accessoperations = getAnoAccessConfigurationService().getAccessOperations();
		List accessoperationsValues = new ArrayList(accessoperations.size()+1);
		accessoperationsValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.anoaccessconfiguration.data.AccessOperation accessoperationTemp : accessoperations){
			LabelValueBean bean = new LabelValueBean(accessoperationTemp.getId(), accessoperationTemp.getName() + " [" + accessoperationTemp.getId() + "]" );
			accessoperationsValues.add(bean);
		}
		form.setAccessOperationCollection(accessoperationsValues);
		try{
			form.setAccessOperationCurrentValue(getAnoAccessConfigurationService().getAccessOperation(box.getAccessOperation()).getName());
		}catch(Exception e){
			form.setAccessOperationCurrentValue("none");
			form.setAccessOperationIdOfCurrentValue("none");
		}

		//link feature to ASFeature.Feature
		List features = getASFeatureService().getFeatures();
		List featuresValues = new ArrayList(features.size()+1);
		featuresValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.asfeature.data.Feature featureTemp : features){
			LabelValueBean bean = new LabelValueBean(featureTemp.getId(), featureTemp.getName() + " [" + featureTemp.getId() + "]" );
			featuresValues.add(bean);
		}
		form.setFeatureCollection(featuresValues);
		try{
			form.setFeatureCurrentValue(getASFeatureService().getFeature(box.getFeature()).getName());
		}catch(Exception e){
			form.setFeatureCurrentValue("none");
			form.setFeatureIdOfCurrentValue("none");
		}
		addBeanToRequest(req, "objectId" , box.getId());
		addBeanToRequest(req, "EditASWebDataBoxForm" , form);
		addBeanToRequest(req, "objectInfoString" , box.getObjectInfo().toString());
		addBeanToRequest(req, "apply.label.prefix", "Apply");
		addBeanToRequest(req, "save.label.prefix", "Save");

		addFieldExplanations(req, box);

		return mapping.findForward("success");
	}

	private void addFieldExplanations(HttpServletRequest req, Box box) {
		if (!CMSViewHelperRegistry.getCMSViewHelpers("ASWebData.Box").isEmpty()) {
			String fieldDescription = null;
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "name");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.name", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "content");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.content", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "mediaLinks");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.mediaLinks", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "scripts");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.scripts", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "localizations");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.localizations", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "subboxes");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.subboxes", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "cssClass");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.cssClass", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter1");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter1", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter2");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter2", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter3");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter3", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter4");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter4", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter5");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter5", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter6");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter6", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter7");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter7", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter8");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter8", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter9");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter9", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "parameter10");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.parameter10", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "guards");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.guards", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Box", box, "attributes");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.attributes", fieldDescription);
		} //
	} //addFieldExplanations END


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy