Ejemplo n.º 1
0
  private String getAvailableApps(Representation representation) {
    JSONArray array = new JSONArray();
    Form form = new Form(representation);

    try {
      long id = 0;

      if (form.getFirstValue("id") != null) id = Long.parseLong(form.getFirstValue("id"));

      if (id != 0) {

        ChannelBase selected = ChannelDatabaseFactory.getPersistance().getSingle(id);
        for (ServiceBase service : selected.getServices()) {
          JSONArray dataArray = new JSONArray();
          dataArray.put(service.getId());
          dataArray.put(service.getName());
          dataArray.put(service.getServiceUrl());
          dataArray.put(true);
          array.put(dataArray);
        }

        List<ServiceBase> allServices = ServiceDatabaseFactory.getPersistance().getList();
        for (ServiceBase service : allServices) {
          if (!selected.getServices().contains(service)) {
            JSONArray dataArray = new JSONArray();
            dataArray.put(service.getId());
            dataArray.put(service.getName());
            dataArray.put(service.getServiceUrl());
            dataArray.put(false);
            array.put(dataArray);
          }
        }
      }

    } catch (Exception e) {

    }

    return array.toString();
  }
Ejemplo n.º 2
0
  private String getList() {
    JSONObject rootObj = new JSONObject();
    JSONArray array = new JSONArray();

    try {
      List<ChannelBase> channels = ChannelDatabaseFactory.getPersistance().getList();
      for (ChannelBase channel : channels) {
        JSONArray dataArray = new JSONArray();
        dataArray.put(channel.getId());
        dataArray.put(channel.getName());
        dataArray.put(channel.getStreamUrl());

        array.put(dataArray);
      }

      rootObj.put("aaData", array);
    } catch (Exception e) {

    }

    return rootObj.toString();
  }