private void save() {
    try {
      Record records[] = listGrid.getRecords();

      Integer mainIdList[] = new Integer[records.length];
      int i = 0;
      for (Record record : records) {
        mainIdList[i++] = record.getAttributeAsInt("main_id");
      }
      DataSource dataSource = DataSource.get("OrgDS");
      com.smartgwt.client.rpc.RPCManager.startQueue();
      Record record = new Record();
      record.setAttribute("mainIdList", mainIdList);
      record.setAttribute(
          "loggedUserName", CommonSingleton.getInstance().getSessionPerson().getUserName());
      DSRequest req = new DSRequest();
      req.setAttribute("operationId", "updateMainServiceOrders");
      dataSource.updateData(
          record,
          new DSCallback() {
            @Override
            public void execute(DSResponse response, Object rawData, DSRequest request) {
              destroy();
              tabOrganization.search();
            }
          },
          req);
      com.smartgwt.client.rpc.RPCManager.sendQueue();

    } catch (Exception e) {
      e.printStackTrace();
      SC.say(e.toString());
    }
  }
  private void delete(ListGridRecord listGridRecord) {
    try {
      com.smartgwt.client.rpc.RPCManager.startQueue();

      Record record = new Record();
      record.setAttribute(
          "loggedUserName", CommonSingleton.getInstance().getSessionPerson().getUser_name());
      record.setAttribute(
          "billing_company_id", listGridRecord.getAttributeAsInt("billing_company_id"));

      DSRequest req = new DSRequest();
      req.setAttribute("operationId", "removeBillingComp");

      billingCompsGrid.removeData(
          record,
          new DSCallback() {
            @Override
            public void execute(DSResponse response, Object rawData, DSRequest request) {}
          },
          req);
      com.smartgwt.client.rpc.RPCManager.sendQueue();
    } catch (Exception e) {
      SC.say(e.toString());
    }
  }
 @Override
 public GUIDocument markSelectedAsCheckedOut() {
   Record record = getSelectedRecord();
   if (record == null) return null;
   record.setAttribute("locked", "page_edit");
   record.setAttribute("lockUserId", Session.get().getUser().getId());
   record.setAttribute("status", Constants.DOC_CHECKED_OUT);
   redraw();
   return getSelectedDocument();
 }
  @Override
  public GUIDocument markSelectedAsCheckedIn() {
    Record record = getSelectedRecord();
    if (record == null) return null;
    record.setAttribute("locked", "blank");
    record.setAttribute("status", Constants.DOC_UNLOCKED);
    record.setAttribute("indexed", Constants.INDEX_TO_INDEX);
    record.setAttribute("signed", "blank");
    record.setAttribute("extResId", (String) null);
    redraw();

    return getSelectedDocument();
  }
示例#5
0
 private DataSource getRecentlyAccessed() {
   final DataSource datasource = new DataSource();
   datasource.setClientOnly(true);
   datasource.setCacheAllData(true);
   datasource.setAutoCacheAllData(true);
   int j = accesshistory.get(selectedCriterion.displaytype).getStack().size();
   final Record[] records = new Record[j];
   for (final AccessString access : accesshistory.get(selectedCriterion.displaytype).getStack()) {
     final Record record =
         new Record(JSONParser.parseStrict(access.asString()).isObject().getJavaScriptObject());
     record.setAttribute("row", j);
     record.setAttribute("lastmodified", record.getAttribute("lastmodified").substring(0, 10));
     records[--j] = record;
   }
   datasource.setTestData(records);
   return datasource;
 }
示例#6
0
    private void saveNewDigitalObject(String modelId, String pid, String mods) {
      Record r = new Record();
      DigitalObjectDataSource ds = DigitalObjectDataSource.getInstance();
      r.setAttribute(DigitalObjectDataSource.FIELD_MODEL, modelId);
      if (mods != null) {
        r.setAttribute(DigitalObjectDataSource.FIELD_MODS, mods);
      }
      if (pid != null && !pid.isEmpty()) {
        r.setAttribute(DigitalObjectDataSource.FIELD_PID, pid);
      }
      DSRequest dsRequest = new DSRequest();
      dsRequest.setWillHandleError(true);
      ds.addData(
          r,
          new DSCallback() {

            @Override
            public void execute(DSResponse response, Object rawData, DSRequest request) {
              if (response.getStatus() == RPCResponse.STATUS_VALIDATION_ERROR) {
                Map errors = response.getErrors();
                newDigObject.setValidationErrors(errors);
                request.setWillHandleError(true);
                return;
              }
              if (response.getHttpResponseCode() >= 400) {
                // failure
                SC.warn("Failed to create digital object!");
              } else {
                Record[] data = response.getData();
                if (data != null && data.length > 0) {
                  String pid = data[0].getAttribute(DigitalObjectDataSource.FIELD_PID);
                  // here should be updated DigitalObject data stream
                  // caches to prevent server round-trip delays
                  StatusView.getInstance().show(i18n.DigitalObjectCreator_FinishedStep_Done_Msg());
                  places.goTo(new DigitalObjectEditorPlace(DatastreamEditorType.MODS, pid));
                } else {
                  SC.warn("Failed to create digital object!");
                }
              }
            }
          },
          dsRequest);
    }
  private void changeStatus(Integer calendar_id, Integer deleted) {
    try {
      com.smartgwt.client.rpc.RPCManager.startQueue();
      Record record = new Record();
      record.setAttribute("deleted", deleted);
      record.setAttribute("calendar_id", calendar_id);
      record.setAttribute(
          "loggedUserName", CommonSingleton.getInstance().getSessionPerson().getUserName());
      DSRequest req = new DSRequest();

      req.setAttribute("operationId", "updateSecularCalendarStatus");
      listGrid.updateData(
          record,
          new DSCallback() {
            @Override
            public void execute(DSResponse response, Object rawData, DSRequest request) {}
          },
          req);
      com.smartgwt.client.rpc.RPCManager.sendQueue();
    } catch (Exception e) {
      SC.say(e.toString());
    }
  }
 @Override
 protected void transformResponse(DSResponse dsResponse, DSRequest dsRequest, Object data) {
   if (RestConfig.isStatusOk(dsResponse)) {
     Record[] records = dsResponse.getData();
     for (Record record : records) {
       String mid = record.getAttribute(FIELD_ID);
       String way = record.getAttribute(FIELD_WAY);
       String pk = mid;
       if (way != null) {
         pk = mid + way;
       }
       record.setAttribute(PRIMARY_KEY, pk);
     }
   }
   super.transformResponse(dsResponse, dsRequest, data);
 }
示例#9
0
 private void askForExportOptions(String[] pids) {
   if (pids == null || pids.length == 0) {
     return;
   }
   Record export = new Record();
   export.setAttribute(ExportResourceApi.CROSSREF_PID_PARAM, pids);
   //        ExportOptionsWidget.showOptions(export, new Callback<Record, Void>() {
   //
   //            @Override
   //            public void onFailure(Void reason) {
   //                // no-op
   //            }
   //
   //            @Override
   //            public void onSuccess(Record result) {
   //                exportOrValidate(result);
   //            }
   //        });
   exportOrValidate(export);
 }
示例#10
0
 public void setDataValue(Object val, Record record) {
   record.setAttribute("_obj", val);
   setOtherValues(val, record);
 }
示例#11
0
 public void copyToRecord(Record to) {
   to.setAttribute("id", getId());
   to.setAttribute("name", getName());
   to.setAttribute("date", getDate());
 }
示例#12
0
  private void saveCountry() {
    try {
      String cityNameGeo = cityNameGeoItem.getValueAsString();
      if (cityNameGeo == null || cityNameGeo.trim().equalsIgnoreCase("")) {
        SC.say("შეიყვანეთ ქართული დასახელება !");
        return;
      }

      String town_code = cityCodeItem.getValueAsString();
      //			if (town_code == null || town_code.trim().equalsIgnoreCase("")) {
      //				SC.say("შეიყვანეთ ქალაქის კოდი !");
      //				return;
      //			}
      String town_code_new = cityNewCodeItem.getValueAsString();

      ListGridRecord country_record = countryItem.getSelectedRecord();
      if (country_record == null || country_record.getAttributeAsInt("country_id") == null) {
        SC.say("გთხოვთ აირჩიოთ ქვეყანა !");
        return;
      }
      Integer country_id = country_record.getAttributeAsInt("country_id");

      if (cityNameGeo.length() > 1005) {
        SC.say("ქართული დასახელება შედგება მაქსიმუმ 155 სიმბოლოსაგან !");
        return;
      }
      //			if (town_code.length() > 180) {
      //				SC.say("ქალაქის კოდი შედგება მაქსიმუმ 90 სიმბოლოსაგან !");
      //				return;
      //			}
      //			if (town_code_new != null && town_code_new.length() > 180) {
      //				SC.say("ქალაქის ახალი კოდი შედგება მაქსიმუმ 90 სიმბოლოსაგან !");
      //				return;
      //			}

      ListGridRecord city_type_record = townTypeItem.getSelectedRecord();
      if (city_type_record == null
          || city_type_record.getAttributeAsInt("description_id") == null) {
        SC.say("გთხოვთ აირჩიოთ ქალაქის ტიპი !");
        return;
      }
      Integer town_type_id = city_type_record.getAttributeAsInt("description_id");

      String capital_town_record = isCapitalItem.getValueAsString();
      if (capital_town_record == null || capital_town_record.trim().equals("")) {
        SC.say("გთხოვთ აირჩიოთ ქალაქის სახეობა !");
        return;
      }
      Integer capital_town = Integer.parseInt(capital_town_record);

      //			try {
      //				Integer.parseInt(town_code);
      //			} catch (NumberFormatException e) {
      //				SC.say("ქალაქის კოდის შედგება მხოლოდ ციფრებისაგან !");
      //				return;
      //			}
      //			if (town_code_new != null && !town_code_new.equals("")) {
      //				try {
      //					Integer.parseInt(town_code_new);
      //				} catch (NumberFormatException e) {
      //					SC.say("ქალაქის ახალი კოდის შედგება მხოლოდ ციფრებისაგან !");
      //					return;
      //				}
      //			}
      String normal_gmt = ofGmtItem.getValueAsString();
      if (normal_gmt == null || normal_gmt.trim().equals("")) {
        SC.say("გთხოვთ შეიყვანოთ დრო !");
        return;
      }
      try {
        Integer.parseInt(normal_gmt);
      } catch (NumberFormatException e) {
        SC.say("დრო შედგება მხოლოდ ციფრებისაგან !");
        return;
      }
      String winter_gmt = ofGmtWinterItem.getValueAsString();
      if (winter_gmt == null || winter_gmt.trim().equals("")) {
        SC.say("გთხოვთ შეიყვანოთ ზამთრის დრო !");
        return;
      }
      try {
        Integer.parseInt(winter_gmt);
      } catch (NumberFormatException e) {
        SC.say("ზამთრის დრო შედგება მხოლოდ ციფრებისაგან !");
        return;
      }

      com.smartgwt.client.rpc.RPCManager.startQueue();
      Record record = new Record();
      record.setAttribute("town_name", cityNameGeo);
      record.setAttribute("town_code", town_code);
      record.setAttribute("town_new_code", town_code_new);
      record.setAttribute("country_id", country_id);
      record.setAttribute("town_type_id", town_type_id);
      record.setAttribute("capital_town", capital_town);
      record.setAttribute("normal_gmt", normal_gmt);
      record.setAttribute("winter_gmt", winter_gmt);

      if (lCityRecord != null) {
        record.setAttribute("town_id", lCityRecord.getAttributeAsInt("town_id"));
      }
      record.setAttribute(
          "loggedUserName", CommonSingleton.getInstance().getSessionPerson().getUser_name());
      DSRequest req = new DSRequest();

      if (lCityRecord == null) {
        req.setAttribute("operationId", "townAdd");
        cityGrid.addData(
            record,
            new DSCallback() {
              @Override
              public void execute(DSResponse response, Object rawData, DSRequest request) {
                destroy();
              }
            },
            req);
      } else {
        req.setAttribute("operationId", "townUpdate");
        cityGrid.updateData(
            record,
            new DSCallback() {
              @Override
              public void execute(DSResponse response, Object rawData, DSRequest request) {
                destroy();
              }
            },
            req);
      }
      com.smartgwt.client.rpc.RPCManager.sendQueue();
    } catch (Exception e) {
      e.printStackTrace();
      SC.say(e.toString());
    }
  }