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

net.anotheria.anosite.gen.ascustomaction.action.MultiOpActionMappingDefsLocalizationBundlesAction Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** MultiOpActionMappingDefsLocalizationBundlesAction.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.ascustomaction.action;

import java.util.List;
import java.util.ArrayList;
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 net.anotheria.anosite.gen.ascustomaction.data.ActionMappingDefFactory;
import net.anotheria.anosite.gen.ascustomaction.data.ActionMappingDef;
import net.anotheria.anosite.gen.ascustomaction.bean.LocalizationBundlesElementFB;
import net.anotheria.anosite.gen.ascustomaction.bean.LocalizationBundlesQuickAddFB;
import net.anotheria.anosite.gen.asresourcedata.data.LocalizationBundle;
import net.anotheria.anosite.gen.asresourcedata.data.LocalizationBundleSortType;
import net.anotheria.webutils.bean.LabelValueBean;
import net.anotheria.anodoc.data.NoSuchDocumentException;
import net.anotheria.util.StringUtils;
import net.anotheria.asg.exception.ASGRuntimeException;


public class MultiOpActionMappingDefsLocalizationBundlesAction extends BaseActionMappingDefAction{

	// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateContainerMultiOpAction

	public ActionForward anoDocExecute(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		String path = stripPath(mapping.getPath());
		if (path.equals("ascustomactionActionMappingDefLocalizationBundlesShow"))
			return ascustomactionActionMappingDefLocalizationBundlesShow(mapping, af, req, res);
		if (path.equals("ascustomactionActionMappingDefLocalizationBundlesAdd"))
			return ascustomactionActionMappingDefLocalizationBundlesAdd(mapping, af, req, res);
		if (path.equals("ascustomactionActionMappingDefLocalizationBundlesDelete"))
			return ascustomactionActionMappingDefLocalizationBundlesDelete(mapping, af, req, res);
		if (path.equals("ascustomactionActionMappingDefLocalizationBundlesMove"))
			return ascustomactionActionMappingDefLocalizationBundlesMove(mapping, af, req, res);
		if (path.equals("ascustomactionActionMappingDefLocalizationBundlesQuickAdd"))
			return ascustomactionActionMappingDefLocalizationBundlesQuickAdd(mapping, af, req, res);
		throw new IllegalArgumentException("Unknown path: "+path);
	}

	// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateListShowActionMethod

	public ActionForward ascustomactionActionMappingDefLocalizationBundlesShow(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		String id = getStringParameter(req, "ownerId");
		ActionMappingDef actionmappingdef = getASCustomActionService().getActionMappingDef(id);
		addBeanToRequest(req, "ownerId", id);
		checkActionMappingDefs(actionmappingdef, req);

		LocalizationBundlesElementFB form = new LocalizationBundlesElementFB() ;
		form.setPosition(-1);
		form.setOwnerId(actionmappingdef.getId());
		addBeanToRequest(req, "ascustomactionActionMappingDefLocalizationBundlesElementForm", form);

		LocalizationBundlesQuickAddFB quickAddForm = new LocalizationBundlesQuickAddFB() ;
		quickAddForm.setOwnerId(actionmappingdef.getId());
		addBeanToRequest(req, "ascustomactionActionMappingDefLocalizationBundlesQuickAddForm", quickAddForm);


		//link localizationBundles to ASResourceData.LocalizationBundle
		List localizationbundles = getASResourceDataService().getLocalizationBundles(new LocalizationBundleSortType(LocalizationBundleSortType.SORT_BY_NAME));
		List localizationbundlesValues = new ArrayList(localizationbundles.size());
		for (int i=0; i beans = new ArrayList(size);
		for (int i=0; i targetList = actionmappingdef.getLocalizationBundles();
		String toSwap = targetList.remove(position);
		targetList.add(0, toSwap);
		actionmappingdef.setLocalizationBundles(targetList);
		getASCustomActionService().updateActionMappingDef(actionmappingdef);
	}

	private void moveDown(ActionMappingDef actionmappingdef, int position) throws ASGRuntimeException {
		if (position targetList = actionmappingdef.getLocalizationBundles();
		String toSwap = targetList.remove(position);
		targetList.add(toSwap);
		actionmappingdef.setLocalizationBundles(targetList);
		getASCustomActionService().updateActionMappingDef(actionmappingdef);
	}

	// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateListAddRowActionMethod

	public ActionForward ascustomactionActionMappingDefLocalizationBundlesAdd(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		LocalizationBundlesElementFB form = new LocalizationBundlesElementFB();
		populateFormBean(req, form);
		String id = form.getOwnerId();
		ActionMappingDef actionmappingdef;
		actionmappingdef = getASCustomActionService().getActionMappingDef(id);
		canUpdateActionMappingDefs(actionmappingdef, req);
		checkActionMappingDefs(actionmappingdef, req);
		actionmappingdef.addLocalizationBundlesElement(form.getLocalizationBundles());
		getASCustomActionService().updateActionMappingDef(actionmappingdef);
		return ascustomactionActionMappingDefLocalizationBundlesShow(mapping, af, req, res);
	}

	// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateListQuickAddActionMethod

	public ActionForward ascustomactionActionMappingDefLocalizationBundlesQuickAdd(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		LocalizationBundlesQuickAddFB form = new LocalizationBundlesQuickAddFB();
		populateFormBean(req, form);
		String id = form.getOwnerId();
		ActionMappingDef actionmappingdef;
		actionmappingdef = getASCustomActionService().getActionMappingDef(id);
		canUpdateActionMappingDefs(actionmappingdef, req);
		checkActionMappingDefs(actionmappingdef, req);
		String paramIdsToAdd = form.getQuickAddIds();

		String idParameters[] = StringUtils.tokenize(paramIdsToAdd, ',');
		for (String anIdParam : idParameters){
			String ids[] = StringUtils.tokenize(anIdParam, '-');
			for (int i=Integer.parseInt(ids[0]); i<=Integer.parseInt(ids[ids.length-1]); i++){
				actionmappingdef.addLocalizationBundlesElement(""+i);
			}
		}
		getASCustomActionService().updateActionMappingDef(actionmappingdef);
		return ascustomactionActionMappingDefLocalizationBundlesShow(mapping, af, req, res);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy