Example #1
0
    def _getAnswer(self):
        """This method does everything necessary to create a CDS record and also update the micala database.
        For plain_video talks, it does the following:
         - calls createCDSRecord(),
                 which generates the MARC XML,
                 submits it to CDS,
                 and makes sure a record for this talk exists in micala DB
        For web_lecture talks, it does the following:
         - calls createCDSRecord(),
                 which generates the MARC XML and submits it to CDS
         - calls associateIndicoIDToLOID(),
                 which associates the chosen IndicoID to the existing record of the LOID in micala DB
                 (no need to create a new record, because the user is only allowed to choose LOID's that are already in the micala DB)
         - calls submitMicalaMetadata(), which generates the micala lecture.xml and submits it to micala DB.
        All of these methods update their status to micala DB.
        """

        # Get the MARC XML and submit it to CDS,
        # then update micala database Status table showing task completed.
        # do this for both plain_video and web_lecture talks
        resultCreateCDSRecord = createCDSRecord(
            self._aw, self._IndicoID, self._LODBID, self._lectureTitle,
            self._lectureSpeakers, self._contentType, self._videoFormat,
            self._languages)
        if resultCreateCDSRecord["success"] == False:
            raise RecordingManagerException(
                _("CDS record creation failed.\n%s") %
                resultCreateCDSRecord["result"])
            return _("CDS record creation aborted.")

        if self._contentType == 'web_lecture':
            # Update the micala database to match the LODBID with the IndicoID
            # This only makes sense for web_lecture talks
            # (for plain_video, a record in Lectures should already have been created by createCDSRecord() )
            resultAssociateIndicoIDToLOID = MicalaCommunication.associateIndicoIDToLOID(
                self._IndicoID, self._params.get('LODBID', None))
            if resultAssociateIndicoIDToLOID["success"] == False:
                raise RecordingManagerException(
                    _("micala database update failed.\n%s") %
                    resultAssociateIndicoIDToLOID["result"])
                return _("CDS record creation aborted.")

            # Create lecture.xml and submit to micala server,
            # then update micala database Status table showing task completed
            # (this only makes sense if it is a web_lecture)
            resultSubmitMicalaMetadata = submitMicalaMetadata(
                self._aw, self._IndicoID, self._contentType, self._LODBID,
                self._params.get('LOID', None), self._videoFormat,
                self._languages)
            if resultSubmitMicalaMetadata["success"] == False:
                raise RecordingManagerException(
                    _("CDS record creation failed.\n%s") %
                    resultSubmitMicalaMetadata["result"])
                return _("micala metadata creation aborted.")

        return _(
            "Successfully updated micala database and submitted CDS record for creation."
        )
Example #2
0
    def _checkParams(self):
        CollaborationPluginServiceBase._checkParams(
            self)  #puts the Conference in self._conf
        self._IndicoID = self._params.get('IndicoID', None)
        self._confId = self._params.get('conference', None)
        self._CDSID = self._params.get('CDSID', None)

        if not self._IndicoID:
            raise RecordingManagerException(_("No IndicoID supplied"))
        if not self._confId:
            raise RecordingManagerException(_("No conference ID supplied"))
        if not self._CDSID:
            raise RecordingManagerException(_("No CDS record ID supplied"))
Example #3
0
    def getVars(self):
        vars = WCSPageTemplateBase.getVars(self)

        resultGetOrphans = getOrphans()
        if resultGetOrphans["success"] == True:
            orphans = resultGetOrphans["result"]
        else:
            raise RecordingManagerException(resultGetOrphans["result"])

        vars["Orphans"] = orphans
        talks = getTalks(self._conf, sort=True)
        vars["Talks"] = talks
        vars["Conference"] = self._conf
        previewURL = CollaborationTools.getOptionValue("RecordingManager",
                                                       "micalaPreviewURL")
        if self._rh.use_https():
            previewURL = previewURL.replace("http", "https")
        vars["PreviewURL"] = previewURL

        langPrimary = CollaborationTools.getOptionValue(
            "RecordingManager", "languageCodePrimary")
        langSecondary = CollaborationTools.getOptionValue(
            "RecordingManager", "languageCodeSecondary")
        langDict = CollaborationTools.getOptionValue("RecordingManager",
                                                     "languageDictionary")
        (vars["FlagLanguageDataOK"], vars["LanguageErrorMessages"]) = \
            self._checkLanguageData(langPrimary, langSecondary, langDict)
        vars["LanguageCodePrimary"] = langPrimary
        vars["LanguageCodeSecondary"] = langSecondary
        vars["LanguageDictionary"] = langDict
        vars["LanguageCodes"] = sorted(
            CollaborationTools.getOptionValue("RecordingManager",
                                              "languageDictionary").keys())

        return vars
Example #4
0
    def getMatches(cls, confID):
        '''For the current conference, get list from the database of IndicoID's already matched to Lecture Objects.'''

        try:
            connection = MySQLdb.connect(host   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBServer"),
                                         port   = int(CollaborationTools.getOptionValue("RecordingManager", "micalaDBPort")),
                                         user   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBReaderUser"),
                                         passwd = CollaborationTools.getOptionValue("RecordingManager", "micalaDBReaderPW"),
                                         db     = CollaborationTools.getOptionValue("RecordingManager", "micalaDBName"))
        except MySQLdb.Error, e:
            raise RecordingManagerException(_("MySQL database error %d: %s") % (e.args[0], e.args[1]))
Example #5
0
    def updateLectureInfo(cls, idLecture, lectureTitle, lectureSpeakers):
        '''Update basic info in micala DB for convenience in identifying records.'''

        try:
            connection = MySQLdb.connect(host   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBServer"),
                                         port   = int(CollaborationTools.getOptionValue("RecordingManager", "micalaDBPort")),
                                         user   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBUser"),
                                         passwd = CollaborationTools.getOptionValue("RecordingManager", "micalaDBPW"),
                                         db     = CollaborationTools.getOptionValue("RecordingManager", "micalaDBName"))
        except MySQLdb.Error, e:
            raise RecordingManagerException(_("MySQL database error %d: %s") % (e.args[0], e.args[1]))
Example #6
0
    def _checkParams(self):
        CollaborationPluginServiceBase._checkParams(
            self)  #puts the Conference in self._conf
        self._IndicoID = self._params.get('IndicoID', None)
        self._LOID = self._params.get('LOID', None)
        self._LODBID = self._params.get('LODBID', None)
        self._lectureTitle = self._params.get('lectureTitle', None)
        self._lectureSpeakers = self._params.get('lectureSpeakers', None)
        self._confId = self._params.get('conference', None)
        self._videoFormat = self._params.get('videoFormat', None)
        self._contentType = self._params.get('contentType', None)
        self._languages = self._params.get('languages', None)

        if not self._contentType:
            raise RecordingManagerException(
                _("No content type supplied (plain video or web lecture)"))
        if not self._IndicoID:
            raise RecordingManagerException(_("No IndicoID supplied"))

        if self._contentType == 'web_lecture':
            if not self._LODBID:
                raise RecordingManagerException(_("No LODBID supplied"))
        elif self._contentType == 'plain_video':
            if not self._videoFormat:
                raise RecordingManagerException(_("No video format supplied"))

        if not self._confId:
            raise RecordingManagerException(_("No conference ID supplied"))

        if not self._languages:
            raise RecordingManagerException(_("No languages supplied"))
Example #7
0
    def getIdTask(cls, task_name):
        '''Look up ID of this task in database'''

#        Logger.get('RecMan').debug('task_name = [%s]' % task_name)

        try:
            connection = MySQLdb.connect(host   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBServer"),
                                         port   = int(CollaborationTools.getOptionValue("RecordingManager", "micalaDBPort")),
                                         user   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBReaderUser"),
                                         passwd = CollaborationTools.getOptionValue("RecordingManager", "micalaDBReaderPW"),
                                         db     = CollaborationTools.getOptionValue("RecordingManager", "micalaDBName"))
        except MySQLdb.Error, e:
            raise RecordingManagerException(_("MySQL database error %d: %s") % (e.args[0], e.args[1]))
Example #8
0
    def getCDSPending(cls, confId):
        """Query the Micala database to find Indico IDs whose MARC has been exported to CDS, but not marked as completed in the micala DB.
        (Note: they may have just been completed, but we'll deal with newly completed tasks separately)
         Return a list of these Indico IDs."""

        try:
            connection = MySQLdb.connect(host   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBServer"),
                                         port   = int(CollaborationTools.getOptionValue("RecordingManager", "micalaDBPort")),
                                         user   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBReaderUser"),
                                         passwd = CollaborationTools.getOptionValue("RecordingManager", "micalaDBReaderPW"),
                                         db     = CollaborationTools.getOptionValue("RecordingManager", "micalaDBName"))
        except MySQLdb.Error, e:
            raise RecordingManagerException("MySQL database error %d: %s" % (e.args[0], e.args[1]))
Example #9
0
    def createNewMicalaLecture(cls, lecture_name, contentType):
        '''insert a record into the micala database for a new lecture'''

#        Logger.get('RecMan').debug('createNewMicalaLecture for [%s]' % lecture_name)

        try:
            connection = MySQLdb.connect(host   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBServer"),
                                         port   = int(CollaborationTools.getOptionValue("RecordingManager", "micalaDBPort")),
                                         user   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBUser"),
                                         passwd = CollaborationTools.getOptionValue("RecordingManager", "micalaDBPW"),
                                         db     = CollaborationTools.getOptionValue("RecordingManager", "micalaDBName"))
        except MySQLdb.Error, e:
            raise RecordingManagerException(_("MySQL database error %d: %s") % (e.args[0], e.args[1]))
Example #10
0
    def isTaskComplete(cls, idLecture, idTask):
        '''Check to see if given task has been completed for the given lecture.'''

        flagComplete = False

        try:
            connection = MySQLdb.connect(host   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBServer"),
                                         port   = int(CollaborationTools.getOptionValue("RecordingManager", "micalaDBPort")),
                                         user   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBReaderUser"),
                                         passwd = CollaborationTools.getOptionValue("RecordingManager", "micalaDBReaderPW"),
                                         db     = CollaborationTools.getOptionValue("RecordingManager", "micalaDBName"))
        except MySQLdb.Error, e:
            raise RecordingManagerException(_("MySQL database error %d: %s") % (e.args[0], e.args[1]))
Example #11
0
    def reportStatus(cls, status, message, idMachine, idTask, idLecture):
        '''Make status report to the database'''

#        Logger.get('RecMan').debug('in reportStatus()')

        if idLecture == '':
            idLecture = None

        try:
            connection = MySQLdb.connect(host   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBServer"),
                                         port   = int(CollaborationTools.getOptionValue("RecordingManager", "micalaDBPort")),
                                         user   = CollaborationTools.getOptionValue("RecordingManager", "micalaDBUser"),
                                         passwd = CollaborationTools.getOptionValue("RecordingManager", "micalaDBPW"),
                                         db     = CollaborationTools.getOptionValue("RecordingManager", "micalaDBName"))
        except MySQLdb.Error, e:
            raise RecordingManagerException(_("MySQL database error %d: %s") % (e.args[0], e.args[1]))
Example #12
0
def getBasicXMLRepresentation(aw, IndicoID, contentType, videoFormat,
                              languages):
    '''Generate the basic XML that is to be transformed using one of the XSL files.'''

    # Incantation to initialize XML that I don't fully understand
    xmlGen = XMLGen()
    xmlGen.initXml()

    # aw stands for AccessWrapper. I don't really understand exactly what
    # this command does, but it is apparently necessary
    og = outputGenerator(aw, xmlGen)

    # Generate XML event tag to enclose the entire conference
    xmlGen.openTag("event")

    # Given the IndicoID, retrieve the type of talk and IDs
    parsed = parseIndicoID(IndicoID)

    # populate dictionary with RecordingManager parameters to be used by methods in outputGenerator
    # such as confToXML, _confToXML, _sessionToXML, _contribToXML, _subContributionToXML
    tags = {
        'talkType': parsed['type'],
        'talkId': parsed[parsed['type']],
        'contentType': contentType,
        'videoFormat': videoFormat,
        'languages': languages
    }

    #    Logger.get('RecMan').info("tags: [%s] [%s] [%s] [%s]" %\
    #                              (tags['talkType'],
    #                              tags['talkId'],
    #                              tags['contentType'],
    #                              tags['videoFormat']))
    #    for l in tags["languages"]:
    #        Logger.get('RecMan').info("language: %s" % l)

    # Given the conference ID, retrieve the corresponding Conference object
    conference = ConferenceHolder().getById(parsed["conference"])

    # Defining the dictionary 'tags' is how we identify ourselves to the outputGenerator
    # methods.
    # Call ConfToXML with different args depending on talk type.
    # includeSession - descend into each session.
    #                  This is necessary for sessions, contributions, and subcontributions,
    #                  since contributions and subcontributions are children of sessions.
    # includeContribution - necessary for contributions and subcontributions
    # includeMaterial - this is always set to "1".
    # showSession - create XML for a particular session, identified by ID
    # showContribution - create XML for a particular contribution, identified by ID
    # showSubContribution - create XML for a particular subcontribution, identified by ID
    # overrideCache - True means force it NOT to use the cache.
    # recordingManagerTags - this is how we pass along all the necessary RecordingManager args to the outputGenerator methods.
    #
    # Nobody outside CERN should have access to CERN access lists.
    # OAI harvesters outside CERN call the same methods we'll be calling,
    # and we don't want to make the access lists available to them.
    if parsed["type"] == 'conference':
        #        Logger.get('RecMan').info("generating MARC XML for a conference")
        og.confToXML(
            conference,
            0,  # includeSession
            0,  # includeContribution
            1,  # includeMaterial
            showSession=None,
            showContribution=None,
            showSubContribution=None,
            overrideCache=True,
            recordingManagerTags=tags)
    elif parsed["type"] == 'session':
        #        Logger.get('RecMan').info("generating MARC XML for a session")
        og.confToXML(
            conference,
            1,  # includeSession
            0,  # includeContribution
            1,  # includeMaterial
            showSession=parsed["session"],
            showContribution=None,
            showSubContribution=None,
            overrideCache=True,
            recordingManagerTags=tags)
    elif parsed["type"] == 'contribution':
        #        Logger.get('RecMan').info("generating MARC XML for a contribution")
        og.confToXML(
            conference,
            1,  # includeSession
            1,  # includeContribution
            1,  # includeMaterial
            showSession=parsed["session"],
            showContribution=parsed["contribution"],
            showSubContribution=None,
            overrideCache=True,
            recordingManagerTags=tags)
    elif parsed["type"] == 'subcontribution':
        #        Logger.get('RecMan').info("generating MARC XML for a subcontribution")
        og.confToXML(
            conference,
            1,  # includeSession
            1,  # includeContribution
            1,  # includeMaterial
            showSession=None,
            showContribution=parsed[
                "contribution"],  # maybe I should turn this on?
            showSubContribution=parsed["subcontribution"],
            overrideCache=True,
            recordingManagerTags=tags)
    else:
        raise RecordingManagerException(
            _("IndicoID %s is not a known conference, session, contribution or subcontribution."
              ) % IndicoID)

    xmlGen.closeTag("event")

    # Retrieve the entire basic XML string
    return xmlGen.getXml()