Esempio n. 1
0
def supportInfo(dbi, withRBDB, prevVersion):
    """
    Moving support info fields from conference to a dedicated class
    """
    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):
        dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf)
        caption = email = telephone = ""

        if hasattr(dMgr, "_supportEmailCaption"):
            caption = dMgr._supportEmailCaption
            del dMgr._supportEmailCaption
        if hasattr(conf, "_supportEmail"):
            email = conf._supportEmail
            del conf._supportEmail

        supportInfo = SupportInfo(conf, caption, email, telephone)
        conf.setSupportInfo(supportInfo)

        if i % 1000 == 999:
            dbi.commit()
        i += 1
    dbi.commit()
Esempio n. 2
0
def main():
    dbi = DBMgr.getInstance()

    dbi.startRequest()

    ch = ConferenceHolder()

    totalSize = 0
    fNumber = 0

    for __, obj in conferenceHolderIterator(ch, verbose=True):
        for material in obj.getAllMaterialList():
            for res in material.getResourceList():
                if isinstance(res, LocalFile):
                    try:
                        totalSize += res.getSize()
                        fNumber += 1
                    except OSError:
                        print "Problems stating size of '%s'" % res.getFilePath(
                        )

    dbi.endRequest(False)

    print "%d files, %d bytes total" % (fNumber, totalSize)
    print "avg %s bytes/file" % (float(totalSize) / fNumber)
Esempio n. 3
0
def slotLocationMigration(dbi, withRBDB, prevVersion):
    """
    Add missing location info to slots of a session that contains location or room
    """

    ch = ConferenceHolder()
    i = 0

    for (level, obj) in console.conferenceHolderIterator(ch, deepness='event'):
        for session in obj.getSessionList():
            for slot in session.getSlotList():
                sessionLoc = session.getOwnLocation()
                sessionRoom = session.getOwnRoom()
                if (sessionRoom is not None or sessionLoc is not None) and \
                    (slot.getOwnRoom() is None and slot.getOwnLocation() is None):
                    if sessionLoc:
                        loc = CustomLocation()
                        slot.setLocation(loc)
                        loc.setName(sessionLoc.getName())
                        loc.setAddress(sessionLoc.getAddress())
                    if sessionRoom:
                        r = CustomRoom()
                        slot.setRoom(r)
                        r.setName(sessionRoom.getName())
                        if sessionLoc and withRBDB:
                            r.retrieveFullName(sessionLoc.getName())
        if i%1000 == 999:
            dbi.commit()
        i+=1
    dbi.commit()
Esempio n. 4
0
def slotLocationMigration(dbi, withRBDB, prevVersion):
    """
    Add missing location info to slots of a session that contains location or room
    """

    ch = ConferenceHolder()
    i = 0

    for (level, obj) in console.conferenceHolderIterator(ch, deepness='event'):
        for session in obj.getSessionList():
            for slot in session.getSlotList():
                sessionLoc = session.getOwnLocation()
                sessionRoom = session.getOwnRoom()
                if (sessionRoom is not None or sessionLoc is not None) and \
                    (slot.getOwnRoom() is None and slot.getOwnLocation() is None):
                    if sessionLoc:
                        loc = CustomLocation()
                        slot.setLocation(loc)
                        loc.setName(sessionLoc.getName())
                        loc.setAddress(sessionLoc.getAddress())
                    if sessionRoom:
                        r = CustomRoom()
                        slot.setRoom(r)
                        r.setName(sessionRoom.getName())
                        if sessionLoc and withRBDB:
                            r.retrieveFullName(sessionLoc.getName())
        if i%1000 == 999:
            dbi.commit()
        i+=1
    dbi.commit()
Esempio n. 5
0
def updateAbstractFields(dbi, withRBDB, prevVersion):
    """
    Migrates old AbstractField to new AbstractField subclasses
    """

    i = 0
    for (__, conf) in console.conferenceHolderIterator(ConferenceHolder(), deepness='event'):
        afm = conf.getAbstractMgr().getAbstractFieldsMgr()
        for index, field in enumerate(afm._fields):
            if field is not None:
                if type(field) != AbstractField:
                    continue  # Database already contains AbstractField objects created on v1.2.
                params = {}
                params["id"] = field._id
                params["type"] = field._type
                params["caption"] = field._caption
                params["isMandatory"] = field._isMandatory
                try:
                    params["maxLength"] = field._maxLength
                except:
                    pass
                try:
                    params["limitation"] = field._limitation
                except:
                    pass
                afm._fields[index] = AbstractField.makefield(params)
                afm._p_changed = 1
        # Delete all None items in the field list
        afm._fields = filter(None, afm._fields)
        if i % 100 == 99:
            dbi.commit()
        i += 1
    dbi.commit()
Esempio n. 6
0
def indexConferenceTitle(dbi, withRBDB, prevVersion):
    """
    Indexing Conference Title
    """
    ch = ConferenceHolder()
    nameIdx = IndexesHolder().getIndex('conferenceTitle')
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):
        nameIdx.index(conf.getId(), conf.getTitle().decode('utf-8'))
        i += 1
        if i % 10000 == 0:
            dbi.commit()
Esempio n. 7
0
def fix_everything(dbi):
    i = 0
    for level, c in conferenceHolderIterator(ConferenceHolder(), deepness='event'):
        fix_prop(c, 'Title')
        fix_prop(c, 'Description')

        for spk in c.getChairList():
            fix_prop(spk, 'Affiliation')
            fix_prop(spk, 'FamilyName')
            fix_prop(spk, 'FirstName')

    if i % 999 == 0:
        dbi.commit()
    i += 1
Esempio n. 8
0
def fix_everything(dbi):
    i = 0
    for level, c in conferenceHolderIterator(ConferenceHolder(), deepness='event'):
        fix_prop(c, 'Title')
        fix_prop(c, 'Description')

        for spk in c.getChairList():
            fix_prop(spk, 'Affiliation')
            fix_prop(spk, 'FamilyName')
            fix_prop(spk, 'FirstName')

    if i % 999 == 0:
        dbi.commit()
    i += 1
Esempio n. 9
0
def conferenceMigration1_2(dbi, prevVersion):
    """
    Tasks: 1. Migrates old AbstractField to new AbstractField subclasses
           2. Add download e-ticket PDF link to the menu
    """

    def updateAbstractFields(conf):
        """
        Migrates old AbstractField to new AbstractField subclasses
        """

        afm = conf.getAbstractMgr().getAbstractFieldsMgr()
        for index, field in enumerate(afm._fields):
            if field is not None:
                if type(field) != AbstractField:
                    continue  # Database already contains AbstractField objects created on v1.2.
                params = {}
                params["id"] = field._id
                params["type"] = field._type
                params["caption"] = field._caption
                params["isMandatory"] = field._isMandatory
                try:
                    params["maxLength"] = field._maxLength
                except:
                    pass
                try:
                    params["limitation"] = field._limitation
                except:
                    pass
                afm._fields[index] = AbstractField.makefield(params)
                afm._p_changed = 1
        # Delete all None items in the field list
        afm._fields = filter(None, afm._fields)

    cdmr = displayMgr.ConfDisplayMgrRegistery()
    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        updateAbstractFields(conf)
        # Add download e-ticket PDF link to the menu:
        _fixDefaultStyle(conf, cdmr)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Esempio n. 10
0
def reindexCategoryNameAndConferenceTitle(dbi, prevVersion):
    """
    Indexing Conference Title with new WhooshTextIndex
    """
    IndexesHolder().removeById('conferenceTitle')
    IndexesHolder().removeById('categoryName')
    confTitleIdx = IndexesHolder().getIndex('conferenceTitle')
    categNameIdx = IndexesHolder().getIndex('categoryName')
    dbi.commit()

    iterator = (x[1] for x in console.conferenceHolderIterator(ConferenceHolder(), deepness='event'))
    confTitleIdx.clear()
    confTitleIdx.initialize(dbi, iterator)

    categNameIdx.clear()
    categNameIdx.initialize(dbi, CategoryManager().itervalues())
Esempio n. 11
0
    def _export(self, args):
        logger = _basicStreamHandler()

        if console.yesno("This will export all the data to the remote service "
                         "using the agent (takes LONG). Are you sure?"):
            try:
                agent = self._sm.getAllAgents()[args.agent]
            except KeyError:
                raise Exception("Agent '%s' was not found!" % args.agent)

            root = CategoryManager().getById(args.cat or 0)

            if args.monitor:
                monitor = open(args.monitor, 'w')
            else:
                monitor = None

            if args.fast:
                iterator = console.conferenceHolderIterator(
                    ConferenceHolder(), verbose=args.verbose)
            else:
                iterator = categoryIterator(root, 0, verbose=args.verbose)

            if args.output:
                nbatch = 0
                batch = []
                for record, rid, operation in _wrapper(_only_second(iterator),
                                                       agent._creationState,
                                                       self._dbi):
                    if len(batch) > SIZE_BATCH_PER_FILE:
                        self._writeFile(agent, args.output, nbatch, batch,
                                        logger)
                        nbatch += 1
                        batch = []

                    batch.append((record, rid, operation))

                if batch:
                    self._writeFile(agent, args.output, nbatch, batch, logger)
            else:
                agent._run(_wrapper(_only_second(iterator),
                                    agent._creationState, self._dbi),
                           logger=logger,
                           monitor=monitor)

            if monitor:
                monitor.close()
Esempio n. 12
0
    def _export(self, args):
        logger = _basicStreamHandler()

        if console.yesno("This will export all the data to the remote service "
                         "using the agent (takes LONG). Are you sure?"):
            try:
                agent = self._sm.getAllAgents()[args.agent]
            except KeyError:
                raise Exception("Agent '%s' was not found!" % args.agent)

            root = CategoryManager().getById(args.cat or 0)

            if args.monitor:
                monitor = open(args.monitor, 'w')
            else:
                monitor = None

            if args.fast:
                iterator = console.conferenceHolderIterator(ConferenceHolder(),
                                                            verbose=args.verbose)
            else:
                iterator = categoryIterator(root, 0, verbose=args.verbose)

            if args.output:
                nbatch = 0
                batch = []
                for record, rid, operation in _wrapper(_only_second(iterator),
                                                  agent._creationState,
                                                  self._dbi):
                    if len(batch) > SIZE_BATCH_PER_FILE:
                        self._writeFile(agent, args.output,
                                        nbatch, batch, logger)
                        nbatch += 1
                        batch = []

                    batch.append((record, rid, operation))

                if batch:
                    self._writeFile(agent, args.output, nbatch, batch, logger)
            else:
                agent._run(_wrapper(_only_second(iterator),
                                    agent._creationState, self._dbi),
                           logger=logger,
                           monitor=monitor)

            if monitor:
                    monitor.close()
Esempio n. 13
0
def conferenceMigration1_2(dbi, prevVersion):
    """
    Tasks: 1. Migrates old AbstractField to new AbstractField subclasses
           2. Add download e-ticket PDF link to the menu
    """
    def updateAbstractFields(conf):
        """
        Migrates old AbstractField to new AbstractField subclasses
        """

        afm = conf.getAbstractMgr().getAbstractFieldsMgr()
        for index, field in enumerate(afm._fields):
            if field is not None:
                if type(field) != AbstractField:
                    continue  # Database already contains AbstractField objects created on v1.2.
                params = {}
                params["id"] = field._id
                params["type"] = field._type
                params["caption"] = field._caption
                params["isMandatory"] = field._isMandatory
                try:
                    params["maxLength"] = field._maxLength
                except:
                    pass
                try:
                    params["limitation"] = field._limitation
                except:
                    pass
                afm._fields[index] = AbstractField.makefield(params)
                afm._p_changed = 1
        # Delete all None items in the field list
        afm._fields = filter(None, afm._fields)

    cdmr = displayMgr.ConfDisplayMgrRegistery()
    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        updateAbstractFields(conf)
        # Add download e-ticket PDF link to the menu:
        _fixDefaultStyle(conf, cdmr)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Esempio n. 14
0
def main():
    to_fix = defaultdict(list)
    info(
        "Looking for broken contribution links in participants... (This might take a while.)"
    )
    contribs = (x[1] for x in conferenceHolderIterator(ConferenceHolder(),
                                                       deepness='contrib')
                if x[0] == 'contrib')
    for contrib in contribs:
        for part in contrib.getPrimaryAuthorList():
            if part.getContribution() is None:
                to_fix[contrib].append(('primary author', part))
        for part in contrib.getCoAuthorList():
            if part.getContribution() is None:
                to_fix[contrib].append(('co-author', part))
        for part in contrib.getAuthorList():
            if part.getContribution() is None:
                to_fix[contrib].append(('author', part))
        for part in contrib.getSpeakerList():
            if part.getContribution() is None:
                to_fix[contrib].append(('speaker', part))

    if not to_fix:
        success("No broken contribution links found.")
        return

    DBMgr.getInstance().sync(
    )  # searching takes a long time, sync to prevent conflicts
    for contrib, parts in to_fix.iteritems():
        conference = contrib.getConference()
        conference_title = conference.getTitle(
        ) if conference is not None else 'N/A'
        conference_id = conference.getId() if conference is not None else 'N/A'
        print "Event {} (id {})".format(conference_title, conference_id)
        print "  Contribution {} (id {}):".format(contrib.getTitle(),
                                                  contrib.getId())
        print "  {}".format(UHContributionDisplay.getURL(contrib))
        for part_type, part in parts:
            if part.getContribution() is not None:  # already fixed
                info("  - link already restored for {} {} (id {})".format(
                    part_type, part.getFullName(), part.getId()))
                continue
            part._contrib = contrib
            success("  - restored link for {} {} (id {})".format(
                part_type, part.getFullName(), part.getId()))
    DBMgr.getInstance().commit()
Esempio n. 15
0
def removeVideoServicesLinksFromCore(dbi, withRBDB, prevVersion):
    """Video Services migration remove from core"""
    ch = ConferenceHolder()
    idx = Catalog.getIdx("cs_bookingmanager_conference")
    i = 0
    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):
        # Store CSBookingManager in the index
        csbm = getattr(conf, "_CSBookingManager", None)
        if csbm is None:
            continue
        idx.index(conf.getId(), csbm)
        # Update Menu Links
        menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf).getMenu()
        if menu:
            link = menu.getLinkByName("collaboration")
            if link:
                link.setURLHandler(urlHandlers.UHCollaborationDisplay)
        i += 1
        if dbi and i % 1000 == 999:
            dbi.commit()
    dbi.commit()
Esempio n. 16
0
def update_menus(dbi):
    links = ("collaboration", "downloadETicket")
    ch = ConferenceHolder()
    cdmr = ConfDisplayMgrRegistery()
    counter = Counter()

    for __, event in conferenceHolderIterator(ch, deepness="event"):
        menu = cdmr.getDisplayMgr(event).getMenu()
        must_update = False
        for linkname in links:
            if menu.getLinkByName(linkname) is None:
                counter[linkname] += 1
                must_update = True
        if must_update:
            menu.updateSystemLink()
            counter["updated"] += 1
        if counter["updated"] % 100:
            dbi.commit()

    for linkname in links:
        print "{} links missing: {}".format(linkname, counter[linkname])
    success("Event menus updated: {}".format(counter["updated"]))
Esempio n. 17
0
def update_menus(dbi):
    links = ('collaboration', 'downloadETicket')
    ch = ConferenceHolder()
    cdmr = ConfDisplayMgrRegistery()
    counter = Counter()

    for __, event in conferenceHolderIterator(ch, deepness='event'):
        menu = cdmr.getDisplayMgr(event).getMenu()
        must_update = False
        for linkname in links:
            if menu.getLinkByName(linkname) is None:
                counter[linkname] += 1
                must_update = True
        if must_update:
            menu.updateSystemLink()
            counter['updated'] += 1
        if counter['updated'] % 100:
            dbi.commit()

    for linkname in links:
        print "{} links missing: {}".format(linkname, counter[linkname])
    success("Event menus updated: {}".format(counter['updated']))
def main():
    to_fix = defaultdict(list)
    info("Looking for broken contribution links in participants... (This might take a while.)")
    contribs = (x[1] for x in conferenceHolderIterator(ConferenceHolder(), deepness='contrib') if x[0] == 'contrib')
    for contrib in contribs:
        for part in contrib.getPrimaryAuthorList():
            if part.getContribution() is None:
                to_fix[contrib].append(('primary author', part))
        for part in contrib.getCoAuthorList():
            if part.getContribution() is None:
                to_fix[contrib].append(('co-author', part))
        for part in contrib.getAuthorList():
            if part.getContribution() is None:
                to_fix[contrib].append(('author', part))
        for part in contrib.getSpeakerList():
            if part.getContribution() is None:
                to_fix[contrib].append(('speaker', part))

    if not to_fix:
        success("No broken contribution links found.")
        return

    DBMgr.getInstance().sync()  # searching takes a long time, sync to prevent conflicts
    for contrib, parts in to_fix.iteritems():
        conference = contrib.getConference()
        conference_title = conference.getTitle() if conference is not None else 'N/A'
        conference_id = conference.getId() if conference is not None else 'N/A'
        print "Event {} (id {})".format(conference_title, conference_id)
        print "  Contribution {} (id {}):".format(contrib.getTitle(), contrib.getId())
        print "  {}".format(UHContributionDisplay.getURL(contrib))
        for part_type, part in parts:
            if part.getContribution() is not None:  # already fixed
                info("  - link already restored for {} {} (id {})".format(part_type, part.getFullName(), part.getId()))
                continue
            part._contrib = contrib
            success("  - restored link for {} {} (id {})".format(part_type, part.getFullName(), part.getId()))
    DBMgr.getInstance().commit()
Esempio n. 19
0
def main():
    dbi = DBMgr.getInstance()

    dbi.startRequest()

    ch = ConferenceHolder()

    totalSize = 0
    fNumber = 0

    for __, obj in conferenceHolderIterator(ch, verbose=True):
        for material in obj.getAllMaterialList():
            for res in material.getResourceList():
                if isinstance(res, LocalFile):
                    try:
                        totalSize += res.getSize()
                        fNumber += 1
                    except OSError:
                        print "Problems stating size of '%s'" % res.getFilePath()

    dbi.endRequest(False)

    print "%d files, %d bytes total" % (fNumber, totalSize)
    print "avg %s bytes/file" % (float(totalSize) / fNumber)
Esempio n. 20
0
def conferenceMigration1_2(dbi, withRBDB, prevVersion):
    """
    Tasks: 1. Removing Video Services from core
           2. Migrates old AbstractField to new AbstractField subclasses
           3. Add download e-ticket PDF link to the menu
    """
    def removeVideoServicesLinksFromCore(conf):
        """
        Video Services migration remove from core
        """

        # Update Menu Links
        menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
            conf).getMenu()
        if menu:
            link = menu.getLinkByName("collaboration")
            if link:
                link.setURLHandler(urlHandlers.UHCollaborationDisplay)

    def updateAbstractFields(conf):
        """
        Migrates old AbstractField to new AbstractField subclasses
        """

        afm = conf.getAbstractMgr().getAbstractFieldsMgr()
        for index, field in enumerate(afm._fields):
            if field is not None:
                if type(field) != AbstractField:
                    continue  # Database already contains AbstractField objects created on v1.2.
                params = {}
                params["id"] = field._id
                params["type"] = field._type
                params["caption"] = field._caption
                params["isMandatory"] = field._isMandatory
                try:
                    params["maxLength"] = field._maxLength
                except:
                    pass
                try:
                    params["limitation"] = field._limitation
                except:
                    pass
                afm._fields[index] = AbstractField.makefield(params)
                afm._p_changed = 1
        # Delete all None items in the field list
        afm._fields = filter(None, afm._fields)

    cdmr = displayMgr.ConfDisplayMgrRegistery()
    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        removeVideoServicesLinksFromCore(conf)
        updateAbstractFields(conf)
        # Add download e-ticket PDF link to the menu:
        _fixDefaultStyle(conf, cdmr)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Esempio n. 21
0
def conferenceMigration1_0(dbi, withRBDB, prevVersion):
    """
    Tasks: 1. Moving support info fields from conference to a dedicated class
           2. Update non inherited children list
           3. Update Vidyo indexes
    """

    def _updateMaterial(obj):
        for material in obj.getAllMaterialList(sort=False):
            material.getAccessController().setNonInheritingChildren(set())
            if material.getAccessController().getAccessProtectionLevel() != 0:
                material.notify_protection_to_owner(material)
            for resource in material.getResourceList(sort=False):
                if resource.getAccessController().getAccessProtectionLevel() != 0:
                    resource.notify_protection_to_owner()

    def updateSupport(conf):
        #################################################################
        #Moving support info fields from conference to a dedicated class:
        #################################################################

        dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf)
        caption = email = telephone = ""

        if hasattr(dMgr, "_supportEmailCaption"):
            caption = dMgr._supportEmailCaption
            del dMgr._supportEmailCaption
        if hasattr(conf, "_supportEmail"):
            email = conf._supportEmail
            del conf._supportEmail

        supportInfo = SupportInfo(conf, caption, email, telephone)
        conf.setSupportInfo(supportInfo)

    def updateNonInheritedChildren (conf):
        ####################################
        #Update non inherited children list:
        ####################################

        conf.getAccessController().setNonInheritingChildren(set())
        _updateMaterial(conf)

        for session in conf.getSessionList():
            session.getAccessController().setNonInheritingChildren(set())
            if session.getAccessController().getAccessProtectionLevel() != 0:
                session.notify_protection_to_owner(session)
            _updateMaterial(session)
        for contrib in conf.getContributionList():
            contrib.getAccessController().setNonInheritingChildren(set())
            if contrib.getAccessController().getAccessProtectionLevel() != 0:
                contrib.notify_protection_to_owner(contrib)
            _updateMaterial(contrib)
            for subContrib in contrib.getSubContributionList():
                _updateMaterial(subContrib)

    def updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex, pluginActive):
        ######################
        #Update Vidyo indexes:
        ######################
        if not pluginActive:
            return
        csbm = conf.getCSBookingManager()
        for booking in csbm.getBookingList():
            if booking.getType() == "Vidyo" and booking.isCreated():
                endDateIndex.indexBooking(booking)
                vidyoRoomIndex.indexBooking(booking)

    endDateIndex = VidyoTools.getEventEndDateIndex()
    vidyoRoomIndex = VidyoTools.getIndexByVidyoRoom()
    endDateIndex.clear()
    vidyoRoomIndex.clear()
    ph = PluginsHolder()
    collaboration_pt = ph.getPluginType("Collaboration")
    pluginActive = collaboration_pt.isActive() and collaboration_pt.getPlugin("Vidyo").isActive()

    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        updateSupport(conf)
        updateNonInheritedChildren(conf)
        updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex, pluginActive)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Esempio n. 22
0
def conferenceMigration(dbi, withRBDB, prevVersion):
    """
    Adding missing attributes to conference objects and children
    """

    cdmr = displayMgr.ConfDisplayMgrRegistery()
    ch = ConferenceHolder()
    i = 0

    from97 = prevVersion < parse_version("0.98b1")

    # migrating from <=0.97.1 requires smaller granularity
    for (level, obj) in console.conferenceHolderIterator(ch, deepness='subcontrib' if from97 else 'event'):
        # only for conferences
        if level == 'event':

            if from97:
                # handle sessions, that our iterator ignores
                for session in obj.getSessionList():
                    _fixAccessController(session)

                if hasattr(obj, '_Conference__alarmCounter'):
                    raise Exception("Conference Object %s (%s) seems to have been "
                                    "already converted" % (obj, obj.id))

                existingKeys = obj.alarmList.keys()
                existingKeys.sort()
                nstart = int(existingKeys[-1]) + 1 if existingKeys else 0
                obj._Conference__alarmCounter = Counter(nstart)

                # For each conference, take the existing tasks and
                # convert them to the new object classes.
                _convertAlarms(obj)

            # convert registration form's "Personal Data" section to new format
            obj.getRegistrationForm()._convertPersonalData()

            # For each conference, fix the default style
            _fixDefaultStyle(obj, cdmr)

        if from97:
            _fixAccessController(obj,
                                 fixSelf=(level != 'subcontrib'))

            # Convert RegistrationSessions to RegistrantSessions
            if isinstance(obj, Conference):
                for reg in obj.getRegistrants().itervalues():
                    if reg._sessions and \
                           isinstance(reg._sessions[0], RegistrationSession):
                        reg._sessions = [RegistrantSession(ses, reg) \
                                         for ses in reg._sessions]

        if i % 1000 == 999:
            dbi.commit()
            if withRBDB and from97:
                DALManager.commit()

        i += 1

    dbi.commit()
    if withRBDB and from97:
        DALManager.commit()
Esempio n. 23
0
def conferenceMigration1_2(dbi, withRBDB, prevVersion):
    """
    Tasks: 1. Removing Video Services from core
           2. Migrates old AbstractField to new AbstractField subclasses
           3. Add download e-ticket PDF link to the menu
    """

    def removeVideoServicesLinksFromCore(conf):
        """
        Video Services migration remove from core
        """

        # Update Menu Links
        menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf).getMenu()
        if menu:
            link = menu.getLinkByName("collaboration")
            if link:
                link.setURLHandler(urlHandlers.UHCollaborationDisplay)

    def updateAbstractFields(conf):
        """
        Migrates old AbstractField to new AbstractField subclasses
        """

        afm = conf.getAbstractMgr().getAbstractFieldsMgr()
        for index, field in enumerate(afm._fields):
            if field is not None:
                if type(field) != AbstractField:
                    continue  # Database already contains AbstractField objects created on v1.2.
                params = {}
                params["id"] = field._id
                params["type"] = field._type
                params["caption"] = field._caption
                params["isMandatory"] = field._isMandatory
                try:
                    params["maxLength"] = field._maxLength
                except:
                    pass
                try:
                    params["limitation"] = field._limitation
                except:
                    pass
                afm._fields[index] = AbstractField.makefield(params)
                afm._p_changed = 1
        # Delete all None items in the field list
        afm._fields = filter(None, afm._fields)

    cdmr = displayMgr.ConfDisplayMgrRegistery()
    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        removeVideoServicesLinksFromCore(conf)
        updateAbstractFields(conf)
        # Add download e-ticket PDF link to the menu:
        _fixDefaultStyle(conf, cdmr)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Esempio n. 24
0
def conferenceMigration1_0(dbi, withRBDB, prevVersion):
    """
    Tasks: 1. Moving support info fields from conference to a dedicated class
           2. Update non inherited children list
           3. Update Vidyo indexes
    """

    def _updateMaterial(obj):
        for material in obj.getAllMaterialList(sort=False):
            material.getAccessController().setNonInheritingChildren(set())
            if material.getAccessController().getAccessProtectionLevel() != 0:
                material.notify_protection_to_owner(material)
            for resource in material.getResourceList(sort=False):
                if resource.getAccessController().getAccessProtectionLevel() != 0:
                    resource.notify_protection_to_owner()

    def updateSupport(conf):
        #################################################################
        #Moving support info fields from conference to a dedicated class:
        #################################################################

        dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf)
        caption = email = telephone = ""

        if hasattr(dMgr, "_supportEmailCaption"):
            caption = dMgr._supportEmailCaption
            del dMgr._supportEmailCaption
        if hasattr(conf, "_supportEmail"):
            email = conf._supportEmail
            del conf._supportEmail

        supportInfo = SupportInfo(conf, caption, email, telephone)
        conf.setSupportInfo(supportInfo)

    def updateNonInheritedChildren (conf):
        ####################################
        #Update non inherited children list:
        ####################################

        conf.getAccessController().setNonInheritingChildren(set())
        _updateMaterial(conf)

        for session in conf.getSessionList():
            session.getAccessController().setNonInheritingChildren(set())
            if session.getAccessController().getAccessProtectionLevel() != 0:
                session.notify_protection_to_owner(session)
            _updateMaterial(session)
        for contrib in conf.getContributionList():
            contrib.getAccessController().setNonInheritingChildren(set())
            if contrib.getAccessController().getAccessProtectionLevel() != 0:
                contrib.notify_protection_to_owner(contrib)
            _updateMaterial(contrib)
            for subContrib in contrib.getSubContributionList():
                _updateMaterial(subContrib)

    def updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex):
        ####################################
        #Update vidyo indexes:
        ####################################
        csbm = getattr(conf, "_CSBookingManager", None)
        if csbm is None:
            return
        for booking in csbm.getBookingList():
            if booking.getType() == "Vidyo" and booking.isCreated():
                endDateIndex.indexBooking(booking)
                vidyoRoomIndex.indexBooking(booking)

    ph = PluginsHolder()
    collaboration_pt = ph.getPluginType("Collaboration")
    vidyoPluginActive = collaboration_pt.isActive() and collaboration_pt.getPlugin("Vidyo").isActive()
    if vidyoPluginActive:
        endDateIndex = VidyoTools.getEventEndDateIndex()
        vidyoRoomIndex = VidyoTools.getIndexByVidyoRoom()
        endDateIndex.clear()
        vidyoRoomIndex.clear()

    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        updateSupport(conf)
        updateNonInheritedChildren(conf)
        if vidyoPluginActive:
            updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Esempio n. 25
0
 def _iter_events():
     for i, (_, event) in enumerate(conferenceHolderIterator(ConferenceHolder(), deepness='event'), 1):
         yield event
         if i % 1000 == 0:
             # Clean local ZEO cache
             transaction.abort()
Esempio n. 26
0
def conferenceMigration(dbi, withRBDB, prevVersion):
    """
    Adding missing attributes to conference objects and children
    """

    cdmr = displayMgr.ConfDisplayMgrRegistery()
    ch = ConferenceHolder()
    i = 0

    from97 = prevVersion < parse_version("0.98b1")

    # migrating from <=0.97.1 requires smaller granularity
    for (level, obj) in console.conferenceHolderIterator(ch, deepness='subcontrib' if from97 else 'event'):
        # only for conferences
        if level == 'event':

            if from97:
                # handle sessions, that our iterator ignores
                for session in obj.getSessionList():
                    _fixAccessController(session)

                if hasattr(obj, '_Conference__alarmCounter'):
                    raise Exception("Conference Object %s (%s) seems to have been "
                                    "already converted" % (obj, obj.id))

                existingKeys = obj.alarmList.keys()
                existingKeys.sort()
                nstart = int(existingKeys[-1]) + 1 if existingKeys else 0
                obj._Conference__alarmCounter = Counter(nstart)

                # For each conference, take the existing tasks and
                # convert them to the new object classes.
                _convertAlarms(obj)

            # convert registration form's "Personal Data" section to new format
            obj.getRegistrationForm()._convertPersonalData()

            # For each conference, fix the default style
            _fixDefaultStyle(obj, cdmr)

        if from97:
            _fixAccessController(obj,
                                 fixSelf=(level != 'subcontrib'))

            # Convert RegistrationSessions to RegistrantSessions
            if isinstance(obj, Conference):
                for reg in obj.getRegistrants().itervalues():
                    if reg._sessions and \
                           isinstance(reg._sessions[0], RegistrationSession):
                        reg._sessions = [RegistrantSession(ses, reg) \
                                         for ses in reg._sessions]

        if i % 1000 == 999:
            dbi.commit()
            if withRBDB and from97:
                DALManager.commit()

        i += 1

    dbi.commit()
    if withRBDB and from97:
        DALManager.commit()
Esempio n. 27
0
def fix(getter, setter):
    txt = getter()
    print "fixing... ",
    for encoding in ENCODINGS:
        try:
            utxt = txt.decode(encoding)
            print encoding
            setter(utxt.encode('utf-8'))
            return
        except (UnicodeDecodeError, UnicodeEncodeError):
            pass
    print "error! %s" % repr(txt)

with dbi.transaction() as conn:
    i = 0
    for level, conf in conferenceHolderIterator(ConferenceHolder(), deepness='event', verbose=False):
        try:
            conf.getTitle().decode('utf-8')
        except (UnicodeDecodeError, UnicodeEncodeError):
            print '\r%s title' % conf
            fix(conf.getTitle, conf.setTitle)

        try:
            conf.getDescription().decode('utf-8')
        except (UnicodeDecodeError, UnicodeEncodeError):
            print '\r%s description' % conf
            fix(conf.getDescription, conf.setDescription)

        if i % 999 == 0:
            dbi.commit()
        i += 1