示例#1
0
 def update(self, organisationUiPb):
     organisationPb = OrganisationPb()
     if (Strings.notEmpty(organisationUiPb.dbInfo.id)):
         self.m_entityUpdator.update(pb=organisationPb.dbInfo,
                                     uipb=organisationUiPb.dbInfo)
     else:
         assert True, "DbInfo id  Cannot be empty"
     if (Strings.notEmpty(organisationUiPb.name.firstName)):
         self.m_nameUpdator.update(pb=organisationPb.name,
                                   uipb=organisationUiPb.name)
     if (organisationUiPb.time.milliseconds > 0):
         self.m_timeUpdator.update(pb=organisationPb.time,
                                   uipb=organisationUiPb.time)
     else:
         self.m_timeUpdator.update(
             pb=organisationPb.time,
             uipb=self.m_timeUtility.getTimeUiPb(
                 timeUiPb=organisationUiPb.time,
                 timeZone=organisationUiPb.dbInfo.locale.defaultTimeZone))
     if (Strings.isEmpty(organisationUiPb.orgCode)):
         organisationPb.orgCode = self.m_organisationHelper.getOrgCode(
             id=organisationUiPb.dbInfo.id, timeuipb=organisationUiPb.time)
     else:
         organisationPb.orgCode = organisationUiPb.orgCode
     return organisationPb
    def refUpdator(self, schoolPbRef, schoolUiPbRef):
        if (Strings.notEmpty(schoolUiPbRef.id)):
            schoolPbRef.id = schoolUiPbRef.id
        else:
            return

        if (Strings.notEmpty(schoolUiPbRef.organisation.id)):
            self.m_genericUpdator.update(pb=schoolPbRef.organisation,
                                         uipb=schoolUiPbRef.organisation)
        else:
            raise Exception('School must have his organisation' +
                            schoolUiPbRef)

        if (Strings.notEmpty(schoolUiPbRef.schoolCode)):
            schoolPbRef.schoolCode = schoolUiPbRef.schoolCode

        if (len(schoolUiPbRef.classType) > 0):
            for classType in schoolUiPbRef.classType:
                schoolPbRef.classType.append(classType)
        else:
            raise Exception('School at least at least have one classes')

        if (len(schoolUiPbRef.sectionType) > 0):
            for sectionType in schoolUiPbRef.sectionType:
                schoolPbRef.sectionType.append(sectionType)
        else:
            raise Exception('School at least at least have one section')
    def compare(self, oldPb, newPb):
        if (Strings.notEmpty(oldPb.street)):
            if (Strings.notEmpty(newPb.street)):
                oldPb.street = newPb.street
            else:
                raise Exception('street Cannot be empty' +
                                MessageToJson(newPb))

        if (Strings.notEmpty(oldPb.landmark)):
            if (Strings.notEmpty(newPb.landmark)):
                oldPb.landmark = newPb.landmark
            else:
                raise Exception('landmark Cannot be empty' +
                                MessageToJson(newPb))

        if (Strings.notEmpty(oldPb.area)):
            if (Strings.notEmpty(newPb.area)):
                oldPb.area = newPb.area
            else:
                raise Exception('Area Cannot be empty' + MessageToJson(newPb))

        if (Strings.notEmpty(oldPb.city)):
            if (Strings.notEmpty(newPb.city)):
                oldPb.city = newPb.city
            else:
                raise Exception('city Cannot be empty' + MessageToJson(newPb))

        if (Strings.notEmpty(oldPb.state)):
            if (Strings.notEmpty(newPb.state)):
                oldPb.state = newPb.state
            else:
                raise Exception('state Cannot be empty' + MessageToJson(newPb))
def compare(self, newPb, oldPb):
    self.m_entityComparetor.compare(newPb=newPb.dbInfo, oldPb=oldPb.dbInfo)
    self.m_nameComparetor.comapre(newpb=newPb.name, oldPb=oldPb.name)
    self.m_timeComparetor.comapre(newPb=newPb.createdTime,
                                  oldPb=oldPb.createdTime)
    if (oldPb.classType != UNKNOWN_CLASS):
        if (newPb.classType != UNKNOWN_CLASS):
            oldPb.classType = newPb.classType
        else:
            raise Exception('classType is missing' + MessageToJson(newPb))
    if (oldPb.sectionType != UNKNOWN_SECTION):
        if (newPb.sectionType != UNKNOWN_SECTION):
            oldPb.sectionType = newPb.sectionType
        else:
            raise Exception('sectionType is missing' + MessageToJson(newPb))
    if (Strings.notEmpty(oldPb.schoolRef.id)):
        if (Strings.notEmpty(newPb.schoolRef.id)):
            self.m_schoolRefComparetor.refConvertor(
                schoolPbRef=oldPb.schoolRef, schoolUiPbRef=newPb.schoolRef)
        else:
            raise Exception('schoolRef is missing' + MessageToJson(newPb))
    if (Strings.notEmpty(oldPb.classCode)):
        if (Strings.notEmpty(newPb.classCode)):
            oldPb.classCode = newPb.classCode
        else:
            raise Exception('classCode is missing' + MessageToJson(newPb))
    return oldPb
示例#5
0
 def checkTypeOfMethod(self):
     self.m_method = self.m_request.method
     if (Strings.areEquals(self.m_method, RequestMethodTypeEnum.PUT.name)):
         self.m_requestType = RequestTypeEnum.UPDATE
         self.controlFlow(currentState=State.COVERT_TO_UIPB)
     elif (Strings.areEquals(self.m_method, RequestMethodTypeEnum.POST.name)):
         self.m_requestType = RequestTypeEnum.CREATE
         self.controlFlow(currentState=State.COVERT_TO_UIPB)
     self.controlFlow(currentState=State.CHECK_IS_REQ_EMPTY)
示例#6
0
 def compare(self, newPb, oldPb):
     self.m_entityComparetor.compare(newPb=newPb.dbInfo, oldPb=oldPb.dbInfo)
     self.m_nameComparetor.comapre(newpb=newPb.name, oldPb=oldPb.name)
     self.m_timeComparetor.comapre(newPb=newPb.time, oldPb=oldPb.time)
     if (Strings.notEmpty(oldPb.orgCode)):
         if (Strings.notEmpty(newPb.orgCode)):
             oldPb.orgCode = newPb.orgCode
         else:
             raise Exception('OrgCode is missing' + MessageToJson(newPb))
     return oldPb
示例#7
0
 def builderToMail(self, emailBuilder):
     fromId = Strings.getFormattedEmail(builder=emailBuilder.fromId)
     toids = list()
     for ids in emailBuilder.toId:
         toids.append(Strings.getFormattedEmail(builder=ids))
     subject = emailBuilder.subject
     content = emailBuilder.content
     return Mail(from_email=fromId,
                 to_emails=toids,
                 subject=subject,
                 html_content=content)
示例#8
0
 def compare(self, newPb, oldPb):
     if (Strings.notEmpty(oldPb.id)):
         if (Strings.notEmpty(newPb.id)):
             oldPb.id = newPb.id
         else:
             raise Exception('Id  Is Empty' + MessageToJson(newPb))
     self.m_namePbComparetor.comapre(newpb=newPb.name, oldPb=oldPb.name)
     if (Strings.notEmpty(oldPb.code)):
         if (Strings.notEmpty(newPb.code)):
             oldPb.code = newPb.code
         else:
             raise Exception('Code  Is Empty' + MessageToJson(newPb))
示例#9
0
 def createTable(self, tableName):
     assert Strings.notEmpty(tableName), "table Name Cannot be Empty"
     connection = self.m_databaseConnection.getConnection()
     for env in EnvironmentTypeEnum:
         try:
             query = self.getCreateTableQuery(table=Strings.concatinateWithUnderScore(str1=tableName, str2=env.name))
             print(query)
             connection.cursor().execute(query)
             connection.commit()
         except:
             pass
     self.m_databaseConnection.closeConnection(connection=connection);
示例#10
0
 def compare(self, newpb, oldPb):
     if (oldPb.code != UNKNOWN_CODE):
         if (newpb.code != UNKNOWN_CODE):
             oldPb.code = newpb.code
         else:
             raise Exception('Code Cannot be UNKNOWN_CODE' +
                             MessageToJson(newpb))
     if (Strings.notEmpty(oldPb.number)):
         if (Strings.notEmpty(newpb.number)):
             oldPb.number = newpb.number
         else:
             raise Exception('Number Cannot be Empty' +
                             MessageToJson(newpb))
示例#11
0
 def validate(self, loginpb):
     if (loginpb.lifeTime != StatusEnum.UNKNOWN_STATUS):
         self.typeConfig.append(
             self.m_helper.getEqualToCondition(cond=loginSearchConfig.LIFETIME, value=StatusEnum.Name(loginpb.lifeTime)))
     if (Strings.notEmpty(loginpb.login.contactDetails.email.localPart) and Strings.notEmpty(
             loginpb.login.contactDetails.email.domain)):
         self.typeConfig.append(self.m_helper.getEqualToCondition(cond=loginSearchConfig.EMAIL_LOCAL_PART,
                                                                  value=loginpb.login.contactDetails.email.localPart))
         self.typeConfig.append(self.m_helper.getEqualToCondition(cond=loginSearchConfig.EMAIL_DOMAIN_PART,
                                                                  value=loginpb.login.contactDetails.email.domain))
     if (Strings.notEmpty(loginpb.login.contactDetails.primaryMobile.number)):
         self.typeConfig.append(self.m_helper.getEqualToCondition(cond=loginSearchConfig.PRIMARY_MOBILE_NO,
                                                                  value=loginpb.login.contactDetails.primaryMobile.number))
 def convert(self, organisationPb):
     organisationUiPb = OrganisationUiPb()
     if (Strings.notEmpty(organisationPb.dbInfo.id)):
         self.m_entityPbConvertor.convert(pb=organisationPb.dbInfo,
                                          uipb=organisationUiPb.dbInfo)
     if (Strings.notEmpty(organisationPb.name.firstName)):
         self.m_namePbConvertor.convert(pb=organisationPb.name,
                                        uipb=organisationUiPb.name)
     if (organisationPb.time.milliseconds > 0):
         self.m_timePbConvertor.convert(pb=organisationPb.time,
                                        uipb=organisationUiPb.time)
     if (Strings.notEmpty(organisationPb.orgCode)):
         organisationUiPb.orgCode = organisationPb.orgCode
     return organisationUiPb
示例#13
0
 def checkReqEmpty(self):
     if (Strings.isEmpty(self.m_request.full_path)):
         self.m_error = self.throw(errorTypeEnum=INPUT_ERROR, errorString="Input cannot be Empty or Wrong")
         self.controlFlow(currentState=State.DONE)
     else:
         self.m_requestData = self.m_requestHandlerHelper.getRequestData(request=self.m_request)
         self.controlFlow(currentState=State.IF_GET_CHECK_REQ_JSON)
示例#14
0
 def validate(self, pushNotificationSearchPb):
     if (pushNotificationSearchPb.type.personType != PersonTypeEnum.UNKNOWN_PERSON_TYPE):
         self.typeConfig.append(
             self.m_helper.getEqualToCondition(cond=PushNotificationSearchConfig.PERSON_TYPE, value=PersonTypeEnum.Name(pushNotificationSearchPb.type.personType)))
     if(Strings.notEmpty(pushNotificationSearchPb.workerRef.dbInfo.id)):
         self.typeConfig.append(
             self.m_helper.getEqualToCondition(cond=PushNotificationSearchConfig.WORKER_REF, value=pushNotificationSearchPb.workerRef.dbInfo.id))
示例#15
0
 def getRawData(self, resp):
     for response in resp:
         if (Strings.areEquals(response['Name'],
                               BasicEntityIndex.RAW_DATA.value)):
             return response['Value']
         else:
             continue
     return None
示例#16
0
    def compare(self, newPb, oldPb):
        if (Strings.notEmpty(oldPb.id)):
            if (Strings.notEmpty(newPb.id)):
                if (Strings.areEquals(str1=oldPb.id, str2=newPb.id)):
                    oldPb.id = newPb.id
                else:
                    raise Exception('DbInfo id deffers in pbs' +
                                    MessageToJson(newPb) + " " +
                                    MessageToJson(oldPb))
            else:
                assert True, "id Cannot be Empty"
        else:
            assert True, "id Cannot be Empty"

        if (oldPb.version > 0):
            if (newPb.version > 0):
                if (oldPb.version < newPb.version):
                    oldPb.version = newPb.version
                else:
                    raise Exception(
                        'Version of new pb is should be greator then old' +
                        MessageToJson(newPb) + " " + MessageToJson(oldPb))
            else:
                assert True, "version cant be zero"
        else:
            assert True, "version cant be zero"

        if (oldPb.lifeTime != UNKNOWN_STATUS):
            if (newPb.lifeTime != UNKNOWN_STATUS):
                oldPb.lifeTime = newPb.lifeTime
            else:
                raise Exception('Status Cannot be UNKOWN_STATUS' +
                                MessageToJson(newPb))
        else:
            raise Exception('Status Cannot be UNKOWN_STATUS' +
                            MessageToJson(newPb))

        if (oldPb.locale.defaultTimeZone != UNKNOWN_TIME_ZONE):
            if (newPb.locale.defaultTimeZone != UNKNOWN_TIME_ZONE):
                oldPb.locale.defaultTimeZone = newPb.locale.defaultTimeZone
            else:
                raise Exception('TimeZone Cannot be UNKOWN_TIME_ZONE' +
                                MessageToJson(newPb))
        else:
            raise Exception('TimeZone Cannot be UNKOWN_TIME_ZONE' +
                            MessageToJson(newPb))
 def checkTableExixts(self, tableName):
     if (self.checkTable(tableName)):
         return True
     else:
         if (Strings.areEquals(tableName, "ENTITY")):
             self.m_createEntiyTable.createTable(tableName=tableName)
         else:
             self.m_createTable.createTable(tableName=tableName)
示例#18
0
    def updator(self, classUiPb):
        classPb = ClassPb()
        if (Strings.notEmpty(classUiPb.dbInfo.id)):
            self.m_entityUipbUpdator.update(pb=classPb.dbInfo,
                                            uipb=classUiPb.dbInfo)
        else:
            assert True, "DbInfo id  Cannot be empty"
        if (Strings.notEmpty(classUiPb.name.firstName)):
            self.m_nameUiPbUpdator.update(pb=classUiPb.name,
                                          uipb=classUiPb.name)

        if (classUiPb.classType != UNKNOWN_CLASS):
            classPb.classType = classUiPb.classType
        else:
            assert True, "Class type  Cannot be UNKNOWN_CLASS"

        if (classUiPb.sectionType != UNKNOWN_SECTION):
            classPb.sectionType = classUiPb.sectionType
        else:
            assert True, "Section type  Cannot be UNKNOWN_SECTION"

        if (Strings.notEmpty(classUiPb.schoolRef.id)):
            self.m_schooRefUpdator.refUpdator(
                schoolPbRef=classPb.schoolRef,
                schoolUiPbRef=classUiPb.schoolRef)
        else:
            raise Exception('Class Must have School Ref' +
                            MessageToJson(classUiPb))

        if (Strings.notEmpty(classUiPb.classCode)):
            classPb.classCode = classUiPb.classCode
        else:
            classPb.classCode = self.m_classHelper.getClassCode(
                schoolCode=classUiPb.schoolRef.schoolCode,
                id=classUiPb.dbInfo.id)
        if (classUiPb.createdtime.milliseconds > 0):
            self.m_timeUpdator.update(pb=classPb.createdTime,
                                      uipb=classUiPb.createdtime)
        else:
            self.m_timeUpdator.update(
                pb=classPb.time,
                uipb=self.m_timeUtility.getTimeUiPb(
                    timeUiPb=classUiPb.time,
                    timeZone=classUiPb.dbInfo.locale.default))
示例#19
0
 def getEntityId(self):
     self.m_id = self.m_entityService.getEntityId()
     if (Strings.notEmpty(self.m_id)):
         self.m_uiPb.dbInfo.id = self.m_id
         self.m_uiPb.dbInfo.lifeTime = ACTIVE
         self.m_uiPb.dbInfo.version = 1
         self.controlFlow(currentState=State.CONVERT_TO_PB)
     else:
         # self.controlFlow(currentState=State.DONE)
         raise Exception('Entity id is not Genreated ')
 def isJson(self, json):
     if (Strings.isEmpty(str(json))):
         return None
     elif ("{" in str(json)):
         if (self.json_validator(json)):
             return True
         else:
             return JSON_VALIDATION_ERROR
     else:
         return False
示例#21
0
    def item_map(self, id, keyType, pbGenrated):
        map = HashMap()
        if (keyType == DynamoDbKeyTypeEnum.HASH_KEY):
            map.put(key=DynamoDbKeyTypeEnum.HASH_KEY.name, value=id)
        elif (keyType == DynamoDbKeyTypeEnum.RANGE_KEY):
            key = Strings.splitString(char="@", string=id)
            map.put(key=DynamoDbKeyTypeEnum.HASH_KEY.name, value=key[0])
            map.put(key=DynamoDbKeyTypeEnum.RANGE_KEY.name, value=key[1])

        return self.m_listUtilty.listToDict(map.entry_set(), pbGenrated.entry_set())
 def checkTable(self, tableName):
     assert Strings.notEmpty(tableName), "table Name Cannot be Empty"
     connection = self.m_databaseConnection.getConnection()
     cursor = connection.cursor()
     check = False
     for env in EnvironmentTypeEnum:
         try:
             query = self.ckeckTableQuery(
                 tableName=Strings.concatinateWithUnderScore(str1=tableName,
                                                             str2=env.name))
             print(query)
             cursor.execute(query)
             val = cursor.fetchall()[0]
             check = val[0]
             connection.commit()
         except:
             pass
     self.m_databaseConnection.closeConnection(connection=connection)
     if (check):
         return check
示例#23
0
 def convert(self, schoolPb):
     schoolUiPb = SchoolUiPb()
     if (Strings.notEmpty(schoolPb.dbInfo.id)):
         self.m_entityConvertor.convert(pb=schoolPb.dbInfo,
                                        uipb=schoolUiPb.dbInfo)
     if (Strings.notEmpty(schoolPb.name.firstName)):
         self.m_nameConvertor.convert(pb=schoolPb.name,
                                      uipb=schoolUiPb.name)
     if (Strings.notEmpty(schoolPb.address.street)):
         self.m_addressConvertor.convert(uipb=schoolUiPb.address,
                                         pb=schoolPb.address)
     if (len(schoolPb.mobile) > 0):
         # schoolUiPb.mobile.extend(self.m_mobileConvetor.getMobileListtUiPb(pb=schoolPb.mobile))
         self.m_listConvertor.listConvertor(uipbList=schoolUiPb.mobile,
                                            pbList=schoolPb.mobile)
     if (schoolPb.createdTime.milliseconds > 0):
         self.m_timeConvertor.convert(pb=schoolPb.createdTime,
                                      uipb=schoolUiPb.createdTime)
     if (Strings.notEmpty(schoolPb.organisation.id)):
         self.m_genericRefConvertor.convert(uipb=schoolUiPb.organisation,
                                            pb=schoolPb.organisation)
     if (Strings.notEmpty(schoolPb.schoolCode)):
         schoolUiPb.schoolCode = schoolPb.schoolCode
     if (schoolPb.accountUseType != UNKNOWN_ACCOUNT_TYPE):
         schoolUiPb.accountUseType = schoolPb.accountUseType
     if (Strings.notEmpty(schoolPb.accountDetails.accountNo)):
         self.m_accountDetailsConvertor.convert(
             pb=schoolPb.accountDetails, uipb=schoolUiPb.accountDetails)
     schoolUiPb.accountSection = schoolPb.accountSection
     return schoolUiPb
示例#24
0
    def validate(self, consumerpb):
        if (consumerpb.lifeTime != StatusEnum.UNKNOWN_STATUS):
            self.typeConfig.append(
                self.m_helper.getCondition(cond=ConsumerSearchConfig.LIFETIME,
                                           value=StatusEnum.Name(
                                               (consumerpb.lifeTime))))
        if (Strings.notEmpty(consumerpb.contactDetails.email.localPart)
                and Strings.notEmpty(consumerpb.contactDetails.email.domain)):
            self.typeConfig.append(
                self.m_helper.getCondition(
                    cond=ConsumerSearchConfig.EMAIL_LOCAL_PART,
                    value=consumerpb.contactDetails.email.localPart))
            self.typeConfig.append(
                self.m_helper.getCondition(
                    cond=ConsumerSearchConfig.EMAIL_DOMAIN_PART,
                    value=consumerpb.contactDetails.email.domain))

        if (Strings.notEmpty(consumerpb.contactDetails.primaryMobile.number)):
            self.typeConfig.append(
                self.m_helper.getCondition(
                    cond=ConsumerSearchConfig.PRIMARY_MOBILE_NO,
                    value=consumerpb.contactDetails.primaryMobile.number))
        if (len(consumerpb.contactDetails.secondryMobile) > 0):
            self.typeConfig.append(
                self.m_helper.getConditionForCheckingInJsonArray(
                    listKey='contactDetails',
                    fieldKey='secondryMobile',
                    key='number',
                    value=consumerpb.contactDetais.primaryMobile.number))
        if (Strings.notEmpty(consumerpb.mobileNo.number)):
            self.typeConfig.append(
                self.m_helper.getOrCond(
                    cond1=self.m_helper.getCondition(
                        cond=ConsumerSearchConfig.PRIMARY_MOBILE_NO,
                        value=consumerpb.mobileNo.number),
                    cond2=self.m_helper.getConditionForCheckingInJsonArray(
                        listKey='contactDetails',
                        fieldKey='secondryMobile',
                        key='number',
                        value=consumerpb.mobileNo.number)))
示例#25
0
    def comapre(self, newpb, oldPb):
        if (Strings.notEmpty(oldPb.firstName)):
            if (Strings.notEmpty(newpb.firstName)):
                oldPb.firstName = newpb.firstName
            else:
                raise Exception('First Name Is Empty' + MessageToJson(newpb))

        if (len(oldPb.middleName) > 0):
            if (len(newpb.middleName) > 0):
                del oldPb.middleName[:]
                oldPb.middleName.extend(newpb.middleName)
            else:
                raise Exception('MiddleName Is Empty' + MessageToJson(newpb))

        if (Strings.notEmpty(oldPb.lastName)):
            if (Strings.notEmpty(newpb.lastName)):
                oldPb.lastName = newpb.lastName
            else:
                raise Exception('lastName Is Empty' + MessageToJson(newpb))

        if (Strings.notEmpty(oldPb.canonicalName)):
            if (Strings.notEmpty(newpb.canonicalName)):
                oldPb.canonicalName = newpb.canonicalName
            else:
                raise Exception('canonicalName Is Empty' +
                                MessageToJson(newpb))
示例#26
0
 def convert(self, classPb):
     classUiPb = ClassUiPb()
     if (Strings.notEmpty(classPb.dbInfo.id)):
         self.m_entityPbConvertor.convert(pb=classPb.dbInfo,
                                          uipb=classUiPb.dbInfo)
     if (Strings.notEmpty(classPb.name.firstName)):
         self.m_namePbConvertor.convert(pb=classPb.name,
                                        uipb=classUiPb.name)
     if (classPb.crteatedTime.milliseconds > 0):
         self.m_timePbConvertor.convert(pb=classPb.createdTime,
                                        uipb=classUiPb.createdTime)
     if (Strings.notEmpty(classPb.schoolCode)):
         classUiPb.schoolCode = classPb.schoolCode
     if (classPb.classType != UNKNOWN_CLASS):
         classUiPb.classType = classPb.classType
     if (classPb.sectionType != UNKNOWN_SECTION):
         classUiPb.sectionType = classPb.sectionType
     if (Strings.notEmpty(classPb.schoolRef.id)):
         self.m_schoolRefConverotor.refConvertor(
             schoolPbRef=classPb.schoolRef,
             schoolUiPbRef=classUiPb.schoolRef)
     return classUiPb
示例#27
0
    def getKey(self, id, keyType):
        if (keyType == DynamoDbKeyTypeEnum.HASH_KEY):
            map = dict()
            map[DynamoDbKeyTypeEnum.HASH_KEY.name] = id
            return map
        elif (keyType == DynamoDbKeyTypeEnum.RANGE_KEY):
            key = Strings.splitString("@",id)
            map = dict()
            map[DynamoDbKeyTypeEnum.HASH_KEY.name] = key[0]
            map[DynamoDbKeyTypeEnum.RANGE_KEY.name] = key[1]
            return map

        else:
            raise Exception("Key Type is Not Exixts")
 def get(self):
     try:
         query = self.m_helper.getEntityQuery(
             data=Strings.concatinateWithUnderScore(
                 self.m_table.tableName(),
                 self.m_serverEnvironment.getServerEnvironment().name))
         print(query)
         conn = self.m_dbConnection.getConnection()
         cursor = conn.cursor()
         cursor.execute(query)
         row = cursor.fetchall()[0]
         self.id = row[1]
         conn.close()
         return self.m_encoder.convert(id=int(row[1]))
     except (Exception, psycopg2.Error) as error:
         print("Error in update operation", error)
    def update(self):

        try:
            query = self.m_helper.updateEntityQuery(
                data=Strings.concatinateWithUnderScore(
                    self.m_table.tableName(),
                    self.m_serverEnvironment.getServerEnvironment().name),
                value=self.getIdNumber(self.id))
            print(query)
            conn = self.m_dbConnection.getConnection()
            cursor = conn.cursor()
            cursor.execute(query)
            conn.commit()
            count = cursor.rowcount
            conn.close()
        except (Exception, psycopg2.Error) as error:
            print("Error in update operation", error)
示例#30
0
    def comapre(self, newPb, oldPb):
        if (Strings.notEmpty(oldPb.date)):
            if (Strings.notEmpty(newPb.date)):
                oldPb.date = newPb.date
            else:
                raise Exception('Date Is Empty' + MessageToJson(newPb))

        if (Strings.notEmpty(oldPb.month)):
            if (Strings.notEmpty(newPb.month)):
                oldPb.month = newPb.month
            else:
                raise Exception('Month Is Empty' + MessageToJson(newPb))

        if (Strings.notEmpty(oldPb.year)):
            if (Strings.notEmpty(newPb.year)):
                oldPb.year = newPb.year
            else:
                raise Exception('Year Is Empty' + MessageToJson(newPb))

        if (newPb.milliseconds > 0):
            if (oldPb.milliseconds > 0):
                newPb.milliseconds = oldPb.milliseconds
            else:
                raise Exception('milliseconds cant be Zero' +
                                MessageToJson(newPb))

        if (Strings.notEmpty(oldPb.formattedDate)):
            if (Strings.notEmpty(newPb.formattedDate)):
                oldPb.formattedDate = newPb.formattedDate
            else:
                raise Exception('Formatted date cant be Empty' +
                                MessageToJson(newPb))

        if (oldPb.timezone != UNKNOWN_TIME_ZONE):
            if (newPb.timezone != UNKNOWN_TIME_ZONE):
                oldPb.timezone = newPb.timezone
            else:
                raise Exception('Time zone cannot be Unknown' +
                                MessageToJson(newPb))