### Home Classes Methods

### In Files

- lib/taskjuggler/PropertyList.rb

### Parent

Object

### Methods

- ::new
- #[]
- #append
- #checkForDuplicates
- #include?
- #includeAdopted
- #index
- #itemIndex
- #method_missing
- #resetSorting
- #setSorting
- #sort!
- #to_ary
- #treeMode?

### Included Modules

- TaskJuggler::MessageHandler

### Files

- CHANGELOG
- COPYING
- README.rdoc

### Class/Module Index

Quicksearch

- TaskJuggler
- TaskJuggler::Account
- TaskJuggler::AccountAttribute
- TaskJuggler::AccountCredit
- TaskJuggler::AccountCreditListAttribute
- TaskJuggler::AccountListRE
- TaskJuggler::AccountScenario
- TaskJuggler::AlertLevelDefinition
- TaskJuggler::AlertLevelDefinitions
- TaskJuggler::Allocation
- TaskJuggler::AllocationAttribute
- TaskJuggler::AttributeBase
- TaskJuggler::AttributeDefinition
- TaskJuggler::AttributeOverwrite
- TaskJuggler::BatchProcessor
- TaskJuggler::Booking
- TaskJuggler::BookingListAttribute
- TaskJuggler::BooleanAttribute
- TaskJuggler::CSVFile
- TaskJuggler::CellSettingPattern
- TaskJuggler::CellSettingPatternList
- TaskJuggler::Charge
- TaskJuggler::ChargeListAttribute
- TaskJuggler::ChargeSet
- TaskJuggler::ChargeSetListAttribute
- TaskJuggler::ChartPlotter
- TaskJuggler::ChartPlotterError
- TaskJuggler::CollisionDetector
- TaskJuggler::ColumnListAttribute
- TaskJuggler::ColumnTable
- TaskJuggler::Daemon
- TaskJuggler::DaemonConnector
- TaskJuggler::DaemonConnectorMixin
- TaskJuggler::DataCache
- TaskJuggler::DataCacheEntry
- TaskJuggler::DateAttribute
- TaskJuggler::DefinitionListAttribute
- TaskJuggler::DependencyListAttribute
- TaskJuggler::DurationAttribute
- TaskJuggler::ExportRE
- TaskJuggler::FileList
- TaskJuggler::FileRecord
- TaskJuggler::FixnumAttribute
- TaskJuggler::FlagListAttribute
- TaskJuggler::FloatAttribute
- TaskJuggler::FormatListAttribute
- TaskJuggler::GanttChart
- TaskJuggler::GanttContainer
- TaskJuggler::GanttHeader
- TaskJuggler::GanttHeaderScaleItem
- TaskJuggler::GanttLine
- TaskJuggler::GanttLoadStack
- TaskJuggler::GanttMilestone
- TaskJuggler::GanttRouter
- TaskJuggler::GanttTaskBar
- TaskJuggler::HTMLDocument
- TaskJuggler::HTMLElements
- TaskJuggler::HTMLGraphics
- TaskJuggler::ICalReport
- TaskJuggler::ICalendar
- TaskJuggler::ICalendar::Component
- TaskJuggler::ICalendar::Event
- TaskJuggler::ICalendar::Journal
- TaskJuggler::ICalendar::Person
- TaskJuggler::ICalendar::Todo
- TaskJuggler::Interval
- TaskJuggler::IntervalList
- TaskJuggler::JobInfo
- TaskJuggler::Journal
- TaskJuggler::JournalEntry
- TaskJuggler::JournalEntryList
- TaskJuggler::JournalSortListAttribute
- TaskJuggler::KateSyntax
- TaskJuggler::KeywordArray
- TaskJuggler::KeywordDocumentation
- TaskJuggler::Leave
- TaskJuggler::LeaveAllowance
- TaskJuggler::LeaveAllowanceList
- TaskJuggler::LeaveAllowanceListAttribute
- TaskJuggler::LeaveList
- TaskJuggler::LeaveListAttribute
- TaskJuggler::Limits
- TaskJuggler::Limits::Limit
- TaskJuggler::LimitsAttribute
- TaskJuggler::ListAttributeBase
- TaskJuggler::Log
- TaskJuggler::LogicalAttribute
- TaskJuggler::LogicalExpression
- TaskJuggler::LogicalExpressionAttribute
- TaskJuggler::LogicalExpressionListAttribute
- TaskJuggler::LogicalFlag
- TaskJuggler::LogicalFunction
- TaskJuggler::LogicalOperation
- TaskJuggler::ManagerResponsibilities
- TaskJuggler::ManagerStatusRecord
- TaskJuggler::Message
- TaskJuggler::MessageHandler
- TaskJuggler::MessageHandlerInstance
- TaskJuggler::MspXmlRE
- TaskJuggler::Navigator
- TaskJuggler::NavigatorElement
- TaskJuggler::NikuProject
- TaskJuggler::NikuReport
- TaskJuggler::NikuResource
- TaskJuggler::NodeListAttribute
- TaskJuggler::PTNProxy
- TaskJuggler::Painter
- TaskJuggler::Painter::Circle
- TaskJuggler::Painter::Color
- TaskJuggler::Painter::Element
- TaskJuggler::Painter::Ellipse
- TaskJuggler::Painter::FontMetrics
- TaskJuggler::Painter::FontMetricsData
- TaskJuggler::Painter::Group
- TaskJuggler::Painter::Line
- TaskJuggler::Painter::Points
- TaskJuggler::Painter::PolyLine
- TaskJuggler::Painter::Primitives
- TaskJuggler::Painter::Rect
- TaskJuggler::Painter::SVGSupport
- TaskJuggler::Painter::Text
- TaskJuggler::PlaceHolderCell
- TaskJuggler::ProcessIntercom
- TaskJuggler::ProcessIntercomIface
- TaskJuggler::Project
- TaskJuggler::ProjectBroker
- TaskJuggler::ProjectBrokerIface
- TaskJuggler::ProjectFileParser
- TaskJuggler::ProjectFileScanner
- TaskJuggler::ProjectRecord
- TaskJuggler::ProjectServer
- TaskJuggler::ProjectServerIface
- TaskJuggler::PropertyAttribute
- TaskJuggler::PropertyList
- TaskJuggler::PropertySet
- TaskJuggler::PropertyTreeNode
- TaskJuggler::Query
- TaskJuggler::RTFHandlers
- TaskJuggler::RTFNavigator
- TaskJuggler::RTFQuery
- TaskJuggler::RTFReport
- TaskJuggler::RTFReportLink
- TaskJuggler::RTFWithQuerySupport
- TaskJuggler::RealFormat
- TaskJuggler::RealFormatAttribute
- TaskJuggler::ReferenceAttribute
- TaskJuggler::Report
- TaskJuggler::ReportBase
- TaskJuggler::ReportContext
- TaskJuggler::ReportScenario
- TaskJuggler::ReportServer
- TaskJuggler::ReportServerIface
- TaskJuggler::ReportServerRecord
- TaskJuggler::ReportServlet
- TaskJuggler::ReportTable
- TaskJuggler::ReportTableCell
- TaskJuggler::ReportTableColumn
- TaskJuggler::ReportTableLegend
- TaskJuggler::ReportTableLine
- TaskJuggler::Resource
- TaskJuggler::ResourceListAttribute
- TaskJuggler::ResourceListRE
- TaskJuggler::ResourceScenario
- TaskJuggler::RichText
- TaskJuggler::RichTextAttribute
- TaskJuggler::RichTextDocument
- TaskJuggler::RichTextElement
- TaskJuggler::RichTextFunctionExample
- TaskJuggler::RichTextFunctionHandler
- TaskJuggler::RichTextImage
- TaskJuggler::RichTextIntermediate
- TaskJuggler::RichTextParser
- TaskJuggler::RichTextScanner
- TaskJuggler::RichTextSnip
- TaskJuggler::RichTextSyntaxRules
- TaskJuggler::Scenario
- TaskJuggler::ScenarioData
- TaskJuggler::ScenarioListAttribute
- TaskJuggler::Scoreboard
- TaskJuggler::ScoreboardInterval
- TaskJuggler::SheetHandlerBase
- TaskJuggler::SheetReceiver
- TaskJuggler::SheetSender
- TaskJuggler::Shift
- TaskJuggler::ShiftAssignment
- TaskJuggler::ShiftAssignments
- TaskJuggler::ShiftAssignmentsAttribute
- TaskJuggler::ShiftScenario
- TaskJuggler::SimpleQueryExpander
- TaskJuggler::SortListAttribute
- TaskJuggler::StatusSheetReceiver
- TaskJuggler::StatusSheetReport
- TaskJuggler::StatusSheetSender
- TaskJuggler::StdIoWrapper
- TaskJuggler::StringAttribute
- TaskJuggler::SymbolAttribute
- TaskJuggler::SymbolListAttribute
- TaskJuggler::SyntaxReference
- TaskJuggler::TOCEntry
- TaskJuggler::TSResourceRecord
- TaskJuggler::TSTaskRecord
- TaskJuggler::TableColumnDefinition
- TaskJuggler::TableColumnSorter
- TaskJuggler::TableOfContents
- TaskJuggler::TableReport
- TaskJuggler::TableReportColumn
- TaskJuggler::TagFile
- TaskJuggler::TagFile::TagFileEntry
- TaskJuggler::Task
- TaskJuggler::TaskDepListAttribute
- TaskJuggler::TaskDependency
- TaskJuggler::TaskListAttribute
- TaskJuggler::TaskListRE
- TaskJuggler::TaskScenario
- TaskJuggler::TernarySearchTree
- TaskJuggler::TextFormatter
- TaskJuggler::TextParser
- TaskJuggler::TextParser::Macro
- TaskJuggler::TextParser::MacroTable
- TaskJuggler::TextParser::Pattern
- TaskJuggler::TextParser::Rule
- TaskJuggler::TextParser::Scanner
- TaskJuggler::TextParser::Scanner::BufferStreamHandle
- TaskJuggler::TextParser::Scanner::FileStreamHandle
- TaskJuggler::TextParser::Scanner::MacroStackEntry
- TaskJuggler::TextParser::Scanner::StreamHandle
- TaskJuggler::TextParser::SourceFileInfo
- TaskJuggler::TextParser::StackElement
- TaskJuggler::TextParser::State
- TaskJuggler::TextParser::StateTransition
- TaskJuggler::TextParser::TextParserResultArray
- TaskJuggler::TextParser::TokenDoc
- TaskJuggler::TextReport
- TaskJuggler::TimeInterval
- TaskJuggler::TimeIntervalListAttribute
- TaskJuggler::TimeSheet
- TaskJuggler::TimeSheetReceiver
- TaskJuggler::TimeSheetRecord
- TaskJuggler::TimeSheetReport
- TaskJuggler::TimeSheetSender
- TaskJuggler::TimeSheetSummary
- TaskJuggler::TimeSheets
- TaskJuggler::Tj3
- TaskJuggler::Tj3AppBase
- TaskJuggler::Tj3Client
- TaskJuggler::Tj3Daemon
- TaskJuggler::Tj3Man
- TaskJuggler::Tj3SheetAppBase
- TaskJuggler::Tj3SsReceiver
- TaskJuggler::Tj3SsSender
- TaskJuggler::Tj3TsReceiver
- TaskJuggler::Tj3TsSender
- TaskJuggler::Tj3TsSummary
- TaskJuggler::Tj3WebD
- TaskJuggler::TjException
- TaskJuggler::TjRuntimeError
- TaskJuggler::TjTime
- TaskJuggler::TjpExample
- TaskJuggler::TjpExportRE
- TaskJuggler::TjpSyntaxRules
- TaskJuggler::TraceReport
- TaskJuggler::URLParameter
- TaskJuggler::UserManual
- TaskJuggler::VimSyntax
- TaskJuggler::WebServer
- TaskJuggler::WelcomePage
- TaskJuggler::WorkingHours
- TaskJuggler::WorkingHoursAttribute
- TaskJuggler::XMLBlob
- TaskJuggler::XMLComment
- TaskJuggler::XMLDocument
- TaskJuggler::XMLElement
- TaskJuggler::XMLNamedText
- TaskJuggler::XMLText
- Diff
- Diff::Hunk
- AppConfig
- Diffable
- DiffableString
- Object
- RuntimeConfig
- String

No matching classes.

# TaskJuggler::PropertyList

The PropertyList is a utility class that can be used to hold a list of properties. It's derived from an Array, so it can hold the properties in a well defined order. The order can be determined by an arbitrary number of sorting levels. A sorting level specifies an attribute who's value should be used for sorting, a scenario index if necessary and the sorting direction (up/down). All nodes in the PropertyList must belong to the same PropertySet.

### Attributes

propertySet[R]
query[RW]
scenarioIdx[R]
sortingCriteria[R]
sortingLevels[R]
sortingUp[R]

### Public Class Methods

new(arg, copyItems = true) click to toggle source

A PropertyList is always bound to a certain PropertySet. All properties in the list must be of that set.

    # File lib/taskjuggler/PropertyList.rb, line 34
    def initialize(arg, copyItems = true)
      @items = copyItems ? arg.to_ary : []
      if arg.is_a?(PropertySet)
        # Create a PropertyList from the given PropertySet.
        @propertySet = arg
        # To keep the list sorted, we may have to access Property attributes.
        # Pre-scheduling, we can only use static attributes. Post-scheduling,
        # we can include dynamic attributes as well. This query template will
        # be used to query attributes when it has been set. Otherwise the list
        # can only be sorted by static attributes.
        @query = nil
        resetSorting
        addSortingCriteria('seqno', true, -1)
        sort!
      else
        # Create a PropertyList from a given other PropertyList.
        @propertySet = arg.propertySet
        @query = arg.query ? arg.query.dup : nil
        @sortingLevels = arg.sortingLevels
        @sortingCriteria = arg.sortingCriteria.dup
        @sortingUp = arg.sortingUp.dup
        @scenarioIdx = arg.scenarioIdx.dup
      end
    end

### Public Instance Methods

[](node) click to toggle source

    # File lib/taskjuggler/PropertyList.rb, line 100
    def [](node)
      @items.find { |n| n.ptn == node.ptn }
    end

append(list) click to toggle source

Append another Array of PropertyTreeNodes or a PropertyList to this. The list will be sorted again.

    # File lib/taskjuggler/PropertyList.rb, line 126
    def append(list)
      if $DEBUG
        list.each do |node|
          unless node.propertySet == @propertySet
            raise "Fatal Error: All nodes must belong to the same PropertySet."
          end
        end
      end

      @items.concat(list)
      raise "Duplicate items" if @items != @items.uniq
      sort!
    end

checkForDuplicates(sourceFileInfo) click to toggle source

Make sure that the list does not contain the same PropertyTreeNode more than once. This could happen for adopted tasks. If you use includeAdopted(), you should call this method after filtering to see if the filter was strict enough.

    # File lib/taskjuggler/PropertyList.rb, line 80
    def checkForDuplicates(sourceFileInfo)
      ptns = {}
      @items.each do |i|
        if ptns.include?(i.ptn)
          error('proplist_duplicate',
                "An adopted property is included as #{i.logicalId} and " +
                "as #{ptns[i.ptn].logicalId}. Please use stronger filtering " +
                'to avoid including the property more than once!',
                sourceFileInfo)
        end
        ptns[i.ptn] = i
      end
    end

include?(node) click to toggle source

Specialized version of Array::include? that also matches adopted tasks.

    # File lib/taskjuggler/PropertyList.rb, line 96
    def include?(node)
      !@items.find { |p| p.ptn == node.ptn }.nil?
    end

includeAdopted() click to toggle source

    # File lib/taskjuggler/PropertyList.rb, line 66
    def includeAdopted
      adopted = []
      @items.each do |p|
        p.adoptees.each do |ap|
          adopted += includeAdoptedR(ap, p)
        end
      end
      append(adopted)
    end

index() click to toggle source

This function sets the index attribute of all the properties in the list. The index starts with 0 and increases for each property.

    # File lib/taskjuggler/PropertyList.rb, line 189
    def index
      i = 0
      @items.each do |p|
        p.force('index', i += 1)
      end
    end

itemIndex(item) click to toggle source

Return the Array index of item or nil.

    # File lib/taskjuggler/PropertyList.rb, line 183
    def itemIndex(item)
      @items.index(item)
    end

method_missing(func, *args, &block) click to toggle source

This class should be a derived class of Array. But since it re-defines sort!() and still needs to call Array::sort!() I took a different route. All missing methods will be propagated to the @items Array.

    # File lib/taskjuggler/PropertyList.rb, line 62
    def method_missing(func, *args, &block)
      @items.method(func).call(*args, &block)
    end

resetSorting() click to toggle source

Clear all sorting levels.

    # File lib/taskjuggler/PropertyList.rb, line 117
    def resetSorting
      @sortingLevels = 0
      @sortingCriteria = []
      @sortingUp = []
      @scenarioIdx = []
    end

setSorting(modes) click to toggle source

Set all sorting levels as Array of triplets.

    # File lib/taskjuggler/PropertyList.rb, line 109
    def setSorting(modes)
      resetSorting
      modes.each do |mode|
        addSortingCriteria(*mode)
      end
    end

sort!() click to toggle source

Sort the properties according to the currently defined sorting criteria.

    # File lib/taskjuggler/PropertyList.rb, line 148
    def sort!
      if treeMode?
        # Tree sorting is somewhat complex. It will be based on the 'tree'
        # attribute of the PropertyTreeNodes but we have to update them first
        # based on the other sorting criteria.

        # Remove the tree sorting mode first.
        sc = @sortingCriteria.delete_at(0)
        su = @sortingUp.delete_at(0)
        si = @scenarioIdx.delete_at(0)
        @sortingLevels -= 1

        # Sort the list based on the rest of the modes.
        sortInternal
        # The update the 'index' attributes of the PropertyTreeNodes.
        index
        # An then the 'tree' attributes.
        indexTree

        # Restore the 'tree' sorting mode again.
        @sortingCriteria.insert(0, sc)
        @sortingUp.insert(0, su)
        @scenarioIdx.insert(0, si)
        @sortingLevels += 1

        # Sort again, now based on the updated 'tree' attributes.
        sortInternal
      else
        sortInternal
      end
      # Update indexes.
      index
    end

to_ary() click to toggle source

    # File lib/taskjuggler/PropertyList.rb, line 104
    def to_ary
      @items.dup
    end

treeMode?() click to toggle source

If the first sorting level is 'tree' the breakdown structure of the list is preserved. This is a somewhat special mode and this function returns true if the mode is set.

    # File lib/taskjuggler/PropertyList.rb, line 143
    def treeMode?
      @sortingLevels > 0 && @sortingCriteria[0] == 'tree'
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.