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

net.anotheria.anosite.gen.aswizarddata.action.MultiOpDialogWizardHandlerDefsAction Maven / Gradle / Ivy

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

import net.anotheria.util.NumberUtils;
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.aswizarddata.data.WizardHandlerDefFactory;
import net.anotheria.anosite.gen.aswizarddata.data.WizardHandlerDef;
import net.anotheria.anosite.gen.aswizarddata.bean.EditWizardHandlerDefFB;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.util.locking.helper.DocumentLockingHelper;
import net.anotheria.maf.bean.annotations.Form;


public class MultiOpDialogWizardHandlerDefsAction extends BaseWizardHandlerDefAction{

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


	@Override
	public ActionForward execute(ActionMapping mapping, @Form(EditWizardHandlerDefFB.class) FormBean formBean, HttpServletRequest req, HttpServletResponse res) throws Exception{
		return super.execute(mapping, formBean, req, res);
	} //execute

	public ActionForward anoDocExecute(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		String path = stripPath(mapping.getPath());
		if (path.equals("aswizarddataWizardHandlerDefDelete"))
			return aswizarddataWizardHandlerDefDelete(mapping, af, req, res);
		if (path.equals("aswizarddataWizardHandlerDefDuplicate"))
			return aswizarddataWizardHandlerDefDuplicate(mapping, af, req, res);
		if (path.equals("aswizarddataWizardHandlerDefUpdate"))
			return aswizarddataWizardHandlerDefUpdate(mapping, af, req, res);
		if (path.equals("aswizarddataWizardHandlerDefClose"))
			return aswizarddataWizardHandlerDefClose(mapping, af, req, res);
		if (path.equals("aswizarddataWizardHandlerDefLock"))
			return aswizarddataWizardHandlerDefLock(mapping, af, req, res);
		if (path.equals("aswizarddataWizardHandlerDefUnLock"))
			return aswizarddataWizardHandlerDefUnLock(mapping, af, req, res);
		throw new IllegalArgumentException("Unknown path: "+path);
	}

	public ActionForward aswizarddataWizardHandlerDefDelete(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		String[] iDs = req.getParameterValues(PARAM_ID);
		if (iDs == null){
		throw new RuntimeException("Parameter " + PARAM_ID + " is not set.");
	}
	for (String id : iDs){
		WizardHandlerDef wizardhandlerdefCurr = getASWizardDataService().getWizardHandlerDef(id);
		if (wizardhandlerdefCurr instanceof LockableObject){ 
		LockableObject lockable = (LockableObject)wizardhandlerdefCurr;
		DocumentLockingHelper.delete.checkExecutionPermission(lockable, false, getUserId(req));
		}
		getASWizardDataService().deleteWizardHandlerDef(id);
	}
	res.sendRedirect("aswizarddataWizardHandlerDefShow?ts="+System.currentTimeMillis());
	return null;
}

public ActionForward aswizarddataWizardHandlerDefDuplicate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	WizardHandlerDef wizardhandlerdefSrc = getASWizardDataService().getWizardHandlerDef(id);
	WizardHandlerDef wizardhandlerdefDest = WizardHandlerDefFactory.createWizardHandlerDef(wizardhandlerdefSrc);


	WizardHandlerDef wizardhandlerdefCreated = getASWizardDataService().createWizardHandlerDef(wizardhandlerdefDest);
	res.sendRedirect("aswizarddataWizardHandlerDefEdit?ts="+System.currentTimeMillis()+"&"+PARAM_ID+"="+wizardhandlerdefCreated.getId());

	return null;
}

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

public ActionForward aswizarddataWizardHandlerDefUpdate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	EditWizardHandlerDefFB form = (EditWizardHandlerDefFB) af;
	boolean create = false;
	WizardHandlerDef wizardhandlerdef = null;
	if (form.getId()==null) {
	res.sendRedirect("asresourcedataLocalizationBundleShow?ts="+System.currentTimeMillis());
	return null;
}
if (form.getId().length()>0){
	wizardhandlerdef = (WizardHandlerDef)getASWizardDataService().getWizardHandlerDef(form.getId()).clone();
}else{
	wizardhandlerdef = WizardHandlerDefFactory.createWizardHandlerDef();
	create = true;
}

String nextAction = req.getParameter("nextAction");
if (nextAction == null || nextAction.length() == 0)
	nextAction = "close";

//skipped id because it's readonly.
wizardhandlerdef.setName(form.getName());
wizardhandlerdef.setClazz(form.getClazz());

WizardHandlerDef updatedCopy = null;
if (create){
	updatedCopy = getASWizardDataService().createWizardHandlerDef(wizardhandlerdef);
}else{
	canUpdateWizardHandlerDefs(wizardhandlerdef, req);
	checkWizardHandlerDefs(wizardhandlerdef, req);
	updatedCopy = getASWizardDataService().updateWizardHandlerDef(wizardhandlerdef);
}
if (nextAction.equalsIgnoreCase("stay")){
	res.sendRedirect("aswizarddataWizardHandlerDefEdit?ts="+System.currentTimeMillis()+"&pId="+updatedCopy.getId());
}else{
	unlockAfterUpdate(wizardhandlerdef, req);
	res.sendRedirect("aswizarddataWizardHandlerDefShow?ts="+System.currentTimeMillis());
}
return null;
}
/**
 * Simply unlocks document after updation.
 */
private void unlockAfterUpdate(WizardHandlerDef wizardhandlerdef, HttpServletRequest req) throws Exception{
	if(((LockableObject)wizardhandlerdef).isLocked())
		unLockWizardHandlerDefs(wizardhandlerdef, req, false);
}

public ActionForward aswizarddataWizardHandlerDefLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	WizardHandlerDef wizardhandlerdefCurr = id != null && !id.equals("") ? getASWizardDataService().getWizardHandlerDef(id) : null;
	if(wizardhandlerdefCurr != null && wizardhandlerdefCurr instanceof LockableObject){ 
		LockableObject lockable = (LockableObject)wizardhandlerdefCurr;
		DocumentLockingHelper.lock.checkExecutionPermission(lockable,false,getUserId(req));
		lockWizardHandlerDefs(wizardhandlerdefCurr, req);
	}
	res.sendRedirect(getRedirectUrl(req, wizardhandlerdefCurr));
	return null;
}

public ActionForward aswizarddataWizardHandlerDefUnLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	WizardHandlerDef wizardhandlerdefCurr = id != null && !id.equals("") ? getASWizardDataService().getWizardHandlerDef(id) : null;
	if(wizardhandlerdefCurr != null && wizardhandlerdefCurr instanceof LockableObject){ 
		LockableObject lockable = (LockableObject)wizardhandlerdefCurr;
		DocumentLockingHelper.unLock.checkExecutionPermission(lockable,isUserInRole(req, "admin"),getUserId(req));
		unLockWizardHandlerDefs(wizardhandlerdefCurr, req, false);
	}
	res.sendRedirect(getRedirectUrl(req, wizardhandlerdefCurr));
	return null;
}

/**
 * Simplest method for redirect url creation. nextAction == showEdit - going to 'editView', to 'listView' otherwise. 
 */
private String getRedirectUrl(HttpServletRequest req, WizardHandlerDef item){
	String nextAction = req.getParameter("nextAction");
	if (item==null || nextAction == null || nextAction.length() == 0)
		return "aswizarddataWizardHandlerDefShow?ts="+System.currentTimeMillis();
	else
		return nextAction.equals("showEdit") ? "aswizarddataWizardHandlerDefEdit?ts="+System.currentTimeMillis()+"&pId="+item.getId()
		       : "aswizarddataWizardHandlerDefShow?ts="+System.currentTimeMillis();
}

public ActionForward aswizarddataWizardHandlerDefClose(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	WizardHandlerDef wizardhandlerdefCurr = id != null && !id.equals("") ? getASWizardDataService().getWizardHandlerDef(id) : null;
	if(wizardhandlerdefCurr != null && wizardhandlerdefCurr instanceof LockableObject && ((LockableObject)wizardhandlerdefCurr).isLocked()) 
		unLockWizardHandlerDefs(wizardhandlerdefCurr, req, false);
	res.sendRedirect("aswizarddataWizardHandlerDefShow?ts="+System.currentTimeMillis());
	return null;
}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy