def _resolve_reference_samples(self, wst, type):
        """
        Resolves the slots and reference samples in accordance with the
        Worksheet Template passed in and the type passed in.
        Returns a list of dictionaries
        :param wst: Worksheet Template that defines the layout
        :param type: type of analyses ('b' for blanks, 'c' for controls)
        :return: list of dictionaries
        """
        if not type or type not in ['b', 'c']:
            return []

        bc = api.get_tool("bika_catalog")
        wst_type = type == 'b' and 'blank_ref' or 'control_ref'

        slots_sample = list()
        available_slots = self.resolve_available_slots(wst, type)
        wst_layout = wst.getLayout()
        for row in wst_layout:
            slot = int(row['pos'])
            if slot not in available_slots:
                continue

            ref_definition_uid = row.get(wst_type, None)
            if not ref_definition_uid:
                # Only reference analyses with reference definition can be used
                # in worksheet templates
                continue

            samples = bc(portal_type='ReferenceSample',
                         review_state='current',
                         is_active=True,
                         getReferenceDefinitionUID=ref_definition_uid)

            # We only want the reference samples that fit better with the type
            # and with the analyses defined in the Template
            services = wst.getService()
            services = [s.UID() for s in services]
            candidates = list()
            for sample in samples:
                obj = api.get_object(sample)
                if (type == 'b' and obj.getBlank()) or \
                        (type == 'c' and not obj.getBlank()):
                    candidates.append(obj)

            sample, uids = self._resolve_reference_sample(candidates, services)
            if not sample:
                continue

            slots_sample.append({'slot': slot,
                                 'sample': sample,
                                 'supported_services': uids})

        return slots_sample
def _resolve_reference_samples ( self , wst , type ) : if not type or type not in [ 'b' , 'c' ] : return [ ] bc = api . get_tool ( "bika_catalog" ) wst_type = type == 'b' and 'blank_ref' or 'control_ref' slots_sample = list ( ) available_slots = self . resolve_available_slots ( wst , type ) wst_layout = wst . getLayout ( ) for row in wst_layout : slot = int ( row [ 'pos' ] ) if slot not in available_slots : continue ref_definition_uid = row . get ( wst_type , None ) if not ref_definition_uid : continue samples = bc ( portal_type = 'ReferenceSample' , review_state = 'current' , is_active = True , getReferenceDefinitionUID = ref_definition_uid ) services = wst . getService ( ) services = [ s . UID ( ) for s in services ] candidates = list ( ) for sample in samples : obj = api . get_object ( sample ) if ( type == 'b' and obj . getBlank ( ) ) or ( type == 'c' and not obj . getBlank ( ) ) : candidates . append ( obj ) sample , uids = self . _resolve_reference_sample ( candidates , services ) if not sample : continue slots_sample . append ( { 'slot' : slot , 'sample' : sample , 'supported_services' : uids } ) return slots_sample
Resolves the slots and reference samples in accordance with the
        Worksheet Template passed in and the type passed in.
        Returns a list of dictionaries
        :param wst: Worksheet Template that defines the layout
        :param type: type of analyses ('b' for blanks, 'c' for controls)
        :return: list of dictionaries