Example #1
0
 @SuppressWarnings("unchecked")
 @Override
 public XmlRpcStruct toXmlRpcStruct() {
   final XmlRpcStruct result = super.toXmlRpcStruct();
   result.put(MIME_TYPE_FIELD, this.getMimeType());
   return result;
 }
Example #2
0
  public String createAV(ExpBrwModel model) throws Exception {
    log.info("interface : createAV");

    Boolean success = false;
    String msgs = null;
    Map<String, Object> map = new HashMap<String, Object>();

    try {
      Map<String, Object> cfg =
          getConnectionConfig(CommonConstant.EXT_ADMIN_USER, CommonConstant.EXT_ADMIN_PASSWORD);
      XmlRpcClient client = getXmlRpcClient(cfg);

      List<Map<String, Object>> list = expBrwService.listForInf(model.getId());
      Map<String, Object> data = list.size() > 0 ? list.get(0) : null;

      List args = getInitArgs(cfg);
      args.add("hr.expense.expense"); // Remote Object
      args.add("generate_hr_expense"); // method

      List a = new ArrayList();

      /*
       * Header
       */
      map.put("is_employee_advance", "True");
      map.put("number", data.get("av_id"));
      map.put("employee_code", data.get("req_by"));
      map.put("preparer_code", data.get("created_by"));
      map.put("date", CommonDateTimeUtil.convertToOdooFieldDate(CommonDateTimeUtil.now()));
      //	        map.put("write_date",CommonDateTimeUtil.convertToOdooFieldDateTime((Timestamp)
      // data.get("updated_time")));
      map.put("advance_type", data.get("objective_type"));
      map.put(
          "date_back",
          CommonDateTimeUtil.convertToOdooFieldDate(
              data.get("date_back") != null
                  ? (Timestamp) data.get("date_back")
                  : CommonDateTimeUtil.now()));
      map.put("name", data.get("objective"));
      map.put("apweb_ref_url", NodeUtil.trimNodeRef((String) data.get("doc_ref")));
      map.put("receive_method", receiveMethodForInf((String) data.get("bank_type")));
      map.put("employee_bank_id.id", data.get("bank") != null ? data.get("bank") : "");
      map.put("reason_bypass_procure", data.get("reason") != null ? data.get("reason") : "");
      map.put("note", data.get("note") != null ? data.get("note") : "");
      map.put("remark", data.get("av_remark") != null ? data.get("av_remark") : "");

      for (String key : map.keySet()) {
        log.info(" - " + key + ":" + map.get(key));
      }

      /*
       * Line Item
       */
      list = expBrwService.listDtlForInf(model.getId());

      List orderLine = new ArrayList();

      String bgType = (String) data.get("budget_cc_type");
      String bg = ((Integer) data.get("budget_cc")).toString();
      String sid = bgType.equals(MainBudgetSrcConstant.TYPE_UNIT) ? bg : "";
      String pid = bgType.equals(MainBudgetSrcConstant.TYPE_PROJECT) ? bg : "";
      String aid = bgType.equals(MainBudgetSrcConstant.TYPE_ASSET) ? bg : "";
      String cid = bgType.equals(MainBudgetSrcConstant.TYPE_CONSTRUCTION) ? bg : "";

      String ccid =
          data.get("cost_control_id") != null ? data.get("cost_control_id").toString() : "";

      String fundid = data.get("fund_id") != null ? data.get("fund_id").toString() : "";

      for (Map<String, Object> dtl : list) {
        Map<String, Object> line = new HashMap<String, Object>();
        line.put("section_id.id", sid);
        line.put("project_id.id", pid);
        line.put("invest_asset_id.id", aid);
        line.put("invest_construction_phase_id.id", cid);
        line.put("fund_id.id", fundid);
        line.put("is_advance_product_line", "True");
        line.put("activity_group_id.id", String.valueOf(dtl.get("act_grp_id")));
        line.put("activity_id.id", String.valueOf(dtl.get("act_id")));
        line.put("name", dtl.get("activity"));
        line.put("unit_amount", String.valueOf(dtl.get("amount")));
        line.put("cost_control_id.id", ccid);
        orderLine.add(line);

        for (String key : line.keySet()) {
          log.info(" -- " + key + ":" + line.get(key));
        }
      }

      map.put("line_ids", orderLine);

      /*
       * Employee
       */
      List<Map<String, Object>> empList =
          expBrwService.listAttendeeByMasterIdAndType(
              model.getId(), ExpBrwAttendeeConstant.T_EMPLOYEE, null);
      log.info("empList.size()=" + empList.size());

      List employees = new ArrayList();

      int seq = 1;

      for (Map<String, Object> emp : empList) {

        Map<String, Object> employee = new HashMap<String, Object>();
        employee.put("sequence", String.valueOf(seq++));
        employee.put("employee_code", emp.get("code"));
        employees.add(employee);

        for (String key : employee.keySet()) {
          log.info(" ---- " + key + ":" + employee.get(key));
        }
      }

      map.put("attendee_employee_ids", employees);

      /*
       * Non employee
       */
      List<Map<String, Object>> nonempList =
          expBrwService.listAttendeeByMasterIdAndType(
              model.getId(), ExpBrwAttendeeConstant.T_OTHER, null);
      log.info("nonempList.size()=" + nonempList.size());

      List nonemployees = new ArrayList();

      seq = 1;

      for (Map<String, Object> nonemp : nonempList) {

        Map<String, Object> nonemployee = new HashMap<String, Object>();
        nonemployee.put("sequence", String.valueOf(seq++));
        nonemployee.put(
            "attendee_name",
            nonemp.get("title") + " " + nonemp.get("fname") + " " + nonemp.get("lname"));
        nonemployee.put("position", nonemp.get("position") != null ? nonemp.get("position") : "");
        nonemployee.put(
            "organization", nonemp.get("unit_type") != null ? nonemp.get("unit_type") : "");
        nonemployees.add(nonemployee);

        for (String key : nonemployee.keySet()) {
          log.info(" ----- " + key + ":" + nonemployee.get(key));
        }
      }

      map.put("attendee_external_ids", nonemployees);

      /*
       * Attachment
       */
      List<FileModel> fileList = expBrwService.listFile(model.getId(), false);
      log.info("fileList.size()=" + fileList.size());

      List attachment = new ArrayList();

      for (FileModel file : fileList) {
        // detail :
        // http://localhost:18080/share/page/document-details?nodeRef=workspace://SpacesStore/5190b027-00c6-4322-98c3-1be01314bdd9
        // download format url :
        // http://localhost:18080/share/proxy/alfresco/api/node/content/workspace/SpacesStore/<url>/<name>?a=true
        // example url :
        // http://localhost:18080/share/proxy/alfresco/api/node/content/workspace/SpacesStore/260cdb8d-5a9c-43af-9c8e-178c75f1fe38/PR16000050.pdf?a=true

        Map<String, Object> att = new HashMap<String, Object>();
        att.put("name", file.getName());
        att.put("description", file.getDesc() != null ? file.getDesc() : "");
        att.put("url", NodeUtil.trimNodeRef(file.getNodeRef().toString()));
        attachment.add(att);

        for (String key : att.keySet()) {
          log.info(" ------ " + key + ":" + att.get(key));
        }
      }

      map.put("attachment_ids", attachment);

      /*
       * Final
       */
      a.add(map);

      args.add(a);

      log.info("args=" + args);

      /*
       * Call
       */
      Object res = client.invoke("execute_kw", args);

      /*
       * Result
       */
      log.info("res=" + res);

      XmlRpcStruct strc = (XmlRpcStruct) res;

      for (Object k : strc.keySet()) {
        Object v = strc.get(k);

        log.info(" - " + k + " : " + v + ":" + v.getClass().getName());
      }

      success = (Boolean) strc.get("is_success");
      msgs = strc.get("messages") != null ? strc.get("messages").toString() : "";

    } catch (Exception ex) {
      return ex.toString() + ":" + map.toString();
    }

    return success ? "OK" : msgs + ":" + map.toString();
  }
Example #3
0
 @Override
 public void fromXmlRpcStruct(final XmlRpcStruct x) {
   super.fromXmlRpcStruct(x);
   this.setMimeType((String) x.get(MIME_TYPE_FIELD));
 }
 public ApiStartSession(XmlRpcStruct struct) {
   this.seconds = struct.getDouble("seconds");
   this.status = struct.getString("status");
   this.token = struct.getString("token");
 }