List of usage examples for org.hibernate Session saveOrUpdate
void saveOrUpdate(Object object);
From source file:com.hyron.poscafe.dao.PaymentDaoImpl.java
License:Open Source License
@Override public void saveOrUpdate(Payment entity, Session session) throws HibernateException { log.debug("saving or updating Payment instance"); try {/*from w ww . j a v a 2 s.c om*/ session.saveOrUpdate(entity); log.debug("save or update successful"); } catch (RuntimeException re) { log.error("save or update failed", re); throw re; } }
From source file:com.hyron.poscafe.dao.PayTypeParamDaoImpl.java
License:Open Source License
@Override public void saveOrUpdate(PayTypeParam entity, Session session) throws HibernateException { log.debug("saving or updating PayTypeParam instance"); try {// www. j a v a 2 s . co m session.saveOrUpdate(entity); log.debug("save or update successful"); } catch (RuntimeException re) { log.error("save or update failed", re); throw re; } }
From source file:com.hyron.poscafe.dao.PosParamDaoImpl.java
License:Open Source License
@Override public void saveOrUpdate(PosParam entity, Session session) throws HibernateException { log.debug("saving or updating PosParam instance"); try {//from w w w . j a v a 2 s . c o m session.saveOrUpdate(entity); log.debug("save or update successful"); } catch (RuntimeException re) { log.error("save or update failed", re); throw re; } }
From source file:com.hyron.poscafe.dao.SaleItemDaoImpl.java
License:Open Source License
@Override public void saveOrUpdate(SaleItem entity, Session session) throws HibernateException { log.debug("saving or updating SaleItem instance"); try {// w w w.j av a 2 s. co m session.saveOrUpdate(entity); log.debug("save or update successful"); } catch (RuntimeException re) { log.error("save or update failed", re); throw re; } }
From source file:com.hyron.poscafe.dao.SaleItemDiscDaoImpl.java
License:Open Source License
@Override public void saveOrUpdate(SaleItemDisc entity, Session session) throws HibernateException { log.debug("saving or updating SellItemDisc instance"); try {//from w w w .j a v a 2s . c o m session.saveOrUpdate(entity); log.debug("save or update successful"); } catch (RuntimeException re) { log.error("save or update failed", re); throw re; } }
From source file:com.hyron.poscafe.dao.TransDaoImpl.java
License:Open Source License
@Override public void saveOrUpdate(Trans entity, Session session) throws HibernateException { log.debug("saving or updating Trans instance"); try {//from w ww . jav a 2 s . co m session.saveOrUpdate(entity); log.debug("save or update successful"); } catch (RuntimeException re) { log.error("save or update failed", re); throw re; } }
From source file:com.ibm.tap.misld.delegate.customerSettings.MisldAccountSettingsWriteDelegate.java
/** * @param misldAccountSettings/*from w w w .j a v a 2s. com*/ * @param customer * @param remoteUser * @return * @throws NamingException * @throws HibernateException */ public static void saveMisldAccountSettings(MisldAccountSettings misldAccountSettings, Customer customer, String remoteUser) throws HibernateException, NamingException { boolean select = false; boolean enterprise = false; Session session = getHibernateSession(); Transaction tx = session.beginTransaction(); clearForms(customer); if (customer.getMisldAccountSettings() != null) { misldAccountSettings .setMisldAccountSettingsId(customer.getMisldAccountSettings().getMisldAccountSettingsId()); } if (misldAccountSettings.getMicrosoftSoftwareOwner().equals("IBM")) { misldAccountSettings = computeLicenseAgreement(misldAccountSettings, customer, session, remoteUser); } else { for (int i = 0; i < misldAccountSettings.getCustomerAgreementLongs().length; i++) { CustomerAgreementType customerAgreementType = CustomerAgreementTypeReadDelegate .getCustomerAgreementTypeByLong(misldAccountSettings.getCustomerAgreementLongs()[i]); CustomerAgreement customerAgreement = new CustomerAgreement(); customerAgreement.setCustomerAgreementType(customerAgreementType); customerAgreement.setCustomer(customer); customerAgreement.setRecordTime(new Date()); customerAgreement.setRemoteUser(remoteUser); customerAgreement.setStatus(Constants.ACTIVE); session.save(customerAgreement); if (!misldAccountSettings.getMicrosoftSoftwareOwner().equals(Constants.IBM)) { if (customerAgreementType.getCustomerAgreementType().equals(Constants.SELECT)) { ConsentLetterWriteDelegate.addConsentLetter(Constants.SELECT_HOSTING, customer, session, remoteUser); select = true; } if (customerAgreementType.getCustomerAgreementType().equals(Constants.ENTERPRISE)) { ConsentLetterWriteDelegate.addConsentLetter(Constants.ENTERPRISE_HOSTING, customer, session, remoteUser); enterprise = true; } if (customerAgreementType.getCustomerAgreementType().equals(Constants.PRELOAD)) { ConsentLetterWriteDelegate.addConsentLetter(Constants.PRO_FORMA, customer, session, remoteUser); } } } if (!misldAccountSettings.getMicrosoftSoftwareBuyer().equals(Constants.CUSTOMER)) { if (select) { ConsentLetterWriteDelegate.addConsentLetter(Constants.SELECT_OUTSOURCER, customer, session, remoteUser); } if (enterprise) { ConsentLetterWriteDelegate.addConsentLetter(Constants.ENTERPRISE_OUTSOURCER, customer, session, remoteUser); } } if (misldAccountSettings.getMicrosoftSoftwareOwner().equals(Constants.CUSTOMER)) { misldAccountSettings.setLicenseAgreementType(null); } if (misldAccountSettings.getMicrosoftSoftwareOwner().equals(Constants.BOTH)) { misldAccountSettings = computeLicenseAgreement(misldAccountSettings, customer, session, remoteUser); } } misldAccountSettings.setQualifiedDiscount(QualifiedDiscountReadDelegate .getQualifiedDiscountByLong(misldAccountSettings.getQualifiedDiscountLong())); misldAccountSettings .setDefaultLpid(LpidReadDelegate.getLpidByLong(misldAccountSettings.getDefaultLpidLong())); misldAccountSettings.setStatus(Constants.COMPLETE); if ((misldAccountSettings.getPriceReportStatus() == null) || (misldAccountSettings.getPriceReportStatus().trim().equals(""))) { misldAccountSettings.setPriceReportStatus(Constants.REGISTERED); misldAccountSettings.setPriceReportStatusUser(remoteUser); misldAccountSettings.setPriceReportTimestamp(new Date()); } misldAccountSettings.setCustomer(customer); misldAccountSettings.setRemoteUser(remoteUser); misldAccountSettings.setRecordTime(new Date()); session.saveOrUpdate(misldAccountSettings); tx.commit(); session.close(); }
From source file:com.ibm.tap.misld.delegate.customerSettings.MisldAccountSettingsWriteDelegate.java
/** * @param misldAccountSettings//from w ww . j a va 2s . co m * @param customer * @param remoteUser * @throws NamingException * @throws HibernateException */ public static void saveDraftMisldAccountSettings(MisldAccountSettings misldAccountSettings, Customer customer, String remoteUser) throws HibernateException, NamingException { Session session = getHibernateSession(); Transaction tx = session.beginTransaction(); if (customer.getMisldAccountSettings() != null) { misldAccountSettings .setMisldAccountSettingsId(customer.getMisldAccountSettings().getMisldAccountSettingsId()); } misldAccountSettings.setQualifiedDiscount(QualifiedDiscountReadDelegate .getQualifiedDiscountByLong(misldAccountSettings.getQualifiedDiscountLong())); misldAccountSettings .setDefaultLpid(LpidReadDelegate.getLpidByLong(misldAccountSettings.getDefaultLpidLong())); misldAccountSettings.setStatus(Constants.DRAFT); misldAccountSettings.setCustomer(customer); misldAccountSettings.setRemoteUser(remoteUser); misldAccountSettings.setRecordTime(new Date()); session.saveOrUpdate(misldAccountSettings); tx.commit(); session.close(); }
From source file:com.ibm.tap.misld.delegate.microsoftPriceList.MicrosoftPriceListWriteDelegate.java
/** * @param microsoftPriceList/*ww w . j a va2 s. c o m*/ * @throws NamingException * @throws HibernateException */ public static void saveMicrosoftPriceList(MicrosoftPriceList microsoftPriceList) throws HibernateException, NamingException { Session session = getHibernateSession(); Transaction tx = session.beginTransaction(); session.saveOrUpdate(microsoftPriceList); tx.commit(); session.close(); }
From source file:com.ibm.tap.misld.report.PriceReportDelegate.java
/** * @param priceReport/* ww w . ja va 2 s.com*/ * @param customerIdStr * @throws NamingException * @throws HibernateException */ public static void createPriceReportArchive(Customer customer, PriceReport priceReport, String status, String remoteUser) throws HibernateException, NamingException, Exception { String esplaNumber = null; String splaNumber = "5585168"; HashMap lpidHash = new HashMap(); // Customer customer = CustomerReadDelegate // .getCustomerByAccountNumber(priceReport.getAccountNumber() // .longValue()); // MisldAccountSettings misldAccountSettings = customer // .getMisldAccountSettings(); List customerNumbers = LpidReadDelegate.getCustomerLpids(customer); Iterator j = customerNumbers.iterator(); Lpid lpidDefault = new Lpid(); while (j.hasNext()) { Lpid lpid = (Lpid) j.next(); lpidHash.put("" + lpid.getLpidId(), lpid); lpidDefault = lpid; } ConsentType enrollmentFormType = ConsentTypeReadDelegate .getConsentTypeByName(Constants.ESPLA_ENROLLMENT_FORM); ConsentLetter enrollmentForm = ConsentLetterReadDelegate.getConsentLetter(enrollmentFormType, customer); if (enrollmentForm != null) { if (enrollmentForm.getEsplaEnrollmentNumber() != null) { esplaNumber = enrollmentForm.getEsplaEnrollmentNumber(); } } if (Util.isBlankString(esplaNumber)) { esplaNumber = ""; } PriceReportCycle priceReportCycle = getActivePriceReportCycle(customer); if (priceReportCycle == null) { priceReportCycle = new PriceReportCycle(); } Session session = getHibernateSession(); Transaction tx = session.beginTransaction(); priceReportCycle.setApprovalTime(new Date()); priceReportCycle.setApprover(remoteUser); priceReportCycle.setCustomer(customer); priceReportCycle.setCycleStatus(status); priceReportCycle.setRecordTime(new Date()); priceReportCycle.setRemoteUser(remoteUser); priceReportCycle.setStatus(Constants.ACTIVE); priceReportCycle.setPriceReportStatus(status); priceReportCycle.setPriceReportStatusUser(remoteUser); priceReportCycle.setPriceReportStatusTimestamp(new Date()); session.saveOrUpdate(priceReportCycle); // Get the price report for this customer Iterator i = priceReport.getDetails().iterator(); while (i.hasNext()) { PriceReportDetail priceReportDetail = (PriceReportDetail) i.next(); PriceReportArchive priceReportArchive = new PriceReportArchive(); if (!Util.isBlankString(priceReportDetail.getLpid())) { Lpid lpid = (Lpid) lpidHash.get(priceReportDetail.getLpid()); priceReportArchive.setLpid(lpid.getLpidName()); priceReportArchive.setMajor(lpid.getMajor().getMajorName()); } else { Lpid lpid = (Lpid) lpidHash.get(priceReport.getLpid()); if (lpid == null) { lpid = lpidDefault; } if (lpid != null) { priceReportArchive.setLpid(lpid.getLpidName()); priceReportArchive.setMajor(lpid.getMajor().getMajorName()); } } // Create a new price report archive priceReportArchive.setAccountNumber(priceReport.getAccountNumber()); priceReportArchive.setCustomerLicenseAgreementType(priceReport.getCustomerAgreementType()); priceReportArchive.setCustomerName(priceReport.getCustomerName()); priceReportArchive.setCustomerType(priceReport.getCustomerType()); priceReportArchive.setEsplaNumber(esplaNumber); priceReportArchive.setIndustry(priceReport.getIndustry()); priceReportArchive.setPod(priceReport.getPod()); priceReportArchive.setPoNumber(priceReport.getPoNumber()); priceReportArchive.setPoDate(new Date(0)); priceReportArchive.setUsageDate(new Date(0)); if (priceReport.getPriceLevel() == null) { priceReportArchive.setPriceLevel(""); } else { priceReportArchive.setPriceLevel(priceReport.getPriceLevel()); } priceReportArchive.setPriceReportCycle(priceReportCycle); priceReportArchive.setQualifiedDiscount(priceReport.getQualifiedDiscount()); // priceReportArchive.setPriceLevel(priceReport.getPriceLevel()); priceReportArchive.setRecordTime(new Date()); priceReportArchive.setRemoteUser(remoteUser); priceReportArchive.setSector(priceReport.getSector()); if (priceReportDetail.getLicenseAgreementType() != null && priceReportDetail.getLicenseAgreementType().equals(Constants.SPLA)) { priceReportArchive.setSplaNumber(splaNumber); } else { priceReportArchive.setSplaNumber(""); } priceReportArchive.setStatus(Constants.ACTIVE); priceReportArchive.setOfferingType("STD"); priceReportArchive.setOrderType("NE"); if (priceReportDetail.getCountry() == null) { priceReportArchive.setCountry(""); } else { priceReportArchive.setCountry(priceReportDetail.getCountry()); } if (priceReportDetail.getNodeName() == null) { priceReportArchive.setNodeName("UNKNOWN"); } else { priceReportArchive.setNodeName(priceReportDetail.getNodeName()); } if (priceReportDetail.getSerialNumber() == null) { priceReportArchive.setSerialNumber("UNKNOWN"); } else { priceReportArchive.setSerialNumber(priceReportDetail.getSerialNumber()); } if (priceReportDetail.getMachineType() == null) { priceReportArchive.setMachineType(""); } else { priceReportArchive.setMachineType(priceReportDetail.getMachineType()); } if (priceReportDetail.getMachineModel() == null) { priceReportArchive.setMachineModel("UNKNOWN"); } else { priceReportArchive.setMachineModel(priceReportDetail.getMachineModel()); } if (priceReportDetail.getScanDate() == null) { Date date = Util.parseBaselineDate("1970-01-01-01.01.01.000000"); priceReportArchive.setScanDate(date); } else { priceReportArchive.setScanDate(priceReportDetail.getScanDate()); } if (priceReportDetail.getNodeOwner() == null) { priceReportArchive.setNodeOwner(""); } else { priceReportArchive.setNodeOwner(priceReportDetail.getNodeOwner()); } if (priceReportDetail.getSoftwareOwner() != null) { priceReportArchive.setSoftwareOwner(priceReportDetail.getSoftwareOwner()); } else { priceReportArchive.setSoftwareOwner(""); } priceReportArchive.setProcessorCount(priceReportDetail.getProcessorCount()); priceReportArchive.setUserCount(priceReportDetail.getUserCount()); if (priceReportDetail.getAuthenticated() == null) { priceReportArchive.setAuthenticated(""); } else { priceReportArchive.setAuthenticated(priceReportDetail.getAuthenticated()); } if (priceReportDetail.getSku() != null) { priceReportArchive.setSku(priceReportDetail.getSku()); } else { priceReportArchive.setSku(""); } if (priceReportDetail.getLicenseType() != null) { priceReportArchive.setLicenseType(priceReportDetail.getLicenseType()); } else { priceReportArchive.setLicenseType(""); } if (priceReportDetail.getProductDescription() != null) { priceReportArchive.setProductDescription(priceReportDetail.getProductDescription()); } else { priceReportArchive.setProductDescription(""); } if (priceReportDetail.getLicenseAgreementType() != null) { priceReportArchive.setLicenseAgreementType(priceReportDetail.getLicenseAgreementType()); } else { priceReportArchive.setLicenseAgreementType(""); } if (priceReportDetail.getSplaQuarterlyPrice() != null) { priceReportArchive.setSplaQuarterlyPrice(priceReportDetail.getSplaQuarterlyPrice()); } else { priceReportArchive.setSplaQuarterlyPrice(new BigDecimal(0)); } if (priceReportDetail.getEsplaYearlyPrice() != null) { priceReportArchive.setEsplaYearlyPrice(priceReportDetail.getEsplaYearlyPrice()); } else { priceReportArchive.setEsplaYearlyPrice(new BigDecimal(0)); } if (!Util.isBlankString(priceReportDetail.getPoNumber())) { priceReportArchive.setPoNumber(priceReportDetail.getPoNumber()); } else { priceReportArchive.setPoNumber(""); } session.save(priceReportArchive); } tx.commit(); session.close(); }