com.dlsc.flexgantt.policy.layer

## Class DefaultRelationshipPolicy

- java.lang.Object
- - com.dlsc.flexgantt.policy.AbstractPolicy
  - - com.dlsc.flexgantt.policy.layer.DefaultRelationshipPolicy

- All Implemented Interfaces:
    IPolicy, IRelationshipPolicy
  Direct Known Subclasses:
    DefaultConstraintPolicy

      public class DefaultRelationshipPolicy
      extends AbstractPolicy
      implements IRelationshipPolicy

  The default implementation of the `IRelationshipPolicy` allows all timeline objects to be linked with each other and returns a `DefaultCreateRelationshipCommand` command object for performing the actual linking.
  Since:
    1.0
  Version:
    $Revision: 1.5 $
  Author:
    Dirk Lemmermann

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultRelationshipPolicy()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ICommand` | `getCreateRelationshipCommand(TimelineObjectPath sourcePath, TimelineObjectPath targetPath, RelationshipType type, IGanttChartModel model)` Returns a command object that will perform the actual linking of the source and target timeline objects by making the appropriate changes in the model.
    `ICommand` | `getDeleteRelationshipsCommand(Collection<IRelationship> relationships, IGanttChartModel model)` Returns a command object that will perform the actual deletion of several relationship objects from the given model.
    `RelationshipType[]` | `getSupportedRelationshipTypes(TimelineObjectPath path, IGanttChartModel model)` Determines the types of relationships that are supported by the given timeline object (end to start, start to end, start to start, end to end).
    `boolean` | `isDeletable(IRelationship relationship, IGanttChartModel model)` Determines whether the given relationship object is deletable.
    `boolean` | `isRelationshipSource(TimelineObjectPath path, IGanttChartModel model)` Determines whether the given timeline object can be used for creating a relationship to another object.
    `boolean` | `isRelationshipTarget(TimelineObjectPath sourcePath, TimelineObjectPath targetPath, IGanttChartModel model)` Determines whether the given source timeline object can be linked to the given target timeline object.

    - ### Methods inherited from class com.dlsc.flexgantt.policy.AbstractPolicy

      `assertClass`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultRelationshipPolicy

          public DefaultRelationshipPolicy()

  - ### Method Detail

    - #### getSupportedRelationshipTypes

          public RelationshipType[] getSupportedRelationshipTypes(TimelineObjectPath path,
                                                                  IGanttChartModel model)

      Description copied from interface: `IRelationshipPolicy`
      Determines the types of relationships that are supported by the given timeline object (end to start, start to end, start to start, end to end).
      Specified by:
        `getSupportedRelationshipTypes` in interface `IRelationshipPolicy`
      Parameters:
        `path` - the path to the timeline object
        `model` - the model of the nodes and timeline objects
      Returns:
        the supported relationship types

    - #### getCreateRelationshipCommand

          public ICommand getCreateRelationshipCommand(TimelineObjectPath sourcePath,
                                                       TimelineObjectPath targetPath,
                                                       RelationshipType type,
                                                       IGanttChartModel model)

      Description copied from interface: `IRelationshipPolicy`
      Returns a command object that will perform the actual linking of the source and target timeline objects by making the appropriate changes in the model.
      Specified by:
        `getCreateRelationshipCommand` in interface `IRelationshipPolicy`
      Parameters:
        `sourcePath` - the path to the source timeline object
        `targetPath` - the path to the target timeline object
        `type` - the type of relationship that the user wants to create (end to start, start to end, start to start, end to end)
        `model` - the source model of the node and timeline object
      Returns:
        a command that will create a relationship between the timeline objects
      See Also:
        `IRelationship`, `DefaultCreateRelationshipCommand`

    - #### getDeleteRelationshipsCommand

          public ICommand getDeleteRelationshipsCommand(Collection<IRelationship> relationships,
                                                        IGanttChartModel model)

      Description copied from interface: `IRelationshipPolicy`
      Returns a command object that will perform the actual deletion of several relationship objects from the given model.
      Specified by:
        `getDeleteRelationshipsCommand` in interface `IRelationshipPolicy`
      Parameters:
        `relationships` - the relationships to delete
        `model` - the model to which the relationship belongs objects
      Returns:
        a command that will delete the given relationship object from its model
      See Also:
        `IRelationship`, `DefaultDeleteMultipleRelationshipsCommand`

    - #### isDeletable

          public boolean isDeletable(IRelationship relationship,
                                     IGanttChartModel model)

      Description copied from interface: `IRelationshipPolicy`
      Determines whether the given relationship object is deletable. This method delegates to `IRelationship.isDeletable()`.
      Specified by:
        `isDeletable` in interface `IRelationshipPolicy`
      Parameters:
        `relationship` - the relationship to check
        `model` - the model to which the relationship belongs
      Returns:
        TRUE if the user can delete the relationship

    - #### isRelationshipSource

          public boolean isRelationshipSource(TimelineObjectPath path,
                                              IGanttChartModel model)

      Description copied from interface: `IRelationshipPolicy`
      Determines whether the given timeline object can be used for creating a relationship to another object.
      Specified by:
        `isRelationshipSource` in interface `IRelationshipPolicy`
      Parameters:
        `path` - the source timeline object path
        `model` - the model of the node and timeline object
      Returns:
        TRUE if the given timeline object can be used for a relationship object
      See Also:
        `IRelationshipPolicy.isRelationshipTarget(TimelineObjectPath, TimelineObjectPath, IGanttChartModel)`

    - #### isRelationshipTarget

          public boolean isRelationshipTarget(TimelineObjectPath sourcePath,
                                              TimelineObjectPath targetPath,
                                              IGanttChartModel model)

      Description copied from interface: `IRelationshipPolicy`
      Determines whether the given source timeline object can be linked to the given target timeline object.
      Specified by:
        `isRelationshipTarget` in interface `IRelationshipPolicy`
      Parameters:
        `sourcePath` - the source timeline object
        `targetPath` - the target timeline object
        `model` - the model of the nodes and timeline objects
      Returns:
        TRUE if the given source timeline object can be linked with the given target timeline object
      See Also:
        `IRelationshipPolicy.isRelationshipSource(TimelineObjectPath, IGanttChartModel)`

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.