|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.metadata.DynamicElement
com.arsdigita.metadata.DynamicObjectType
DynamicObjectType is a class that can be used to dynamically
create and modify ObjectType
. It can be used to
create the subtype, add and remove Attributes and RoleReferences as
well as perform many other tasks related to the new object type.
When the application is done creating the object type, it should
call save()
to persist the information about the newly created
object type.
Field Summary | |
static String |
versionId
|
Constructor Summary | |
DynamicObjectType(ObjectType objectType)
This allows the programmer to instantiate an already existing dynamic object type. |
|
DynamicObjectType(String typeName)
This allows the programmer to instantiate an already existing dynamic object type. |
|
DynamicObjectType(String name,
ObjectType supertype)
This procedures allows developers to dynamically create object types that subtype existing object types. |
|
DynamicObjectType(String name,
ObjectType supertype,
Model model)
This procedures allows developers to dynamically create object types that may or may not subtype an object. |
Method Summary | |
Property |
addAssociation(String name,
ObjectType objType,
int mult,
Object defaultValue)
Adds a one-way association (a role reference) to this Dynamic ObjectType. |
Property |
addCollectionAssociation(String name,
ObjectType type)
Adds a multiplicitous one-way association (a role reference) to this Dynamic ObjectType. |
Property |
addOptionalAssociation(String name,
ObjectType type)
Adds an optional one-way association (a role reference) to this Dynamic ObjectType. |
Property |
addOptionalAttribute(String name,
SimpleType propertyType)
This adds an Attribute of multiplicity 0..1 which is the equivalent to adding a column to a table without a "not null" constraint |
Property |
addOptionalAttribute(String name,
SimpleType propertyType,
int size)
This adds an Attribute of multiplicity 0..1 which is the equivalent to adding a column to a table without a "not null" constraint |
Property |
addRequiredAssociation(String name,
ObjectType type,
Object defaultValue)
Adds an required one-way association (a role reference) to this Dynamic ObjectType. |
Property |
addRequiredAttribute(String name,
SimpleType propertyType,
int size,
Object defaultValue)
This adds an Attribute of multiplicity 1..1 which is the equivalent to adding a column to a table with a "not null" constraint |
Property |
addRequiredAttribute(String name,
SimpleType propertyType,
Object defaultValue)
This adds an Attribute of multiplicity 1..1 which is the equivalent to adding a column to a table with a "not null" constraint |
ObjectType |
getObjectType()
This method returns the ObjectType that is being manipulated by this DynamicObjectType |
boolean |
hasProperty(String name)
Returns true if this object type has the specified
property. |
static void |
main(String[] args)
This allows the user to either input or output a given data object type x |
String[] |
makeMappingTablesDDL()
Returns an array of Strings containing DDL for new mapping tables. |
String |
makeObjectTypePDL()
Creates the PDL for the object type. |
Collection |
makeTableDDL()
Returns the table creaton DDL. |
void |
removeAttribute(String name)
This removes an attribute from object type definition. |
ObjectType |
save()
This persists the changes made so that the information is stored and will not be lost on server restart. |
String |
toString()
This prints out a String representation of this object type |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
public DynamicObjectType(String name, ObjectType supertype)
supertype
- This is the existing ObjectType that should
be extended to create this ObjectType.
If the supertype is a DynamicObjectType,
it must be saved before saving this new
DynamicObjectType. A supertype can not be nullname
- This is the name of the new object type. This
should only be the name and should not contain
and "." The fully qualified name (which is
required by the other constructor) is the
model of the supertype followed by a "."
followed by the passed in name. This can
be retrieved by calling
DataType.getQualifiedName()
.
The name must not be null.public DynamicObjectType(String name, ObjectType supertype, Model model)
supertype
- This is the existing ObjectType that should
be extended to create this ObjectType.
If the supertype is a DynamicObjectType,
it must be saved before saving this new
DynamicObjectType. A supertype can be null.name
- This is the name of the new object type. This
should only be the name and should not contain
and "." The fully qualified name (which is
required by the other constructor) is the
model of the supertype followed by a "."
followed by the passed in name. This can
be retrieved by calling
DataType.getQualifiedName()
.
The name must not be null and must only contain
alpha-numeric characters.model
- This is the name of the model that will be used
for the object type. If this is specified, it is used
as the object type.public DynamicObjectType(String typeName)
typeName
- The name of the object type to instantiate.
This needs to be the fully qualified name
such as "com.arsdigita.cms.metadata.Hotel"
This is the same name that is returned by
calling
DataType.getQualifiedName()
PersistenceException
- thrown if the requested
type cannot be found or has not yet been savedpublic DynamicObjectType(ObjectType objectType)
objectType
- The object type that should be mutated
PersistenceException
- is thrown if passed in ObjectType
is not mutableMethod Detail |
public boolean hasProperty(String name)
true
if this object type has the specified
property.
public Property addOptionalAttribute(String name, SimpleType propertyType)
name
- The name of the new attributepropertyType
- The type of the Property. This should be
one of the SimpleTypes specified in
MetadataRoot
PersistenceException
- if the name is
already in use for this object typepublic Property addOptionalAttribute(String name, SimpleType propertyType, int size)
name
- The name of the new attributepropertyType
- The type of the Property. This should be
one of the SimpleTypes specified in
MetadataRoot
size
- This is the size of the attribute. This is an
optional argument but is important for Strings.
Specifically, if the String size > 4000 then a
Clob is used. Otherwise, a varchar is used.
PersistenceException
- if the name is
already in use for this object typepublic Property addRequiredAttribute(String name, SimpleType propertyType, Object defaultValue)
You must call save()
for the changes to be permanent
name
- The name of the new attributepropertyType
- The type of the Property. This should be
one of the SimpleTypes specified in
MetadataRoot
defaultValue
- This is the default value for this column. This
is required to be "not null" because it is used to
fill in the values for any rows already in the table.
Due to limitations in the system, however, you must
still set the value on new rows so that you avoid
the "not null" constraint violation
PersistenceException
- if the name is
already in use for this object type or the default
value is nullpublic Property addRequiredAttribute(String name, SimpleType propertyType, int size, Object defaultValue)
You must call save()
for the changes to be permanent
name
- The name of the new attributepropertyType
- The type of the Property. This should be
one of the SimpleTypes specified in
MetadataRoot
size
- This is the size of the attribute. This is an
optional argument but is important for Strings.
Specifically, if the String size > 4000 then a
Clob is used. Otherwise, a varchar is used.
PersistenceException
- if the name is
already in use for this object type or the provided
default is null.public void removeAttribute(String name)
getAttributes()
This does not remove any information from the database. Rather, it simply dereferences the column in the object type. Therefore, if an attribute is removed, the data can still be recovered
You must call save()
for the changes to be permanent
name
- the name of the attribute to remove
ModelException
- if the name passed
in is not an Attribute that can be removedpublic Property addOptionalAssociation(String name, ObjectType type)
name
- the name of the role referencetype
- the type of the referenced type
public Property addRequiredAssociation(String name, ObjectType type, Object defaultValue)
name
- the name of the role referencetype
- the type of the referenced typedefaultValue
- the default value of this Property
public Property addCollectionAssociation(String name, ObjectType type)
name
- the name of the role referencetype
- the type of the referenced type
public Property addAssociation(String name, ObjectType objType, int mult, Object defaultValue)
name
- the name of the role referencemult
- the multiplicity of the type to adddefaultValue
- the default value of the new Property
public ObjectType save()
public ObjectType getObjectType()
public String makeObjectTypePDL()
public final Collection makeTableDDL()
public final String[] makeMappingTablesDDL()
public String toString()
public static void main(String[] args)
This is only meant to be called from the command line.
the usage is
java com.arsdigita.persistence.metadataDyanmicObjectType
<[import | export]> <DynamicObjectType> <FileLocation>
<StartupScript> <WebAppRoot>
com.arsdigita.cms.MyDynamicType
/home/tomcat/webapps/acs/WEB-INF/resources/enterprise.init
/home/tomcat/webapps/enterprise
java com.arsdigita.persistence.metadata.DynamicObjectType export
com.arsdigita.cms.MyDynamicType /tmp/MyDynamicType.pdl
/home/tomcat/webapps/enterprise/WEB-INF/resources/enterprise.init
/home/tomcat/webapps/enterprise
Make sure that you have the DynamicObjectType.class file in your classpath (which is something that is not in your classpath when you typically start your server)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |