Method: TaskJuggler::ProjectBroker#removeProject

Defined in:
lib/taskjuggler/daemon/ProjectBroker.rb

#removeProject(indexOrId) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/taskjuggler/daemon/ProjectBroker.rb', line 261

def removeProject(indexOrId)
  @projects.synchronize do
    # Find all projects with the IDs in indexOrId and mark them as
    # :obsolete.
    if /^[0-9]$/.match(indexOrId)
      index = indexOrId.to_i - 1
      if index >= 0 && index < @projects.length
        # If we have marked the project as obsolete, we return false to
        # indicate the double remove.
        return false if p.state == :obsolete
        @projects[index].state = :obsolete
        return true
      end
    else
      @projects.each do |p|
        if indexOrId == p.id
          # If we have marked the project as obsolete, we return false to
          # indicate the double remove.
          return false if p.state == :obsolete
          p.state = :obsolete
          return true
        end
      end
    end
  end
  false
end