Ejemplo n.º 1
0
 def lockers(self):
     """Get sequence of id/name pairs for users with locked documents."""
     if not hasattr(self, "_lockers"):
         fields = "COUNT(*) AS n", "u.id", "u.name", "u.fullname"
         query = Query("usr u", *fields)
         query.join("checkout c", "c.usr = u.id")
         query.join("document d", "d.id = c.id")
         query.group(*fields[1:])
         query.where("c.dt_in IS NULL")
         users = []
         for row in query.execute(self.cursor):
             name = row.fullname or row.name
             display = f"{name} ({row.n} locks)"
             users.append((name.lower(), row.id, display))
         self._lockers = [(uid, label) for key, uid, label in sorted(users)]
     return self._lockers
Ejemplo n.º 2
0
    def _term_sets(self):
        """
        Collect named sets of CDR terms

        Parameters:
          SetType - optional string restricting report to term sets
                    whose type name matches the pattern passed
                    (any wildcards in the pattern must be included,
                    the report code does not wrap the string in a
                    pair of wildcards); as of this writing, this
                    parameter is of limited use, as all of the
                    existing term sets have the set type of
                    "diagnosis macro"

        Return:
          XML document node with the following structure:
            ReportBody
              ReportName
              TermSet*
                Name
                Members [string of CDR term IDs]
        """

        query = Query("doc_version v", "v.id", "MAX(v.num) AS num")
        query.join("query_term_pub t", "t.doc_id = v.id")
        query.where("t.path = '/TermSet/TermSetType'")
        query.where("v.publishable = 'Y'")
        query.group("v.id")
        pattern = self.__opts.get("SetType")
        if pattern:
            query.where(query.Condition("t.value", pattern, "LIKE"))
        body = self.__start_body()
        for id, num in query.execute(self.cursor).fetchall():
            doc = Doc(self.session, id=id, version=num)
            result = doc.filter("name:Get TermSet Name and Members")
            body.append(result.result_tree.getroot())
        return body