Get the json represenation of a unit's relation
437205
def relation_for_unit(unit=None, rid=None):
    """"""
    unit = unit or remote_unit()
    relation = relation_get(unit=unit, rid=rid)
    for key in relation:
        if key.endswith('-list'):
            relation[key] = relation[key].split()
    relation['__unit__'] = unit
    return relation
91339
def json_data(self, instance, default=None):
        
        value = self.get(instance)
        if value:
            return value.output
        return value
1265017
def get_unit(unit_id, **kwargs):
    
    try:
        unit = db.DBSession.query(Unit).filter(Unit.id==unit_id).one()
        return JSONObject(unit)
    except NoResultFound:
        # The dimension does not exist
        raise ResourceNotFoundError("Unit %s not found"%(unit_id))
594535
def relations():
    """"""
    rels = {}
    for reltype in relation_types():
        relids = {}
        for relid in relation_ids(reltype):
            units = {local_unit(): relation_get(unit=local_unit(), rid=relid)}
            for unit in related_units(relid):
                reldata = relation_get(unit=unit, rid=relid)
                units[unit] = reldata
            relids[relid] = units
        rels[reltype] = relids
    return rels
158797
def _get_relation_value(self, dictionary, key, type):
        
        value = dictionary[key]

        if type == 'one':
            return value[0]

        return self._related.new_collection(value)
1216903
def json(self, var, default=NOTSET, force=True):
        """"""
        return self._get(var, default=default, cast=json.loads, force=force)
154087
def json_data(self, instance, default=None):
        
        value = self.get(instance)
        return value or default
1139487
def get_json(identifier, namespace='cid', domain='compound', operation=None, searchtype=None, **kwargs):
    """"""
    try:
        return json.loads(get(identifier, namespace, domain, operation, 'JSON', searchtype, **kwargs).decode())
    except NotFoundError as e:
        log.info(e)
        return None
871303
def json_data(self, instance, default=None):
        
        value = self.get(instance)

        out = []
        for rel in value:
            if rel.isBroken():
                logger.warn("Skipping broken relation {}".format(repr(rel)))
                continue
            obj = rel.to_object
            out.append(api.get_url_info(obj))
        return out
47819
def fetch_related(self, ids):
        
        if not ids:
            return []
        meta = '&id='.join(id['Id'] for id in ids)
        url = ('{url}/meta/any?id={meta}'
               '&include=bundle-metadata&include=stats'
               '&include=supported-series&include=extra-info'
               '&include=bundle-unit-count&include=owner').format(
                   url=self.url, meta=meta)
        data = self._get(url)
        return data.json().values()
561477
def _coerce_json_to_collection(self, json_repr):
        """"""
        if isinstance(json_repr, dict):
            collection = json_repr
        else:
            try:
                collection = anyjson.loads(json_repr)
            except:
                _LOG.warn('> invalid JSON (failed anyjson parsing)')
                return None
        return collection
1177877
def get(self, param=None, must=[APIKEY]):
        '''
        '''
        param = {} if param is None else param
        r = self.verify_param(param, must)
        if not r.is_succ():
            return r
        handle = CommonResultHandler(lambda rsp: {VERSION_V1:rsp.get(USER), VERSION_V2:rsp}[self.version()])
        return self.path('get.json').post(param, handle, r)
1235184
def get_json_representation(self):
        
        repres = {}
        repres['type'] = self.TYPE
        repres['parameters'] = self._parameters
        repres['icon'] = self.ICON
        repres['authors'] = self.AUTHORS
        repres['title'] = self.TITLE
        repres['category'] = self.CATEGORY
        repres['description'] = self.DESCRIPTION
        repres['documentation'] = self.DOCUMENTATION
        repres['license'] = self.LICENSE
        repres['version'] = self.VERSION
        repres['selfpath'] = self.SELFPATH
        repres['selfexec'] = self.SELFEXEC
        repres['execshell'] = self.EXECSHELL
        repres['max_number_of_workers'] = self.MAX_NUMBER_OF_WORKERS
        repres['min_number_of_workers'] = self.MIN_NUMBER_OF_WORKERS
        repres['max_memory_limit'] = self.MAX_MEMORY_LIMIT
        repres['max_cpu_limit'] = self.MAX_CPU_LIMIT 
        repres['min_memory_limit'] = self.MIN_MEMORY_LIMIT
        repres['min_cpu_limit'] = self.MIN_CPU_LIMIT 
        repres['min_gpu_limit'] = self.MIN_GPU_LIMIT
        repres['max_gpu_limit'] = self.MAX_GPU_LIMIT
        return repres
1189666
def get_relation(self, relation):
        
        from .relations import Relation

        with Relation.no_constraints(True):
            rel = getattr(self.get_model(), relation)()

        nested = self._nested_relations(relation)

        if len(nested) > 0:
            rel.get_query().with_(nested)

        return rel
790342
def save_to_json(self):
        """"""

        requestvalues = {
            'id': self.dataset,
            'publicationDate': self.publication_date.strftime('%Y-%m-%d'),
            'source': self.source,
            'refUrl': self.refernce_url,
        }        
        return json.dumps(requestvalues)
34690
function getRelatedModelFields(User) {
    const fields = {};

    _.forEach(User.relations, (relation) => {

        const model = relation.modelTo;

        fields[_.lowerFirst(relation.name)] = {
            args: Object.assign({
                where: {
                    type: getType('JSON')
                },
                order: {
                    type: getType('JSON')
                },
            }, connectionArgs),
            type: getConnection(model.modelName),
            resolve: (obj, args, context) => {

                if (!context.req.accessToken) return null;

                return findUserFromAccessToken(context.req.accessToken, User)
                    .then(user => connectionFromPromisedArray(findAllRelated(User, user, relation.name, args, context), args, model));
            }
        };
    });

    return fields;
}
456298
def get_relavent_units(self):
        '''
        
        '''
        relavent_units = {}

        for location,unit in self.units.items():
            if self.unit_is_related(location, self.worksheet):
                relavent_units[location] = unit

        return relavent_units