コード例 #1
0
    def local_reindex(self):
        """Reindex all local tasks."""

        query = getUtility(ITaskQuery)
        intids = getUtility(IIntIds)

        # Get all tasks and forwardings currently in the global index
        indexed_tasks = [
            task.int_id
            for task in query.get_tasks_for_client(client=get_client_id())
        ]

        catalog = getToolByName(self, 'portal_catalog')
        tasks = catalog(object_provides=ITask.__identifier__)
        log = self.mklog()

        # Update the existing tasks
        for task in tasks:
            obj = task.getObject()
            int_id = intids.getId(obj)
            index_task(obj, None)
            if int_id in indexed_tasks:
                indexed_tasks.remove(int_id)
            log('Obj %s updated in the globalindex.\n' % (obj))

        # Clear tasks in the globalindex who's not-existing anymore.
        if len(indexed_tasks):
            for int_id in indexed_tasks:
                task = query.get_task_by_oguid('%s:%i' %
                                               (get_client_id(), int_id))

                log('ERROR: Task(%s) with the id: %i does not exist in the'
                    'catalog. It should be manually removed.\n' %
                    (task, task.task_id))
        return True
コード例 #2
0
    def local_reindex(self):
        """Reindex all local tasks."""

        query = getUtility(ITaskQuery)
        intids = getUtility(IIntIds)

        # Get all tasks and forwardings currently in the global index
        indexed_tasks = [task.int_id for task in query.get_tasks_for_client(
                client=get_client_id())]

        catalog = getToolByName(self, 'portal_catalog')
        tasks = catalog(object_provides=ITask.__identifier__)
        log = self.mklog()

        # Update the existing tasks
        for task in tasks:
            obj = task.getObject()
            int_id = intids.getId(obj)
            index_task(obj, None)
            if int_id in indexed_tasks:
                indexed_tasks.remove(int_id)
            log('Obj %s updated in the globalindex.\n' % (obj))

        # Clear tasks in the globalindex who's not-existing anymore.
        if len(indexed_tasks):
            for int_id in indexed_tasks:
                task = query.get_task_by_oguid('%s:%i' % (
                        get_client_id(), int_id))

                log('ERROR: Task(%s) with the id: %i does not exist in the'
                    'catalog. It should be manually removed.\n' % (
                        task, task.task_id)
                    )
        return True
コード例 #3
0
    def test_list_only_active_tasks(self):
        active = create(
            Builder('forwarding').having(responsible='inbox:client1'))
        closed = create(
            Builder('forwarding').having(responsible='inbox:client1').in_state(
                'forwarding-state-closed'))
        index_task(closed, None)

        self.assertEquals([task2sqltask(active)], self.view.assigned_tasks())
コード例 #4
0
    def test_list_only_active_tasks(self):
        active = create(Builder('forwarding')
                      .having(responsible='inbox:client1'))
        closed = create(Builder('forwarding')
                        .having(responsible='inbox:client1')
                        .in_state('forwarding-state-closed'))
        index_task(closed, None)

        self.assertEquals(
            [task2sqltask(active)], self.view.assigned_tasks())
コード例 #5
0
def fix_none_responsible(app):

    plone = setup_plone(app)

    print "Get brains of task..."
    brains = plone.portal_catalog(
        {'portal_type': 'opengever.task.task'})

    print "%s task found" % len(brains)

    print "check local roles on task ..."

    for brain in brains:
        task = brain.getObject()

        responsible = task.responsible

        if responsible.startswith('inbox:'):
            responsible = 'og_%s_eingangskorb' %(responsible[6:])

        if responsible == 'None':
            if task.predecessor:
                new_task = ISuccessorTaskController(task).get_predecessor()
            else:
                new_task = ISuccessorTaskController(task).get_successors()[0]

            new_responsible = new_task.responsible
            new_responsible_client = new_task.assigned_client

            print "None Responsible: Task %s should change to %s %s (%s:%s)" %(
                '/'.join(task.getPhysicalPath()),
                new_responsible, new_responsible_client,
                new_task.client_id, new_task.physical_path)

            task.responsible = new_responsible
            task.responsible_client = new_responsible_client

            index_task(task, None)

            last_response = IResponseContainer(task)[-1]

            new_changes = PersistentList()
            for change in last_response.changes:
                if change.get('id') in ['responsible', 'reponsible'] and change.get('after') == 'None':
                    # drop it
                    pass
                else:
                    new_changes.append(change)
            last_response.changes = new_changes

            transaction.commit()
コード例 #6
0
def reindex_containing_dossier(dossier, event):
    """Reindex the containging_dossier index for all the contained obects,
    when the title has changed."""
    if not IDossierMarker.providedBy(aq_parent(aq_inner(dossier))):
        for descr in event.descriptions:
            for attr in descr.attributes:
                if attr == 'IOpenGeverBase.title':
                    for brain in dossier.portal_catalog(
                        path='/'.join(dossier.getPhysicalPath())):

                        brain.getObject().reindexObject(
                            idxs=['containing_dossier'])

                        if brain.portal_type in ['opengever.task.task',
                            'opengever.inbox.forwarding']:
                            index_task(brain.getObject(), event)
コード例 #7
0
    def __call__(self):
        ptool = getToolByName(self, 'plone_utils')
        catalog = getToolByName(self, 'portal_catalog')
        session = Session()

        # Get the current client's ID
        registry = getUtility(IRegistry)
        client_config = registry.forInterface(IClientConfiguration)
        client_id = client_config.client_id

        # Get all tasks and forwardings currently in the global index
        task_query = TaskQuery()
        indexed_tasks = task_query.get_tasks_for_client(client=client_id)

        # Clear existing tasks in global index that have been created on this client
        for task in indexed_tasks:
            session.delete(task)
        transaction.commit()

        # Get tasks and forwardings that need to be reindexed from catalog
        cataloged_tasks = catalog(portal_type="opengever.task.task")
        forwardings = catalog(portal_type="opengever.inbox.forwarding")
        objs_to_reindex = cataloged_tasks + forwardings

        # Re-Index tasks
        for obj in objs_to_reindex:
            index_task(obj.getObject(), None)

        ptool.addPortalMessage(_(
            "Global task index has been cleared (${cleared}) and rebuilt (${rebuilt})",
            mapping={
                'cleared': len(indexed_tasks),
                'rebuilt': len(objs_to_reindex)
            }),
                               type="info")

        return self.context.REQUEST.RESPONSE.redirect(
            self.context.absolute_url() +
            '/@@ogds-controlpanel#ogds-cp-alltasks')
コード例 #8
0
    def __call__(self):
        ptool = getToolByName(self, 'plone_utils')
        catalog = getToolByName(self, 'portal_catalog')
        session = Session()

        # Get the current client's ID
        registry = getUtility(IRegistry)
        client_config = registry.forInterface(IClientConfiguration)
        client_id = client_config.client_id

        # Get all tasks and forwardings currently in the global index
        task_query = TaskQuery()
        indexed_tasks = task_query.get_tasks_for_client(client=client_id)

        # Clear existing tasks in global index that have been created on this client
        for task in indexed_tasks:
            session.delete(task)
        transaction.commit()

        # Get tasks and forwardings that need to be reindexed from catalog
        cataloged_tasks = catalog(portal_type="opengever.task.task")
        forwardings = catalog(portal_type="opengever.inbox.forwarding")
        objs_to_reindex = cataloged_tasks + forwardings

        # Re-Index tasks
        for obj in objs_to_reindex:
            index_task(obj.getObject(), None)

        ptool.addPortalMessage(
            _("Global task index has been cleared (${cleared}) and rebuilt (${rebuilt})",
                  mapping = {'cleared': len(indexed_tasks),
                             'rebuilt': len(objs_to_reindex)}),
              type="info")

        return self.context.REQUEST.RESPONSE.redirect(self.context.absolute_url() 
                                        + '/@@ogds-controlpanel#ogds-cp-alltasks')

                                        
コード例 #9
0
ファイル: localroles.py プロジェクト: vincero/opengever.core
 def globalindex_reindex_task(self):
     """We need to reindex the task in globalindex. This was done
     already with an earlier event handler - but we have just changed
     the roles which are indexed too (allowed users).
     """
     index_task(self.task, self.event)