예제 #1
0
 public JSONValue visit(Property property) {
   JSONObject o = new JSONObject();
   o.put("name", new JSONString(property.getName()));
   o.put("type", new JSONString(property.getType()));
   o.put("subproperties", property.getSubproperties().accept(this));
   return o;
 }
예제 #2
0
  /*
   * view Album contents
   */
  private void viewAlbum(JSONValue a_Value) {

    JSONArray jsonArray = (JSONArray) a_Value;

    Item item = null;
    int id;
    JSONObject jso;

    m_Items.clear();

    for (int i = 0; i < jsonArray.size(); ++i) {
      jso = (JSONObject) jsonArray.get(i);
      id = Utils.extractId(jso.get("id"));

      if (m_IDtoItem.containsKey(id)) {
        item = m_IDtoItem.get(id);
        item.updateValues(jso);
      } else {
        item = new Item(this, jso, m_Container);
        m_IDtoItem.put(id, item);

        if (item.isAlbum()) {
          linkAlbum(item);
        }
      }
      m_Items.add(item);
    }

    m_View.setAlbum(this);
    addPendingDownloads();
  }
예제 #3
0
 public JSONValue visit(Comparison<?> comparison) {
   JSONObject o = new JSONObject();
   o.put(OPERATOR, new JSONString(comparison.getOperator()));
   o.put(FIELD, new JSONString(comparison.getField()));
   o.put(VALUE, JSONUtil.toJsonValue(comparison.getValue()));
   return o;
 }
예제 #4
0
  @Override
  protected void onInit(final JSONValue data) {

    try {
      final JSONArray criteria = data.isArray();
      this.criteria.clear();

      for (int i = 0; i < criteria.size(); i++) {
        final JSONObject searchTypeJSON = criteria.get(i).isObject();
        final Map<String, Criterion> searchType = new LinkedHashMap<String, Criterion>();

        for (int j = 0; j < searchTypeJSON.get("elements").isArray().size(); j++) {
          final Criterion criterion = Criterion.readMe(j, searchTypeJSON);
          if (j == 0
              && (selectedCriterion == null && i == 0
                  || selectedCriterion != null
                      && criterion.displaytype.equalsIgnoreCase(selectedCriterion.displaytype))) {
            selectedCriterion = criterion;
            selectedCriterionHistory.put(selectedCriterion.displaytype, selectedCriterion);
          }
          searchType.put(criterion.getName(), criterion);
        }
        this.criteria.put(
            searchTypeJSON.get("displaytype").isString().stringValue().trim(), searchType);
      }
    } catch (final Exception e) {
      getLogger().severe(getClass().getName().replace("Impl", "") + ".onInit() : " + e);
    }
  }
예제 #5
0
  private static JSONValue toJSON(SerValue serValue) {
    if (serValue.isString()) {
      return new JSONString(serValue.asString());

    } else if (serValue.isReal()) {
      return new JSONNumber(serValue.asReal());

    } else if (serValue.isArray()) {
      SerArray serArray = serValue.asArray();
      JSONArray jsonArray = new JSONArray();
      for (int i = 0; i != serArray.size(); ++i) {
        jsonArray.set(i, toJSON(serArray.get(i)));
      }
      return jsonArray;

    } else if (serValue.isObject()) {
      SerObject serObject = serValue.asObject();
      JSONObject jsonObject = new JSONObject();
      for (String key : serObject.keySet()) {
        jsonObject.put(key, toJSON(serObject.get(key)));
      }
      return jsonObject;

    } else {
      throw new IllegalArgumentException();
    }
  }
예제 #6
0
    @Override
    public void onResponseReceived(Request request, Response response) {
      JSONValue j = JSONParser.parseStrict(response.getText());
      JSONObject obj = j.isObject();
      if (obj != null && obj.containsKey("error")) {
        Window.alert(obj.get("error").isString().stringValue());
        changeButtonSelection();
        setTextEnabled(false);
        clearTextBoxes();
        singleSelectionModel.clear();
      } else {
        List<OrganismInfo> organismInfoList =
            OrganismInfoConverter.convertJSONStringToOrganismInfoList(response.getText());
        dataGrid.setSelectionModel(singleSelectionModel);
        MainPanel.getInstance().getOrganismInfoList().clear();
        MainPanel.getInstance().getOrganismInfoList().addAll(organismInfoList);
        changeButtonSelection();
        OrganismChangeEvent organismChangeEvent = new OrganismChangeEvent(organismInfoList);
        organismChangeEvent.setAction(OrganismChangeEvent.Action.LOADED_ORGANISMS);
        Annotator.eventBus.fireEvent(organismChangeEvent);

        // in the case where we just add one . . .we should refresh the app state
        if (organismInfoList.size() == 1) {
          MainPanel.getInstance().getAppState();
        }
      }
      if (savingNewOrganism) {
        savingNewOrganism = false;
        setNoSelection();
        changeButtonSelection(false);
        loadingDialog.hide();
      }
    }
예제 #7
0
  public Polymer(JSONObject jsonObject) {
    super(SchemaClass.POLYMER, jsonObject);

    if (jsonObject.containsKey("maxUnitCount")) {
      this.maxUnitCount = FactoryUtils.getIntValue(jsonObject, "maxUnitCount");
    }

    if (jsonObject.containsKey("minUnitCount")) {
      this.minUnitCount = FactoryUtils.getIntValue(jsonObject, "minUnitCount");
    }

    if (jsonObject.containsKey("totalProt")) {
      this.totalProt = FactoryUtils.getStringValue(jsonObject, "totalProt");
    }

    if (jsonObject.containsKey("maxHomologues")) {
      this.maxHomologues = FactoryUtils.getStringValue(jsonObject, "maxHomologues");
    }

    if (jsonObject.containsKey("inferredProt")) {
      this.inferredProt = FactoryUtils.getStringValue(jsonObject, "inferredProt");
    }

    for (JSONObject object : FactoryUtils.getObjectList(jsonObject, "repeatedUnit")) {
      this.repeatedUnits.add((PhysicalEntity) ModelFactory.getDatabaseObject(object));
    }
  }
  /**
   * Prepares a JSON object
   *
   * @return JSONObject the whole query
   */
  private JSONObject prepareJSONObject() {

    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("facility", new JSONNumber(facilityId));
    jsonQuery.put("execService", new JSONNumber(execServiceId));
    return jsonQuery;
  }
예제 #9
0
  // translate the json for an elective to the class attributes
  protected void translateJson(JSONObject winJson) {
    String startDate, endDate;

    handle = winJson.get("handle").isString().stringValue();

    id = (int) winJson.get("id").isNumber().doubleValue();

    complete = winJson.get("complete").isBoolean().booleanValue();

    // what are the dates that this elective spans?
    JSONString firstPeriod = winJson.get("firstPeriod").isString();
    if (firstPeriod != null) {
      String startStr = firstPeriod.stringValue();
      Date start = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").parse(startStr);
      startDate = DateTimeFormat.getFormat("yyyy-MM-dd").format(start);
    } else {
      startDate = "None";
    }

    JSONString lastPeriod = winJson.get("lastPeriod").isString();
    if (lastPeriod != null) {
      String endStr = lastPeriod.stringValue();
      Date end = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").parse(endStr);
      endDate = DateTimeFormat.getFormat("yyyy-MM-dd").format(end);
    } else {
      endDate = "None";
    }

    // the header is a summary: [date range] time, complete (id)
    header = "Elective [" + startDate + " - " + endDate + "] (" + Integer.toString(id) + "): ";
  }
예제 #10
0
  @Override
  protected void onResponseReceived(
      boolean succeed, JSONObject jsonResponse, Request request, Response response) {
    if (succeed) {
      // Parsing project
      Project proj = getProps().getProject();
      proj.setName(project);
      JSONProjectParser projParser = new JSONProjectParser();
      JSONObject projectJSON = jsonResponse.get(JSONConstants.KEY_PROJECT).isObject();
      projParser.fillProject(proj, projectJSON);

      // Parsing current user
      User user = getProps().getUser();
      user.setLogin(login);
      user.setPwd(pwd);
      JSONObject userJSON = jsonResponse.get(JSONConstants.KEY_USER).isObject();
      JSONUserParser userParser = new JSONUserParser();
      userParser.fillUser(user, userJSON);

      // parsing of the project members
      JSONMemberParser.parseListMembers(jsonResponse, proj);

      parentScreen.onValidLogin();
    } else {
      parentScreen.onWrongLogin();
    }
  }
  private List<ContainerPort> parsePorts(Object exposedPorts) {
    if (!(exposedPorts instanceof JSONObject)) {
      return emptyList();
    }

    JSONObject ports = (JSONObject) exposedPorts;
    Jso jso = ports.getJavaScriptObject().cast();

    JsoArray<String> keys = jso.getKeys();

    List<ContainerPort> containerPorts = new ArrayList<>();

    for (int i = 0; i < keys.size(); i++) {
      String[] split = keys.get(i).split("/");
      if (split.length != 2) {
        continue;
      }
      containerPorts.add(
          newDto(ContainerPort.class)
              .withContainerPort(Integer.valueOf(split[0]))
              .withProtocol(split[1].toUpperCase()));
    }

    return containerPorts;
  }
  private void rebuildJSON() {
    JSONObject obj = new JSONObject();

    obj.put(base_name, new JSONString(this.items_list.getText()));

    this.current_json = new JSON_Representation(obj);
  }
예제 #13
0
  /**
   * Generates the values from the form
   *
   * @return
   */
  public ArrayList<ApplicationFormItemData> getValues() {
    ArrayList<ApplicationFormItemData> formItemDataList = new ArrayList<ApplicationFormItemData>();

    // goes through all the item generators and retrieves the value
    for (RegistrarFormItemGenerator gen : applFormGenerators) {

      String value = gen.getValue();
      String prefilled = gen.getPrefilledValue();
      JSONObject formItemJSON = new JSONObject(gen.getFormItem());

      // remove text (locale), saves data transfer & removes problem with parsing locale
      formItemJSON.put("i18n", new JSONObject());

      // cast form item back
      ApplicationFormItem formItem = formItemJSON.getJavaScriptObject().cast();

      // prepare package with data
      ApplicationFormItemData data =
          ApplicationFormItemData.construct(
              formItem, formItem.getShortname(), value, prefilled, "");

      formItemDataList.add(data);
    }
    return formItemDataList;
  }
예제 #14
0
  @Override
  public JSONObject toJSONObject() {
    JSONObject object = super.toJSONObject();

    ImageDataFilterChain chain = m_filters;

    if ((null != chain) && (chain.size() > 0)) {
      JSONArray filters = new JSONArray();

      JSONObject filter = new JSONObject();

      filter.put("active", JSONBoolean.getInstance(chain.isActive()));

      for (ImageDataFilter<?> ifilter : chain.getFilters()) {
        if (null != ifilter) {
          JSONObject make = ifilter.toJSONObject();

          if (null != make) {
            filters.set(filters.size(), make);
          }
        }
      }
      filter.put("filters", filters);

      object.put("filter", filter);
    }
    return object;
  }
예제 #15
0
  private static ServerEvent parseJsonEvent(String msg) {
    try {
      JSONObject eventJ = JSONParser.parseStrict(msg).isObject();
      Name name = new Name(eventJ.get("name").isString().stringValue(), "");
      ServerEvent.Scope scope =
          ServerEvent.Scope.valueOf(eventJ.get("scope").isString().stringValue());
      ServerEvent.DataType dataType =
          eventJ.get("dataType") == null
              ? ServerEvent.DataType.STRING
              : ServerEvent.DataType.valueOf(eventJ.get("dataType").isString().stringValue());
      Serializable data;
      String from = eventJ.get("from") == null ? null : eventJ.get("from").toString();
      if (dataType == ServerEvent.DataType.BG_STATUS) {
        data = BackgroundStatus.parse(eventJ.get("data").isString().stringValue());
      } else if (dataType == ServerEvent.DataType.JSON) {
        data = eventJ.get("data").isObject().toString();
      } else {
        data = eventJ.get("data").isString().stringValue();
      }
      ServerEvent sEvent = new ServerEvent(name, scope, dataType, data);
      sEvent.setFrom(from);
      return sEvent;

    } catch (Exception e) {
      GwtUtil.getClientLogger()
          .log(Level.WARNING, "Unable to parse json message into ServerEvent: " + msg, e);
      return null;
    }
  }
예제 #16
0
 /**
  * Prepares a JSON object
  *
  * @return JSONObject the whole query
  */
 private JSONObject prepareJSONObject() {
   JSONObject jsonQuery = new JSONObject();
   jsonQuery.put("securityTeam", new JSONNumber(securityTeamId));
   jsonQuery.put("user", new JSONNumber(userId));
   jsonQuery.put("description", new JSONString(description));
   return jsonQuery;
 }
 protected JSONObject getJsonComplexTrigger(
     ScheduleType scheduleType,
     MonthOfYear month,
     WeekOfMonth weekOfMonth,
     List<DayOfWeek> daysOfWeek,
     Date startDate,
     Date endDate) {
   JSONObject trigger = new JSONObject();
   trigger.put(
       "uiPassParam",
       new JSONString(scheduleEditorWizardPanel.getScheduleType().name())); // $NON-NLS-1$
   if (month != null) {
     JSONArray jsonArray = new JSONArray();
     jsonArray.set(0, new JSONString(Integer.toString(month.ordinal())));
     trigger.put("monthsOfYear", jsonArray); // $NON-NLS-1$
   }
   if (weekOfMonth != null) {
     JSONArray jsonArray = new JSONArray();
     jsonArray.set(0, new JSONString(Integer.toString(weekOfMonth.ordinal())));
     trigger.put("weeksOfMonth", jsonArray); // $NON-NLS-1$
   }
   if (daysOfWeek != null) {
     JSONArray jsonArray = new JSONArray();
     int index = 0;
     for (DayOfWeek dayOfWeek : daysOfWeek) {
       jsonArray.set(index++, new JSONString(Integer.toString(dayOfWeek.ordinal())));
     }
     trigger.put("daysOfWeek", jsonArray); // $NON-NLS-1$
   }
   addJsonStartEnd(trigger, startDate, endDate);
   return trigger;
 }
  /**
   * * Enregistrer les paramètres liés à chaque Element (titre) Params: Les positions de l'elements
   * (X,Y) et son emplacement dans la liste des elements
   *
   * @param last **
   */
  @SuppressWarnings("rawtypes")
  private void ajouterParametre(int emplacement, String name, String option) {

    ArrayList params = (ArrayList) parametres.get(emplacement);
    int k = 0;
    for (int i = 0; i < params.size(); i++) {

      final ArrayList p = (ArrayList) params.get(i);

      /** ****** */
      JSONObject paramAsJSONObjectBis =
          BuildJsonObject.buildJSONObjectParametreBis(
              "-1", "" + p.get(0), "" + p.get(1), "" + emplacement);
      /** ****** */
      formAsJSONObjectBis.put("parametre" + emplacement + i, paramAsJSONObjectBis);
      k = i + 1;
    }
    if (((ArrayList) elements.get(emplacement)).get(0).equals("checkbox")
        || ((ArrayList) elements.get(emplacement)).get(0).equals("radio")) {
      JSONObject paramAsJSONObjectBis =
          BuildJsonObject.buildJSONObjectParametreBis(
              "-1", "libelles", "" + choices.get(Integer.parseInt(name)), "" + emplacement);
      formAsJSONObjectBis.put("parametre" + emplacement + k, paramAsJSONObjectBis);

    } else if (((ArrayList) elements.get(emplacement)).get(0).equals("combobox")) {
      JSONObject paramAsJSONObjectBis =
          BuildJsonObject.buildJSONObjectParametreBis(
              "-1", "libelles", "" + options.get(Integer.parseInt(option)), "" + emplacement);
      formAsJSONObjectBis.put("parametre" + emplacement + k, paramAsJSONObjectBis);
    }

    /** ********* */
  }
예제 #19
0
  public JSONObject asJsonObject() {
    JSONObject object = new JSONObject();
    object.put(IM_PROTOCOL, new JSONString(getProtocol()));
    object.put(IM_ADDRESS, new JSONString(getAddress()));

    return object;
  }
  public static <KeyType, ValueType> Map<KeyType, ValueType> toMap(
      JSONValue value,
      AbstractJsonEncoderDecoder<KeyType> keyEncoder,
      AbstractJsonEncoderDecoder<ValueType> valueEncoder,
      Style style) {
    if (value == null || value.isNull() != null) {
      return null;
    }

    switch (style) {
      case DEFAULT:
      case SIMPLE:
        {
          JSONObject object = value.isObject();
          if (object == null) {
            throw new DecodingException("Expected a json object, but was given: " + value);
          }

          HashMap<KeyType, ValueType> rc = new HashMap<KeyType, ValueType>(object.size() * 2);
          for (String key : object.keySet()) {
            rc.put(keyEncoder.decode(key), valueEncoder.decode(object.get(key)));
          }
          return rc;
        }
      case JETTISON_NATURAL:
        {
          JSONObject object = value.isObject();
          if (object == null) {
            throw new DecodingException("Expected a json object, but was given: " + value);
          }
          value = object.get("entry");
          if (value == null) {
            throw new DecodingException("Expected an entry array not found");
          }
          JSONArray entries = value.isArray();
          if (entries == null) {
            throw new DecodingException("Expected an entry array, but was given: " + value);
          }

          HashMap<KeyType, ValueType> rc = new HashMap<KeyType, ValueType>(object.size() * 2);
          for (int i = 0; i < entries.size(); i++) {
            JSONObject entry = entries.get(i).isObject();
            if (entry == null)
              throw new DecodingException("Expected an entry object, but was given: " + value);
            JSONValue key = entry.get("key");
            if (key == null) throw new DecodingException("Expected an entry key field not found");
            JSONString k = key.isString();
            if (k == null)
              throw new DecodingException(
                  "Expected an entry key to be a string, but was given: " + value);
            rc.put(keyEncoder.decode(k.stringValue()), valueEncoder.decode(entry.get("value")));
          }
          return rc;
        }
      default:
        throw new UnsupportedOperationException(
            "The encoding style is not yet supported: " + style.name());
    }
  }
예제 #21
0
 /**
  * A convenient way to create an options JSONObject. Use SliderOption for keys.
  *
  * @param min - default minimum of the slider
  * @param max - default maximum of the slider
  * @param defaultValues - default points of each anchor
  * @return a JSONObject of Slider options
  */
 public static JSONObject getOptions(int min, int max, int[] defaultValues) {
   JSONObject options = new JSONObject();
   options.put(SliderOption.MIN.toString(), new JSONNumber(min));
   options.put(SliderOption.MAX.toString(), new JSONNumber(max));
   JSONArray vals = intArrayToJSONArray(defaultValues);
   options.put(SliderOption.VALUES.toString(), vals);
   return options;
 }
  protected boolean addBlockoutPeriod(
      final JSONObject schedule, final JsJobTrigger trigger, String urlSuffix) {
    String url = GWT.getHostPageBaseURL() + "api/scheduler/blockout/" + urlSuffix; // $NON-NLS-1$

    RequestBuilder addBlockoutPeriodRequest = new RequestBuilder(RequestBuilder.POST, url);
    addBlockoutPeriodRequest.setHeader("accept", "text/plain"); // $NON-NLS-1$ //$NON-NLS-2$
    addBlockoutPeriodRequest.setHeader(
        "Content-Type", "application/json"); // $NON-NLS-1$ //$NON-NLS-2$
    addBlockoutPeriodRequest.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");

    // Create a unique blockout period name
    final Long duration = trigger.getBlockDuration();
    final String blockoutPeriodName =
        trigger.getScheduleType()
            + Random.nextInt()
            + ":"
            + //$NON-NLS-1$
            /* PentahoSessionHolder.getSession().getName() */ "admin"
            + ":"
            + duration; //$NON-NLS-1$ //$NON-NLS-2$

    // Add blockout specific parameters
    JSONObject addBlockoutParams = schedule;
    addBlockoutParams.put("jobName", new JSONString(blockoutPeriodName)); // $NON-NLS-1$
    addBlockoutParams.put("duration", new JSONNumber(duration)); // $NON-NLS-1$
    addBlockoutParams.put("timeZone", new JSONString(scheduleEditorWizardPanel.getTimeZone()));

    try {
      addBlockoutPeriodRequest.sendRequest(
          addBlockoutParams.toString(),
          new RequestCallback() {
            public void onError(Request request, Throwable exception) {
              MessageDialogBox dialogBox =
                  new MessageDialogBox(
                      Messages.getString("error"),
                      exception.toString(),
                      false,
                      false,
                      true); //$NON-NLS-1$
              dialogBox.center();
              setDone(false);
            }

            public void onResponseReceived(Request request, Response response) {
              if (response.getStatusCode() == Response.SC_OK) {
                if (null != callback) {
                  callback.okPressed();
                }
              }
            }
          });
    } catch (RequestException e) {
      // ignored
    }

    return true;
  }
 protected JSONObject getJsonCronTrigger(String cronString, Date startDate, Date endDate) {
   JSONObject trigger = new JSONObject();
   trigger.put(
       "uiPassParam",
       new JSONString(scheduleEditorWizardPanel.getScheduleType().name())); // $NON-NLS-1$
   trigger.put("cronString", new JSONString(cronString)); // $NON-NLS-1$
   addJsonStartEnd(trigger, startDate, endDate);
   return trigger;
 }
 /**
  * Returns a JSON representation of the object. This method is the counterpart to the
  * PropertyGroup(String) constructor.
  *
  * @return a JSON object
  */
 @Override
 public JSONObject toJson() {
   JSONObject json = super.toJson();
   List<JSONValue> jsonProperties = new ArrayList<JSONValue>();
   for (JSONMetaDataObject property : properties) {
     jsonProperties.add(property.toJson());
   }
   json.put(PROPERTIES, JsonUtil.buildArray(jsonProperties));
   return json;
 }
  /**
   * Before creating a new schedule, we want to check to see if the schedule that is being created
   * is going to conflict with any one of the blockout periods if one is provisioned.
   *
   * @param schedule
   * @param trigger
   */
  protected void verifyBlockoutConflict(final JSONObject schedule, final JsJobTrigger trigger) {
    String url = GWT.getHostPageBaseURL() + "api/scheduler/blockout/blockstatus"; // $NON-NLS-1$

    RequestBuilder blockoutConflictRequest = new RequestBuilder(RequestBuilder.POST, url);
    blockoutConflictRequest.setHeader("accept", "application/json"); // $NON-NLS-1$ //$NON-NLS-2$
    blockoutConflictRequest.setHeader(
        "Content-Type", "application/json"); // $NON-NLS-1$ //$NON-NLS-2$
    blockoutConflictRequest.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");

    final JSONObject verifyBlockoutParams = schedule;
    verifyBlockoutParams.put("jobName", new JSONString(scheduleName)); // $NON-NLS-1$

    try {
      blockoutConflictRequest.sendRequest(
          verifyBlockoutParams.toString(),
          new RequestCallback() {
            public void onError(Request request, Throwable exception) {
              MessageDialogBox dialogBox =
                  new MessageDialogBox(
                      Messages.getString("error"),
                      exception.toString(),
                      false,
                      false,
                      true); //$NON-NLS-1$
              dialogBox.center();
              setDone(false);
            }

            public void onResponseReceived(Request request, Response response) {
              if (response.getStatusCode() == Response.SC_OK) {
                JsBlockStatus statusResponse =
                    (JsBlockStatus) parseJson(JsonUtils.escapeJsonForEval(response.getText()));

                // Determine if this schedule conflicts all the time or some of the time
                boolean partiallyBlocked =
                    Boolean.parseBoolean(statusResponse.getPartiallyBlocked());
                boolean totallyBlocked = Boolean.parseBoolean(statusResponse.getTotallyBlocked());
                if (partiallyBlocked || totallyBlocked) {
                  promptDueToBlockoutConflicts(totallyBlocked, partiallyBlocked, schedule, trigger);
                } else {
                  // Continue with other panels in the wizard (params, email)
                  handleWizardPanels(schedule, trigger);
                }
              } else {
                handleWizardPanels(schedule, trigger);
              }
            }
          });
    } catch (RequestException e) {
      // ignored
    }

    super.nextClicked();
  }
 protected JSONObject getJsonSimpleTrigger(
     int repeatCount, int interval, Date startDate, Date endDate) {
   JSONObject trigger = new JSONObject();
   trigger.put(
       "uiPassParam",
       new JSONString(scheduleEditorWizardPanel.getScheduleType().name())); // $NON-NLS-1$
   trigger.put("repeatInterval", new JSONNumber(interval)); // $NON-NLS-1$
   trigger.put("repeatCount", new JSONNumber(repeatCount)); // $NON-NLS-1$
   addJsonStartEnd(trigger, startDate, endDate);
   return trigger;
 }
예제 #27
0
  /**
   * Prepares a JSON object.
   *
   * @return JSONObject - the whole query
   */
  private JSONObject prepareJSONObject() {
    // query
    JSONObject query = new JSONObject();
    query.put("id", new JSONNumber(appId));

    if (reason != null) {
      query.put("reason", new JSONString(reason));
    }

    return query;
  }
예제 #28
0
  public Album(JSONObject jsonObject, G3Viewer a_Container) {
    m_UploadControl = a_Container.getUploadControl();
    m_ID = Utils.extractId(jsonObject.get("id"));
    m_Title = ((JSONString) jsonObject.get("title")).stringValue();
    m_Sort = ((JSONString) jsonObject.get("sort")).stringValue();

    m_Container = a_Container;
    m_View = a_Container.getView();
    m_DropController = new AlbumTreeDropController(this);
    m_Label = initComponents();
  }
예제 #29
0
 /**
  * Factory method.
  *
  * @param <J> type of {@link JavaScriptObject} returned by this method
  * @param pJson the JSON representation of a {@link com.tj.civ.client.model.jso.CbGameJSO}
  * @return a new instance, or <code>null</code> if the instance could not be created
  */
 @SuppressWarnings("unchecked")
 public static <J extends JavaScriptObject> J createFromJson(final String pJson) {
   J result = null;
   JSONValue v = JSONParser.parseStrict(pJson);
   if (v != null) {
     JSONObject obj = v.isObject();
     if (obj != null) {
       result = (J) obj.getJavaScriptObject().cast();
     }
   }
   return result;
 }
 public static JSONObject toObjectFromWrapper(JSONValue value, String name) {
   JSONObject object = value.isObject();
   if (object == null) {
     throw new DecodingException("Expected a json object, but was given: " + object);
   }
   JSONValue result = object.get(name);
   if (result == null) {
     // no wrapper found but that is possible within the hierarchy
     return toObject(value);
   }
   return toObject(result);
 }