All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
net.anotheria.anosite.gen.asresourcedata.action.ExportLocalizationBundlesAction Maven / Gradle / Ivy
/**
********************************************************************************
*** ExportLocalizationBundlesAction.java ***
*** generated by AnoSiteGenerator (ASG), Version: 3.2.2 ***
*** Copyright (C) 2005 - 2023 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 java.util.List;
import java.util.ArrayList;
import net.anotheria.asg.util.filter.DocumentFilter;
import net.anotheria.util.xml.XMLNode;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionCommand;
import net.anotheria.maf.action.ActionMapping;
import net.anotheria.anosite.gen.asresourcedata.data.LocalizationBundle;
import net.anotheria.anosite.gen.asresourcedata.data.LocalizationBundleSortType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MarkerFactory;
import net.anotheria.util.sorter.Sorter;
import net.anotheria.util.sorter.QuickSorter;
import net.anotheria.anosite.gen.asresourcedata.bean.LocalizationBundleListItemBeanSortType;
public class ExportLocalizationBundlesAction extends BaseLocalizationBundleAction{
public static final String SA_SORT_TYPE = SA_SORT_TYPE_PREFIX+"LocalizationBundle";
public static final String SA_FILTER = SA_FILTER_PREFIX+"LocalizationBundle";
private static final List ITEMS_ON_PAGE_SELECTOR = java.util.Arrays.asList(new String[]{"5","10","20","25","50","100","500","1000"});
private static final Logger log = LoggerFactory.getLogger(ExportLocalizationBundlesAction.class);
private Sorter sorter;
private DocumentFilter nameFilterAZ;
private DocumentFilter anyFilterMissingTranslation;
public ExportLocalizationBundlesAction(){
super();
sorter = new QuickSorter();
try{
nameFilterAZ = (DocumentFilter) Class.forName("net.anotheria.asg.util.filter.AZDocumentFilter").newInstance();
anyFilterMissingTranslation = (DocumentFilter) Class.forName("net.anotheria.asg.util.filter.MissingAnyTranslationFilter").newInstance();
} catch(Exception e){
log.error(MarkerFactory.getMarker("FATAL"), "Couldn't instantiate filter:", e);
}
}
public ActionCommand anoDocExecute(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String filterParameter0 = "";
try{
filterParameter0 = getStringParameter(req, "pFilter0");
addBeanToSession(req, SA_FILTER+"0", filterParameter0);
}catch(Exception ignored){
// no filter parameter given, tring to check in the session.
filterParameter0 = (String)getBeanFromSession(req, SA_FILTER+"0");
if (filterParameter0==null)
filterParameter0 = "";
}
req.setAttribute("currentFilterParameter0", filterParameter0);
String filterParameter1 = "";
try{
filterParameter1 = getStringParameter(req, "pFilter1");
addBeanToSession(req, SA_FILTER+"1", filterParameter1);
}catch(Exception ignored){
// no filter parameter given, tring to check in the session.
filterParameter1 = (String)getBeanFromSession(req, SA_FILTER+"1");
if (filterParameter1==null)
filterParameter1 = "";
}
req.setAttribute("currentFilterParameter1", filterParameter1);
int sortMethod = LocalizationBundleListItemBeanSortType.SORT_BY_DEFAULT;
boolean sortOrder = LocalizationBundleListItemBeanSortType.ASC;
boolean sortParamSet = false;
try{
sortMethod = getIntParameter(req, PARAM_SORT_TYPE);
sortParamSet = true;
}catch(Exception ignored){}
try{
String sortMethodName = getStringParameter(req, PARAM_SORT_TYPE_NAME);
sortMethod = LocalizationBundleListItemBeanSortType.name2method(sortMethodName);
sortParamSet = true;
}catch(Exception ignored){}
try{
sortOrder = getStringParameter(req, PARAM_SORT_ORDER).equals("ASC") ?
LocalizationBundleListItemBeanSortType.ASC : LocalizationBundleListItemBeanSortType.DESC;
}catch(Exception ignored){}
LocalizationBundleListItemBeanSortType sessionSortType = null;
LocalizationBundleSortType sortType = null;
if (sortParamSet){
sessionSortType = new LocalizationBundleListItemBeanSortType(sortMethod, sortOrder);
sortType = new LocalizationBundleSortType(sortMethod, sortOrder);
addBeanToSession(req, SA_SORT_TYPE, sessionSortType);
}else{
sessionSortType = (LocalizationBundleListItemBeanSortType)getBeanFromSession(req, SA_SORT_TYPE);
sortType = sessionSortType == null ? new LocalizationBundleSortType(sortMethod, sortOrder) : new LocalizationBundleSortType(sessionSortType.getSortBy(), sessionSortType.getSortOrder());
sessionSortType = sessionSortType == null ? new LocalizationBundleListItemBeanSortType(sortMethod, sortOrder) : sessionSortType;
}
req.setAttribute("currentSortCode", sessionSortType.getMethodAndOrderCode());
List _unfiltered_localizationbundles = getASResourceDataService().getLocalizationBundles();
List localizationbundles = new ArrayList();
for (LocalizationBundle element : _unfiltered_localizationbundles ){
boolean mayPass = true;
mayPass = mayPass && (nameFilterAZ.mayPass( element, "name", filterParameter0));
mayPass = mayPass && (anyFilterMissingTranslation.mayPass( element, "any", filterParameter1));
if (mayPass)
localizationbundles.add(element);
}
localizationbundles = sorter.sort(localizationbundles, sortType);
addBeanToRequest(req, "localizationbundles", localizationbundles);
XMLNode beans = getASResourceDataService().exportLocalizationBundlesToXML(localizationbundles);
/**
* for XML node - page
*/
addBeanToRequest(req, "localizationbundlesXML", beans);
/**
* for CSV - page
*/
addBeanToRequest(req, "localizationbundlesCSV", localizationbundles);
addBeanToRequest(req, "nameFilterAZ", nameFilterAZ.getTriggerer(""));
addBeanToRequest(req, "anyFilterMissingTranslation", anyFilterMissingTranslation.getTriggerer(""));
return mapping.success();
}
}