Set relation information for the current unit
342554
def relation_set(relation_id=None, relation_settings=None, **kwargs):
    """"""
    relation_settings = relation_settings if relation_settings else {}
    relation_cmd_line = ['relation-set']
    accepts_file = "--file" in subprocess.check_output(
        relation_cmd_line + ["--help"], universal_newlines=True)
    if relation_id is not None:
        relation_cmd_line.extend(('-r', relation_id))
    settings = relation_settings.copy()
    settings.update(kwargs)
    for key, value in settings.items():
        # Force value to be a string: it always should, but some call
        # sites pass in things like dicts or numbers.
        if value is not None:
            settings[key] = "{}".format(value)
    if accepts_file:
        # --file was introduced in Juju 1.23.2. Use it by default if
        # available, since otherwise we'll break if the relation data is
        # too big. Ideally we should tell relation-set to read the data from
        # stdin, but that feature is broken in 1.23.2: Bug #1454678.
        with tempfile.NamedTemporaryFile(delete=False) as settings_file:
            settings_file.write(yaml.safe_dump(settings).encode("utf-8"))
        subprocess.check_call(
            relation_cmd_line + ["--file", settings_file.name])
        os.remove(settings_file.name)
    else:
        for key, value in settings.items():
            if value is None:
                relation_cmd_line.append('{}='.format(key))
            else:
                relation_cmd_line.append('{}={}'.format(key, value))
        subprocess.check_call(relation_cmd_line)
    # Flush cache of any relation-gets for local unit
    flush(local_unit())
353958
def encode_relation(obj):
    """"""
    warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_relation", DeprecationWarning)
    return bioc.biocxml.encoder.encode_relation(obj)
1056107
def touch(self):
        
        key = self.get_related().get_key_name()

        columns = self.get_related_fresh_update()

        ids = self.get_related_ids()

        if len(ids) > 0:
            self.get_related().new_query().where_in(key, ids).update(columns)
775992
def relation_get(attribute=None, unit=None, rid=None):
    """"""
    _args = ['relation-get', '--format=json']
    if rid:
        _args.append('-r')
        _args.append(rid)
    _args.append(attribute or '-')
    if unit:
        _args.append(unit)
    try:
        return json.loads(subprocess.check_output(_args).decode('UTF-8'))
    except ValueError:
        return None
    except CalledProcessError as e:
        if e.returncode == 2:
            return None
        raise
702226
def relation(self, table, origin_field, search_field,
                 destination_field=None, id_field="id"):
        
        df = self._relation(table, origin_field,
                            search_field, destination_field, id_field)
        self.df = df
1095728
def relation_column(instance, fields):
    '''
    
    '''
    relation = getattr(instance.__class__, fields[0]).property
    _field = getattr(instance, fields[0])
    if relation.lazy == 'dynamic':
        _field = _field.first()
    return getattr(_field, fields[1]) if _field else ''
1189465
def store_relation(self, src, name, dst):
        '''  '''
        self.__require_string__(name)
        #print('storing relation', src, name, dst)
        # make sure both items are stored
        self.store_item(src)
        self.store_item(dst)
        with self._write_lock:
            #print(locals())
            # run the insertion
            self._execute(
                'insert into relations select ob1.id, ?, ob2.id from objects as ob1, objects as ob2 where ob1.code=? and ob2.code=?;',
                (name, self.serialize(src), self.serialize(dst))
            )
            self.autocommit()
1353240
def add_relations(self, relations):
        """"""
        for source, destination in relations:
            self.add_relation(source, destination)
1094366
def relation_id(relation_name=None, service_or_unit=None):
    """"""
    if not relation_name and not service_or_unit:
        return os.environ.get('JUJU_RELATION_ID', None)
    elif relation_name and service_or_unit:
        service_name = service_or_unit.split('/')[0]
        for relid in relation_ids(relation_name):
            remote_service = remote_service_name(relid)
            if remote_service == service_name:
                return relid
    else:
        raise ValueError('Must specify neither or both of relation_name and service_or_unit')
529656
def set_data(self, ids=None):
        
        fun = lambda x: x.set_data()
        self.apply(fun, ids=ids, applyto='measurement')
1331968
def set_data(self, index, value):
        """"""
        acces, field = self.get_item(index), self.header[index.column()]
        self.beginResetModel()
        self.set_data_hook(acces, field, value)
        self.endResetModel()
1134821
def with_(self, *relations):
        
        if not relations:
            return self

        eagers = self._parse_relations(list(relations))

        self._eager_load.update(eagers)

        return self
1022111
def relation_operation(self):
        
        if len(self.nodes) > 0:
            rel_op = self.nodes[-1].relation_operation
        else:
            rel_op = None
        return rel_op
50716
public void setRelations(int i, Relation v) { 
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_relations == null)
      jcasType.jcas.throwFeatMissing("relations", "de.julielab.jules.types.ace.Document");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_relations), i);
    jcasType.ll_cas.ll_setRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_relations), i, jcasType.ll_cas.ll_getFSRef(v));}
917596
def init_relation(self, models, relation):
        
        for model in models:
            model.set_relation(relation, Result(None, self, model))

        return models
1074778
public void setRelation_ref(Relation v) {
    if (RelationMention_Type.featOkTst && ((RelationMention_Type)jcasType).casFeat_relation_ref == null)
      jcasType.jcas.throwFeatMissing("relation_ref", "de.julielab.jules.types.ace.RelationMention");
    jcasType.ll_cas.ll_setRefValue(addr, ((RelationMention_Type)jcasType).casFeatCode_relation_ref, jcasType.ll_cas.ll_getFSRef(v));}
536924
def init_datamembers(self, rec):
        """"""
        # pylint: disable=multiple-statements
        if 'synonym'      in self.optional_attrs: rec.synonym = []
        if 'xref'         in self.optional_attrs: rec.xref = set()
        if 'subset'       in self.optional_attrs: rec.subset = set()
        if 'comment'      in self.optional_attrs: rec.comment = ""
        if 'relationship' in self.optional_attrs:
            rec.relationship = {}
            rec.relationship_rev = {}