Get all :class:`rtcclient.workitem.Workitem` objects by
        project area id or name

        If both `projectarea_id` and `projectarea_name` are `None`,
        all the workitems in all project areas will be returned.

        If no :class:`rtcclient.workitem.Workitem` objects are retrieved,
        `None` is returned.

        You can also customize your preferred properties to be returned
        by specified `returned_properties`

        :param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
            id
        :param projectarea_name: the project area name
        :param returned_properties: the returned properties that you want.
            Refer to :class:`rtcclient.client.RTCClient` for more explanations
        :param archived: (default is False) whether the workitems are archived
        :return: a :class:`list` that contains all the
            :class:`rtcclient.workitem.Workitem` objects
        :rtype: list

def getWorkitems(self, projectarea_id=None, projectarea_name=None,
                     returned_properties=None, archived=False):
        """Get all :class:`rtcclient.workitem.Workitem` objects by
        project area id or name

        If both `projectarea_id` and `projectarea_name` are `None`,
        all the workitems in all project areas will be returned.

        If no :class:`rtcclient.workitem.Workitem` objects are retrieved,
        `None` is returned.

        You can also customize your preferred properties to be returned
        by specified `returned_properties`

        :param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
            id
        :param projectarea_name: the project area name
        :param returned_properties: the returned properties that you want.
            Refer to :class:`rtcclient.client.RTCClient` for more explanations
        :param archived: (default is False) whether the workitems are archived
        :return: a :class:`list` that contains all the
            :class:`rtcclient.workitem.Workitem` objects
        :rtype: list
        """

        workitems_list = list()
        projectarea_ids = list()
        if not isinstance(projectarea_id,
                          six.string_types) or not projectarea_id:
            pa_ids = self.getProjectAreaIDs(projectarea_name)
            if pa_ids is None:
                self.log.warning("Stop getting workitems because of "
                                 "no ProjectAreas")
                return None
            projectarea_ids.extend(pa_ids)
        else:
            if self.checkProjectAreaID(projectarea_id):
                projectarea_ids.append(projectarea_id)
            else:
                raise exception.BadValue("Invalid ProjectAred ID: "
                                         "%s" % projectarea_id)

        self.log.warning("For a single ProjectArea, only latest 1000 "
                         "workitems can be fetched. "
                         "This may be a bug of Rational Team Concert")

        rp = self._validate_returned_properties(returned_properties)
        for projarea_id in projectarea_ids:
            workitems = self._get_paged_resources("Workitem",
                                                  projectarea_id=projarea_id,
                                                  page_size="100",
                                                  returned_properties=rp,
                                                  archived=archived)
            if workitems is not None:
                workitems_list.extend(workitems)

        if not workitems_list:
            self.log.warning("Cannot find a workitem in the ProjectAreas "
                             "with ids: %s" % projectarea_ids)
            return None
        return workitems_list