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

net.anotheria.asg.generator.view.action.BaseViewActionGenerator Maven / Gradle / Ivy

package net.anotheria.asg.generator.view.action;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import net.anotheria.asg.generator.AbstractGenerator;
import net.anotheria.asg.generator.FileEntry;
import net.anotheria.asg.generator.GeneratedClass;
import net.anotheria.asg.generator.GeneratorDataRegistry;
import net.anotheria.asg.generator.IGenerateable;
import net.anotheria.asg.generator.meta.MetaModule;
import net.anotheria.asg.generator.view.CMSMappingsConfiguratorGenerator;
import net.anotheria.asg.generator.view.meta.MetaCustomSection;
import net.anotheria.asg.generator.view.meta.MetaModuleSection;
import net.anotheria.asg.generator.view.meta.MetaSection;
import net.anotheria.asg.generator.view.meta.MetaView;
import net.anotheria.util.StringUtils;

/**
 * This generator generates the base action for a view.
 *
 * @author another
 * @version $Id: $Id
 */
public class BaseViewActionGenerator extends AbstractGenerator {

	/* (non-Javadoc)
	 * @see net.anotheria.anodoc.generator.IGenerator#generate(net.anotheria.anodoc.generator.IGenerateable, net.anotheria.anodoc.generator.Context)
	 */
	/**
	 * 

generate.

* * @param g a {@link net.anotheria.asg.generator.IGenerateable} object. * @return a {@link net.anotheria.asg.generator.FileEntry} object. */ public FileEntry generate(IGenerateable g) { MetaView view = (MetaView)g; return new FileEntry(generateViewAction(view)); } /** *

getViewActionName.

* * @param view a {@link net.anotheria.asg.generator.view.meta.MetaView} object. * @return a {@link java.lang.String} object. */ public static String getViewActionName(MetaView view){ return "Base"+StringUtils.capitalize(view.getName())+"Action"; } /** *

generateViewAction.

* * @param view a {@link net.anotheria.asg.generator.view.meta.MetaView} object. * @return a {@link net.anotheria.asg.generator.GeneratedClass} object. */ public GeneratedClass generateViewAction(MetaView view){ GeneratedClass clazz = new GeneratedClass(); startNewJob(clazz); clazz.setPackageName(GeneratorDataRegistry.getInstance().getContext().getPackageName(MetaModule.SHARED)+".action"); List sections = view.getSections(); List modules = new ArrayList(); for (int i=0; i0){ clazz.addImport(Arrays.class); String roles = ""; for (String r : view.getRequiredRoles()){ if (roles.length()>0) roles += ", "; roles += quote(r); } appendStatement("private static final List MY_ROLES = Arrays.asList(new String[]{"+roles+"})"); appendString("protected List getRequiredRoles(){"); appendIncreasedStatement("return MY_ROLES"); appendString("}"); } emptyline(); appendString("protected List getSubNavigation(){"); appendStatement("List subNavi = new ArrayList()"); increaseIdent(); for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy