Interface StructureView
StructureView represents a view - a named collection of parameters (such as grid columns) that are used
to configure how Structure widget displays a structure.
The main property of a StructureView is view specification, which defines the visual configuration.
Other properties - id, name, description, permissions and owner - help manage the views.
You typically get an instance of StructureView by calling get... methods of StructureViewManager.
Like Structure, an instance of StructureView is mutable — you can change its properties, but to
have changes take effect you need to save them using saveChanges().
To create a new view, call StructureViewManager.createView() to get
an empty StructureView instance, call set... methods to set the properties (at least, view name and view specification must be set)
and then call saveChanges().
When saveChanges has completed, the new View has been created and you can use getId() to get the
new view's ID.
Like structures, views also have an owner and a set of permission rules. The similar access level calculation
algorithm applies for the views, except that PermissionRule.ApplyStructure rules are ignored.
Access level applied to view has the following meaning:
PermissionLevel.NONE- the view is not accessible for the user.PermissionLevel.VIEW- the user can apply this view when viewing any structure. The user can adjust the visual configuration in the browser by, say, adding columns, but they won't be able to save the changes as the new view specification.PermissionLevel.EDIT- the user can use the view and also change its specification (save the adjustments they made in browser). The user won't be able to change other properties of the view, like name or permissions.PermissionLevel.ADMIN- the user can make any change of the view or delete it.
Instances of classes implementing this interface have reference equality: their equals()
and hashCode() behave in the same way as Object's.
The implementations of this interface are not thread-safe. Every thread must obtain their
own copy of the StructureView instance. Moreover, every time you need an
instance of StructureView, you should get it from the StructureViewManager
because the properties might have changed or the view might have been deleted.
- Since:
- 7.2.0 (Structure 2.0)
- Author:
- Igor Sereda
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the description of the view or an empty string if description was not setgetEffectivePermission(ApplicationUser user) Calculates access level to this view for the specified user.longgetId()Returns the ID of the view, or0if the view has no ID (when it's new and hasn't been saved yet).getName()Returns the name of the view or an empty string if the view name has not been set yetApplicationUsergetOwner()Returns the owner of the view, ornullif the view has no owner.Used to get permissions rules that are used to calculate user's access level.Returns the view specification, which defines the visual configuration of the widgetbooleanisPublic()Checks if the view is "public", that is, everyone has at leastVIEWaccess to it.booleanisShared()Checks if the view is "shared", that is, the permission rules give at leastVIEWaccess to someone.Convenience method that modifies the view's permission rules, making it viewable by anyone.Call this method to save the changes made withset...methods and update the database.setDescription(String description) Sets the description of the view.Sets the name of the view.setOwner(ApplicationUser owner) Sets the owner of the view.setPermissions(Collection<? extends PermissionRule> permissions) Sets the permission rules for this view.setSpecification(ViewSpecification specification) Sets the specification of the view, which defines the visual configuration of the gadget.setSpecification(ViewSpecification.Builder specification) Sets the specification of the view, which defines the visual configuration of the gadget.update(StructureViewBean.Builder builder) Updates the properties that have been set (have non-null value) in the passed builder.
-
Method Details
-
getId
long getId()Returns the ID of the view, or0if the view has no ID (when it's new and hasn't been saved yet).- Returns:
- the ID of the view, or 0 if it doesn't yet have an ID
-
getName
Returns the name of the view or an empty string if the view name has not been set yet -
getDescription
Returns the description of the view or an empty string if description was not set -
getSpecification
Returns the view specification, which defines the visual configuration of the widget- See Also:
-
getOwner
@Nullable ApplicationUser getOwner()Returns the owner of the view, ornullif the view has no owner. In the latter case, it is manageable by JIRA administrators, or whoever hasPermissionLevel.ADMINaccess to it. -
getPermissions
Used to get permissions rules that are used to calculate user's access level. As with the permission rules forStructure, the last matching rule defines the access level.- Returns:
- permission rules used to calculate the user's access level to this view
-
getEffectivePermission
Calculates access level to this view for the specified user. If the user is not allowed to use Structure plugin, the result will always be
PermissionLevel.NONE.This method does not take into account pending changes to the permissions list made through
setPermissions(java.util.Collection<? extends com.almworks.jira.structure.api.permissions.PermissionRule>)method call, until they are committed to the database withsaveChanges().This method does not take into account
authentication context.- Parameters:
user- the user, null means anonymous- Returns:
- the permissions level
- See Also:
-
isPublic
boolean isPublic()Checks if the view is "public", that is, everyone has at leastVIEWaccess to it.This method takes into account the pending changes to permissions made through
setPermissions(java.util.Collection<? extends com.almworks.jira.structure.api.permissions.PermissionRule>).- Returns:
- true if the view is public
-
setName
Sets the name of the view. Although it is possible to set name to null, it is an invalid value and
saveChangeswill throw an error when called, unless a non-null name is set.To store the changed information in the database, use
saveChanges().- Parameters:
name- view name;nullis interpreted as "don't change"- Returns:
- this view
-
setDescription
Sets the description of the view.
To store the changed information in the database, use
saveChanges().- Parameters:
description- view description;nullis interpreted as "don't change"- Returns:
- this view
-
setOwner
Sets the owner of the view.
To store the changed information in the database, use
saveChanges().- Parameters:
owner- new owner.nullis interpreted as "don't change".- Returns:
- this view
-
setPermissions
Sets the permission rules for this view. Like with
Structure, permission rules are evaluated in the specified order and the last matching rule defines the access level to the view for the given user.View owner and JIRA administrators always have
PermissionLevel.ADMINaccess level.Currently only
PermissionRule.SetLevelrules are allowed for views.To store the changed information in the database, use
saveChanges(). At this point, the specified rules are validated, andStructureExceptionis thrown if any of them is found invalid.- Parameters:
permissions- a collection of permissions.nullis interpreted as "don't change"- Returns:
- this view
-
setSpecification
Sets the specification of the view, which defines the visual configuration of the gadget.
This method is intended for cases where you already have a ready specification that needs to be saved in a view. If you are building a specification, consider using
setSpecification(ViewSpecification.Builder)}.To store the changed information in the database, use
saveChanges().- Parameters:
specification- view specification.nullis interpreted as "don't change"- Returns:
- this view
-
setSpecification
Sets the specification of the view, which defines the visual configuration of the gadget.
This method is intended for cases where you build a new specification or adjust an existing specification via
ViewSpecification.Builder. If you already have a ready instance ofViewSpecification, you can set it withsetSpecification(ViewSpecification).To store the changed information in the database, use
saveChanges().- Parameters:
specification- view specification.nullis interpreted as "don't change"- Returns:
- this view
-
update
Updates the properties that have been set (have non-null value) in the passed builder. SeeStructureViewBeanfor details on the builder.To store the changed information in the database, use
saveChanges().- Parameters:
builder- the builder with view properties- Returns:
- this view
-
makePublic
Convenience method that modifies the view's permission rules, making it viewable by anyone.
If permission list contains rules that give higher than
permission to someone, those rules are retained. Other rules are removed.PermissionLevel.VIEWTo store the changed information in the database, use
saveChanges().- Returns:
- this view.
-
saveChanges
Call this method to save the changes made with
set...methods and update the database.Before this method is called, all changes are only stored in this instance of
StructureViewand have no other effect. After this method has successfully executed, the changes are stored in the database and applied.The updater -
the current user- must havePermissionLevel.ADMINaccess level to the view and be allowed to use Structure plugin inStructureConfiguration. Anyone, except anonymous, can create new views. To share a view with someone else, the user needs to have "Create Shared Objects" global permission.All security checks can be
disabledfor the current context.For detailed description of the permission rules validation, see
Structure.saveChanges().- Returns:
- this view
- Throws:
StructureException- if there's a permissions problem, if required fields (name, specification) are not set, or if there are other problems- See Also:
-