def createTestProperty():
    testEntity = createTestEntity()
    testEntity.save()

    propertydata = {
        'entity': testEntity,
        'isPrimary': True,
        'isLookUpResult': True,
        'isNullable': True,
        'isRequired': True,
        'isReadOnly': True,
        'isEssential': True,
        'isForeign': False,
        'isSensitive' : True,
        'crudType': 'testCrudType',
        'dbName': 'testDbName'
    }

    testProperty = Property(**propertydata)
    testProperty.save()

    return testProperty
def createTestProperty():
    testEntity = createTestEntity()
    testEntity.save()

    propertydata = {
        'entity': testEntity,
        'isPrimary': True,
        'isLookUpResult': True,
        'isNullable': True,
        'isRequired': True,
        'isReadOnly': True,
        'isEssential': True,
        'isForeign': False,
        'isSensitive' : True,
        'crudType': 'testCrudType',
        'dbName': 'testDbName',
        'smUUID': '49be7d784dcf38ab3733b4108701fce4'
    }

    testProperty = Property(**propertydata)
    testProperty.save()

    return testProperty
Example #3
0
    def __write(self):

        # Logging info
        self.__logger.info("Ecriture dans la base de donnee...")

        # Los elementos superXXX son referencias de tipo caracter,
        fdsModel = ('code', 'category', 'modelPrefix',)
        
        fdsEntity = ('code',)
        
        # fdsProperty = ( 'code', 'alias', 'physicalName', 'foreignEntity' )
        fdsProperty = ('code',)
        booProperty = ('isPrimary', 'isNullable', 'isRequired', 'isSensitive', 'isEssential',)
        
        fdsRelationship = ('code', 'baseMin', 'baseMax', 'refMin', 'refMax',)

        # need for setSecurityInfo 
        data = {}

        # We populate the database
        if (self.__tree != None):  # A file has been loaded
        
            xProjects = self.__tree.getiterator("domain")
            
            # ------------------------------------------------------------------------------
            xModels = xProjects[0].getiterator("model")
            for xModel in xModels:
                dModel = Model()
                dModel.project = self.project 
                modelUdps = []

                for child in xModel:
                    if child.tag in fdsModel:
                        setattr(dModel, child.tag, child.text)
                    elif child.tag == 'udps':
                        for xUdp in child:
                            modelUdps.append((xUdp.tag, xUdp.get('text')))

                try:
                    setSecurityInfo(dModel, data, self.userProfile, True )
                    dModel.save()
                except:  
                    self.__logger.info("Error dModel.save")
                    return
                    
                self.__logger.info("Model..." + dModel.code)

                # ------------------------------------------------------------------------------
                xEntitys = xModel.getiterator("concept")
                for xEntity in xEntitys:
                    dEntity = Entity()
                    dEntity.model = dModel
                    
                    for child in xEntity:
                        if (child.tag in fdsEntity):
                            if (child.text is not None):
                                setattr(dEntity, child.tag, child.text)
                        elif  (child.tag == 'physicalName'):
                            setattr(dEntity, 'dbName' , child.text)
                        
                    try:              
                        setSecurityInfo(dEntity, data, self.userProfile, True )
                        dEntity.save()
                    except: 
                        self.__logger.info("Error dEntity.save")
                        return

                    self.__logger.info("Entity..." + dEntity.code)


                    # ------------------------------------------------------------------------------
                    xProperties = xEntity.getiterator("property")
                    for xProperty in xProperties:
                        
                        dProperty = Property()
                        dProperty.entity = dEntity

                        for child in xProperty:

                            if child.tag in fdsProperty:
                                if (child.text is not None):
                                    setattr(dProperty, child.tag, child.text)
                                
                            elif child.tag in booProperty:
                                bValue = toBoolean(child.text)
                                setattr(dProperty, child.tag, bValue)


                        try: 
                            setSecurityInfo(dProperty, data, self.userProfile, True )
                            dProperty.save()
                        except: 
                            self.__logger.info("Error prpDom.save")
                            return


                    # Relationship -------------------------------------------------------------------
                    xForeigns = xEntity.getiterator("foreign")
                    for xForeign in xForeigns:
                        dForeign = Relationship()

                        dForeign.entity = dEntity 
                        dForeign.refEntity = dEntity

                        for child in xForeign:
                            if child.tag in fdsRelationship:
                                setattr(dForeign, child.tag, child.text)

                            elif  (child.tag == 'baseConcept'):
                                setattr(dForeign, 'dbName' , child.text)

                            elif  (child.tag == 'alias'):
                                setattr(dForeign, 'relatedName' , child.text)
                                
                            elif child.tag in booProperty:
                                bValue = toBoolean(child.text)
                                setattr(dForeign, child.tag, bValue)

                        try:
                            setSecurityInfo(dForeign, data, self.userProfile, True )
                            dForeign.save()
                        except Exception, e: 
                            self.__logger.info("Error dForeign.save" + str(e))
                            return