typestub.javajet

来自「jsp开发 com.objectlearn.jdt.j2ee_3.0.1」· JAVAJET 代码 · 共 58 行

JAVAJET
58
字号
<%@ jet package="com.objectlearn.gmf.templates.entity" class="TypeStubGenerator" imports="java.util.* com.objectlearn.lomboz.xml.lomboz.DocumentRoot com.objectlearn.lomboz.xml.lomboz.EntityBean com.objectlearn.lomboz.xml.lomboz.FieldMapping  com.sun.java.xml.ns.j2ee.EntityBeanType  com.sun.java.xml.ns.j2ee.FullyQualifiedClassType"%>
<% DocumentRoot root = (DocumentRoot)argument;
   EntityBean leb = (EntityBean) root.getEjb().getEntity();
   EntityBeanType eb = leb.getEntityEjb();
   boolean isCMP = "Container".equals(eb.getPersistenceType().getValue());
   
   String primaryKeyType = "java.lang.String";
   int pkCount=0;
   boolean isComposite = false;
   boolean createCompositeKey = false;
   if( isCMP ) { 
       FullyQualifiedClassType pkClassType = eb.getPrimKeyClass();
       if(pkClassType != null && pkClassType.getValue() != null && pkClassType.getValue().length() > 0 )
          primaryKeyType = pkClassType.getValue();
	   Iterator fieldMappings = leb.getFieldMappings().iterator();
	   String pkType = "";
	   while(fieldMappings.hasNext()){
	      FieldMapping mapping = (FieldMapping) fieldMappings.next();
	      if(mapping.isPrimaryKey()){
	        pkType = mapping.getFieldType().getValue();
	        pkCount++;
	      }
	   }
       isComposite = pkCount > 1;
       if(!isComposite )
         primaryKeyType = pkType;
       else if(pkClassType == null || pkClassType.getValue() == null || pkClassType.getValue().length() < 1 ){
		   createCompositeKey = true;
		   primaryKeyType = eb.getEjbClass().getValue()+".PrimaryKey";
       }else if(pkClassType != null && pkClassType.getValue() != null ){
           if(primaryKeyType.equals(eb.getEjbClass().getValue()+".PrimaryKey") )
              createCompositeKey = true;
       }
   }  
%>
public abstract class <%=eb.getEjbClass().getUnqualifiedClassName()%> implements javax.ejb.EntityBean {
    
<% 	   if(createCompositeKey ){ %>
    /**
    * Generated Primary Key Class
    * @generated
    */
    public class PrimaryKey {
<%
	  Iterator fieldMappings = leb.getFieldMappings().iterator();
      while(fieldMappings.hasNext()){
	      FieldMapping mapping = (FieldMapping) fieldMappings.next();
	      if(mapping.isPrimaryKey()){ %>
		  /**
		  * @generated
		  */	       
	      public <%= mapping.getFieldType().getValue() %> <%= mapping.getFieldName().getValue() %> ;
<%        } }%>
	}
<%	}%>

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?