Beispiel #1
0
    def _make_session_endpoint(self, module, form=None):
        if form is not None:
            endpoint_id = form.session_endpoint_id
        else:
            endpoint_id = module.session_endpoint_id

        stack = Stack()
        children = self.get_frame_children(module, form)
        argument_ids = self.get_argument_ids(children, form)

        # Add a claim request for each endpoint argument.
        # This assumes that all arguments are case ids.
        non_computed_argument_ids = [
            child.id for child in children
            if isinstance(child, WorkflowDatumMeta) and child.requires_selection
        ]
        for arg_id in non_computed_argument_ids:
            self._add_claim_frame(stack, arg_id, endpoint_id)

        # Add a frame to navigate to the endpoint
        frame = PushFrame()
        stack.add_frame(frame)
        for child in children:
            if isinstance(child, CommandId):
                frame.add_command(child.to_command())
            elif child.id in argument_ids:
                self._add_datum_for_arg(frame, child.id)

        return SessionEndpoint(
            id=endpoint_id,
            arguments=[Argument(id=i) for i in argument_ids],
            stack=stack,
        )
Beispiel #2
0
 def _build_stack(self):
     stack = Stack()
     frame = PushFrame()
     frame.add_rewind(
         QuerySessionXPath(
             self.module.search_config.case_session_var).instance())
     stack.add_frame(frame)
     return stack
Beispiel #3
0
    def _make_session_endpoint(self, id_string, module, endpoint_id):
        stack = Stack()
        frame = PushFrame()
        stack.add_frame(frame)
        frame.add_command(XPath.string(id_string))
        arguments = []
        helper = WorkflowHelper(self.suite, self.app, self.modules)
        for child in helper.get_frame_children(id_string, module):
            if isinstance(child, WorkflowDatumMeta):
                arguments.append(Argument(id=child.id))
                frame.add_datum(StackDatum(id=child.id, value=f"${child.id}"))

        return SessionEndpoint(
            id=endpoint_id,
            arguments=arguments,
            stack=stack,
        )
Beispiel #4
0
 def build_stack(self):
     stack = Stack()
     rewind_if = None
     if module_uses_smart_links(self.module):
         user_domain_xpath = session_var(COMMCARE_PROJECT, path="user/data")
         # For case in same domain, do a regular case claim rewind
         rewind_if = self._get_case_domain_xpath().eq(user_domain_xpath)
         # For case in another domain, jump to that other domain
         frame = PushFrame(if_clause=XPath.not_(rewind_if))
         frame.add_datum(
             StackJump(url=Text(xpath=TextXPath(
                 function=self.get_smart_link_function(),
                 variables=self.get_smart_link_variables(),
             ), ), ))
         stack.add_frame(frame)
     frame = PushFrame(if_clause=rewind_if)
     frame.add_rewind(QuerySessionXPath(self.case_session_var).instance())
     stack.add_frame(frame)
     return stack
Beispiel #5
0
 def _build_stack(self):
     stack = Stack()
     frame = PushFrame()
     frame.add_rewind(QuerySessionXPath('case_id').instance())
     stack.add_frame(frame)
     return stack
Beispiel #6
0
 def _build_stack(self):
     stack = Stack()
     frame = PushFrame()
     frame.add_rewind(QuerySessionXPath('case_id').instance())
     stack.add_frame(frame)
     return stack