net.anotheria.anosite.gen.asresourcedata.action.MultiOpDialogPushNotificationTemplatesAction Maven / Gradle / Ivy
The newest version!
/**
********************************************************************************
*** MultiOpDialogPushNotificationTemplatesAction.java ***
*** generated by AnoSiteGenerator (ASG), Version: 4.2.2 ***
*** Copyright (C) 2005 - 2025 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.asresourcedata.action;
import net.anotheria.util.NumberUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionCommand;
import net.anotheria.maf.action.ActionMapping;
import java.util.List;
import java.util.ArrayList;
import net.anotheria.anosite.gen.asresourcedata.data.PushNotificationTemplateFactory;
import net.anotheria.anosite.gen.asresourcedata.data.PushNotificationTemplate;
import net.anotheria.anosite.gen.asresourcedata.bean.EditPushNotificationTemplateFB;
import net.anotheria.asg.util.bean.PopulateUtility;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.util.locking.helper.DocumentLockingHelper;
import net.anotheria.asg.data.MultilingualObject;
public class MultiOpDialogPushNotificationTemplatesAction extends BasePushNotificationTemplateAction{
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateMultiOpDialogAction
@Override
public ActionCommand execute(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
return super.execute(mapping, req, res);
} //execute
public ActionCommand anoDocExecute(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String path = stripPath(mapping.getPath());
if (path.equals("asresourcedataPushNotificationTemplateDelete"))
return asresourcedataPushNotificationTemplateDelete(mapping, req, res);
if (path.equals("asresourcedataPushNotificationTemplateDuplicate"))
return asresourcedataPushNotificationTemplateDuplicate(mapping, req, res);
if (path.equals("asresourcedataPushNotificationTemplateUpdate"))
return asresourcedataPushNotificationTemplateUpdate(mapping, req, res);
if (path.equals("asresourcedataPushNotificationTemplateClose"))
return asresourcedataPushNotificationTemplateClose(mapping, req, res);
if (path.equals("asresourcedataPushNotificationTemplateCopyLang"))
return asresourcedataPushNotificationTemplateCopyLang(mapping, req, res);
if (path.equals("asresourcedataPushNotificationTemplateSwitchMultilang"))
return asresourcedataPushNotificationTemplateSwitchMultilang(mapping, req, res);
if (path.equals("asresourcedataPushNotificationTemplateLock"))
return asresourcedataPushNotificationTemplateLock(mapping, req, res);
if (path.equals("asresourcedataPushNotificationTemplateUnLock"))
return asresourcedataPushNotificationTemplateUnLock(mapping, req, res);
throw new IllegalArgumentException("Unknown path: "+path);
}
public ActionCommand asresourcedataPushNotificationTemplateDelete(ActionMapping mapping, 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){
PushNotificationTemplate pushnotificationtemplateCurr = getASResourceDataService().getPushNotificationTemplate(id);
if (pushnotificationtemplateCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)pushnotificationtemplateCurr;
DocumentLockingHelper.delete.checkExecutionPermission(lockable, false, getUserId(req));
}
getASResourceDataService().deletePushNotificationTemplate(id);
}
res.sendRedirect("asresourcedataPushNotificationTemplateShow?ts="+System.currentTimeMillis());
return null;
}
public ActionCommand asresourcedataPushNotificationTemplateDuplicate(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
PushNotificationTemplate pushnotificationtemplateSrc = getASResourceDataService().getPushNotificationTemplate(id);
PushNotificationTemplate pushnotificationtemplateDest = PushNotificationTemplateFactory.createPushNotificationTemplate(pushnotificationtemplateSrc);
PushNotificationTemplate pushnotificationtemplateCreated = getASResourceDataService().createPushNotificationTemplate(pushnotificationtemplateDest);
res.sendRedirect("asresourcedataPushNotificationTemplateEdit?ts="+System.currentTimeMillis()+"&"+PARAM_ID+"="+pushnotificationtemplateCreated.getId());
return null;
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateUpdateActionMethod
public ActionCommand asresourcedataPushNotificationTemplateUpdate(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
EditPushNotificationTemplateFB form = new EditPushNotificationTemplateFB();
PopulateUtility.populate(form, req);
boolean create = false;
PushNotificationTemplate pushnotificationtemplate = null;
if (form.getId()==null) {
res.sendRedirect("asresourcedataLocalizationBundleShow?ts="+System.currentTimeMillis());
return null;
}
if (form.getId().length()>0){
pushnotificationtemplate = (PushNotificationTemplate)getASResourceDataService().getPushNotificationTemplate(form.getId()).clone();
}else{
pushnotificationtemplate = PushNotificationTemplateFactory.createPushNotificationTemplate();
create = true;
}
String nextAction = req.getParameter("nextAction");
if (nextAction == null || nextAction.length() == 0)
nextAction = "close";
//skipped id because it's readonly.
pushnotificationtemplate.setName(form.getName());
pushnotificationtemplate.setMessageEN(form.getMessageEN());
pushnotificationtemplate.setMessageDE(form.getMessageDE());
// skipped container localizations
PushNotificationTemplate updatedCopy = null;
if (create){
updatedCopy = getASResourceDataService().createPushNotificationTemplate(pushnotificationtemplate);
}else{
canUpdatePushNotificationTemplates(pushnotificationtemplate, req);
checkPushNotificationTemplates(pushnotificationtemplate, req);
updatedCopy = getASResourceDataService().updatePushNotificationTemplate(pushnotificationtemplate);
}
if (nextAction.equalsIgnoreCase("stay")){
res.sendRedirect("asresourcedataPushNotificationTemplateEdit?ts="+System.currentTimeMillis()+"&pId="+updatedCopy.getId());
}else{
unlockAfterUpdate(pushnotificationtemplate, req);
res.sendRedirect("asresourcedataPushNotificationTemplateShow?ts="+System.currentTimeMillis());
}
return null;
}
/**
* Simply unlocks document after updation.
*/
private void unlockAfterUpdate(PushNotificationTemplate pushnotificationtemplate, HttpServletRequest req) throws Exception{
if(((LockableObject)pushnotificationtemplate).isLocked())
unLockPushNotificationTemplates(pushnotificationtemplate, req, false);
}
public ActionCommand asresourcedataPushNotificationTemplateCopyLang(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String sourceLanguage = req.getParameter("pSrcLang");
if (sourceLanguage==null || sourceLanguage.length()==0)
throw new RuntimeException("No source language");
String destLanguage = req.getParameter("pDestLang");
if (destLanguage==null || destLanguage.length()==0)
throw new RuntimeException("No destination language");
String id = getStringParameter(req, PARAM_ID);
PushNotificationTemplate pushnotificationtemplate = getASResourceDataService().getPushNotificationTemplate(id);
canUpdatePushNotificationTemplates(pushnotificationtemplate, req);
checkPushNotificationTemplates(pushnotificationtemplate, req);
pushnotificationtemplate.copyLANG2LANG(sourceLanguage, destLanguage);
getASResourceDataService().updatePushNotificationTemplate(pushnotificationtemplate);
res.sendRedirect("asresourcedataPushNotificationTemplateEdit?ts="+System.currentTimeMillis()+"&pId="+id);
return null;
}
public ActionCommand asresourcedataPushNotificationTemplateSwitchMultilang(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
String value = getStringParameter(req, "value");
PushNotificationTemplate pushnotificationtemplate = getASResourceDataService().getPushNotificationTemplate(id);
canUpdatePushNotificationTemplates(pushnotificationtemplate, req);
checkPushNotificationTemplates(pushnotificationtemplate, req);
((MultilingualObject)pushnotificationtemplate).setMultilingualDisabledInstance(Boolean.valueOf(value));
getASResourceDataService().updatePushNotificationTemplate(pushnotificationtemplate);
res.sendRedirect("asresourcedataPushNotificationTemplateEdit?ts="+System.currentTimeMillis()+"&pId="+id);
return null;
}
public ActionCommand asresourcedataPushNotificationTemplateLock(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
PushNotificationTemplate pushnotificationtemplateCurr = id != null && !id.equals("") ? getASResourceDataService().getPushNotificationTemplate(id) : null;
if(pushnotificationtemplateCurr != null && pushnotificationtemplateCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)pushnotificationtemplateCurr;
DocumentLockingHelper.lock.checkExecutionPermission(lockable,false,getUserId(req));
lockPushNotificationTemplates(pushnotificationtemplateCurr, req);
}
res.sendRedirect(getRedirectUrl(req, pushnotificationtemplateCurr));
return null;
}
public ActionCommand asresourcedataPushNotificationTemplateUnLock(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
PushNotificationTemplate pushnotificationtemplateCurr = id != null && !id.equals("") ? getASResourceDataService().getPushNotificationTemplate(id) : null;
if(pushnotificationtemplateCurr != null && pushnotificationtemplateCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)pushnotificationtemplateCurr;
DocumentLockingHelper.unLock.checkExecutionPermission(lockable,isUserInRole(req, "admin"),getUserId(req));
unLockPushNotificationTemplates(pushnotificationtemplateCurr, req, false);
}
res.sendRedirect(getRedirectUrl(req, pushnotificationtemplateCurr));
return null;
}
/**
* Simplest method for redirect url creation. nextAction == showEdit - going to 'editView', to 'listView' otherwise.
*/
private String getRedirectUrl(HttpServletRequest req, PushNotificationTemplate item){
String nextAction = req.getParameter("nextAction");
if (item==null || nextAction == null || nextAction.length() == 0)
return "asresourcedataPushNotificationTemplateShow?ts="+System.currentTimeMillis();
else
return nextAction.equals("showEdit") ? "asresourcedataPushNotificationTemplateEdit?ts="+System.currentTimeMillis()+"&pId="+item.getId()
: "asresourcedataPushNotificationTemplateShow?ts="+System.currentTimeMillis();
}
public ActionCommand asresourcedataPushNotificationTemplateClose(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
PushNotificationTemplate pushnotificationtemplateCurr = id != null && !id.equals("") ? getASResourceDataService().getPushNotificationTemplate(id) : null;
if(pushnotificationtemplateCurr != null && pushnotificationtemplateCurr instanceof LockableObject && ((LockableObject)pushnotificationtemplateCurr).isLocked())
unLockPushNotificationTemplates(pushnotificationtemplateCurr, req, false);
res.sendRedirect("asresourcedataPushNotificationTemplateShow?ts="+System.currentTimeMillis());
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy