Пример #1
0
  /*
   * 备注:平台编写规则类
   * 接口执行类
   */
  public Object runComClass(PfParameterVO vo) throws BusinessException {
    try {
      super.m_tmpVo = vo;
      // ####本脚本必须含有返回值,返回DLG和PNL的组件不允许有返回值####
      Object retObj = null;
      // ####该组件为单动作工作流处理开始...不能进行修改####
      Object m_sysflowObj = procActionFlow(vo);
      if (m_sysflowObj != null) {
        return m_sysflowObj;
      }
      // ####该组件为单动作工作流处理结束...不能进行修改####

      // ####重要说明:生成的业务组件方法尽量不要进行修改####
      // 方法说明:反查单据主表VO的ts属性
      retObj =
          runClass(
              "nc.bs.trade.business.HYPubBO",
              "setBillTs",
              "nc.vo.pub.AggregatedValueObject:01",
              vo,
              m_keyHas,
              m_methodReturnHas);
      // ##################################################
      return retObj;
    } catch (Exception ex) {
      if (ex instanceof BusinessException) throw (BusinessException) ex;
      else throw new PFBusinessException(ex.getMessage(), ex);
    }
  }
  /**
   * Method 'execute'
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @throws Exception
   * @return ActionForward
   */
  public ActionForward handle(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    try {
      // parse parameters
      // create the DAO class
      TelesalesCallSourceDao dao = TelesalesCallSourceDaoFactory.create();

      // execute the finder
      TelesalesCallSource dto[] = dao.findAll();

      // store the results
      request.setAttribute("result", dto);

      return mapping.findForward("success");
    } catch (Exception e) {
      ActionErrors _errors = new ActionErrors();
      _errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError("internal.error", e.getClass().getName() + ": " + e.getMessage()));
      saveErrors(request, _errors);
      return mapping.findForward("failure");
    }
  }
Пример #3
0
  public static void main(String[] args) {
    try {
      Context ctx = new InitialContext();
      Object objref = ctx.lookup(JNDI_NAME);

      SavingsAccountHome home =
          (SavingsAccountHome) PortableRemoteObject.narrow(objref, SavingsAccountHome.class);

      BigDecimal zeroAmount = new BigDecimal("0.00");
      SavingsAccount John = home.create("100", "John", "Smith", zeroAmount);

      System.out.println("Account Name: " + John.getFirstName());
      System.out.println("Credit: 88.50");

      John.credit(new BigDecimal("88.50"));
      System.out.println("Debit: 20.25");

      John.debit(new BigDecimal("20.25"));
      BigDecimal balance = John.getBalance();
      System.out.println("Balance = " + balance);
      // John.remove();
      System.exit(0);
    } catch (InsufficientBalanceException ex) {
      System.err.println("Caught an InsufficientBalanceException: " + ex.getMessage());
    } catch (Exception ex) {
      System.err.println("Caught an exception.");
      ex.printStackTrace();
    }
  }
Пример #4
0
  /*
   * 备注:平台编写规则类
   * 接口执行类
   */
  public Object runComClass(PfParameterVO vo) throws BusinessException {
    try {
      super.m_tmpVo = vo;
      // ####本脚本必须含有返回值,返回DLG和PNL的组件不允许有返回值####
      Object retObj = null;
      // ####该组件为单动作弃审处理开始...不能进行修改####
      boolean isFinishToGoing = procUnApproveFlow(vo);
      // ###返回值:true-审批流程由完成态返回到运行态;false-其他情况
      // ####该组件为单动作弃审处理结束...不能进行修改####

      if (isFinishToGoing) {
        // 审批流程由完成态返回到运行态,需要进行的业务补偿
      }

      // ####重要说明:生成的业务组件方法尽量不要进行修改####
      // 方法说明:反查单据主表VO的ts属性
      retObj =
          runClass(
              "nc.bs.trade.business.HYPubBO",
              "setBillTs",
              "nc.vo.pub.AggregatedValueObject:01",
              vo,
              m_keyHas,
              m_methodReturnHas);
      // ##################################################
      return getVo();
    } catch (Exception ex) {
      if (ex instanceof BusinessException) throw (BusinessException) ex;
      else throw new PFBusinessException(ex.getMessage(), ex);
    }
  }
Пример #5
0
  /**
   * @param obj ValueObject related to the current row
   * @param colIndex TableModel column index
   * @return Object contained into the TableModel at the specified column and ValueObject
   */
  public final Object getField(ValueObject obj, int colIndex) {
    try {
      Method[] m = (Method[]) voGetterMethods.get(getFieldName(colIndex));
      if (m == null)
        Logger.error(
            this.getClass().getName(),
            "getField",
            "No getter method for index "
                + colIndex
                + " and attribute name '"
                + getFieldName(colIndex)
                + "'.",
            null);

      for (int i = 0; i < m.length - 1; i++) {
        obj = (ValueObject) m[i].invoke(obj, new Object[0]);
        if (obj == null) {
          if (grids.getGridControl() == null || !grids.getGridControl().isCreateInnerVO())
            return null;
          else obj = (ValueObject) m[i].getReturnType().newInstance();
        }
      }

      return m[m.length - 1].invoke(obj, new Object[0]);
    } catch (Exception ex) {
      ex.printStackTrace();
      return null;
    }
  }
Пример #6
0
  public String getRangeDescription() {
    try {
      org.openxava.test.calculators.RangeDescriptionCalculator rangeDescriptionCalculator =
          (org.openxava.test.calculators.RangeDescriptionCalculator)
              getMetaModel()
                  .getMetaProperty("rangeDescription")
                  .getMetaCalculator()
                  .createCalculator();

      rangeDescriptionCalculator.setSubfamilyNumberFrom(getSubfamily().getNumber());

      rangeDescriptionCalculator.setSubfamilyNumberTo(getSubfamilyTo().getNumber());
      return (String) rangeDescriptionCalculator.calculate();
    } catch (NullPointerException ex) {
      // Usually for multilevel property access with null references
      return null;
    } catch (Exception ex) {
      ex.printStackTrace();
      throw new RuntimeException(
          XavaResources.getString(
              "generator.calculate_value_error",
              "RangeDescription",
              "FilterBySubfamily",
              ex.getLocalizedMessage()));
    }
  }
Пример #7
0
 // User defined finders/Buscadores definidos por el usuario
 public static FilterBySubfamily findBy() throws javax.ejb.ObjectNotFoundException {
   if (XavaPreferences.getInstance().isJPAPersistence()) {
     javax.persistence.Query query =
         org.openxava.jpa.XPersistence.getManager().createQuery("from FilterBySubfamily as o");
     try {
       return (FilterBySubfamily) query.getSingleResult();
     } catch (Exception ex) {
       // In this way in order to work with Java pre 5
       if (ex.getClass().getName().equals("javax.persistence.NoResultException")) {
         throw new javax.ejb.ObjectNotFoundException(
             XavaResources.getString("object_not_found", "FilterBySubfamily"));
       } else {
         ex.printStackTrace();
         throw new RuntimeException(ex.getMessage());
       }
     }
   } else {
     org.hibernate.Query query =
         org.openxava.hibernate.XHibernate.getSession().createQuery("from FilterBySubfamily as o");
     FilterBySubfamily r = (FilterBySubfamily) query.uniqueResult();
     if (r == null) {
       throw new javax.ejb.ObjectNotFoundException(
           XavaResources.getString("object_not_found", "FilterBySubfamily"));
     }
     return r;
   }
 }
Пример #8
0
 // User defined finders/Buscadores definidos por el usuario
 public static Size findById(int id) throws javax.ejb.ObjectNotFoundException {
   if (XavaPreferences.getInstance().isJPAPersistence()) {
     javax.persistence.Query query =
         org.openxava.jpa.XPersistence.getManager()
             .createQuery("from Size as o where o.id = :arg0");
     query.setParameter("arg0", new Integer(id));
     try {
       return (Size) query.getSingleResult();
     } catch (Exception ex) {
       // In this way in order to work with Java pre 5
       if (ex.getClass().getName().equals("javax.persistence.NoResultException")) {
         throw new javax.ejb.ObjectNotFoundException(
             XavaResources.getString("object_not_found", "Size"));
       } else {
         ex.printStackTrace();
         throw new RuntimeException(ex.getMessage());
       }
     }
   } else {
     org.hibernate.Query query =
         org.openxava.hibernate.XHibernate.getSession()
             .createQuery("from Size as o where o.id = :arg0");
     query.setParameter("arg0", new Integer(id));
     Size r = (Size) query.uniqueResult();
     if (r == null) {
       throw new javax.ejb.ObjectNotFoundException(
           XavaResources.getString("object_not_found", "Size"));
     }
     return r;
   }
 }
Пример #9
0
 public static boolean download(
     URL url, String file, int prefix, int totalFilesize, IProgressUpdater updater) {
   File fFile = new File(new File(file).getParentFile().getPath());
   if (!fFile.exists()) fFile.mkdirs();
   boolean downloaded = true;
   BufferedInputStream in = null;
   FileOutputStream out = null;
   BufferedOutputStream bout = null;
   try {
     int count;
     int totalCount = 0;
     byte data[] = new byte[BUFFER];
     in = new BufferedInputStream(url.openStream());
     out = new FileOutputStream(file);
     bout = new BufferedOutputStream(out);
     while ((count = in.read(data, 0, BUFFER)) != -1) {
       bout.write(data, 0, count);
       totalCount += count;
       if (updater != null) updater.update(prefix + totalCount, totalFilesize);
     }
   } catch (Exception e) {
     e.printStackTrace();
     Utils.logger.log(Level.SEVERE, "Download error!");
     downloaded = false;
   } finally {
     try {
       close(in);
       close(bout);
       close(out);
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   return downloaded;
 }
Пример #10
0
 /**
  * @param colIndex TableModel column index
  * @return TableCellEditor for the specified column
  */
 public final TableCellEditor getCellEditor(int colIndex) {
   try {
     return colProperties[colIndex].getCellEditor(tableContainer, grids);
   } catch (Exception ex) {
     ex.printStackTrace();
     return null;
   }
 }
Пример #11
0
 public static JSONObject readJSONUrlFile(String url) {
   try {
     return readJSONUrlFile(new URL(url));
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Пример #12
0
 private static void setStream(String in, String out) {
   try {
     System.setIn(new BufferedInputStream(new FileInputStream(in)));
     System.setOut(new PrintStream(out));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #13
0
 /**
  * Load the actual DO data if necessary. Called by get/set methods.
  *
  * @exception DataObjectException If a data access error occurs.
  */
 private void checkLoad() throws DataObjectException {
   if (null == data)
     try {
       loadData();
     } catch (Exception e) {
       throw new DataObjectException(
           "Unable to load data for TreeLeafDO id=" + getOId() + ", error = " + e.getMessage());
     }
 }
Пример #14
0
 private void receiveEGTable() {
   int nBytes = (nBits - 1) / 8 + 1;
   try {
     for (int j = 0; j < nCols; j++)
       EGTable[j] = Utils.readBigInteger(nBytes * Wire.labelBitLength, ois);
   } catch (Exception e) {
     e.printStackTrace();
     System.exit(1);
   }
 }
Пример #15
0
 /**
  * Set Sex of the PersonalProfile
  *
  * @param Sex of the PersonalProfile
  * @exception DataObjectException If the object is not found in the database.
  */
 public void setSex(String Sex) throws DataObjectException {
   try {
     // business actions/assertions prior to data assignment
     beforeAnySet();
   } catch (Exception e) {
     throw new DataObjectException("beforeAnySet: " + e.getMessage());
   }
   checkLoad();
   data.Sex = markNewValue(data.Sex, Sex, 0, 32, true);
   afterAnySet(); // business actions/assertions after data assignment
 }
Пример #16
0
 public static JSONObject readJSONUrlFile(URL url) {
   try {
     JSONParser tmp = new JSONParser();
     Object o = tmp.parse(new InputStreamReader(url.openStream()));
     if (!(o instanceof JSONObject)) return null;
     else return (JSONObject) o;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Пример #17
0
 public static JSONObject readJSONFile(String filename) {
   try {
     JSONParser tmp = new JSONParser();
     Object o = tmp.parse(new InputStreamReader(new FileInputStream(filename)));
     if (!(o instanceof JSONObject)) return null;
     else return (JSONObject) o;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Пример #18
0
 /**
  * Set Nationality of the PersonalProfile
  *
  * @param Nationality of the PersonalProfile
  * @exception DataObjectException If the object is not found in the database.
  */
 public void setNationality(jobmatch.data.CountryDO Nationality) throws DataObjectException {
   try {
     // business actions/assertions prior to data assignment
     beforeAnySet();
   } catch (Exception e) {
     throw new DataObjectException("beforeAnySet: " + e.getMessage());
   }
   checkLoad();
   data.Nationality = (jobmatch.data.CountryDO) markNewValue(data.Nationality, Nationality);
   afterAnySet(); // business actions/assertions after data assignment
 }
Пример #19
0
  private void init() {
    try {
      receiveParams();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }

    EGTable = new BigInteger[nCols];
    outputLabels = new BigInteger[nBits];
  }
Пример #20
0
 /**
  * Set Mandatory of the NewDBTable
  *
  * @param Mandatory of the NewDBTable
  * @exception DataObjectException If the object is not found in the database.
  */
 public void setMandatory(boolean Mandatory) throws DataObjectException {
   try {
     // business actions/assertions prior to data assignment
     beforeAnySet();
   } catch (Exception e) {
     throw new DataObjectException("beforeAnySet: " + e.getMessage());
   }
   checkLoad();
   data.Mandatory = markNewValue(data.Mandatory, Mandatory);
   afterAnySet(); // business actions/assertions after data assignment
 }
Пример #21
0
 /**
  * Set Profile of the NewDBTable
  *
  * @param Profile of the NewDBTable
  * @exception DataObjectException If the object is not found in the database.
  */
 public void setProfile(jobmatch.data.ProfileDO Profile) throws DataObjectException {
   try {
     // business actions/assertions prior to data assignment
     beforeAnySet();
   } catch (Exception e) {
     throw new DataObjectException("beforeAnySet: " + e.getMessage());
   }
   checkLoad();
   data.Profile = (jobmatch.data.ProfileDO) markNewValue(data.Profile, Profile);
   afterAnySet(); // business actions/assertions after data assignment
 }
Пример #22
0
 /**
  * Set LeafNumber of the NewDBTable
  *
  * @param LeafNumber of the NewDBTable
  * @exception DataObjectException If the object is not found in the database.
  */
 public void setLeafNumber(int LeafNumber) throws DataObjectException {
   try {
     // business actions/assertions prior to data assignment
     beforeAnySet();
   } catch (Exception e) {
     throw new DataObjectException("beforeAnySet: " + e.getMessage());
   }
   checkLoad();
   data.LeafNumber = markNewValue(data.LeafNumber, LeafNumber);
   afterAnySet(); // business actions/assertions after data assignment
 }
Пример #23
0
 /*
  * 备注:平台编写规则类
  * 接口执行类
  */
 public Object runComClass(PfParameterVO vo) throws BusinessException {
   try {
     super.m_tmpVo = vo;
     // ####本脚本必须含有返回值,返回DLG和PNL的组件不允许有返回值####
     Object retObj = null;
     return null;
   } catch (Exception ex) {
     if (ex instanceof BusinessException) throw (BusinessException) ex;
     else throw new PFBusinessException(ex.getMessage(), ex);
   }
 }
Пример #24
0
 private void receiveEGTable_EXT() {
   int nBytes = (nBits - 1) / 8 + 1;
   try {
     for (int j = 0; j < nCols; j++) {
       boolean temp = ois.readBoolean();
       if (temp) EGTable[j] = Utils.readBigInteger(nBytes * Wire.labelBitLength, ois);
       else EGTable[j] = null;
     }
   } catch (Exception e) {
     e.printStackTrace();
     System.exit(1);
   }
 }
Пример #25
0
 private org.openxava.converters.IConverter getNameConverter() {
   if (nameConverter == null) {
     try {
       nameConverter =
           (org.openxava.converters.IConverter) getMetaModel().getMapping().getConverter("name");
     } catch (Exception ex) {
       ex.printStackTrace();
       throw new RuntimeException(
           XavaResources.getString("generator.create_converter_error", "name"));
     }
   }
   return nameConverter;
 }
Пример #26
0
 public static void close(Object o) {
   try {
     if (o == null) return;
     if (o instanceof InputStream) {
       ((InputStream) o).close();
     } else if (o instanceof OutputStream) {
       ((OutputStream) o).flush();
       ((OutputStream) o).close();
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #27
0
 public static String loadStringFromFile(String filename) {
   String line = "";
   File file = new File(filename);
   if (!file.exists()) return line;
   try {
     BufferedReader reader = new BufferedReader(new FileReader(file));
     line = reader.readLine();
     reader.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return line;
 }
Пример #28
0
 public void run() {
   // long time = System.currentTimeMillis();
   try {
     br = new BufferedReader(new FileReader(new File("cell.in")));
     out = new PrintWriter("cell.out");
     solve();
   } catch (Exception e) {
     e.printStackTrace();
     System.exit(111);
   }
   // System.err.println(System.currentTimeMillis() - time);
   out.close();
 }
Пример #29
0
  /**
   * Prepares the statement used to insert this object into the database.
   *
   * @param conn the database connection.
   * @return the insert statement.
   * @exception java.sql.SQLException if an error occurs.
   */
  public PreparedStatement getInsertStatement(DBConnection conn) throws SQLException {
    /*
     * It would probably be better to have CoreDO implement
     * 	void addToCache(CoreDO DO) {}
     * and have each DO that has caching enabled override it as
     *      void addToCache(CoreDO DO) { cache.put( DO.getOId(), DO ); }
     * and change CoreDO to invoke addToCache()
     * when it invokes getInsertStatement().
     */

    ObjectId oid;

    PreparedStatement stmt =
        conn.prepareStatement(
            "insert into PersonalProfile ( LeafNumber, Profile, Mandatory, MinAge, MaxAge, Nationality, Sex, "
                + getOIdColumnName()
                + ", "
                + getVersionColumnName()
                + " ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ? )");

    param = new int[1];
    param[0] = 1;
    // writeMemberStuff uses the JDBCsetCalls.template
    // to build up the value for this tag:
    // the value is a series of calls to setPrepStmtParam_TYPE methods.
    // Those methods are defined in GenericDO.
    try {
      setPrepStmtParam_int(stmt, param, getLeafNumber());
      setPrepStmtParam_DO(stmt, param, getProfile());
      setPrepStmtParam_boolean(stmt, param, getMandatory());
      setPrepStmtParam_int(stmt, param, getMinAge());
      setPrepStmtParam_int(stmt, param, getMaxAge());
      setPrepStmtParam_DO(stmt, param, getNationality());
      setPrepStmtParam_String(stmt, param, getSex());

      /* The order of the values being inserted must match
       * the order of the columns listed in the CREATE TABLE command
       * that appears in the .sql file for this DO.
       * Since the id and version number are always the last columns
       * listed in the CREATE TABLE command, their values are added
       * to the PreparedStatement after all other values.
       */
      setPrepStmtParam_BigDecimal(stmt, param, getOId().toBigDecimal());
      setPrepStmtParam_int(stmt, param, getNewVersion());

    } catch (Exception e) {
      throw new SQLException("Data Object error: " + e.getMessage());
    }

    return stmt;
  }
Пример #30
0
 public static boolean saveStringToFile(String filename, String data) {
   BufferedWriter writer = null;
   try {
     writer = new BufferedWriter(new FileWriter(filename));
     writer.write(data);
     writer.close();
   } catch (Exception e) {
     e.printStackTrace();
     if (writer != null)
       try {
         writer.close();
       } catch (Exception ee) {
       }
     return false;
   }
   return true;
 }