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

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

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** MultiOpNaviItemsGuardsAction.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 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.assitedata.data.NaviItemFactory;
import net.anotheria.anosite.gen.assitedata.data.NaviItem;
import net.anotheria.anosite.gen.assitedata.bean.GuardsElementFB;
import net.anotheria.anosite.gen.assitedata.bean.GuardsQuickAddFB;
import net.anotheria.anosite.gen.asfederateddata.data.GuardDef;
import net.anotheria.anosite.gen.asfederateddata.data.GuardDefSortType;
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 MultiOpNaviItemsGuardsAction extends BaseNaviItemAction{

	// 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("assitedataNaviItemGuardsShow"))
			return assitedataNaviItemGuardsShow(mapping, af, req, res);
		if (path.equals("assitedataNaviItemGuardsAdd"))
			return assitedataNaviItemGuardsAdd(mapping, af, req, res);
		if (path.equals("assitedataNaviItemGuardsDelete"))
			return assitedataNaviItemGuardsDelete(mapping, af, req, res);
		if (path.equals("assitedataNaviItemGuardsMove"))
			return assitedataNaviItemGuardsMove(mapping, af, req, res);
		if (path.equals("assitedataNaviItemGuardsQuickAdd"))
			return assitedataNaviItemGuardsQuickAdd(mapping, af, req, res);
		throw new IllegalArgumentException("Unknown path: "+path);
	}

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

	public ActionForward assitedataNaviItemGuardsShow(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		String id = getStringParameter(req, "ownerId");
		NaviItem naviitem = getASSiteDataService().getNaviItem(id);
		addBeanToRequest(req, "ownerId", id);
		checkNaviItems(naviitem, req);

		GuardsElementFB form = new GuardsElementFB() ;
		form.setPosition(-1);
		form.setOwnerId(naviitem.getId());
		addBeanToRequest(req, "assitedataNaviItemGuardsElementForm", form);

		GuardsQuickAddFB quickAddForm = new GuardsQuickAddFB() ;
		quickAddForm.setOwnerId(naviitem.getId());
		addBeanToRequest(req, "assitedataNaviItemGuardsQuickAddForm", quickAddForm);


		//link guard to ASFederatedData.GuardDef
		List guarddefs = getASFederatedDataService().getGuardDefs(new GuardDefSortType(GuardDefSortType.SORT_BY_NAME));
		List guarddefsValues = new ArrayList(guarddefs.size());
		for (int i=0; i beans = new ArrayList(size);
		for (int i=0; i targetList = naviitem.getGuards();
		String toSwap = targetList.remove(position);
		targetList.add(0, toSwap);
		naviitem.setGuards(targetList);
		getASSiteDataService().updateNaviItem(naviitem);
	}

	private void moveDown(NaviItem naviitem, int position) throws ASGRuntimeException {
		if (position targetList = naviitem.getGuards();
		String toSwap = targetList.remove(position);
		targetList.add(toSwap);
		naviitem.setGuards(targetList);
		getASSiteDataService().updateNaviItem(naviitem);
	}

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

	public ActionForward assitedataNaviItemGuardsAdd(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		GuardsElementFB form = new GuardsElementFB();
		populateFormBean(req, form);
		String id = form.getOwnerId();
		NaviItem naviitem;
		naviitem = getASSiteDataService().getNaviItem(id);
		canUpdateNaviItems(naviitem, req);
		checkNaviItems(naviitem, req);
		naviitem.addGuardsElement(form.getGuard());
		getASSiteDataService().updateNaviItem(naviitem);
		return assitedataNaviItemGuardsShow(mapping, af, req, res);
	}

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

	public ActionForward assitedataNaviItemGuardsQuickAdd(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		GuardsQuickAddFB form = new GuardsQuickAddFB();
		populateFormBean(req, form);
		String id = form.getOwnerId();
		NaviItem naviitem;
		naviitem = getASSiteDataService().getNaviItem(id);
		canUpdateNaviItems(naviitem, req);
		checkNaviItems(naviitem, 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++){
				naviitem.addGuardsElement(""+i);
			}
		}
		getASSiteDataService().updateNaviItem(naviitem);
		return assitedataNaviItemGuardsShow(mapping, af, req, res);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy