Package com.groiss.wfxml
Class WfXMLForm
java.lang.Object
com.groiss.wfxml.WfXMLObject
com.groiss.wfxml.WfXMLForm
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
WfXMLDocForm
,WfXMLFolder
This class can be used to represent forms. You can create new empty forms and
add content to them. You can also create a WfXMLForm out of an existing
DMSForm.
When you have created a WfXMLForm according to your needs, you can use it for sending within WfXML messages, and for creating DMSForms out of it.
See the super class
When you have created a WfXMLForm according to your needs, you can use it for sending within WfXML messages, and for creating DMSForms out of it.
See the super class
WfXMLObject
for a general explanation and
examples.-
Field Summary
Fields inherited from class com.groiss.wfxml.WfXMLObject
notes, userId
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSubForm
(WfXMLForm form, int subFormId) Add a subform to thisWfXMLForm
.void
attachNote
(WfXMLNote note) Adds a note to this form.void
attachNote
(String subject, String noteContent, String noteCreator, boolean isPrivate) Adds a note to this form.clone()
Use the clone method if you need a copy of this WfXMLForm.createDMSObject
(User defaultCreator) void
Use this method to retrieve the value of one of this form's fields.Returns the form name, with which the form is defined in process definitions.getId()
Returns the id that has been set for this form.getName()
This method returns the form name.getNotes()
Returns aList
with all attached notes.int
Returns the subform id.getSubForms
(String subId) Returns aList
containing all subforms for the given id.int
Returns the version that has been set for this form.org.apache.xmlbeans.XmlObject
void
removeField
(String name) This method removes a field from this form.void
Set a field to a double value.void
This method sets a field to an integer value.void
This method sets a field to a long value.void
Use this method to set a field to various values.void
setFormName
(String formName) Set the form name, with which the form is defined in process definitions.void
Sets an id for thisWfXMLForm
.void
setSubformId
(int id) Set a subform id for this form.void
setVersion
(int version) Use this method to set a version for the form.Methods inherited from class com.groiss.wfxml.WfXMLObject
createInstance, createInstance, getUser, getUser, getUserId, setUserId
-
Field Details
-
formName
-
id
-
version
protected int version -
subformId
protected int subformId -
-
subForms
-
-
Constructor Details
-
WfXMLForm
public WfXMLForm()Creates a completely emptyWfXMLForm
object. Use the setter and add methods to add content to the form. -
WfXMLForm
Creates an emptyWfXMLForm
object and sets a form name, a class name, and a creator user id for the form. Use the setter and add methods to add content to the form.- Parameters:
id
-id
andversion
are used to identify aFormType
when aDMSForm
object is created with this form.version
- The version of theFormType
(seeid
).userId
- With this parameter you can specify the id of a user, who will be used when aDMSForm
is created out of this form. If you don't want to set a special user for creating the form, you can simply passnull
(in that case,WfXMLForm
will try to create theDMSForm
with another user --- default document creator, process instance creator...). If no user can be found, creating theDMSForm
will fail.
-
WfXMLForm
public WfXMLForm(org.apache.xmlbeans.XmlObject obj) -
WfXMLForm
This constructor creates aWfXMLForm
out of aDMSForm
. TheWfXMLForm
will contain all fields, referenced forms, subforms, and attached notes.
-
-
Method Details
-
setId
Sets an id for thisWfXMLForm
. Together, id and version are used to identify theFormType
of which thisWfXMLForm
is.- Parameters:
id
- The id you want to set for this form.
-
getId
Returns the id that has been set for this form. Together, id and version specify theFormType
of which thisWfXMLForm
is.- Returns:
- The id of this form.
-
setVersion
public void setVersion(int version) Use this method to set a version for the form. Version and id are used to identify aFormType
, which will be used when aDMSForm
is created.- Parameters:
version
- The new version you want to set for this form.version
should be a positive value.
-
getVersion
public int getVersion()Returns the version that has been set for this form. Version and id are used to identify aFormType
, which will be used when aDMSForm
is created.- Returns:
- The version which has been set for this form. A value of
-1
indicates, that no version has been set.
-
setSubformId
public void setSubformId(int id) Set a subform id for this form. This makes sense if you want to use this form as subform.- Parameters:
id
- The subform id (should be a positive value).
-
getSubformId
public int getSubformId()Returns the subform id.- Returns:
- The subform id. A value of
-1
means, that no subform id has been set.
-
getFormName
Returns the form name, with which the form is defined in process definitions.- Returns:
- A string containing the form name or
null
if no form name has been specified.
-
setFormName
Set the form name, with which the form is defined in process definitions.- Parameters:
formName
- A string containing the form name
-
setField
This method sets a field to a long value. If you get the field value with thegetField
method, you will receive aLong
object.- Parameters:
name
- Name of the field. If a field with this name already exists, the old value will be overwritten.value
- An integer value for that field.
-
setField
This method sets a field to an integer value. If you get the field value with thegetField
method, you will receive aInteger
object.- Parameters:
name
- Name of the field. If a field with this name already exists, the old value will be overwritten.value
- An integer value for that field.
-
setField
Set a field to a double value. If you get the value later withgetField(java.lang.String)
you will receive aDouble
object.- Parameters:
name
- Name of the parameter you want to set.value
- A decimal value.
-
setField
Use this method to set a field to various values.value
can be one of the following:
String
, a simple text value.Long
, an integer value (you can usesetField(String, long)
to set a long value without creating an object.).Double
, a decimal value (see alsosetField(String, double)
).Date
, a date (and time) value.User
, a user.Role
, a role.OrgUnit
, a organizational unit.WfXMLForm
, a reference to another form.
- Parameters:
name
- The name of the field. If a field with this name already exists, the old field value will be lost.value
- An Object holding the value that you want to set.
-
getField
Use this method to retrieve the value of one of this form's fields. The method returns an object of typeObject
because it is not sure what lies behind the field. Object can be one of the following:- Parameters:
name
- The name of the field that you want to retrieve.- Returns:
- An object representing the value of the field, or
null
if no value is set for a field with the namename
.
-
removeField
This method removes a field from this form. If the field does not exist, nothing happens.- Parameters:
name
- The name of the field you want to remove.
-
addSubForm
Add a subform to thisWfXMLForm
. You must specify an id for adding the subform. The type of the added form is set toTYPE_SUB
automatically.- Parameters:
form
- AWfXMLForm
you want to add as subform.subFormId
- The id for which the subform will be added.
-
getSubForms
-
attachNote
Adds a note to this form. The note will be attached to the form, whenDMSObject
objects are created with thecreateDMSObject
method.- Parameters:
subject
- A subject for the note.noteContent
- The content of the note.noteCreator
- The user id of the user who is the creator of the note. If you don't want to set a special user here, usenull
. In that case another user will be used for creating the note (line in thecreateDMSObject
method.isPrivate
-true
makes the note private, thus being viewable only for its creator.false
means that the note is public and can be viewed by anybody.
-
attachNote
Adds a note to this form. The note will be attached to the form, whenDMSObject
objects are created with thecreateDMSObject
method.- Parameters:
note
- AWfXMLNote
object representing the note that you want to add.
-
getNotes
- Returns:
- A list containing all attached notes as
WfXMLNote
objects. Use the returned list in a read-only way!
-
createDMSObject
This method createsDMSObject
objects out of thisWfXMLForm
. At least aDMSForm
object will be created. That object represents this form. Additionally other objects may be created (e.g., subforms, notes, ...).
All these objects will be created with the users who have been set for them. If no user has been set, the method will use thedefaultCreator
to create objects. If no user can be found at all, an exception is thrown.- Specified by:
createDMSObject
in classWfXMLObject
- Parameters:
defaultCreator
- DMSObjects will be created with this user, if no particular user is defined for them. If you don't want to set a default creator, simply passnull
.- Returns:
- A reference to the
DMSForm
, which represents thisWfXMLForm
. - Throws:
Exception
- if creating theDMSForm
fails (e.g., no user found, etc.).
-
fill
This method fills an existingDMSForm
with the values of thisWfXMLForm
. It's similar tocreateDMSObject(com.groiss.org.User)
, with the only difference, that theDMSForm
must already exist.
Notes and subforms will also be created and attached to theDMSForm
. All values that have been defined in thisWfXMLForm
will be set in theDMSForm
. So values, which exist in theDMSForm
, will not be changed, if they are not defined in theWfXMLForm
...
After filling the form with data, changes are stored in the database.- Specified by:
fill
in classWfXMLObject
- Parameters:
existingForm
- An existingDMSForm
, which will be filled with the values set in thisWfXMLForm
. If you pass an object of a different type to this method, nothing will be done.defaultCreator
- A default user for creating objects (notes, subforms), if no particular user is defined for creating them. You can set this parameter tonull
if you don't want to provide a default creator.- Throws:
Exception
- if no user could be found, or if something fails while objects are created and attached/added.
-
getName
This method returns the form name. The form name is the name of the form, as it is displayed in a DMS folder when a form is located there. The form name is one or more of the form fields (the form type defines which form fields have to be used to build the form name). For getting the form name the correspondingFormType
must be present (id
andversion
). If no such form type exists on the local server,null
will be returned.- Specified by:
getName
in classWfXMLObject
- Returns:
- Returns the name of the form, or
null
if the name cannot be read. That might happen if the specified form type is not available, or if the form does not contain any of the fields which form the name.
-
getXMLObject
public org.apache.xmlbeans.XmlObject getXMLObject()- Specified by:
getXMLObject
in classWfXMLObject
-
clone
Use the clone method if you need a copy of this WfXMLForm. This method creates a kind of deep copy of the WfXMLForm, but, in fact, the copy is not completely deep.
So, what will be copied is the following:
- id
- version
- formName
- userId
- type (main, reference, sub)
- fields plus simple String field values
- subform ids
But: All WfXMLForm objects that have been added to this WfXMLForm object (as subForms or fields) will not be cloned! For most cases this is a good behavior.
What you can do with the cloned form (without affecting the old form) includes:
- changing id, version, form name, type
- adding new fields
- removing fields
- adding new subforms
- attaching notes
The only thing you must take care with, is when you want to perform changes on other WfXMLForm objects or WfXMLNotes:
- when you retrieve a WfXMLForm with
getField(String)
, you will retrieve a reference to the WfXMLForm object which is still referenced by the old form (of which the copy was made), too. - when you get a List of subforms with the
getSubForms
method, changes to that list do not affect the old form (because that List has been copied, too), but: the WfXMLForm objects referenced by this List were not copied, so again you retrieve references to the same WfXMLForm objects that are also still referenced by the old form, when you access the List's content. getNotes
gives you a list of all notes. This list is copied, so changes to the list don't affect the old WfXMLForm. If you access the content of the list and if you change theWfXMLNote
objects, which are in the list, theWfXMLNote
objects of the old WfXMLForm are also changed.
So, if there is really need of changing a subform or a referenced form, you should do the following:
- get the form (e.g.,
getField
) - remove the form (e.g.,
removeField
) - clone the form
- do changes on the form
- and finally add the changed form again
new WfXMLForm(null, yourOldForm.getAsXML())
This, in fact, creates a real deep copy with all subforms and referenced forms, because first XML code is genereted and then a new WfXMLForm is build with that XML code... (which is expensive, of course).
-