List of usage examples for org.apache.commons.beanutils BeanUtilsBean BeanUtilsBean
BeanUtilsBean
From source file:com.linkedin.databus.core.util.ConfigLoader.java
public ConfigLoader(String propPrefix, ConfigBuilder<D> dynConfigBuilder) throws InvalidConfigException { super(true);//from w w w . j av a 2s. co m _propPrefix = propPrefix; _configBuilder = dynConfigBuilder; _beanUtilsBean = new BeanUtilsBean(); }
From source file:com.teamsun.framework.util.ConvertUtil.java
public static Object[] convertListToObjctArray(ArrayList src, Object dest) throws ConvertException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException { if (src == null || src.size() < 1) return null; BeanUtilsBean ub = new BeanUtilsBean(); Object[] result = new Object[src.size()]; for (int i = 0; i < src.size(); i++) { Map obj = (Map) src.get(i); Iterator names = obj.keySet().iterator(); while (names.hasNext()) { String name = (String) names.next(); String reName = dealField(name); Object value = obj.get(name); ub.copyProperty(dest, reName, value); }/*w ww . j av a2s. co m*/ Object clone = BeanUtils.cloneBean(dest); result[i] = clone; // } return result; }
From source file:com.linkedin.databus.core.util.TestConfigManager.java
@Test public void testPaddedInt() throws Exception { ConvertUtilsBean convertUtils = new ConvertUtilsBean(); Integer intValue = (Integer) convertUtils.convert("456", int.class); assertEquals("correct int value", 456, intValue.intValue()); BeanUtilsBean beanUtils = new BeanUtilsBean(); PropertyDescriptor propDesc = beanUtils.getPropertyUtils().getPropertyDescriptor(_configBuilder, "intSetting"); assertEquals("correct setting type", int.class, propDesc.getPropertyType()); _configManager.setSetting("com.linkedin.databus2.intSetting", " 123 "); DynamicConfig config = _configManager.getReadOnlyConfig(); assertEquals("correct int value", 123, config.getIntSetting()); }
From source file:com.datatorrent.stram.moduleexperiment.InjectConfigTest.java
@Test public void testBeanUtils() throws Exception { // http://www.cowtowncoder.com/blog/archives/2011/02/entry_440.html BeanUtilsTestBean testBean = new BeanUtilsTestBean(); testBean.url = new URL("http://localhost:12345/context"); ObjectMapper mapper = new ObjectMapper(); Map<String, Object> properties = mapper.convertValue(testBean, Map.class); System.out.println("testBean source: " + properties); BeanUtilsTestBean testBean2 = new BeanUtilsTestBean(); testBean2.string2 = "testBean2"; Assert.assertFalse("contains transientProperty", properties.containsKey("transientProperty")); Assert.assertTrue("contains string2", properties.containsKey("string2")); properties.remove("string2"); // remove null //properties.put("string3", ""); BeanUtilsBean bub = new BeanUtilsBean(); try {/*ww w. ja v a2s .c om*/ bub.getProperty(testBean, "invalidProperty"); Assert.fail("exception expected"); } catch (Exception e) { Assert.assertTrue(e.getMessage().contains("Unknown property 'invalidProperty'")); } bub.setProperty(properties, "mapProperty.someKey", "someValue"); JsonNode sourceTree = mapper.convertValue(testBean2, JsonNode.class); JsonNode updateTree = mapper.convertValue(properties, JsonNode.class); merge(sourceTree, updateTree); // mapper.readerForUpdating(testBean2).readValue(sourceTree); // Assert.assertEquals("preserve existing value", "testBean2", testBean2.string2); // Assert.assertEquals("map property", "someValue", testBean2.mapProperty.get("someKey")); // System.out.println("testBean cloned: " + mapper.convertValue(testBean2, Map.class)); PropertyUtilsBean propertyUtilsBean = BeanUtilsBean.getInstance().getPropertyUtils(); //PropertyDescriptor pd = propertyUtilsBean.getPropertyDescriptor(testBean2, "mapProperty.someKey2"); // set value on non-existing property try { propertyUtilsBean.setProperty(testBean, "nonExistingProperty.someProperty", "ddd"); Assert.fail("should throw exception"); } catch (NoSuchMethodException e) { Assert.assertTrue("" + e, e.getMessage().contains("Unknown property 'nonExistingProperty'")); } // set value on read-only property try { testBean.getMapProperty().put("s", "s1Val"); PropertyDescriptor pd = propertyUtilsBean.getPropertyDescriptor(testBean, "mapProperty"); Class<?> type = propertyUtilsBean.getPropertyType(testBean, "mapProperty.s"); propertyUtilsBean.setProperty(testBean, "mapProperty", Integer.valueOf(1)); Assert.fail("should throw exception"); } catch (Exception e) { Assert.assertTrue("" + e, e.getMessage().contains("Property 'mapProperty' has no setter method")); } // type mismatch try { propertyUtilsBean.setProperty(testBean, "intProp", "s1"); Assert.fail("should throw exception"); } catch (Exception e) { Assert.assertEquals(e.getClass(), IllegalArgumentException.class); } try { propertyUtilsBean.setProperty(testBean, "intProp", "1"); } catch (IllegalArgumentException e) { // BeanUtils does not report invalid properties, but it handles type conversion, which above doesn't Assert.assertEquals("", 0, testBean.getIntProp()); bub.setProperty(testBean, "intProp", "1"); // by default beanutils ignores conversion error Assert.assertEquals("", 1, testBean.getIntProp()); } }
From source file:com.teamsun.framework.util.ConvertUtil.java
/** * ??LIST??LIST VO???//from w ww .j ava 2s. c o m * * @param src * @param dest * @return * @throws ConvertException * @throws IllegalAccessException * @throws InvocationTargetException * @throws InstantiationException * @throws NoSuchMethodException */ public static List convertListToObjctList(ArrayList src, Object dest) { if (src == null || src.size() < 1) return null; BeanUtilsBean ub = new BeanUtilsBean(); List result = new ArrayList(); try { for (int i = 0; i < src.size(); i++) { Map obj = (Map) src.get(i); Iterator names = obj.keySet().iterator(); while (names.hasNext()) { String name = (String) names.next(); String reName = dealField(name); Object value = obj.get(name); ub.copyProperty(dest, reName, value); } Object clone = BeanUtils.cloneBean(dest); result.add(clone); } } catch (Exception e) { throw new ConvertException("convertListToObjctList?", e); } return result; }
From source file:com.jk.util.JKObjectUtil.java
/** * Populate.//from w w w . j a v a 2 s . co m * * @param instance * the instance * @param values * the values */ public static void populate(Object instance, Map<String, Object> values) { try { BeanUtilsBean beanUtilBean = new BeanUtilsBean(); for (String key : values.keySet()) { Object value = values.get(key); beanUtilBean.setProperty(instance, key, value); } } catch (Exception e) { JKExceptionUtil.handle(e); } }
From source file:com.yucheng.cmis.pvp.app.component.PvpAuthorizeComponent.java
/** * ????????/* ww w . ja v a 2 s .c o m*/ * ???? * @param pvpSerno ?? * @throws EMPException * @throws InvocationTargetException * @throws IllegalAccessException * @throws Exception */ public String addPvpLoanAuthorize(String pvpSerno) throws EMPException, IllegalAccessException, InvocationTargetException { Context context = this.getContext(); Connection connn = this.getConnection(); String strReturnMessage = CMISMessage.ADDDEFEAT; PvpLoanAppAgent pvpLoanAppAgent = (PvpLoanAppAgent) this.getAgentInstance(PUBConstant.PVPLOANAPP); PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE); AccAgent accAgent = (AccAgent) this.getAgentInstance(PUBConstant.ACC); ComponentHelper cHelper = new ComponentHelper(); PvpLoanApp pvpLoanApp = new PvpLoanApp(); PvpAuthorize pvpAuthorize = new PvpAuthorize(); String billNo = ""; //????? pvpLoanApp = pvpLoanAppAgent.queryPvpLoanApp(pvpSerno); if (pvpLoanApp == null || pvpLoanApp.getContNo() == null) { return strReturnMessage; } //?? CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE); CusBase cusBase = customIface.getCusBase(pvpLoanApp.getCusId()); //? String transCusId = cusBase.getTransCusId(); //? String certType = cusBase.getCertType(); //??? String certCode = cusBase.getCertCode(); //?? String cusName = cusBase.getCusName(); //??????? ICtrCont iCtrCont = (ICtrCont) this.getComponentInterface(PUBConstant.CTRCONTIMPL); CtrLoanCont ctrLoanCont = new CtrLoanCont(); ctrLoanCont = iCtrCont.getLoanContInfo(pvpLoanApp.getContNo()); /*//??? //?++6?? //?????????? String sequence = "" ; sequence = accAgent.getSequence(pvpLoanApp.getContNo(), cHelper.modId2tabName(PUBConstant.ACCLOAN)) ; for(int i = sequence.length(); i < 3; i++){ sequence = "0" + sequence; } billNo = pvpLoanApp.getContNo()+sequence; */ // ??? CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService"); String orgId = pvpLoanApp.getInputBrId(); billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context); String loanNo = sequenceService.getSequence("CZ", "fromDate", 14, context); //String deductType = pvpLoanApp.getDeductType() ; //? String deductType = ""; String term = "";//? String[] start = pvpLoanApp.getLoanStartDate().split("-"); String[] end = pvpLoanApp.getLoanEndDate().split("-"); term = ((Integer.parseInt(end[0]) - Integer.parseInt(start[0])) * 12 + (Integer.parseInt(end[1]) - Integer.parseInt(start[1])) + (Integer.parseInt(end[2]) > Integer.parseInt(start[2]) ? 1 : 0)) + ""; // String termDays = Integer .toString(TimeUtil.getBetweenDays(pvpLoanApp.getLoanStartDate(), pvpLoanApp.getLoanEndDate())); pvpAuthorize.setSerno(pvpSerno); pvpAuthorize.setLoanNo(loanNo); pvpAuthorize.setCusManager(pvpLoanApp.getCusManager()); pvpAuthorize.setInputBrId(pvpLoanApp.getInputBrId()); pvpAuthorize.setFinaBrId(pvpLoanApp.getFinaBrId()); pvpAuthorize.setCusId(pvpLoanApp.getCusId()); pvpAuthorize.setCusName(pvpLoanApp.getCusName()); pvpAuthorize.setContNo(pvpLoanApp.getContNo()); pvpAuthorize.setBillNo(billNo); pvpAuthorize.setTradeAmount(pvpLoanApp.getLoanAmount()); pvpAuthorize.setTradeDate(this.getOpenDay()); pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ); //???? pvpAuthorize.setTradeCode(TradeCodeConstant.DKCZ); pvpAuthorize.setFieldNum(34); pvpAuthorize.setFldvalue01("c@CZBH@" + loanNo); //?? pvpAuthorize.setFldvalue02("c@FKZXBZ@" + "1"); //? 1 ?: 1 2 ? pvpAuthorize.setFldvalue03("c@FFLX@" + pvpLoanApp.getLoanForm()); //?1 2 pvpAuthorize.setFldvalue04("c@GSBZ@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //? 1/2? boolean isComLoanEntr = "IqpComLoanEntr".equals(pvpLoanApp.getAppForm()); if (isComLoanEntr) { pvpAuthorize.setFldvalue05("c@DKLB@" + "02"); //01 02 } else { pvpAuthorize.setFldvalue05("c@DKLB@" + "01"); //01 02 } pvpAuthorize.setFldvalue06("c@DKPZ@" + "206020"); //?? pvpAuthorize.setFldvalue07("c@HTBH@" + "HT2984662837498"); //??? pvpAuthorize.setFldvalue08("c@JJBH@" + "JJ2384092333923"); //?? pvpAuthorize.setFldvalue09("c@BZ@" + optTranse("curType" + pvpLoanApp.getCurType())); //?? pvpAuthorize.setFldvalue10("c@HTJE@" + pvpLoanApp.getConAmount()); //??? pvpAuthorize.setFldvalue11("c@DKKM@" + "12580100"); // pvpAuthorize.setFldvalue12("c@KHH@" + transCusId); //? pvpAuthorize.setFldvalue13("c@ZJLX@" + "5");//optTranse("certType"+certType)); //? pvpAuthorize.setFldvalue14("c@ZJHM@" + "610278333");//certCode); //??? pvpAuthorize.setFldvalue15("c@HM@" + cusName); //?? pvpAuthorize.setFldvalue16("c@ZCZH@" + pvpLoanApp.getEnterAccount()); //??"81011101302100430" // pvpAuthorize.setFldvalue17("c@ZCZHLX@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //?? pvpAuthorize.setFldvalue18("c@HBZH@" + pvpLoanApp.getRepaymentAccount());//?? pvpAuthorize.setFldvalue19("c@HBZHLX@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //?? //pvpAuthorize.setFldvalue20("c@HXZH@" + pvpLoanApp.getRepayIntAccount());//??? pvpAuthorize.setFldvalue21("c@HXZHLX@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //??? pvpAuthorize.setFldvalue22("c@WTCKZH@" + "81011101302100430");//?? pvpAuthorize.setFldvalue23("c@WTCKZHLX@" + optTranse("prdType" + pvpLoanApp.getPrdType())); //?? pvpAuthorize.setFldvalue24("c@ZCLL@" + getCoreTradeRate(pvpLoanApp.getRealityIrY())); // //*1.2*100 pvpAuthorize.setFldvalue25("c@DKQX@" + term); //? pvpAuthorize.setFldvalue26("c@DKTS@" + termDays); // //pvpAuthorize.setFldvalue27("c@JXZQ@" + pvpLoanApp.getInterestType()); //? ?? //pvpAuthorize.setFldvalue28("c@JXFS@" + pvpLoanApp.getInterestCalType()); //?? ? //pvpAuthorize.setFldvalue29("c@HKFS@" + pvpLoanApp.getDeductType()); //? //? pvpAuthorize.setFldvalue30("c@DKFFRQ@" + "20090814");//pvpLoanApp.getLoanStartDate().replace("-", "")); //? pvpAuthorize.setFldvalue31("c@DKDQRQ@" + pvpLoanApp.getLoanEndDate().replace("-", "")); // pvpAuthorize.setFldvalue32("c@KHZDHKRQ@" + pvpLoanApp.getRepaymentDate()); // pvpAuthorize.setFldvalue33("c@DBFS@" + "03010101"); //?? pvpAuthorize.setFldvalue34("c@KHJL@" + "100112");// pvpLoanApp.getCusManager()); //?? //??? strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize); //?? AccBillDetails accBillDetails = new AccBillDetails(); accBillDetails.setSerno(pvpSerno); //accBillDetails.setSernoCore("") ; //accBillDetails.setTellerNo("") ; //accBillDetails.setContNo(pvpLoanApp.getContNo()) ; accBillDetails.setBillNo(billNo); //accBillDetails.setLoanAccount("") ; accBillDetails.setCusId(pvpLoanApp.getCusId()); accBillDetails.setCusName(pvpLoanApp.getCusName()); //accBillDetails.setDetailType("02") ; accBillDetails.setReturnType(""); accBillDetails.setCurType(pvpLoanApp.getCurType()); accBillDetails.setTradeAmount(pvpLoanApp.getLoanAmount()); accBillDetails.setTradeDate(this.getOpenDay()); accBillDetails.setTradeType("1"); accBillDetails.setTradeBrief(""); //? strReturnMessage = accAgent.insertAccBillDetails(accBillDetails); if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) { return strReturnMessage; } //???? //???? AccLoan accLoan = new AccLoan(); BeanUtilsBean beanUtil = new BeanUtilsBean(); beanUtil.copyProperties(accLoan, pvpLoanApp); /* accLoan.setCusId(pvpLoanApp.getCusId()) ; accLoan.setCusName(pvpLoanApp.getCusName()) ; accLoan.setContNo(pvpLoanApp.getContNo()) ; accLoan.setPrdPk(pvpLoanApp.getPrdPk()) ; accLoan.setPrdName(pvpLoanApp.getPrdName()) ; accLoan.setPrdType(pvpLoanApp.getPrdType()) ; accLoan.setAccountClass(pvpLoanApp.getAccountClass()) ; accLoan.setLoanForm(pvpLoanApp.getLoanForm()) ; accLoan.setLoanNature(pvpLoanApp.getLoanNature()) ; accLoan.setLoanTypeExt(pvpLoanApp.getLoanTypeExt()) ; accLoan.setBizType(pvpLoanApp.getBizType()) ; accLoan.setBizTypeSub(pvpLoanApp.getBizTypeSub()) ; accLoan.setBizTypeDetail(pvpLoanApp.getBizTypeDetail()) ; accLoan.setAssureMeansMain(pvpLoanApp.getAssureMeansMain()) ; accLoan.setAssureMeans2(pvpLoanApp.getAssureMeans2()) ; accLoan.setAssureMeans3(pvpLoanApp.getAssureMeans3()) ; accLoan.setLimitInd(pvpLoanApp.getLimitInd()) ; accLoan.setMortgageFlg(pvpLoanApp.getMortgageFlg()) ; accLoan.setRepaymentMode(pvpLoanApp.getRepaymentMode()) ; accLoan.setCurType(pvpLoanApp.getCurType()) ; accLoan.setLoanAmount(pvpLoanApp.getLoanAmount()) ; accLoan.setLoanStartDate(pvpLoanApp.getLoanStartDate()) ; accLoan.setLoanEndDate(pvpLoanApp.getLoanEndDate()) ; accLoan.setLoanDirection(pvpLoanApp.getLoanDirection()) ; accLoan.setRulingIr(pvpLoanApp.getRulingIr()) ; accLoan.setFloatingRate(pvpLoanApp.getFloatingRate()) ; accLoan.setRealityIrY(pvpLoanApp.getRealityIrY()) ; accLoan.setOverdueRate(pvpLoanApp.getOverdueRate()) ; accLoan.setOverdueIr(pvpLoanApp.getOverdueIr()) ; accLoan.setDefaultRate(pvpLoanApp.getDefaultRate()) ; accLoan.setDefaultIr(pvpLoanApp.getDefaultIr()) ; accLoan.setCiRate(pvpLoanApp.getCiRate()) ; accLoan.setCiIr(pvpLoanApp.getCiIr()) ; accLoan.setCusManager(pvpLoanApp.getCusManager()) ; accLoan.setInputBrId(pvpLoanApp.getInputBrId()) ; accLoan.setFinaBrId(pvpLoanApp.getFinaBrId()) ; accLoan.setMainBrId(pvpLoanApp.getMainBrId()) ; */ accLoan.setBillNo(billNo); accLoan.setLoanAccount(pvpLoanApp.getEnterAccount());//? accLoan.setLoanBalance(pvpLoanApp.getLoanAmount()); accLoan.setTermType(calTermType(pvpLoanApp.getLoanStartDate(), pvpLoanApp.getLoanEndDate())); accLoan.setCla(ctrLoanCont.getClaResult()); accLoan.setAccountStatus(TradeCodeConstant.TZZT_ZC); accLoan.setRealityIrM(ctrLoanCont.getRealityIrM()); accLoan.setSugRulingIr(ctrLoanCont.getSugRulingIr()); accLoan.setDefaultFlag("2"); accLoan.setLoanForm4("10"); accLoan.setReceIntCumu(0.0); accLoan.setActualIntCumu(0.0); accLoan.setDelayIntCumu(0.0); accLoan.setInnerIntCumu(0.0); accLoan.setOffIntCumu(0.0); accLoan.setRevolvingTimes(0); accLoan.setFirstDisbDate(this.getOpenDay()); accLoan.setExtensionTimes(0); accLoan.setOrigExpiDate(""); accLoan.setCapOverdueDate(""); accLoan.setIntOverdueDate(""); accLoan.setOverTimesCurrent(0); accLoan.setOverTimesTotal(0); accLoan.setMaxTimesTotal(0); accLoan.setClaDate(this.getOpenDay()); accLoan.setClaDatePre(""); accLoan.setClaPre(""); accLoan.setBadLoanFlag("2"); accLoan.setSettlDate(""); accLoan.setLatestDate(this.getOpenDay()); accLoan.setInnerReceInt(0.0); accLoan.setOverdueReceInt(0.0); accLoan.setOffReceInt(0.0); accLoan.setCompoundReceInt(0.0); accLoan.setInnerOffReceInt(0.0); accLoan.setInnerActlInt(0.0); accLoan.setOverdueActlInt(0.0); accLoan.setOffActlInt(0.0); accLoan.setCompoundActlInt(0.0); accLoan.setInnerOffActlInt(0.0); accLoan.setNormalBalance(pvpLoanApp.getLoanAmount()); //??? strReturnMessage = accAgent.insertAccLoan(accLoan); if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) { return strReturnMessage; } //??????? pvpLoanApp.setBillNo(billNo); pvpLoanApp.setChargeoffStatus(Constant.PVPSTATUS2); pvpLoanAppAgent.updatePvpLoanApp(pvpLoanApp); if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) { return strReturnMessage; } Connection connection = this.getConnection(); CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService(); /**????*/ System.err.println("????"); try { //cbqService.queryAccreditNotice4Trade(loanNo,connection,connection,context); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); throw new ComponentException(e.getMessage()); } return strReturnMessage; }
From source file:gov.osti.services.Metadata.java
/** * Remove non-indexable New/Previous RI from metadata. * * @param em the EntityManager to control commits. * @param md the Metadata to evaluate.//w w w .ja v a 2 s. co m * @return Updated DOECodeMetadata object. */ private static DOECodeMetadata removeNonIndexableRi(EntityManager em, DOECodeMetadata md) throws IOException { // need a detached copy of the RI data DOECodeMetadata alteredMd = new DOECodeMetadata(); BeanUtilsBean bean = new BeanUtilsBean(); try { bean.copyProperties(alteredMd, md); } catch (IllegalAccessException | InvocationTargetException ex) { // log issue, swallow error String msg = "NonIndexable RI Removal Bean Error: " + ex.getMessage(); throw new IOException(msg); } TypedQuery<MetadataSnapshot> querySnapshot = em .createNamedQuery("MetadataSnapshot.findByDoiAndStatus", MetadataSnapshot.class) .setParameter("status", DOECodeMetadata.Status.Approved); // get detached list of RI to check List<RelatedIdentifier> riList = new ArrayList<>(); riList.addAll(alteredMd.getRelatedIdentifiers()); // filter to targeted RI List<RelatedIdentifier> filteredRiList = riList.stream() .filter(p -> p.getIdentifierType() == RelatedIdentifier.Type.DOI && (p.getRelationType() == RelatedIdentifier.RelationType.IsNewVersionOf || p.getRelationType() == RelatedIdentifier.RelationType.IsPreviousVersionOf)) .collect(Collectors.toList()); // track removals List<RelatedIdentifier> removalList = new ArrayList<>(); for (RelatedIdentifier ri : filteredRiList) { // lookup by Snapshot by current DOI querySnapshot.setParameter("doi", ri.getIdentifierValue()); List<MetadataSnapshot> results = querySnapshot.getResultList(); // if no results, keep, otherwise remove unless there is a minted version found boolean remove = !results.isEmpty(); for (MetadataSnapshot ms : results) { if (ms.getDoiIsMinted()) { remove = false; break; } } if (remove) removalList.add(ri); } // perform removals, as needed, and update if (!removalList.isEmpty()) { riList.removeAll(removalList); alteredMd.setRelatedIdentifiers(riList); } return alteredMd; }
From source file:com.yucheng.cmis.pvp.app.component.PvpAuthorizeComponent.java
/** * ???????? ????//w w w .j a v a 2s . c om * * @param pvpSerno * ?? * @throws EMPException * @throws InvocationTargetException * @throws IllegalAccessException * @throws Exception * @author modified by zhangwei */ public String addPvpTfObcAuthorize(String pvpSerno) throws EMPException, IllegalAccessException, InvocationTargetException { String strReturnMessage = CMISMessage.ADDDEFEAT;// ?? PvpTfObcComponent pvpTfObcComponent = (PvpTfObcComponent) this.getComponent("PvpTfObc"); PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE); AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM); PvpTfObc pvpTfObc = new PvpTfObc(); // ????? pvpTfObc = pvpTfObcComponent.queryPvpTfObc(pvpSerno); if (pvpTfObc == null || pvpTfObc.getContNo() == null) { System.out.println("??????"); return strReturnMessage; } // ?? //CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE); //CusBase cusBase = customIface.getCusBase(pvpTfObc.getCusId()); // ? //String transCusId = cusBase.getTransCusId(); //???? CtrTfObc ctrTfObc = null; CtrTfObcComponent ctrTfObcComponent = (CtrTfObcComponent) this.getComponent("CtrTfObc"); ctrTfObc = ctrTfObcComponent.queryCtrTfObc(pvpTfObc.getContNo()); //? accTfCommComponent.checkConditionBeforeAuthorize("PvpTfObc", pvpSerno, ctrTfObc.getContNo()); // ????? Context context = this.getContext(); Connection connection = this.getConnection(); CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService"); String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection); //??? String[] billZero = { "", "00", "0", "" }; int billSeqCtr = ctrTfObc.getBillSeq(); String billSeq = String.valueOf(billSeqCtr); billSeq = billZero[billSeq.length()] + billSeq; String billNo = pvpTfObc.getContNo() + billSeq; // ??? ?????? billSeqCtr++; ctrTfObc.setBillSeq(billSeqCtr); //???? PvpAuthorize pvpAuthorize = new PvpAuthorize(); pvpAuthorize.setTradeCode("0016"); // ? pvpAuthorize.setLoanNo(loanNo); // ?? pvpAuthorize.setContNo(billNo); // ??? pvpAuthorize.setContNo(pvpTfObc.getContNo()); // ??? pvpAuthorize.setCusId(pvpTfObc.getCusId()); // ? pvpAuthorize.setCusName(pvpTfObc.getCusName()); // ?? pvpAuthorize.setSerno(pvpSerno); // ?? pvpAuthorize.setCusManager(pvpTfObc.getCusManager()); // ? pvpAuthorize.setInputBrId(pvpTfObc.getInputBrId()); // ? pvpAuthorize.setFinaBrId(pvpTfObc.getFinaBrId()); // ? pvpAuthorize.setBillNo(billNo); // ?? if ("1".equals(pvpTfObc.getBizTypeSub())) {//1: 2: pvpAuthorize.setTradeAmount(pvpTfObc.getApplyAmount()); // ? } else { pvpAuthorize.setTradeAmount(pvpTfObc.getLocAmt()); // ? } pvpAuthorize.setTradeDate(this.getOpenDay()); // pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ); // ? pvpAuthorize.setFieldNum(18); // ? // pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //? pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //???? pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfObc.getContNo()); //??? pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfObc.getCusId()); //? pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfObc.getCusName()); //?? pvpAuthorize.setFldvalue06("c@bizType@" + "0016"); //?? pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfObc.getLocCurType()); //??? if ("1".equals(pvpTfObc.getBizTypeSub())) {//1: 2: pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfObc.getApplyAmount()); // ? } else { pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfObc.getLocAmt()); // ? } //? pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?) pvpAuthorize.setFldvalue10("c@dueDate@" + pvpTfObc.getDueDate()); //?? pvpAuthorize.setFldvalue11("c@note@" + ""); // //pvpAuthorize.setFldvalue12("c@applyOrg@" + (String)context.getDataValue("S_organno")); // pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfObc.getFinaBrId()); // pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); // //? pvpAuthorize.setFldvalue14("c@bpNo@" + pvpTfObc.getBpNo()); //? //pvpAuthorize.setFldvalue15("c@applyAmount@" + pvpTfObc.getApplyAmount()); //? DecimalFormat df = new DecimalFormat("#.000000"); pvpAuthorize.setFldvalue15("c@realityIrY@" + df.format(pvpTfObc.getRealityIrY() * 100)); // //pvpAuthorize.setFldvalue16("c@feeRate@" + df.format(pvpTfObc.getFeeRate()*100)); // String bizTypeSub = ""; if (pvpTfObc.getBizTypeSub().equals("1")) {// bizTypeSub = "0"; } else if (pvpTfObc.getBizTypeSub().equals("2")) {// bizTypeSub = "1"; } else { throw new ComponentException("[" + bizTypeSub + "]"); } pvpAuthorize.setFldvalue16("c@bizTypeSub@" + bizTypeSub); //? pvpAuthorize.setFldvalue17("c@entAccNo@" + pvpTfObc.getEntAccNo()); //?? pvpAuthorize.setFldvalue18("c@intCalType@" + pvpTfObc.getIntCalType()); //?? //?????,???, modified by wxy 20110108 int appterm = 0; String dueDate; if (!this.getOpenDay().equals(pvpTfObc.getStartDate())) { System.out.println("------------openday----" + this.getOpenDay()); appterm = (int) pvpTfObc.getApplyTerm(); dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm); pvpTfObc.setStartDate(this.getOpenDay()); pvpTfObc.setDueDate(dueDate); ctrTfObc.setStartDate(this.getOpenDay()); ctrTfObc.setDueDate(dueDate); pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate); } // ??? strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize); if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) { System.out.println("?/??"); return strReturnMessage; } // ???? AccTfObc accTfObc = new AccTfObc(); AccTfObcAgent accTfObcAgent = (AccTfObcAgent) this.getAgentInstance("AccTfObc"); BeanUtilsBean bub = new BeanUtilsBean(); System.err.println("pvpTfObc acpt_amt==" + pvpTfObc.getAcptAmt()); try { bub.copyProperties(accTfObc, pvpTfObc); } catch (IllegalAccessException e) { new ComponentException("???"); } catch (InvocationTargetException e) { new ComponentException("???"); } accTfObc.setLoanForm4("10"); accTfObc.setCla("10"); accTfObc.setBillNo(billNo); accTfObc.setAccountStatus("0"); accTfObc.setMainBrId(pvpTfObc.getInvestigatorBrId()); accTfObc.setLoanAmount(pvpTfObc.getApplyAmount()); accTfObc.setLoanBalance(pvpTfObc.getApplyAmount()); System.err.println("pvpTfObc acpt_amt==" + accTfObc.getAcptAmt()); accTfObcAgent.insertAccTfObc(accTfObc); // ?? AccTfComm accTfComm = new AccTfComm(); try { bub.copyProperties(accTfComm, accTfObc); } catch (IllegalAccessException e) { new ComponentException("????"); } catch (InvocationTargetException e) { new ComponentException("????"); } accTfComm.setLimitAccNo(accTfObc.getLimitAccNo()); accTfComm.setSendDate(this.getOpenDay()); try { accTfCommComponent.addAccTfComm(accTfComm); } catch (Exception e) { accTfCommComponent.updateDomain(accTfComm); } // ? pvpTfObc.setChargeoffStatus(Constant.PVPSTATUS3); pvpTfObc.setBillNo(billNo); pvpTfObcComponent.updatePvpTfObc(pvpTfObc); //????? ctrTfObcComponent.modifyCtrTfObc(ctrTfObc); /** ???? */ System.err.println("????"); try { /*? CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService(); IndexedCollection icoll = cbqService.queryAccreditNotice4Trade( loanNo, connection, connection, context); KeyedCollection reqPkg = (KeyedCollection) icoll.get(0); String hostSerNo = (String) reqPkg.get("hostSerNo").toString().trim(); pvpAuthorize.setHostSerno(hostSerNo); pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ); pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize"); */ //??? CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService(); cbqService.queryAccreditNotice(connection, context); } catch (Exception e) { e.printStackTrace(); throw new ComponentException("?" + e.getMessage()); } // ??? return strReturnMessage; }
From source file:com.yucheng.cmis.pvp.app.component.PvpAuthorizeComponent.java
/** * ????????????????//from w w w. j av a 2s . co m * * @param pvpSerno * ?? * @throws EMPException * @throws InvocationTargetException * @throws IllegalAccessException * @throws Exception * @since 2009-09-17 * @author modified by zhangwei */ public String addPvpTfOinsfAuthorize(String pvpSerno) throws EMPException, IllegalAccessException, InvocationTargetException { String strReturnMessage = CMISMessage.ADDDEFEAT;//?? //?? PvpTfOinsf pvpTfOinsf = new PvpTfOinsf(); PvpTfIface pvpTfIface = (PvpTfImpl) this.getComponentInterface("PvpTfImpl"); pvpTfOinsf = pvpTfIface.queryPvpTfOinsfBySerNo(pvpSerno); if (pvpTfOinsf == null || pvpTfOinsf.getContNo() == null) { System.out.println("?????"); return strReturnMessage; } //?? CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE); AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM); CusBase cusBase = customIface.getCusBase(pvpTfOinsf.getCusId()); String transCusId = cusBase.getTransCusId(); //???? CtrTfOinsf ctrTfOinsf = new CtrTfOinsf(); CtrTfLocImpl ctrTfLocImpl = (CtrTfLocImpl) this.getComponentInterface("CtrTfLoc"); ctrTfOinsf = ctrTfLocImpl.getCtrTfOinsf(pvpTfOinsf.getContNo()); if (ctrTfOinsf == null) { System.out.println("????????"); return strReturnMessage; } //???? accTfCommComponent.checkConditionBeforeAuthorize("PvpTfOinsf", pvpSerno, ctrTfOinsf.getContNo()); //?? ?? Context context = this.getContext(); Connection connection = this.getConnection(); CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService"); String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection); //??? String[] billZero = { "", "00", "0", "" }; int billSeqCtr = ctrTfOinsf.getBillSeq(); String billSeq = String.valueOf(billSeqCtr); billSeq = billZero[billSeq.length()] + billSeq; String billNo = pvpTfOinsf.getContNo() + billSeq; // ??? ?????? billSeqCtr++; ctrTfOinsf.setBillSeq(billSeqCtr); //??? // ********************/ PvpAuthorize pvpAuthorize = new PvpAuthorize(); pvpAuthorize.setSerno(pvpSerno); //?? pvpAuthorize.setLoanNo(loanNo); //? pvpAuthorize.setCusManager(pvpTfOinsf.getCusManager()); //?? pvpAuthorize.setInputBrId(pvpTfOinsf.getInputBrId()); pvpAuthorize.setFinaBrId(pvpTfOinsf.getFinaBrId()); pvpAuthorize.setCusId(pvpTfOinsf.getCusId()); pvpAuthorize.setCusName(pvpTfOinsf.getCusName()); pvpAuthorize.setContNo(pvpTfOinsf.getContNo()); pvpAuthorize.setBillNo(billNo); //?? pvpAuthorize.setTradeAmount(pvpTfOinsf.getApplyAmount()); pvpAuthorize.setTradeDate(this.getOpenDay()); pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ); pvpAuthorize.setTradeCode("0018"); pvpAuthorize.setFieldNum(27); // pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //? pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //???? pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfOinsf.getContNo()); //??? pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfOinsf.getCusId()); //? pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfOinsf.getCusName()); //?? pvpAuthorize.setFldvalue06("c@bizType@" + "0018"); //?? pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfOinsf.getApplyCurType()); //??? pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfOinsf.getApplyAmount()); //? pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?) pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfOinsf.getDueDate())); //?? pvpAuthorize.setFldvalue11("c@note@" + "???"); // pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfOinsf.getFinaBrId()); // pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); // //? pvpAuthorize.setFldvalue14("c@oinsfNo@" + pvpTfOinsf.getOinsfNo()); pvpAuthorize.setFldvalue15("c@buyerId@" + pvpTfOinsf.getBuyerId()); pvpAuthorize.setFldvalue16("c@usedCrdRate@" + pvpTfOinsf.getUsedCrdRate()); pvpAuthorize.setFldvalue17( "c@avaCrdRate@" + String.valueOf(pvpTfOinsf.getAvaCrdRate() - pvpTfOinsf.getUsedCrdRate())); DecimalFormat df = new DecimalFormat("#.000000"); pvpAuthorize.setFldvalue18("c@realityIrY@" + df.format(pvpTfOinsf.getRealityIrY() * 100)); String sub = ""; if ("1".equals(pvpTfOinsf.getBizTypeSub())) { sub = "0"; } else if ("2".equals(pvpTfOinsf.getBizTypeSub())) { sub = "2"; } else if ("3".equals(pvpTfOinsf.getBizTypeSub())) { sub = "1"; } pvpAuthorize.setFldvalue19("c@bizTypeSub@" + sub); pvpAuthorize.setFldvalue20("c@enterAccount@" + pvpTfOinsf.getEnterAccount()); pvpAuthorize.setFldvalue21("c@ciNo@" + pvpTfOinsf.getCiNo()); pvpAuthorize.setFldvalue22("c@intCalType@" + pvpTfOinsf.getIntCalType()); String decNo = ""; if (pvpTfOinsf.getDecNo() != null) { decNo = pvpTfOinsf.getDecNo(); } String nvoiceNo = ""; if (pvpTfOinsf.getNvoiceNo() != null) { nvoiceNo = pvpTfOinsf.getNvoiceNo(); } pvpAuthorize.setFldvalue23("c@decNo@" + decNo); pvpAuthorize.setFldvalue24("c@nvoiceNo@" + nvoiceNo); pvpAuthorize.setFldvalue25("c@nvoiceCurType@" + pvpTfOinsf.getApplyCurType()); pvpAuthorize.setFldvalue26("c@nvoiceAmt@" + pvpTfOinsf.getNvoiceAmt()); pvpAuthorize.setFldvalue27("c@payTransferNo@" + pvpTfOinsf.getPayTransferContNo()); //pvpAuthorize.setFldvalue03("c@putoutSerialno@" + checkNull(loanNo)); //?????,? modified by wxy 20110108 int appterm = 0; String dueDate; if (!this.getOpenDay().equals(pvpTfOinsf.getStartDate())) { appterm = (int) pvpTfOinsf.getApplyTerm(); dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm); pvpTfOinsf.setStartDate(this.getOpenDay()); pvpTfOinsf.setDueDate(dueDate); //pvpTfIface.updatePvpTfOinsf(pvpTfOinsf); ctrTfOinsf.setStartDate(this.getOpenDay()); ctrTfOinsf.setDueDate(dueDate); pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate); } //?? PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE); strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize); if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) { System.out.println("?????"); return strReturnMessage; } //????? AccTfOinsf accTfOinsf = new AccTfOinsf(); AccTfOinsfAgent accTfOinsfAgent = (AccTfOinsfAgent) this.getAgentInstance(PUBConstant.ACCTFOINSF); BeanUtilsBean bub = new BeanUtilsBean(); try { bub.copyProperties(accTfOinsf, pvpTfOinsf); } catch (IllegalAccessException e) { new ComponentException("??????"); } catch (InvocationTargetException e) { new ComponentException("??????"); } accTfOinsf.setLoanForm4("10"); accTfOinsf.setCla("10"); accTfOinsf.setBillNo(billNo); accTfOinsf.setAccountStatus("0"); accTfOinsf.setMainBrId(pvpTfOinsf.getInvestigatorBrId()); accTfOinsf.setLoanAmount(pvpTfOinsf.getApplyAmount()); accTfOinsf.setLoanBalance(pvpTfOinsf.getApplyAmount()); accTfOinsfAgent.insertAccTfOinsf(accTfOinsf); //??? AccTfComm accTfComm = new AccTfComm(); try { bub.copyProperties(accTfComm, accTfOinsf); } catch (IllegalAccessException e) { new ComponentException("?????"); } catch (InvocationTargetException e) { new ComponentException("?????"); } accTfComm.setLimitAccNo(accTfOinsf.getLimitAccNo()); //??? accTfComm.setSendDate(this.getOpenDay()); try { accTfCommComponent.addAccTfComm(accTfComm); } catch (Exception e) { accTfCommComponent.updateDomain(accTfComm); } //?? pvpTfOinsf.setChargeoffStatus(Constant.PVPSTATUS3); pvpTfIface.updatePvpTfOinsf(pvpTfOinsf); //????? ctrTfLocImpl.modifyCtrTfOinsf(ctrTfOinsf); // try { /* CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService(); IndexedCollection icoll = cbqService.queryAccreditNotice4Trade( loanNo, connection, connection, context); KeyedCollection reqPkg = (KeyedCollection) icoll.get(0); String hostSerNo = (String) reqPkg.get("hostSerNo").toString().trim(); pvpAuthorize.setHostSerno(hostSerNo); pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ); pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize"); */ //??? CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService(); cbqService.queryAccreditNotice(connection, context); } catch (Exception e) { e.printStackTrace(); throw new ComponentException("??" + e.getMessage()); } //???? return strReturnMessage; }