From JSON -> Activity object
330368
def unserialize(self, data):
        

        # copy activity attributes into object
        if "author" not in data["object"]:
            data["object"]["author"] = data["actor"]
        for key in ["to", "cc", "bto", "bcc"]:
            if key not in data["object"] and key in data:
                data["object"][key] = data[key]

        Mapper(pypump=self._pump).parse_map(self, data=data)
        self._add_links(data)

        return self
1230080
@NonNull
    private Activity getActivity() {
        Activity result = null;
        if (activity != null) {
            result = activity;
        } else if (fragment != null) {
            result = fragment.getActivity();
        } else if (fragmentSupport != null) {
            result = fragmentSupport.getActivity();
        }
        if (result == null) {
            throw new NullPointerException("No activity or fragment instance");
        }
        return result;
    }
422325
function startActivity(activityMessage) {
  var activityId = createActivity(activityMessage);

  markActivity(activityId);

  var activity = getActivity(activityId);
  writeActivity(activityEvents.start, activity);

  return activityId;
}
130039
public JsonObject getJsonObject() {

        JsonObject obj = new JsonObject();
        obj.add("field", this.field);

        obj.add("value", this.value);

        return obj;
    }
517358
def _load_activity(self, activity):
        
        fpths = []
        full_path = ''
        errors = []
        paths = settings.ACTIVITY_MODULES_IMPORT_PATHS
        number_of_paths = len(paths)
        for index_no in range(number_of_paths):
            full_path = "%s.%s" % (paths[index_no], activity)
            for look4kls in (0, 1):
                try:
                    self.current.log.info("try to load from %s[%s]" % (full_path, look4kls))
                    kls, cls_name, cls_method = self._import_object(full_path, look4kls)
                    if cls_method:
                        self.current.log.info("WILLCall %s(current).%s()" % (kls, cls_method))
                        self.wf_activities[activity] = lambda crnt: getattr(kls(crnt), cls_method)()
                    else:
                        self.wf_activities[activity] = kls
                    return
                except (ImportError, AttributeError):
                    fpths.append(full_path)
                    errmsg = "{activity} not found under these paths:\n\n >>> {paths} \n\n" \
                             "Error Messages:\n {errors}"
                    errors.append("\n========================================================>\n"
                                  "| PATH | %s"
                                  "\n========================================================>\n\n"
                                  "%s" % (full_path, traceback.format_exc()))
                    assert index_no != number_of_paths - 1, errmsg.format(activity=activity,
                                                                          paths='\n >>> '.join(
                                                                              set(fpths)),
                                                                          errors='\n\n'.join(errors)
                                                                          )
                except:
                    self.current.log.exception("Cannot found the %s" % activity)
1027619
def bulk_update_from_activity(activity)
      all_aggs = entities_as_json_hashes(activity)
      agg_batches = bulk_update_batches(all_aggs)
      agg_batches.each do |batch|
        index_with_error_handling(activity) { bulk_add(batch) }
      end
    end
404813
def from_json(cls, json):
    
    if json["name"] in _KEYRANGES_CLASSES:
      return _KEYRANGES_CLASSES[json["name"]].from_json(json)
    raise ValueError("Invalid json %s", json)
802891
def from_json(self, json_string):
        

        obj = json.loads(json_string)
        self.from_dict(obj['groups'], obj['data'])

        return self
128411
private static JsonObject getJsonObject(JsonObject object, String propName) {
        JsonObject obj = null;
        JsonValue val = object.get(propName);
        if (val != null && val.getValueType() == ValueType.OBJECT) {
            obj = val.asJsonObject();
        }
        return obj;
    }
58196
@JavaScriptMethod public final JSONObject news() {
        lastNewsTime = System.currentTimeMillis();
        JSONObject r = new JSONObject();
        try {
            r.put("data", data());
        } catch (RuntimeException x) {
            LOG.log(Level.WARNING, "failed to update " + uri, x);
            status = ERROR;
        }
        Object statusJSON = status == 1 ? "done" : status == CANCELED ? "canceled" : status == ERROR ? "error" : status;
        r.put("status", statusJSON);
        if (statusJSON instanceof String) { // somehow completed
            LOG.log(Level.FINE, "finished in news so releasing {0}", boundId);
            release();
        }
        lastNewsTime = System.currentTimeMillis();
        LOG.log(Level.FINER, "news from {0}", uri);
        return r;
    }
106287
def __get_activity_by_name(self, name, category_id = None, resurrect = True):
        """"""

        if category_id:
            query = """
                       SELECT a.id, a.name, a.deleted, coalesce(b.name, ?) as category
                         FROM activities a
                    LEFT JOIN categories b ON category_id = b.id
                        WHERE lower(a.name) = lower(?)
                          AND category_id = ?
                     ORDER BY a.deleted, a.id desc
                        LIMIT 1
            """

            res = self.fetchone(query, (self._unsorted_localized, name, category_id))
        else:
            query = """
                       SELECT a.id, a.name, a.deleted, coalesce(b.name, ?) as category
                         FROM activities a
                    LEFT JOIN categories b ON category_id = b.id
                        WHERE lower(a.name) = lower(?)
                     ORDER BY a.deleted, a.id desc
                        LIMIT 1
            """
            res = self.fetchone(query, (self._unsorted_localized, name, ))

        if res:
            keys = ('id', 'name', 'deleted', 'category')
            res = dict([(key, res[key]) for key in keys])
            res['deleted'] = res['deleted'] or False

            # if the activity was marked as deleted, resurrect on first call
            # and put in the unsorted category
            if res['deleted'] and resurrect:
                update = """
                            UPDATE activities
                               SET deleted = null, category_id = -1
                             WHERE id = ?
                        """
                self.execute(update, (res['id'], ))

            return res

        return None
144200
@Override
    public JSONObject getJson() throws JSONException {
        JSONObject json = create();
        json.put("id", id);
        if (eventName != null)
            json.put("eventName", eventName);
        if (createDate != null) {
            json.put("createDate", createDate);
        }
        if (createUser != null) {
            json.put("createUser", createUser);
        }
        if (source != null) {
            json.put("source", source);
        }
        if (category != null) {
            json.put("category", category);
        }
        if (subCategory != null) {
            json.put("subCategory", subCategory);
        }
        if (ownerType != null) {
            json.put("ownerType", ownerType);
        }
        if (ownerId != null) {
            json.put("ownerId", ownerId);
        }
        if (comment != null) {
            json.put("comment", comment);
        }
        return json;
    }
806386
def from_dict(cls, d):
        """"""
        kwargs = {}
        for key, val in d.iteritems():
            if key.startswith('display'): # includes phone.display_international
                continue
            if key.startswith('@'):
                key = key[1:]
            if key == 'type':
                key = 'type_'
            elif key == 'valid_since':
                val = str_to_datetime(val)
            elif key == 'date_range':
                val = DateRange.from_dict(val)
            kwargs[key.encode('ascii')] = val
        return cls(**kwargs)
1184591
function getMainLaunchActivityIndex(activities) {
  var launchActivityIndex = -1;
  activities.some(function(activity, index) {
    if (isLaunchActivity(activity)) {
      launchActivityIndex = index;
      return true;
    }

    return false;
  });

  return launchActivityIndex;
}
77147
function(webViewId, eventName, jsonData){
            // getting webviewInterface object by webViewId from static map.
            var oWebViewInterface = getWebViewIntefaceObjByWebViewId(webViewId);
            if (oWebViewInterface) {
                oWebViewInterface._onWebViewEvent(eventName, jsonData);
            }
        }
1185246
def create_activity(self, data):
        
        url = self._build_url('my', 'activities')
        if isinstance(data, dict):
            data = json.dumps(data)
        r = self.session.post(url, data=data)
        r.raise_for_status()
        return r
167992
def from_json(cls, data):
        """"""
        # Decode JSON string
        assert isinstance(data, str)
        data = json.loads(data)
        assert isinstance(data, dict)
        return cls.from_dict(data)