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

net.anotheria.asg.generator.view.jsp.ShowPageJspGenerator Maven / Gradle / Ivy

The newest version!
package net.anotheria.asg.generator.view.jsp;

import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.generator.GeneratedJSPFile;
import net.anotheria.asg.generator.GeneratorDataRegistry;
import net.anotheria.asg.generator.meta.MetaDocument;
import net.anotheria.asg.generator.meta.MetaProperty;
import net.anotheria.asg.generator.meta.StorageType;
import net.anotheria.asg.generator.view.CMSMappingsConfiguratorGenerator;
import net.anotheria.asg.generator.view.CMSMappingsConfiguratorGenerator.SectionAction;
import net.anotheria.asg.generator.view.ViewConstants;
import net.anotheria.asg.generator.view.action.ModuleActionsGenerator;
import net.anotheria.asg.generator.view.action.ModuleBeanGenerator;
import net.anotheria.asg.generator.view.meta.*;
import net.anotheria.util.StringUtils;

import java.util.List;

/**
 * Generator for show page.
 *
 * @author another
 * @version $Id: $Id
 */
public class ShowPageJspGenerator extends AbstractJSPGenerator {
	
	private MetaSection currentSection;
	
	/**
	 * 

generate.

* * @param section a {@link net.anotheria.asg.generator.view.meta.MetaModuleSection} object. * @param view a {@link net.anotheria.asg.generator.view.meta.MetaView} object. * @return a {@link net.anotheria.asg.generator.GeneratedJSPFile} object. */ public GeneratedJSPFile generate(MetaModuleSection section, MetaView view){ currentSection = section; GeneratedJSPFile jsp = new GeneratedJSPFile(); startNewJob(jsp); jsp.setName(getShowPageName(section.getDocument())); jsp.setPackage(GeneratorDataRegistry.getInstance().getContext().getJspPackageName(section.getModule())); ident = 0; append(getBaseJSPHeader()); MetaDocument doc = section.getDocument(); appendString(""); appendString(""); appendString(""); appendString(""); increaseIdent(); appendString(""+view.getTitle()+""); generatePragmas(view); appendString(""); appendString(""); appendString(""); appendString(""); appendString(""); getShowUsagesScript(section); decreaseIdent(); appendString(""); appendString(""); increaseIdent(); appendString(""); List elements = createMultilingualList(section.getElements(), doc); appendString("
"); increaseIdent(); appendString("
"); increaseIdent(); //top navigation start appendString("
"); increaseIdent(); appendString("
"); appendString("
"); appendString("
"+generateNewFunction("", new MetaFunctionElement("add")) +"  " + generateDeleteSelectedFunction("", new MetaFunctionElement("delete"))+"
"); appendString("
\"\"/"); increaseIdent(); appendString("
"); increaseIdent(); appendString("
"); increaseIdent(); appendString("
"); decreaseIdent(); appendString("
"); increaseIdent(); appendString("
"); increaseIdent(); appendString("
"); increaseIdent(); appendString("
"); increaseIdent(); appendString("Export to XML or CSV"); decreaseIdent(); appendString("
"); decreaseIdent(); appendString("
"); decreaseIdent(); appendString("
"); appendString("
"); appendString("
"); appendString("
"); decreaseIdent(); decreaseIdent(); appendString("
"); decreaseIdent(); appendString("
"); decreaseIdent(); appendString("
"); //top navigation end appendString("
"); increaseIdent(); appendString("
"); appendString("
"); appendString("
"); appendString("
"); //filters start appendString("Filters"); appendString("
"); increaseIdent(); appendString("
"); appendString("
"); appendString("
"); appendString("
"); for (int i=0; i"); appendString("<% String filterParameter"+i+" = (String) request.getAttribute(\"currentFilterParameter"+i+"\");"); appendString("if (filterParameter"+i+"==null)"); appendIncreasedString("filterParameter"+i+" = \"\";%>"); appendString("
    "); increaseIdent(); appendString("
  • "+StringUtils.capitalize(f.getName())+" "+StringUtils.capitalize(f.getFieldName())+":
  • "); increaseIdent(); appendString(""); increaseIdent(); appendString("")+">"); appendIncreasedString("
  • "); appendString("
    "); appendString("")+">"); appendIncreasedString("
  • ")+">
  • "); appendString("
    "); decreaseIdent(); appendString("
    "); decreaseIdent(); decreaseIdent(); appendString("
"); appendString("
"); } //filters end appendString("
"); decreaseIdent(); appendString("
"); appendString("<% String selectedPaging = \"\"+request.getAttribute("+quote("currentItemsOnPage")+"); %>"); //first paging start appendString("
"); increaseIdent(); appendString(""); appendString("
    "); increaseIdent(); appendString(""); appendIncreasedString("
  • \">prev
  • "); appendString("
    "); appendString(""); increaseIdent(); appendString("
  • "); increaseIdent(); appendString("..."); appendString(""); appendString("\">"); decreaseIdent(); appendString("
  • "); decreaseIdent(); appendString("
    "); appendString(""); appendIncreasedString("
  • \">next
  • "); appendString("
    "); decreaseIdent(); appendString("
"); appendString("
"); increaseIdent(); appendString(""); decreaseIdent(); decreaseIdent(); appendString("
"); appendString("
"); //first paging end //main table start appendString("
"); appendString(""); increaseIdent(); appendString(""); appendString(""); increaseIdent(); boolean opened = false; appendString(""); for (int i=0; i "); opened = true; } appendString(generateElementHeader(element)); } decreaseIdent(); appendString(""); appendString(""); appendString(""); increaseIdent(); String entryName = doc.getName().toLowerCase(); appendString(""); appendString(""); appendString(""); appendString(""); appendString(""); appendString(""); if (isShowUsagesElementAllowed(section)){ appendString(""); } appendString("
"); appendString(""); increaseIdent(); appendString(" highlightable\">"); appendString(""); opened = false; for (int i = 0; i < elements.size(); i++) { MetaViewElement element = elements.get(i); if (element instanceof MetaFunctionElement && opened == false){ appendString(""); appendString(""); decreaseIdent(); appendString(""); decreaseIdent(); appendString(""); decreaseIdent(); appendString("
\">"); opened = true; } appendString(generateElement(entryName, element,doc,section)); } opened = false; appendString("
"); appendString("
"); //main table end //second paging start appendString("
"); increaseIdent(); appendString(""); appendString("
    "); increaseIdent(); appendString(""); appendIncreasedString("
  • \">prev
  • "); appendString("
    "); appendString(""); increaseIdent(); appendString("
  • "); increaseIdent(); appendString("..."); appendString(""); appendString("\">"); decreaseIdent(); appendString("
  • "); decreaseIdent(); appendString("
    "); appendString(""); appendIncreasedString("
  • \">next
  • "); appendString("
    "); decreaseIdent(); appendString("
"); appendString("
"); increaseIdent(); appendString(""); decreaseIdent(); decreaseIdent(); appendString("
"); appendString("
"); decreaseIdent(); appendString("
"); decreaseIdent(); appendString("
"); decreaseIdent(); appendString("
"); //second paging end //lightbox start appendString("
"); appendString("
"); appendString("
"); increaseIdent(); appendString("
"); increaseIdent(); appendString("
"); appendString(""); appendString(""); appendString("
"); decreaseIdent(); appendString("
"); appendString("
"); increaseIdent(); appendString("
"); increaseIdent(); appendString("
"); appendString("
"); decreaseIdent(); appendString("
"); decreaseIdent(); appendString("
"); appendString("
"); increaseIdent(); appendString("
"); appendString(""); decreaseIdent(); appendString("
"); decreaseIdent(); //lightbox end appendString("
"); appendString("
"); appendString(""); appendString(""); appendString(""); return jsp; } private String generateNewFunction(String entryName, MetaFunctionElement element){ String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection)currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_NEW); return ""+getImage("add", "add new "+((MetaModuleSection)currentSection).getDocument().getName())+"Add new element" ; } private String generateDeleteSelectedFunction(String entryName, MetaFunctionElement element){ String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection)currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_DELETE); //todo change images names here getImage("add", "add new.... return ""+getImage("add", "add new "+((MetaModuleSection)currentSection).getDocument().getName())+"Delete selected" ; } private String generateElementHeader(MetaViewElement element){ if (element instanceof MetaFieldElement) return generateFieldHeader((MetaFieldElement)element); return ""; } private String generateFieldHeader(MetaFieldElement element){ String name = element instanceof MultilingualFieldElement ? element.getVariableName() : element.getName(); String header = ""; String caption;//field caption to show on table header; if (element.getCaption() == null) { caption = StringUtils.capitalize(name); } else { caption = element.getCaption(); if (element instanceof MultilingualFieldElement) { caption += "("+((MultilingualFieldElement)element).getLanguage().toUpperCase() + ")"; } } if (element.isComparable()){ String action = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection)currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_SHOW); action = action+"?"+ViewConstants.PARAM_SORT_TYPE_NAME+"="+name; String actionAZ = action + "&" + ViewConstants.PARAM_SORT_ORDER + "="+ViewConstants.VALUE_SORT_ORDER_ASC; String actionZA = action + "&" + ViewConstants.PARAM_SORT_ORDER + "="+ViewConstants.VALUE_SORT_ORDER_DESC; header += ""+ ""+caption+""+ ""+ ""+ ""+caption+""+ ""+ ""+ ""+ ""+caption+""+ ""+ ""; } else { header = caption;//StringUtils.capitalize(name); } String displayLanguageCheck = ""; if(element instanceof MultilingualFieldElement) { MultilingualFieldElement multilangualElement = (MultilingualFieldElement) element; displayLanguageCheck = "class=\"lang_hide lang_"+multilangualElement.getLanguage()+"\" style=\"display:none\""; } return ""+header+""; } private String generateElement(String entryName, MetaViewElement element,MetaDocument doc, MetaModuleSection section){ if (element instanceof MetaFieldElement) return getField(entryName, (MetaFieldElement)element); if (element instanceof MetaFunctionElement) return getFunction(entryName, (MetaFunctionElement)element,doc,section); if (element instanceof MetaCustomFunctionElement) return getCustomFunction(entryName, (MetaCustomFunctionElement)element); return ""; } private String getField(String entryName, MetaFieldElement element){ if (((MetaModuleSection)currentSection).getDocument().getField(element.getName()).getType() == MetaProperty.Type.IMAGE && element.getDecorator()==null) return generateImage(entryName, element); String elementName = element instanceof MultilingualFieldElement ? element.getVariableName() : element.getName(); String cmsDocumentIdClass = elementName.equals("id") ? "showUsagesPId" : ""; String displayLanguageCheck = ""; if(element instanceof MultilingualFieldElement) { MultilingualFieldElement multilangualElement = (MultilingualFieldElement) element; displayLanguageCheck = "class=\"lang_hide lang_"+multilangualElement.getLanguage()+"\" style=\"display:none\" "+cmsDocumentIdClass; }else{ if (!StringUtils.isEmpty(cmsDocumentIdClass)) displayLanguageCheck = "class=\""+cmsDocumentIdClass+"\""; } return ""; //return ""; } private String generateImage(String entryName, MetaFieldElement element){ String ret = ""; ret += ""; ret += ""; ret += "none"; ret += ""; ret += ""; String imagePath = "getFile?pName="; ret += ""; ret += ""; ret += ""; return ret; } private String getFunction(String entryName, MetaFunctionElement element, MetaDocument doc, MetaModuleSection section){ if (element.getName().equals("version")){ return getVersionFunction(entryName, element); } if (element.getName().equals("delete")){ return getDeleteFunction(entryName, element); } if (element.getName().equals("deleteWithConfirmation")){ return getDeleteWithConfirmationFunction(entryName, element); } if (element.getName().equals("preview")) { if(section.getDocument().getName().equalsIgnoreCase("LPEntryPoint")) return "\">" + getPreviewImage() + ""; return ".html>" + getPreviewImage() + ""; } if (element.getName().equals("edit")) return getEditFunction(entryName, element); if (element.getName().equals("duplicate")) return getDuplicateFunction(entryName, element); if (element.getName().equals("lock") && StorageType.CMS.equals(doc.getParentModule().getStorageType())) return getLockFunction(entryName, element); if (element.getName().equals("unlock") && StorageType.CMS.equals(doc.getParentModule().getStorageType())) return getUnLockFunction(entryName, element); if (element.getName().equals("transfer")) { return getTransferFunction(entryName, element); } if (element.getName().equals("showUsages")){ if (isShowUsagesElementAllowed(section)){ return getShowUsagesFunction(); } return ""; } return ""; //return ""; } private String getCustomFunction(String entryName, MetaCustomFunctionElement element){ String caption = element.getCaption(); String link = element.getLink(); link = StringUtils.replace(link, "$plainId", ""); return ""+caption+""; } private String getShowUsagesFunction(){ return "\"show" ; } /** * Transfer to prod link for List show! */ private String getTransferFunction(String entryName, MetaFunctionElement element){ String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection)currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_TRANSFER); String id = ""; return "" + "\"transfer" ; } /* * Lock link for List show! */ private String getUnLockFunction(String entryName, MetaFunctionElement element) { String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection) currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_UNLOCK); path += "?pId="; path+="&nextAction=showList"; String alt = "Locked by: , at: "; String link = " Unlock "+((MetaModuleSection)currentSection).getDocument().getName()+" with id: ?','"+path+"');")+">"+getUnLockImage(alt)+""; String result = ""; result+=link; result+= ""; return result; } /** * UnLock link for List show! */ private String getLockFunction(String entryName, MetaFunctionElement element) { String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection) currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_LOCK); path += "?pId="; path+="&nextAction=showList"; String link = "?','"+path+"');")+">"+getLockImage()+"" ; String result = ""; result+=link; result+= ""; return result; } private String getDuplicateFunction(String entryName, MetaFunctionElement element){ String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection)currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_DUPLICATE); path += "?pId="; return ""+path+"")+">"+getDuplicateImage()+"" ; } private String getVersionFunction(String entryName, MetaFunctionElement element){ String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection)currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_VERSIONINFO); path += "?pId="; return ""+path+"")+">"+getImage("version", "LastUpdate: ")+"" ; } private String getDeleteFunction(String entryName, MetaFunctionElement element){ String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection)currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_DELETE); path += "?pId="; return ""+path+"")+">"+getDeleteImage()+"" ; } private String getDeleteWithConfirmationFunction(String entryName, MetaFunctionElement element){ String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection)currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_DELETE); path += "?pId="; return "?','"+path+"');")+">"+getDeleteImage()+"" ; } private String getEditFunction(String entryName, MetaFunctionElement element){ String path = CMSMappingsConfiguratorGenerator.getPath(((MetaModuleSection)currentSection).getDocument(), CMSMappingsConfiguratorGenerator.ACTION_EDIT); path += "?pId="; return ""+path+"")+">"+getEditImage()+"" ; } private String getShowUsagesScript(MetaModuleSection section){ if (isShowUsagesElementAllowed(section)){ increaseIdent(); appendString(""); } return null; } private boolean isShowUsagesElementAllowed(MetaModuleSection section){ if(section.getModule().getName().equalsIgnoreCase("aswebdata") || section.getModule().getName().equalsIgnoreCase("aslayoutdata") || section.getModule().getName().equalsIgnoreCase("asgenericdata") || section.getModule().getName().equalsIgnoreCase("ascustomdata") || section.getModule().getName().equalsIgnoreCase("assitedata")){ if (!section.getDocument().getName().equalsIgnoreCase("RedirectUrl") && !section.getDocument().getName().equalsIgnoreCase("EntryPoint")){ return true; } } return false; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy