Beispiel #1
0
def normValueById(schema, normid):
    '''
    select * from luminormsv2data where data_id=normid
    output:
        {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}
    '''
    result = {}
    l = nameDealer.luminormv2dataTableName()
    paramdict = {}
    qHandle = schema.newQuery()
    try:
        qHandle.addToTableList(l)
        qConditionStr = 'DATA_ID=:normid'
        qCondition = coral.AttributeList()
        qCondition.extend('normid', 'unsigned long long')
        qCondition['normid'].setData(normid)
        qResult = coral.AttributeList()
        qHandle.setCondition(qConditionStr, qCondition)
        cursor = qHandle.execute()
        while cursor.next():
            since = cursor.currentRow()['SINCE'].data()
            corrector = cursor.currentRow()['CORRECTOR'].data()
            amodetag = cursor.currentRow()['AMODETAG'].data()
            nominalegev = cursor.currentRow()['NOMINALEGEV'].data()
            comment = ''
            if not cursor.currentRow()['COMMENT'].isNull():
                comment = cursor.currentRow()['COMMENT'].data()
            (correctorfunc, params) = CommonUtil.parselumicorrector(corrector)
            paramdict = {}
            for param in params:
                paramvalue = 0.0
                if not cursor.currentRow()[param.upper()].isNull():
                    paramvalue = cursor.currentRow()[param.upper()].data()
                    paramdict[param] = paramvalue
            result[since] = [
                correctorfunc, paramdict, amodetag, nominalegev, comment
            ]
    except:
        raise
    return result
Beispiel #2
0
def normValueById(schema,normid):
    '''
    select * from luminormsv2data where data_id=normid
    output:
        {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}
    '''
    result={}
    l=nameDealer.luminormv2dataTableName()
    paramdict={}
    qHandle=schema.newQuery()
    try:
        qHandle.addToTableList(l)
        qConditionStr='DATA_ID=:normid'
        qCondition=coral.AttributeList()
        qCondition.extend('normid','unsigned long long')
        qCondition['normid'].setData(normid)
        qResult=coral.AttributeList()
        qHandle.setCondition(qConditionStr,qCondition)
        cursor=qHandle.execute()
        while cursor.next():
            since=cursor.currentRow()['SINCE'].data()
            corrector=cursor.currentRow()['CORRECTOR'].data()
            amodetag=cursor.currentRow()['AMODETAG'].data()
            nominalegev=cursor.currentRow()['NOMINALEGEV'].data()
            comment=''
            if not cursor.currentRow()['COMMENT'].isNull():
                comment=cursor.currentRow()['COMMENT'].data()
            (correctorfunc,params)=CommonUtil.parselumicorrector(corrector)
            paramdict={}
            for param in params:
                paramvalue=0.0
                if not cursor.currentRow()[param.upper()].isNull():
                    paramvalue=cursor.currentRow()[param.upper()].data()
                    paramdict[param]=paramvalue
            result[since]=[correctorfunc,paramdict,amodetag,nominalegev,comment]
    except:
        raise
    return result
Beispiel #3
0
                raise RuntimeError(
                    'parameter corrector is required for create/insert action')
            if not normvalueDict.has_key(
                    'since') or not normvalueDict['since']:
                raise RuntimeError(
                    'parameter since is required for create/insert action')
            correctorStr = normvalueDict['corrector']
            sincerun = int(normvalueDict['since'])
            if options.firstsince:
                if sincerun < int(options.firstsince):
                    continue
            amodetag = normvalueDict['amodetag']
            egev = int(normvalueDict['egev'])
            detailcomment = normvalueDict['comment']
            (correctorname,
             parameterlist) = CommonUtil.parselumicorrector(correctorStr)
            parameterDict = {}
            for param in parameterlist:
                parameterDict[param] = normvalueDict[param]
            normDML.insertValueToNormId(dbsession.nominalSchema(),
                                        normdata_id,
                                        sincerun,
                                        correctorStr,
                                        amodetag,
                                        egev,
                                        parameterDict,
                                        comment=detailcomment)
        dbsession.transaction().commit()

    ##############################
    #  setdefault/unsetdefault
Beispiel #4
0
     else:
         normdata_id=normDML.normIdByName(dbsession.nominalSchema(),normname)
     for normvalueDict in normvalues:
         if 'corrector' not in normvalueDict or not normvalueDict['corrector']:
             raise RuntimeError('parameter corrector is required for create/insert action')
         if 'since' not in normvalueDict or not normvalueDict['since']:
             raise RuntimeError('parameter since is required for create/insert action')
         correctorStr=normvalueDict['corrector']
         sincerun=int(normvalueDict['since'])
         if options.firstsince:
             if sincerun<int(options.firstsince):
                 continue
         amodetag=normvalueDict['amodetag']
         egev=int(normvalueDict['egev'])
         detailcomment=normvalueDict['comment']
         (correctorname,parameterlist)=CommonUtil.parselumicorrector(correctorStr)
         parameterDict={}
         for param in parameterlist:
             parameterDict[param]=normvalueDict[param]
         normDML.insertValueToNormId(dbsession.nominalSchema(),normdata_id,sincerun,correctorStr,amodetag,egev,parameterDict,comment=detailcomment)
     dbsession.transaction().commit()
     
 ##############################
 #  setdefault/unsetdefault
 ##############################
 if options.action in ['setdefault','unsetdefault']:
     dbsession=svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
     dbsession.transaction().start(False)      
     if options.action=='setdefault':
         normDML.promoteNormToTypeDefault(dbsession.nominalSchema(),options.normname,options.lumitype)
     if options.action=='unsetdefault':