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

panda.tool.codegen.bean.Module Maven / Gradle / Ivy

package panda.tool.codegen.bean;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

import panda.io.Settings;
import panda.lang.Arrays;

/**
 * 

* Java class for Module complex type. *

* The following schema fragment specifies the expected content contained within this class. * *

 * <complexType name="Module">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="include" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
 *         <element name="entity" type="{panda.tool.codegen}Entity" maxOccurs="unbounded" minOccurs="0"/>
 *         <element name="action" type="{panda.tool.codegen}Action" maxOccurs="unbounded" minOccurs="0"/>
 *         <element name="resource" type="{panda.tool.codegen}Resource" maxOccurs="unbounded" minOccurs="0"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
*/ @XmlAccessorType(XmlAccessType.NONE) @XmlType(name = "Module") public class Module { @XmlElement(name = "entity") protected List entityList; @XmlElement(name = "action") protected List actionList; @XmlElement(name = "resource") protected List resourceList; protected Settings props; /** * Constructor */ public Module() { } /** * Constructor - copy properties from source * * @param module source module */ public Module(Module module) { entityList = new LinkedList(); for (Entity e : module.getEntityList()) { entityList.add(new Entity(e)); } actionList = new LinkedList(); for (Action a : module.getActionList()) { actionList.add(new Action(a)); } resourceList = new LinkedList(); for (Resource r : module.getResourceList()) { resourceList.add(new Resource(r)); } props.putAll(module.getProps()); } /** * prepare * * @throws Exception if an error occurs */ public void prepare() throws Exception { boolean extend = true; for (Entity entity : getEntityList()) { entity.prepare(); } while (extend) { extend = false; for (Action action : getActionList()) { if (Arrays.isEmpty(action.getExtends())) { continue; } Action na = action; for (String et : action.getExtends()) { // System.out.println("Extend action[" + et + "] of " + action.getName()); Action parent = null; for (Action a2 : getActionList()) { if (a2.getName().equals(et)) { parent = a2; break; } } if (parent == null) { throw new Exception("Can not find extend action[" + et + "] of " + action.getName()); } if (parent == action) { throw new Exception("Can not extend self action[" + et + "] of " + action.getName()); } na = Action.extend(action, parent); } getActionList().remove(action); getActionList().add(na); extend = true; break; } } for (Action action : getActionList()) { action.prepare(); } } /** * @return the props */ public Settings getProps() { if (props == null) { props = new Settings(); } return props; } /** * @param props the props to set */ public void setProps(Settings props) { this.props = props; } /** * @return the entityList */ public List getEntityList() { if (entityList == null) { entityList = new ArrayList(); } return this.entityList; } /** * @return the actionList */ public List getActionList() { if (actionList == null) { actionList = new ArrayList(); } return this.actionList; } /** * @return the resourceList */ public List getResourceList() { if (resourceList == null) { resourceList = new ArrayList(); } return this.resourceList; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy