~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/jgdi/templates/javadescriptor.jsp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 *
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 *
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 *
 
9
 *
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 *
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 *
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 *
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 *
 
28
 *   All Rights Reserved.
 
29
 *
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
/**
 
33
 *  Generated from javadescriptor.jsp
 
34
 *  !!! DO NOT EDIT THIS FILE !!!
 
35
 */
 
36
<%
 
37
  com.sun.grid.cull.CullDefinition cullDef = (com.sun.grid.cull.CullDefinition)params.get("cullDef");
 
38
  com.sun.grid.cull.JavaHelper jh = (com.sun.grid.cull.JavaHelper)params.get("javaHelper");
 
39
  com.sun.grid.cull.CullObject cullObj = (com.sun.grid.cull.CullObject)params.get("cullObj");
 
40
  com.sun.grid.cull.CullAttr   attr = null;
 
41
  com.sun.grid.cull.CullObject parent = cullObj.getParentObject();
 
42
  
 
43
  class DescriptorGenerator {
 
44
  }
 
45
%>
 
46
package <%=jh.getPackageName()%>;
 
47
 
 
48
import com.sun.grid.jgdi.configuration.*;
 
49
import com.sun.grid.jgdi.CullConstants;
 
50
 
 
51
/**
 
52
 *  Java descriptor of the cull object <%=cullObj.getName()%>
 
53
 *  defined in <%=jh.getSource(cullObj).getName()%>
 
54
 */
 
55
public class <%=jh.getClassName(cullObj)%>Descriptor extends <%
 
56
   if (parent != null) {
 
57
     %> <%=jh.getClassName(parent)%>Descriptor <%
 
58
   } else {
 
59
     %> GEObjectDescriptor <%
 
60
   }       
 
61
%>{
 
62
 
 
63
   public <%=jh.getClassName(cullObj)%>Descriptor() {
 
64
      this(<%=jh.getClassName(cullObj)%>Impl.class, <%
 
65
       if (parent != null ) {
 
66
          %>"<%=cullObj.getName()%>" <%
 
67
       } else {
 
68
          %>"<%=cullObj.getName()%>" <%
 
69
       }
 
70
       
 
71
   %>);
 
72
      setImplClass(<%=jh.getClassName(cullObj)%>Impl.class);
 
73
   }
 
74
      
 
75
   protected <%=jh.getClassName(cullObj)%>Descriptor(Class type, String name) {
 
76
      super(type, name);
 
77
<% 
 
78
  if (cullObj.getOwnAttrCount() > 0 ) {
 
79
%>     
 
80
      PropertyDescriptor propDescr = null;
 
81
<%
 
82
    }
 
83
    for (int i = 0; i < cullObj.getOwnAttrCount(); i++ ) {
 
84
        attr = cullObj.getOwnAttr(i);
 
85
        if (attr.isHidden() ) {
 
86
            continue;
 
87
        }
 
88
        String attrType = jh.getFullClassName(attr.getType());
 
89
        String attrName = jh.getAttrName(attr);
 
90
        String gsname = Character.toUpperCase(attrName.charAt(0)) + attrName.substring(1);
 
91
        com.sun.grid.cull.CullObject subobj = null;
 
92
        if (attr instanceof com.sun.grid.cull.CullMapListAttr) {
 
93
            com.sun.grid.cull.CullMapListAttr mapAttr = (com.sun.grid.cull.CullMapListAttr)attr;
 
94
            com.sun.grid.cull.CullAttr keyAttr = mapAttr.getKeyAttr();
 
95
            com.sun.grid.cull.CullAttr valueAttr = mapAttr.getValueAttr();
 
96
            subobj = cullDef.getCullObject(valueAttr.getType());
 
97
            String keyClass = jh.getClassNameWithSuffix(keyAttr.getType());
 
98
            String valueClass = jh.getClassNameWithSuffix(valueAttr.getType());
 
99
            if (attrName.endsWith("List")) {
 
100
                attrName = attrName.substring(0, attrName.length() - 4);
 
101
                gsname = Character.toUpperCase(attrName.charAt(0)) + attrName.substring(1);
 
102
        }
 
103
%>       
 
104
      // keyAttr = <%=keyAttr.getName()%> (type = <%=keyAttr.getType()%>)
 
105
      // valueAttr = <%=valueAttr.getName()%> (type = <%=valueAttr.getType()%>)
 
106
      propDescr = addMapList("<%=attrName%>", <%=valueClass%>, "<%=attr.getType()%>", <%=keyClass%>, "<%=valueAttr.getType()%>",
 
107
             CullConstants.<%=attr.getName()%>, CullConstants.<%=mapAttr.getKeyAttr().getName()%>, CullConstants.<%=mapAttr.getValueAttr().getName()%>,
 
108
             <%=attr.getDefault() == null ? "null" : "\"" + attr.getDefault() + "\"" %>,<%=attr.isReadOnly()%>, <%=attr.isConfigurable()%>);
 
109
<%
 
110
        } else if (attr instanceof com.sun.grid.cull.CullMapAttr) {
 
111
            com.sun.grid.cull.CullMapAttr mapAttr = (com.sun.grid.cull.CullMapAttr)attr;
 
112
            com.sun.grid.cull.CullAttr keyAttr = mapAttr.getKeyAttr();
 
113
            com.sun.grid.cull.CullAttr valueAttr = mapAttr.getValueAttr();
 
114
            subobj = cullDef.getCullObject(valueAttr.getType());
 
115
            String keyClass = jh.getClassNameWithSuffix(keyAttr.getType());
 
116
            String valueClass = jh.getClassNameWithSuffix(valueAttr.getType());
 
117
            if (attrName.endsWith("List")) {
 
118
                attrName = attrName.substring(0, attrName.length() - 4);
 
119
                gsname = Character.toUpperCase(attrName.charAt(0)) + attrName.substring(1);
 
120
        }
 
121
%>
 
122
      // keyAttr = <%=keyAttr.getName()%> (type = <%=keyAttr.getType()%>)
 
123
      // valueAttr = <%=valueAttr.getName()%> (type = <%=valueAttr.getType()%>)
 
124
      propDescr = addMap("<%=attrName%>", <%=valueClass%>, "<%=attr.getType()%>", <%=keyClass%>,
 
125
             CullConstants.<%=attr.getName()%>, CullConstants.<%=mapAttr.getKeyAttr().getName()%>, CullConstants.<%=mapAttr.getValueAttr().getName()%>,
 
126
             <%=attr.getDefault() == null ? "null" : "\"" + attr.getDefault() + "\"" %>, <%=attr.isReadOnly()%>, <%=attr.isConfigurable()%>);
 
127
<%
 
128
        } else if (attr instanceof com.sun.grid.cull.CullListAttr) {
 
129
            subobj = cullDef.getCullObject(attr.getType());
 
130
            if (attrName.endsWith("List")) {
 
131
                attrName = attrName.substring(0, attrName.length() - 4);
 
132
                gsname = Character.toUpperCase(attrName.charAt(0)) + attrName.substring(1);
 
133
        }
 
134
%>
 
135
      propDescr = addList("<%=attrName%>", <%=jh.getClassNameWithSuffix(attr.getType())%>, "<%=attr.getType()%>", CullConstants.<%=attr.getName()%>, true, <%=attr.isReadOnly()%>, <%=attr.isConfigurable()%>);
 
136
<% 
 
137
        } else {
 
138
            subobj = cullDef.getCullObject(attr.getType());
 
139
%>
 
140
      propDescr = addSimple("<%=attrName%>", <%=jh.getClassNameWithSuffix(attr.getType())%>, "<%=attr.getType()%>", CullConstants.<%=attr.getName()%>, <%=attr.isPrimaryKey()%>, <%=attr.isReadOnly()%>, <%=attr.isConfigurable()%>); 
 
141
<%
 
142
        } // end of if
 
143
        if (subobj != null) {
 
144
            if (subobj.getType() == com.sun.grid.cull.CullObject.TYPE_PRIMITIVE) {
 
145
%>
 
146
         propDescr.setHasCullWrapper(true);
 
147
         propDescr.setCullContentField(CullConstants.<%=subobj.getContentAttrName()%>);
 
148
<%
 
149
        } else if (subobj.getType() == com.sun.grid.cull.CullObject.TYPE_MAPPED) {
 
150
%>
 
151
         propDescr.setHasCullWrapper(true);
 
152
         propDescr.setCullContentField(-1);
 
153
<%
 
154
        }
 
155
    }
 
156
} // end of for
 
157
%>
 
158
   }
 
159
   
 
160
   public void validate(Object obj) throws InvalidObjectException {
 
161
   
 
162
      if (!(obj instanceof <%=jh.getClassName(cullObj)%>)) {
 
163
         throw new InvalidObjectException(obj, "obj is not an instanceof <%=jh.getClassName(cullObj)%>");
 
164
      }
 
165
<%
 
166
    if (cullObj.getAttrCount() > 0) {
 
167
%>
 
168
      <%=jh.getClassName(cullObj)%> cullObj = (<%=jh.getClassName(cullObj)%>)obj;
 
169
      InvalidObjectException exc = null;
 
170
<%
 
171
    for (int i = 0; i < cullObj.getPrimaryKeyCount(); i++ ) {
 
172
        attr = cullObj.getPrimaryKeyAttr(i);
 
173
        String attrType = jh.getFullClassName(attr.getType());
 
174
        String attrName = jh.getAttrName(attr);
 
175
        String gsname = Character.toUpperCase(attrName.charAt(0)) + attrName.substring(1);
 
176
%>   
 
177
       if (!cullObj.isSet<%=gsname%>()) {
 
178
          if (exc == null) {
 
179
             exc = new InvalidObjectException(obj, "Primary key fields are not set");
 
180
          }
 
181
          exc.addPropertyError("<%=attrName%>", "primary key field is required");
 
182
       }
 
183
<%
 
184
    } // end of for
 
185
%>
 
186
       if (exc != null) {
 
187
           throw exc;
 
188
       }
 
189
<%
 
190
    } // end of if attrCount > 0
 
191
    if (parent != null) {
 
192
%>     
 
193
       super.validate(obj);
 
194
<%
 
195
    }
 
196
%>
 
197
   }
 
198
}