### Home Classes Methods

### In Files

- lib/taskjuggler/PropertySet.rb

### Parent

Object

### Methods

- ::new
- #[]
- #addAttributeType
- #addProperty
- #attributeName
- #attributeType
- #clearProperties
- #defaultValue
- #each
- #eachAttributeDefinition
- #empty?
- #hasQuery?
- #index
- #inheritedFromParent?
- #inheritedFromProject?
- #items
- #knownAttribute?
- #length
- #levelSeqNo
- #maxDepth
- #removeProperty
- #scenarioSpecific?
- #to_ary
- #to_s
- #topLevelItems
- #userDefined?

### 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::PropertySet

A PropertySet is a collection of properties of the same kind. Properties can be Task, Resources, Scenario, Shift or Accounts objects. All properties of the same kind belong to the same PropertySet. A property may only belong to one PropertySet in the Project. The PropertySet holds the definitions for the attributes. All Properties of the set will have a set of these attributes.

### Attributes

attributeDefinitions[R]
flatNamespace[R]
project[R]

### Public Class Methods

new(project, flatNamespace) click to toggle source

    # File lib/taskjuggler/PropertySet.rb, line 27
    def initialize(project, flatNamespace)
      if $DEBUG && project.nil?
        raise "project parameter may not be NIL"
      end
      # Indicates whether the namespace of this PropertySet is flat or not. In a
      # flat namespace all property IDs must be unique. Otherwise only the IDs
      # within a group of siblings must be unique. The full ID of the Property
      # is then composed of the siblings ID prefixed by the parent ID. ID fields
      # are separated by dots.
      @flatNamespace = flatNamespace
      # The main Project data structure reference.
      @project = project
      # A list of all PropertyTreeNodes in this set.
      @properties = Array.new
      # A hash of all PropertyTreeNodes in this set, hashed by their ID. This is
      # the same data as in @properties, but hashed by ID for faster access.
      @propertyMap = Hash.new

      # This is the blueprint for PropertyTreeNode attribute sets. Whever a new
      # PropertTreeNode is created, an attribute is created for each definition
      # in this list.
      @attributeDefinitions = Hash.new
      [
        [ 'id',   'ID',       StringAttribute, false,  false,  false,  '' ],
        [ 'name', 'Name',     StringAttribute, false,  false,  false,  '' ],
        [ 'seqno', 'Seq. No', FixnumAttribute, false,  false,  false,  0 ]
      ].each { |a| addAttributeType(AttributeDefinition.new(*a)) }
    end

### Public Instance Methods

[](id) click to toggle source

Return the PropertyTreeNode object with ID id from the set or nil if not present.

    # File lib/taskjuggler/PropertySet.rb, line 224
    def [](id)
      @propertyMap[id]
    end

addAttributeType(attributeType) click to toggle source

Use the function to declare the various attributes that properties of this PropertySet can have. The attributes must be declared before the first property is added to the set.

    # File lib/taskjuggler/PropertySet.rb, line 59
    def addAttributeType(attributeType)
      if !@properties.empty?
        raise "Fatal Error: Attribute types must be defined before " +
              "properties are added."
      end

      @attributeDefinitions[attributeType.id] = attributeType
    end

addProperty(property) click to toggle source

Add the new PropertyTreeNode object property to the set. The set is indexed by ID. In case an object with the same ID already exists in the set it will be overwritten.

Whenever the set has been extended, the 'bsi' and 'tree' attributes of the properties are no longer up-to-date. You must call index() before using these attributes.

    # File lib/taskjuggler/PropertySet.rb, line 176
    def addProperty(property)
      # The PropertyTreeNode objects are indexed by ID or hierachical ID
      # depending on the name space setting of this set.
      @propertyMap[property.id] = property
      @properties << property
    end

attributeName(attrId) click to toggle source

Returns the name (human readable description) of the attribute with the Id specified by attrId.

    # File lib/taskjuggler/PropertySet.rb, line 149
    def attributeName(attrId)
      # Some attributes are hardwired into the properties. These need to be
      # treated separately.
      if @attributeDefinitions.include?(attrId)
        return @attributeDefinitions[attrId].name
      end

      nil
    end

attributeType(attrId) click to toggle source

Return the type of the attribute with the Id specified by attrId.

    # File lib/taskjuggler/PropertySet.rb, line 160
    def attributeType(attrId)
      # Hardwired attributes need special treatment.
      if @attributeDefinitions.has_key?(attrId)
        @attributeDefinitions[attrId].objClass
      else
        nil
      end
    end

clearProperties() click to toggle source

Call this function to delete all registered properties.

    # File lib/taskjuggler/PropertySet.rb, line 217
    def clearProperties
      @properties.clear
      @propertyMap.clear
    end

defaultValue(attrId) click to toggle source

Return the default value of the attribute.

    # File lib/taskjuggler/PropertySet.rb, line 141
    def defaultValue(attrId)
      return nil if @attributeDefinitions[attrId].nil?

      @attributeDefinitions[attrId].default
    end

each() click to toggle source

Iterator over all PropertyTreeNode objects in this set.

    # File lib/taskjuggler/PropertySet.rb, line 293
    def each
      @properties.each do |value|
        yield(value)
      end
    end

eachAttributeDefinition() click to toggle source

Iterate over all attribute definitions.

    # File lib/taskjuggler/PropertySet.rb, line 69
    def eachAttributeDefinition
      @attributeDefinitions.sort.each do |key, value|
        yield(value)
      end
    end

empty?() click to toggle source

Return true if the set is empty.

    # File lib/taskjuggler/PropertySet.rb, line 278
    def empty?
      @properties.empty?
    end

hasQuery?(attrId, scenarioIdx = nil) click to toggle source

Check whether the PropertyTreeNode has a calculated attribute with the ID attrId. For scenarioSpecific attributes scenarioIdx needs to be provided.

    # File lib/taskjuggler/PropertySet.rb, line 83
    def hasQuery?(attrId, scenarioIdx = nil)
      return false if @properties.empty?

      property = @properties.first
      methodName = 'query_' + attrId
      # First we check for non-scenario-specific query functions.
      if property.respond_to?(methodName)
        return true
      elsif scenarioIdx
        # Then we check for scenario-specific ones via the @data member.
        return property.data[scenarioIdx].respond_to?(methodName)
      end
      false
    end

index() click to toggle source

Update the breakdown structure indicies (bsi). This method needs to be called whenever the set has been modified.

    # File lib/taskjuggler/PropertySet.rb, line 230
    def index
      each do |p|
        bsIdcs = p.getBSIndicies
        bsi = ""
        first = true
        bsIdcs.each do |idx|
          if first
            first = false
          else
            bsi += '.'
          end
          bsi += idx.to_s
        end
        p.set('bsi', bsi)
      end
    end

inheritedFromParent?(attrId) click to toggle source

Return whether the attribute with attrId is inherited from parent.

    # File lib/taskjuggler/PropertySet.rb, line 126
    def inheritedFromParent?(attrId)
      # All hardwired attributes are not inherited.
      return false if @attributeDefinitions[attrId].nil?

      @attributeDefinitions[attrId].inheritedFromParent
    end

inheritedFromProject?(attrId) click to toggle source

Return whether the attribute with attrId is inherited from the global scope.

    # File lib/taskjuggler/PropertySet.rb, line 118
    def inheritedFromProject?(attrId)
      # All hardwired attributes are not inherited.
      return false if @attributeDefinitions[attrId].nil?

      @attributeDefinitions[attrId].inheritedFromProject
    end

items() click to toggle source

Return the number of PropertyTreeNode objects in this set.

    # File lib/taskjuggler/PropertySet.rb, line 270
    def items
      @properties.length
    end

Also aliased as: length
knownAttribute?(attrId) click to toggle source

Return true if there is an AttributeDefinition for attrId.

    # File lib/taskjuggler/PropertySet.rb, line 76
    def knownAttribute?(attrId)
      @attributeDefinitions.include?(attrId)
    end

length() click to toggle source
Alias for: items
levelSeqNo(property) click to toggle source

Return the index of the top-level property in the set.

    # File lib/taskjuggler/PropertySet.rb, line 248
    def levelSeqNo(property)
      seqNo = 1
      @properties.each do |p|
        unless p.parent
          return seqNo if p == property
          seqNo += 1
        end
      end
      raise "Fatal Error: Unknow property #{property}"
    end

maxDepth() click to toggle source

Return the maximum used number of breakdown levels. A flat list has a maxDepth of 1. A list with one sub level has a maxDepth of 2 and so on.

    # File lib/taskjuggler/PropertySet.rb, line 261
    def maxDepth
      md = 0
      each do |p|
        md = p.level if p.level > md
      end
      md + 1
    end

removeProperty(prop) click to toggle source

Remove the PropertyTreeNode (and all its children) object from the set. prop can either be a property ID or a reference to the PropertyTreeNode.

TODO: This function does not take care of references to this PTN!

    # File lib/taskjuggler/PropertySet.rb, line 187
    def removeProperty(prop)
      if prop.is_a?(String)
        property = @propertyMap[prop]
      else
        property = prop
      end

      # Iterate over all properties and eliminate references to this the
      # PropertyTreeNode to be removed.
      @properties.each do |p|
        p.removeReferences(p)
      end

      # Recursively remove all sub-nodes. The children list is modified during
      # the call, so we can't use an iterator here.
      until property.children.empty? do
        removeProperty(property.children.first)
      end

      @properties.delete(property)
      @propertyMap.delete(property.fullId)

      # Remove this node from the child list of the parent node.
      property.parent.children.delete(property) if property.parent

      property
    end

scenarioSpecific?(attrId) click to toggle source

Return whether the attribute with attrId is scenario specific or not.

    # File lib/taskjuggler/PropertySet.rb, line 99
    def scenarioSpecific?(attrId)
      if @attributeDefinitions[attrId]
        # Check the 'scenarioSpecific' flag of the attribute definition.
        @attributeDefinitions[attrId].scenarioSpecific
      elsif (property = @properties.first) &&
            property && property.data &&
            property.data[0].respond_to?("query_#{attrId}")
        # We've found a query_ function for the attrId that is scenario
        # specific.
        true
      else
        # All hardwired, non-existing and non-scenario-specific query_
        # candidates.
        false
      end
    end

to_ary() click to toggle source

Return the set of PropertyTreeNode objects as flat Array.

    # File lib/taskjuggler/PropertySet.rb, line 300
    def to_ary
      @properties.dup
    end

to_s() click to toggle source

    # File lib/taskjuggler/PropertySet.rb, line 304
    def to_s
      PropertyList.new(self).to_s
    end

topLevelItems() click to toggle source

Return the number of top-level PropertyTreeNode objects. Top-Level items are no children.

    # File lib/taskjuggler/PropertySet.rb, line 284
    def topLevelItems
      items = 0
      @properties.each do |p|
        items += 1 unless p.parent
      end
      items
    end

userDefined?(attrId) click to toggle source

Return whether or not the attribute was user defined.

    # File lib/taskjuggler/PropertySet.rb, line 134
    def userDefined?(attrId)
      return false if @attributeDefinitions[attrId].nil?

      @attributeDefinitions[attrId].userDefined
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.