コード例 #1
0
ファイル: ExplanationCache.py プロジェクト: Verde1705/erp5
  def getUnionBusinessProcess(self):
    """Return a Business Process made of all Business Link
    which are the cause of Simulation Movements in the simulation
    trees related to explanation.
    """
    # Try to return cached value first
    new_business_process = self.union_cache
    if new_business_process is not None:
      return new_business_process

    # Build Union Business Process
    from Products.ERP5Type.Document import newTempBusinessProcess
    new_business_process = newTempBusinessProcess(self.explanation, 'union_business_process')
    i = 0
    for business_link in self.getBusinessLinkValueList():
      i += 1
      id = 'union_path_%s' % i
      new_business_process._setOb(id, business_link.asContext(id=id))

    # Keep it in cache and return
    self.union_cache = new_business_process
    return new_business_process
コード例 #2
0
  def getUnionBusinessProcess(self):
    """Return a Business Process made of all Business Link
    which are the cause of Simulation Movements in the simulation
    trees related to explanation.
    """
    # Try to return cached value first
    new_business_process = self.union_cache
    if new_business_process is not None:
      return new_business_process

    # Build Union Business Process
    from Products.ERP5Type.Document import newTempBusinessProcess
    new_business_process = newTempBusinessProcess(self.explanation, 'union_business_process')
    i = 0
    for business_link in self.getBusinessLinkValueList():
      i += 1
      id = 'union_path_%s' % i
      new_business_process._setOb(id, business_link.asContext(id=id))

    # Keep it in cache and return
    self.union_cache = new_business_process
    return new_business_process
コード例 #3
0
ファイル: ExplanationCache.py プロジェクト: Verde1705/erp5
  def getBusinessLinkClosure(self, business_process, business_link):
    """Creates a Business Process by filtering out all Business Link
    in 'business_process' which are not related to a simulation movement
    which is either a parent or a child of explanation simulations movements
    caused by 'business_link'

    NOTE: Business Link Closure must be at least as "big" as composed
    business path. The appropriate calculation is still not clear.
    Options are:
      - take all link of composed business link (even not yet expanded)
      - take all link of composed business link which phase is not yet expanded
    """
    # Try to return cached value first
    new_business_process = self.closure_cache.get(business_link, None)
    if new_business_process is not None:
      return new_business_process

    # Build a list of path patterns which apply to current business_link
    path_list = iter(self.getSimulationPathPatternList())
    path_dict = {x: path_list.next() for x in path_list}
    # path_dict is like this;
    # {'/erp5/portal_simulation/3/4': r'/erp5/portal\_simulation/3/4/%'}
    path_list = []
    for simulation_movement in \
        self.getBusinessLinkRelatedSimulationMovementValueList(business_link):
      simulation_path = simulation_movement.getPath()
      if simulation_path in path_dict:
        path = simulation_path
      else:
        for path in path_dict:
          if simulation_path.startswith(path) and \
             simulation_path[len(path)] == '/':
            break
        else:
          continue
      # Only keep a path pattern which matches current simulation movement
      path_list.append(path)
      path_list.append(path_dict.pop(path))

    # Lookup in cache based on path_list
    path_list.sort()
    path_list = tuple(path_list)
    new_business_process = self.closure_cache.get(path_list)
    if new_business_process is None:
      business_link_list = []
      new_business_process = business_process
      for x in business_process.getBusinessLinkValueList():
        if self.getSimulationMovementValueList(path=path_list,
                                               causality_uid=x.getUid()):
          # We have matching movements.
          business_link_list.append(x)
        else:
          new_business_process = None
      if new_business_process is None:
        # Build a new closure business process.
        # Initially, business_process is often the result of
        # asComposedDocument() and business_process.getParentValue() is not a
        # module where newContent() allows creation of Business Processes.
        # XXX-JPS is this really OK with union business processes
        from Products.ERP5Type.Document import newTempBusinessProcess
        new_business_process = newTempBusinessProcess(
          self.explanation, 'closure_business_process')
        for i, x in enumerate(business_link_list):
          id = 'closure_path_%s' % i
          new_business_process._setOb(id, x.asContext(id=id))
      self.closure_cache[path_list] = new_business_process

    self.closure_cache[business_link] = new_business_process
    return new_business_process
コード例 #4
0
  def getBusinessLinkClosure(self, business_process, business_link):
    """Creates a Business Process by filtering out all Business Link
    in 'business_process' which are not related to a simulation movement
    which is either a parent or a child of explanation simulations movements
    caused by 'business_link'

    NOTE: Business Link Closure must be at least as "big" as composed 
    business path. The appropriate calculation is still not clear. 
    Options are:
      - take all link of composed business link (even not yet expanded)
      - take all link of composed business link which phase is not yet expanded
    """
    # Try to return cached value first
    new_business_process = self.closure_cache.get(business_link, None)
    if new_business_process is not None:
      return new_business_process

    # Build a list of path patterns which apply to current business_link
    path_list = iter(self.getSimulationPathPatternList())
    path_dict = dict((x, path_list.next()) for x in path_list)
    # path_dict is like this;
    # {'/erp5/portal_simulation/3/4': r'/erp5/portal\_simulation/3/4/%'}
    path_list = []
    for simulation_movement in \
        self.getBusinessLinkRelatedSimulationMovementValueList(business_link):
      simulation_path = simulation_movement.getPath()
      if simulation_path in path_dict:
        path = simulation_path
      else:
        for path in path_dict:
          if simulation_path.startswith(path) and \
             simulation_path[len(path)] == '/':
            break
        else:
          continue
      # Only keep a path pattern which matches current simulation movement
      path_list.append(path)
      path_list.append(path_dict.pop(path))

    # Lookup in cache based on path_list
    path_list.sort()
    path_list = tuple(path_list)
    new_business_process = self.closure_cache.get(path_list)
    if new_business_process is None:
      business_link_list = []
      new_business_process = business_process
      for x in business_process.getBusinessLinkValueList():
        if self.getSimulationMovementValueList(path=path_list,
                                               causality_uid=x.getUid()):
          # We have matching movements.
          business_link_list.append(x)
        else:
          new_business_process = None
      if new_business_process is None:
        # Build a new closure business process.
        # Initially, business_process is often the result of
        # asComposedDocument() and business_process.getParentValue() is not a
        # module where newContent() allows creation of Business Processes.
        # XXX-JPS is this really OK with union business processes
        from Products.ERP5Type.Document import newTempBusinessProcess
        new_business_process = newTempBusinessProcess(
          self.explanation, 'closure_business_process')
        for i, x in enumerate(business_link_list):
          id = 'closure_path_%s' % i
          new_business_process._setOb(id, x.asContext(id=id))
      self.closure_cache[path_list] = new_business_process

    self.closure_cache[business_link] = new_business_process
    return new_business_process