def __init__(self, attrMap, options = None): """ Class to read and match the datatype to respective control on the form""" self._modeller = LookupModeller() self._mapper = DeclareMapping.instance() self._attr = attrMap self.widgetList = OrderedDict() self.hideGUID()
def root(self): ''' Implementation of base class method. ''' for p in self._data: pNode = PersonNode(self._extractPersonInfo(p),self.rootNode) ''' Check if an STR relationship has been defined for the person object and set node to indicate NoSTR if it has not been defined. ''' #strModel,noSTRNode = self.isSTRDefined(p, pNode) mapping=DeclareMapping.instance() stModel=mapping.tableMapping('social_tenure_relationship') model=stModel() spUnitModel=mapping.tableMapping('spatial_unit') spModels=spUnitModel() strModel=model.queryObject().filter(stModel.party == p.id).first() if strModel: #Define additional STR nodes that describe the STR in detail self.setSTRNodeChild(strModel, pNode) spModel=spModels.queryObject().filter(spUnitModel.id == strModel.spatial_unit).first() self.setPropertyNodeChild(spModel, pNode,spUnitModel) # if isinstance(strModel.Conflict,Conflict): # self.setConflictNodeChild(strModel.Conflict, pNode) # if isinstance(strModel.Taxation,Taxation): # self.setTaxationNodeChild(strModel.Taxation, pNode) return self.rootNode
def __init__(self, parent=None, model=None, display_col=None): QWidget.__init__(self, parent) self._model = model self._dbModel = model self.attribute = None self.display_col = display_col self.mapping = DeclareMapping.instance()
def __init__(self, config, treeview, parent=None): from stdm.data import ( foreign_key_parent_tables, numeric_varchar_columns, spatial_tables ) super(EntityNodeFormatter, self).__init__(config, treeview, parent) self._str_ref = "social_tenure_relationship" self._str_title = QApplication.translate("STRFormatterBase", "Social Tenure Relationship") self._str_model = DeclareMapping.instance().tableMapping(self._str_ref) ''' Set STR display mapping due to a bug in the 'displayMapping' function ''' self._str_model_disp_mapping = {} if not self._str_model is None: self._str_model_disp_mapping = self._str_model.displayMapping() self._str_num_char_cols = numeric_varchar_columns(self._str_ref) self._fk_references = foreign_key_parent_tables(self._str_ref) self._current_data_source_fk_ref = self._current_data_source_foreign_key_reference() self._numeric_char_cols = numeric_varchar_columns(config.data_source_name) self._spatial_data_sources = spatial_tables()
def __init__(self, model = None): """ Class to read and match the datatype to respective control on the form""" self._modeller = LookupModeller() self._model = model self._mapper = DeclareMapping.instance() self._attribute_mapper = AttributePropretyType(self._model) self._attr = self._attribute_mapper.attribute_type() self.widgetList = OrderedDict() self.hideGUID()
def _models_from_fk_reference(self, source_model, source_column, referenced_model, referenced_column): """ :return: Retrieves data models based on the foreign key reference information. """ ref_model = referenced_model if hasattr(source_model, source_column): source_col_value = getattr(source_model, source_column) # Create model if string is used as referenced model if isinstance(ref_model, str): ref_model = DeclareMapping.instance().tableMapping(ref_model) if ref_model is None: return [] if hasattr(ref_model, referenced_column): col_prop = getattr(ref_model, referenced_column) # Get property type so that the filter can be applied according to the appropriate type col_prop_type = col_prop.property.columns[0].type ref_model_instance = ref_model() ref_query_obj = ref_model_instance.queryObject() if not isinstance(col_prop_type, String): results = ref_query_obj.filter( col_prop == source_col_value).all() else: results = ref_query_obj.filter( func.lower(col_prop) == func.lower( source_col_value)).all() if len(results) == 0: return [] else: return results return []
def _models_from_fk_reference(self, source_model, source_column, referenced_model, referenced_column): """ :return: Retrieves data models based on the foreign key reference information. """ ref_model = referenced_model if hasattr(source_model, source_column): source_col_value = getattr(source_model, source_column) #Create model if string is used as referenced model if isinstance(ref_model, str) or isinstance(ref_model, unicode): ref_model = DeclareMapping.instance().tableMapping(ref_model) if ref_model is None: return [] if hasattr(ref_model, referenced_column): col_prop = getattr(ref_model, referenced_column) #Get property type so that the filter can be applied according to the appropriate type col_prop_type = col_prop.property.columns[0].type ref_model_instance = ref_model() ref_query_obj = ref_model_instance.queryObject() if not isinstance(col_prop_type, String): results = ref_query_obj.filter(col_prop == source_col_value).all() else: results = ref_query_obj.filter(func.lower(col_prop) == func.lower(source_col_value)).all() if len(results) == 0: return [] else: return results return []
def __init__(self, model): self.model = model self._mapper = DeclareMapping.instance()
def displayMapping(self): #use the mapped table properties self._mapper = DeclareMapping.instance() lkModel = self._mapper.tableMapping(self.model)
def __init__(self,): self._lookup = [] self._lookupFormatter = {} self._mapper = DeclareMapping.instance()