Class DisplayConstraint


  • public class DisplayConstraint
    extends java.lang.Object
    Representation of a PathQuery constraint for use by JSP pages. This object provides methods needed to populate constraint editing boxes and dropdowns, find available bag names, etc. Can either represent a new constraint to be added with no values set or an existing constraint that is being edited. Get methods return null if no values are available
    Author:
    Richard Smith
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AutoCompleter getAutoCompleter()
      Return the autocompleter for this path if one is available.
      java.util.List<DisplayConstraint.DisplayConstraintOption> getBagOps()
      Return the valid constraint ops when constraining on a bag.
      java.util.List<java.lang.String> getBags()
      Get a list of public and user bag names available and currentfor this path.
      java.lang.String getBagType()
      Returns the bag type that the constraint can be constrained to.
      java.util.Set<java.lang.String> getCandidateLoops()
      Returns the set of paths that could feasibly be loop constrained onto the constraint's path, given the query's outer join situation.
      java.lang.String getCode()
      If editing an existing constraint get the code for this constraint in the query, return null if creating a new constraint.
      java.lang.String getDescription()
      Return the label associated with a constraint if editing a template query constraint.
      java.lang.String getEndClassName()  
      java.lang.String getExtraConnectFieldPath()  
      java.lang.String getExtraConstraintClassName()
      If a LOOKUP constraint and an extra value constraint is available return the classname of the extra constraint so it can be displayed.
      java.util.List<java.lang.Object> getExtraConstraintValues()
      If a LOOKUP constraint and an extra constraint is available for this path, return a list of the possible values for populating a dropdown.
      java.lang.String getExtraValueFieldClass()  
      java.util.List<DisplayConstraint.DisplayConstraintOption> getFixedOps()
      If a dropdown is available for a constraint fewer operations are possible, return the list of operations.
      java.lang.String getHelpMessage()
      Return a help message to display alongside the constraint, this will examine the constraint type and generate and appropriate message, e.g.
      java.lang.String getKeyFields()
      Return the key fields for this path as a formatted string, for use in LOOKUP help message.
      DisplayConstraint.DisplayConstraintOption getLookupOp()
      Return the LOOKUP constraint op.
      java.util.List<DisplayConstraint.DisplayConstraintOption> getLoopQueryOps()
      Returns the set of operators valid for loop constraints.
      java.util.Collection<java.lang.String> getMultiValues()
      Returns the value collection if the constraint is a multivalue, otherwise return null.
      java.lang.String getMultiValuesAsString()
      If the constraint is a multivalue, returns the value collection represented as string separated by ', ', otherwise return an empty String.
      java.lang.String getOriginalValue()  
      DisplayPath getPath()
      Get a representation of the path that is being constraint.
      java.util.List<java.lang.Object> getPossibleValues()
      Values to populate a dropdown for the path if possible values are available.
      java.util.List<DisplayConstraint.DisplayConstraintOption> getRangeQueryOps()
      Returns the set of operators valid for range constraints.
      java.lang.String getSelectedConstraint()
      Returns the constraint type selected.
      java.lang.String getSelectedExtraValue()
      If editing an existing LOOKUP constraint return the value selected for the extra constraint field.
      DisplayConstraint.DisplayConstraintOption getSelectedOp()
      If the bag is selected, return the value setted with the method setSelectedBagOp If editing an existing constraint return the operation used.
      java.lang.String getSelectedValue()
      If editing an existing constraint, return the selected value.
      java.lang.String getSwitchable()
      Return the value on, off, locked depending on the constraint SwitchOffAbility .
      java.lang.String getTitle()
      Return the last class in the path and fieldname as the title for the constraint.
      java.util.List<DisplayConstraint.DisplayConstraintOption> getValidOps()
      Given the path being constrained return the valid constraint operations.
      boolean isBagSelected()
      Return true if editing an existing constraint and a bag has been selected.
      boolean isBoolean()
      Return true if editing an existing having the attribute type boolean or Boolean
      boolean isDisabled()
      Return true if the constraint is disabled, false if it is enabled or locked.
      boolean isEditableInTemplate()
      Return true if editing an existing template constraint and that constraint is editable.
      boolean isEnabled()
      Return true if the constraint is enabled, false if it is disabled or locked.
      boolean isExtraConstraint()
      Return true if this is a LOOKUP constraint and an extra constraint should be available.
      boolean isInputFieldDisplayed()
      Return true if the input field can be displayed, method for use in JSP
      boolean isLocked()
      Return true if the constraint is locked, it should'n be enabled or disabled.
      boolean isLookup()
      Return true if this constraint should be a LOOKUP, true if constraining a class (ref/col) instead of an attribute and that class has class keys defined.
      boolean isLoopSelected()
      Return true if editing an existing constraint and a loop value has been selected.
      boolean isMultiValuesDisplayed()
      Return true if the multi-select containing the possibleValue can be displayed, method for use in JSP
      boolean isMultiValueSelected()
      Return true if editing an existing constraint and a multivalue has been selected.
      boolean isNullSelected()
      Return true if editing an existing constraint and 'has a value' or 'has no value' has been selected.
      boolean isPossibleValuesDisplayed()
      Return true if the drop-down containing the possibleValues can be displayed, method for use in JSP
      boolean isRangeSelected()
      Return true if editing an existing constraint and a range has been entered.
      boolean isShowExtraConstraint()  
      boolean isValidRange()  
      boolean isValueSelected()
      Return true if editing an existing constraint and an attribute value or LOOKUP constraint was selected.
      void setBagSelected​(boolean isBagSelected)
      Set if the bag is selected, used by the method isBagSelected that returns true, even if the constraint is an attribute constraint
      protected void setCode​(java.lang.String code)  
      protected void setEditableInTemplate​(boolean editableInTemplate)  
      protected void setLabel​(java.lang.String label)
      Set the label of the constraint.
      protected void setOriginalConstraint​(PathConstraint con)  
      void setSelectedBagOp​(ConstraintOp selectedBagOp)
      Set the seletedBagOp
      void setSelectedBagValue​(java.lang.String selectedBagValue)
      Set the seletedBagValue returned bye the getSelectedValue if the bag is selected
      void setShowExtraConstraint​(boolean showExtraConstraint)  
      void setSwitchOffAbility​(SwitchOffAbility switchOffAbility)
      Set the switchOffAbility
      protected void setTemplatesummary​(java.util.List<java.lang.Object> templateSummary)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DisplayConstraint

        protected DisplayConstraint​(Path path,
                                    Profile profile,
                                    PathQuery query,
                                    AutoCompleter ac,
                                    ObjectStoreSummary oss,
                                    BagQueryConfig bagQueryConfig,
                                    java.util.Map<java.lang.String,​java.util.List<FieldDescriptor>> classKeys,
                                    BagManager bagManager)
        Construct for a new constraint that is being added to a query.
        Parameters:
        path - The path that is being constrained
        profile - user editing the query, used to fetch available bags
        query - the PathQuery, in order to provide information on candidate loops
        ac - auto completer
        oss - summary data for the ObjectStore contents
        bagQueryConfig - addition details for needed for LOOKUP constraints
        classKeys - identifier field config, needed for LOOKUP constraints
        bagManager - provides access to saved bags
    • Method Detail

      • getCode

        public java.lang.String getCode()
        If editing an existing constraint get the code for this constraint in the query, return null if creating a new constraint.
        Returns:
        the constraint code or null
      • isEditableInTemplate

        public boolean isEditableInTemplate()
        Return true if editing an existing template constraint and that constraint is editable.
        Returns:
        true if an editable template constraint, or null
      • getPath

        public DisplayPath getPath()
        Get a representation of the path that is being constraint. DisplayPath provides convenience methods for use in JSP.
        Returns:
        the path being constrained
      • getSelectedValue

        public java.lang.String getSelectedValue()
        If editing an existing constraint, return the selected value. Otherwise return null. If an attribute constraint this will be the user entered. If a bag constraint, the selected bag name, etc. If an attribute constraint, but the use bag is setted, this will be the selectedBagValue setted
        Returns:
        the selected value or null
      • getOriginalValue

        public java.lang.String getOriginalValue()
        Returns:
        the value property of the underlying constraint, if any.
      • getMultiValues

        public java.util.Collection<java.lang.String> getMultiValues()
        Returns the value collection if the constraint is a multivalue, otherwise return null.
        Returns:
        a Collection of Strings
      • getMultiValuesAsString

        public java.lang.String getMultiValuesAsString()
        If the constraint is a multivalue, returns the value collection represented as string separated by ', ', otherwise return an empty String.
        Returns:
        a String representing the multivalues of constraint
      • isBagSelected

        public boolean isBagSelected()
        Return true if editing an existing constraint and a bag has been selected.
        Returns:
        true if a bag has been selected
      • setBagSelected

        public void setBagSelected​(boolean isBagSelected)
        Set if the bag is selected, used by the method isBagSelected that returns true, even if the constraint is an attribute constraint
        Parameters:
        isBagSelected - true if a bag has been selected
      • isNullSelected

        public boolean isNullSelected()
        Return true if editing an existing constraint and 'has a value' or 'has no value' has been selected.
        Returns:
        true if a null constraint was selected
      • isBoolean

        public boolean isBoolean()
        Return true if editing an existing having the attribute type boolean or Boolean
        Returns:
        true if the type is the primitive boolean or the object java.lang.Boolean
      • isValueSelected

        public boolean isValueSelected()
        Return true if editing an existing constraint and an attribute value or LOOKUP constraint was selected.
        Returns:
        true if an attribute/LOOKUP constraint was selected
      • isLoopSelected

        public boolean isLoopSelected()
        Return true if editing an existing constraint and a loop value has been selected.
        Returns:
        true if a loop constraint was selected
      • isRangeSelected

        public boolean isRangeSelected()
        Return true if editing an existing constraint and a range has been entered.
        Returns:
        true if a range constraint was selected
      • isMultiValueSelected

        public boolean isMultiValueSelected()
        Return true if editing an existing constraint and a multivalue has been selected.
        Returns:
        true if a multivalue constraint was selected
      • getTitle

        public java.lang.String getTitle()
        Return the last class in the path and fieldname as the title for the constraint.
        Returns:
        the title of this constraint
      • getEndClassName

        public java.lang.String getEndClassName()
        Returns:
        the name of the last class in the path of this constraint
      • getDescription

        public java.lang.String getDescription()
        Return the label associated with a constraint if editing a template query constraint.
        Returns:
        the constraint label
      • getHelpMessage

        public java.lang.String getHelpMessage()
        Return a help message to display alongside the constraint, this will examine the constraint type and generate and appropriate message, e.g. list the key fields for LOOKUP constraints and explain the use of wildcards. Returns null when there is no appropriate help.
        Returns:
        the help message or null
      • getSelectedOp

        public DisplayConstraint.DisplayConstraintOption getSelectedOp()
        If the bag is selected, return the value setted with the method setSelectedBagOp If editing an existing constraint return the operation used. Otherwise return null.
        Returns:
        the selected constraint op or null
      • setSelectedBagOp

        public void setSelectedBagOp​(ConstraintOp selectedBagOp)
        Set the seletedBagOp
        Parameters:
        selectedBagOp - the constraint op returned by the method getSelectedOp() if the bag is selected
      • setSelectedBagValue

        public void setSelectedBagValue​(java.lang.String selectedBagValue)
        Set the seletedBagValue returned bye the getSelectedValue if the bag is selected
        Parameters:
        selectedBagValue - string to set the selectedBagValue
      • getSelectedExtraValue

        public java.lang.String getSelectedExtraValue()
        If editing an existing LOOKUP constraint return the value selected for the extra constraint field. Otherwise return null
        Returns:
        the LOOKUP constraint extra value or null
      • getValidOps

        public java.util.List<DisplayConstraint.DisplayConstraintOption> getValidOps()
        Given the path being constrained return the valid constraint operations. If constraining an attribute the valid ops depend on the type being constraint - String, Integer, Boolean, etc.
        Returns:
        the valid constraint operations
      • getLoopQueryOps

        public java.util.List<DisplayConstraint.DisplayConstraintOption> getLoopQueryOps()
        Returns the set of operators valid for loop constraints.
        Returns:
        a List of DisplayConstraintOption objects
      • getRangeQueryOps

        public java.util.List<DisplayConstraint.DisplayConstraintOption> getRangeQueryOps()
        Returns the set of operators valid for range constraints.
        Returns:
        a List of DisplayConstraintOption objects
      • isLookup

        public boolean isLookup()
        Return true if this constraint should be a LOOKUP, true if constraining a class (ref/col) instead of an attribute and that class has class keys defined.
        Returns:
        true if this constraint should be a LOOKUP
      • getAutoCompleter

        public AutoCompleter getAutoCompleter()
        Return the autocompleter for this path if one is available. Otherwise return null.
        Returns:
        an autocompleter for this path or null
      • getPossibleValues

        public java.util.List<java.lang.Object> getPossibleValues()
        Values to populate a dropdown for the path if possible values are available.
        Returns:
        possible values to populate a dropdown
      • getFixedOps

        public java.util.List<DisplayConstraint.DisplayConstraintOption> getFixedOps()
        If a dropdown is available for a constraint fewer operations are possible, return the list of operations.
        Returns:
        the constraint ops available when selecting values from a dropdown
      • isExtraConstraint

        public boolean isExtraConstraint()
        Return true if this is a LOOKUP constraint and an extra constraint should be available.
        Returns:
        true if an extra constraint option is available
      • isShowExtraConstraint

        public boolean isShowExtraConstraint()
        Returns:
        whether we should show the extra constraint.
      • setShowExtraConstraint

        public void setShowExtraConstraint​(boolean showExtraConstraint)
        Parameters:
        showExtraConstraint - whether we should show the extra constraint.
      • getExtraValueFieldClass

        public java.lang.String getExtraValueFieldClass()
        Returns:
        the name of the class that the extra value represents
      • getExtraConnectFieldPath

        public java.lang.String getExtraConnectFieldPath()
        Returns:
        the path for the extra value connection field.
      • getExtraConstraintValues

        public java.util.List<java.lang.Object> getExtraConstraintValues()
        If a LOOKUP constraint and an extra constraint is available for this path, return a list of the possible values for populating a dropdown. Otherwise return null.
        Returns:
        a list of possible extra constraint values
      • getExtraConstraintClassName

        public java.lang.String getExtraConstraintClassName()
        If a LOOKUP constraint and an extra value constraint is available return the classname of the extra constraint so it can be displayed. Otherwise return null.
        Returns:
        the extra constraint class name or null
      • getKeyFields

        public java.lang.String getKeyFields()
        Return the key fields for this path as a formatted string, for use in LOOKUP help message.
        Returns:
        a formatted string listing key fields for this path
      • getBags

        public java.util.List<java.lang.String> getBags()
        Get a list of public and user bag names available and currentfor this path. If none available return null.
        Returns:
        a list of available bag names or null
      • getBagType

        public java.lang.String getBagType()
        Returns the bag type that the constraint can be constrained to. If there aren't bags return null
        Returns:
        a String
      • getSelectedConstraint

        public java.lang.String getSelectedConstraint()
        Returns the constraint type selected.
        Returns:
        a String representing the constraint type selected
      • getCandidateLoops

        public java.util.Set<java.lang.String> getCandidateLoops()
                                                          throws PathException
        Returns the set of paths that could feasibly be loop constrained onto the constraint's path, given the query's outer join situation. A candidate path must be a class path, of the same type, and in the same outer join group.
        Returns:
        a Set of String paths that could be loop joined
        Throws:
        PathException - if something goes wrong
      • isValidRange

        public boolean isValidRange()
        Returns:
        true if this path can legally be used with a range constraint.
      • isLocked

        public boolean isLocked()
        Return true if the constraint is locked, it should'n be enabled or disabled.
        Returns:
        true if the constraint is locked
      • isEnabled

        public boolean isEnabled()
        Return true if the constraint is enabled, false if it is disabled or locked.
        Returns:
        true if the constraint is enabled,false if it is disabled or locked
      • isDisabled

        public boolean isDisabled()
        Return true if the constraint is disabled, false if it is enabled or locked.
        Returns:
        true if the constraint is disabled,false if it is enabled or locked
      • getSwitchable

        public java.lang.String getSwitchable()
        Return the value on, off, locked depending on the constraint SwitchOffAbility .
        Returns:
        switchable property (on, off, locked)
      • setSwitchOffAbility

        public void setSwitchOffAbility​(SwitchOffAbility switchOffAbility)
        Set the switchOffAbility
        Parameters:
        switchOffAbility - value
      • isInputFieldDisplayed

        public boolean isInputFieldDisplayed()
        Return true if the input field can be displayed, method for use in JSP
        Returns:
        true if the input is displayed
      • isPossibleValuesDisplayed

        public boolean isPossibleValuesDisplayed()
        Return true if the drop-down containing the possibleValues can be displayed, method for use in JSP
        Returns:
        true if the drop-down is displayed
      • isMultiValuesDisplayed

        public boolean isMultiValuesDisplayed()
        Return true if the multi-select containing the possibleValue can be displayed, method for use in JSP
        Returns:
        true if the multi-select is displayed
      • setEditableInTemplate

        protected void setEditableInTemplate​(boolean editableInTemplate)
        Parameters:
        editableInTemplate - whether this should be editable in a template.
      • setLabel

        protected void setLabel​(java.lang.String label)
        Set the label of the constraint.
        Parameters:
        label - The new label.
      • setOriginalConstraint

        protected void setOriginalConstraint​(PathConstraint con)
        Parameters:
        con - the original underlying constraint.
      • setCode

        protected void setCode​(java.lang.String code)
        Parameters:
        code - the constraint identifier.
      • setTemplatesummary

        protected void setTemplatesummary​(java.util.List<java.lang.Object> templateSummary)
        Parameters:
        templateSummary - the template summary.