1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
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
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.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
33
* Generated from javadescriptor.jsp
34
* !!! DO NOT EDIT THIS FILE !!!
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();
43
class DescriptorGenerator {
46
package <%=jh.getPackageName()%>;
48
import com.sun.grid.jgdi.configuration.*;
49
import com.sun.grid.jgdi.CullConstants;
52
* Java descriptor of the cull object <%=cullObj.getName()%>
53
* defined in <%=jh.getSource(cullObj).getName()%>
55
public class <%=jh.getClassName(cullObj)%>Descriptor extends <%
57
%> <%=jh.getClassName(parent)%>Descriptor <%
59
%> GEObjectDescriptor <%
63
public <%=jh.getClassName(cullObj)%>Descriptor() {
64
this(<%=jh.getClassName(cullObj)%>Impl.class, <%
65
if (parent != null ) {
66
%>"<%=cullObj.getName()%>" <%
68
%>"<%=cullObj.getName()%>" <%
72
setImplClass(<%=jh.getClassName(cullObj)%>Impl.class);
75
protected <%=jh.getClassName(cullObj)%>Descriptor(Class type, String name) {
78
if (cullObj.getOwnAttrCount() > 0 ) {
80
PropertyDescriptor propDescr = null;
83
for (int i = 0; i < cullObj.getOwnAttrCount(); i++ ) {
84
attr = cullObj.getOwnAttr(i);
85
if (attr.isHidden() ) {
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);
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()%>);
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);
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()%>);
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);
135
propDescr = addList("<%=attrName%>", <%=jh.getClassNameWithSuffix(attr.getType())%>, "<%=attr.getType()%>", CullConstants.<%=attr.getName()%>, true, <%=attr.isReadOnly()%>, <%=attr.isConfigurable()%>);
138
subobj = cullDef.getCullObject(attr.getType());
140
propDescr = addSimple("<%=attrName%>", <%=jh.getClassNameWithSuffix(attr.getType())%>, "<%=attr.getType()%>", CullConstants.<%=attr.getName()%>, <%=attr.isPrimaryKey()%>, <%=attr.isReadOnly()%>, <%=attr.isConfigurable()%>);
143
if (subobj != null) {
144
if (subobj.getType() == com.sun.grid.cull.CullObject.TYPE_PRIMITIVE) {
146
propDescr.setHasCullWrapper(true);
147
propDescr.setCullContentField(CullConstants.<%=subobj.getContentAttrName()%>);
149
} else if (subobj.getType() == com.sun.grid.cull.CullObject.TYPE_MAPPED) {
151
propDescr.setHasCullWrapper(true);
152
propDescr.setCullContentField(-1);
160
public void validate(Object obj) throws InvalidObjectException {
162
if (!(obj instanceof <%=jh.getClassName(cullObj)%>)) {
163
throw new InvalidObjectException(obj, "obj is not an instanceof <%=jh.getClassName(cullObj)%>");
166
if (cullObj.getAttrCount() > 0) {
168
<%=jh.getClassName(cullObj)%> cullObj = (<%=jh.getClassName(cullObj)%>)obj;
169
InvalidObjectException exc = null;
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);
177
if (!cullObj.isSet<%=gsname%>()) {
179
exc = new InvalidObjectException(obj, "Primary key fields are not set");
181
exc.addPropertyError("<%=attrName%>", "primary key field is required");
190
} // end of if attrCount > 0
191
if (parent != null) {