Package com.groiss.wfxml
Class WfXMLObject
java.lang.Object
com.groiss.wfxml.WfXMLObject
- Direct Known Subclasses:
WfXMLForm
,WfXMLNote
,WfXMLWebLink
WfXMLObject and its subclasses are used to easily access, modify and create
Therefore the hierarchical structure of these WfXML classes is similar to the structure of the
The mapping between WfXMLObject objects and
Let's take a look on what you can do with WfXMLObject objects:
DMSObject
objects and to do a transformation to and
from XML.Therefore the hierarchical structure of these WfXML classes is similar to the structure of the
DMSObject
interface and its subinterfaces.The mapping between WfXMLObject objects and
DMSObject
objects works like this:WfXMLNote
--DMSNote
WfXMLWebLink
--DMSWebLink
WfXMLForm
--DMSForm
WfXMLDocForm
--DMSDocForm
WfXMLFolder
--DMSFolder
WfXMLObject
--DMSObject
Let's take a look on what you can do with WfXMLObject objects:
- First, you can create WfXMLObject objects in three different ways:
- You can create a new and empty WfXMLObject with one of the subclasses' constructors.
- You can create a WfXMLObject out of an existing
DMSObject
. There are two possible ways to do that. If you know the exact type ofDMSObject
that you have, then you should use a constructor of the corresponding WfXML class. If you don't know the exact type, you can use the staticcreateInstance(DMSObject)
method of this class (WfXMLObject) to create the right WfXMLObject out of yourDMSObject
. - And you can create a WfXMLObject out of a JDOM
Element
object, which typically has been created using one of the WfXMLObject subclasses (but of course, the XML structure can also come from somewhere else). If you know which type of WfXMLObject theElement
holds, you can use a constructor of the corresponding subclass again. If you don't know the type, you should take the staticcreateInstance(Element)
method for that purpose. - Examples:
WfXMLNote
myNote = newWfXMLNote
("About this", "This is the WfXMLObject class", "gerhard", false);
WfXMLObject myObject = WfXMLObject.createInstance(someDMSObject);
WfXMLForm
myForm = newWfXMLForm
(anyDMSForm);
- Once you have a WfXMLObject, you can modify it with various methods (change name/id/etc.; add and change content, fields, and so on).
- When you created and changed a WfXMLObject according to your needs, you
can do two things with it:
- You can create
DMSObject
objects out of the WfXMLObject by calling thecreateDMSObject(User)
method. - And you can use the WfXMLObject to update an existing
DMSObject
with thefill(com.groiss.dms.DMSObject, com.groiss.org.User)
method. - So, using the objects created above, you could do:
DMSObject aNewDMSObject = myObject.createDMSObject("gerhard");
(note, that you don't need to know the type of WfXMLObject at all...)
myObject.fill(existingDMSObject, aUser);
myForm.setField("subject", "Whatever you want");
myForm.attachNote(myNote);
DMSForm
newDMSForm = myForm.createDMSObject(null);
- You can create
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
This default constructor is called implicitly when one of the subclasses is instanciated. -
Method Summary
Modifier and TypeMethodDescriptionabstract DMSObject
createDMSObject
(User defaultCreator) This method creates aDMSObject
out of a WfXMLObject.static WfXMLObject
createInstance
(DMSObject obj) Use this method to create a WfXMLObject out of aDMSObject
.static WfXMLObject
createInstance
(org.apache.xmlbeans.XmlObject elem) abstract void
This method is used for updating existingDMSObject
objects with data fromWfXMLObject
objects.abstract String
getName()
Returns the name of thisWfXMLObject
.getUser()
protected User
This method tries to get a user defined in this WfXMLObject.Get the id of the user who should be used to create aDMSObject
out of this WfXMLObject.abstract org.apache.xmlbeans.XmlObject
void
Set a user (by its id), who will be used when aDMSObject
is created out of this WfXMLObject.
-
Field Details
-
notes
-
userId
-
-
Constructor Details
-
WfXMLObject
protected WfXMLObject()This default constructor is called implicitly when one of the subclasses is instanciated. It creates a collection object for storing attached notes.
-
-
Method Details
-
createInstance
-
getUserId
Get the id of the user who should be used to create aDMSObject
out of this WfXMLObject.- Returns:
- The id of the user who should be used to create the document, or
null
if no user has been specified.
-
getUser
Returns aUser
object representing the user who will be used to create aDMSObject
out of this WfXMLObject. Ifnull
is returned, the defined user was not found on the system.- Returns:
- A
User
object of the user who should create this object ornull
if the user is not available.
-
getUser
This method tries to get a user defined in this WfXMLObject. If there is no user, it simply returns the defaultUser that you passed in to the method. As this is usually performed quite often, this method is useful.- Parameters:
defaultUser
- You can provide a default user here. If no user is found in the WfXMLObject object, you will get this default user back. Mind: if you passnull
and no user is found, you will getnull
back.- Returns:
- The user defined in this WfXMLObject, or
defaultUser
(whatever you passed in to this method) if no user is set in this object.
-
setUserId
Set a user (by its id), who will be used when aDMSObject
is created out of this WfXMLObject.- Parameters:
userId
- The id of the user who you want to set as document creator. You can set this tonull
if you want to remove a previously set user.
-
createInstance
Use this method to create a WfXMLObject out of aDMSObject
. You don't need to care about which type of DMSObject you pass in to this method, it will always return the right type of WfXMLObject.
obj
should be one of the following:
-
createDMSObject
This method creates aDMSObject
out of a WfXMLObject. Depending on the type of WfXMLObject, the rightDMSObject
will be created.
For example: if you callcreateDMSObject
on aWfXMLForm
, you can cast the result toDMSForm
.- Parameters:
defaultCreator
- This optional parameter defines a default creator who will be used for creating theDMSObject
, if no particular user is defined in the WfXMLObject. You can set this parameter tonull
in case you don't want to provide a default creator.- Returns:
- The resulting
DMSObject
. - Throws:
Exception
- if creating the object fails.
-
fill
This method is used for updating existingDMSObject
objects with data fromWfXMLObject
objects. Each subclass implements this method and handles the task of filling existing objects with data and updating them to the database.- Parameters:
object
- The object that has to be filled.defaultCreator
- If any new object must be created, a creator is required. In case that theWfXMLObject
objects themselves don't contain users, it is useful to provide a default creator here.- Throws:
Exception
- if updating the object fails.
-
getName
Returns the name of thisWfXMLObject
.- Returns:
- The name as
String
.
-
getXMLObject
public abstract org.apache.xmlbeans.XmlObject getXMLObject()
-