コード例 #1
0
 @Override
 public void deleteExternalApplication(Long id)
     throws CvqModelException, CvqObjectNotFoundException {
   ExternalApplication ea = getExternalApplicationById(id);
   if (ea.getExternalHomeFolders() != null) {
     //            List<ExternalAccountItem> externalAccountItems =
     // paymentService.getAllExternalAccountItems();
     //            for (ExternalAccountItem eai : externalAccountItems) {
     //                if
     // (eai.getExternalServiceSpecificDataByKey(ExternalServiceUtils.EXTERNAL_APPLICATION_ID_KEY).equals(String.valueOf(ea.getId()))) {
     //                    externalAccountItems.remove(eai);
     //                    eai.setExternalServiceSpecificData(null);
     //                    genericDAO.delete(eai);
     //                }
     //            }
     for (ExternalHomeFolder externalHomeFolder : ea.getExternalHomeFolders()) {
       externalHomeFolderService.deleteHomeFolderMappings(
           ea.getLabel(),
           externalHomeFolderService
               .getHomeFolderMapping(ea.getLabel(), externalHomeFolder.getExternalId())
               .getHomeFolderId());
       genericDAO.delete(externalHomeFolder);
     }
     ea.setExternalHomeFolders(null);
   }
   genericDAO.delete(ea);
 }
コード例 #2
0
 /*
    Account Id
    Account Value
    Account Date
    Account Label
    External Family Account Id
 */
 @Override
 public Map<String, Integer> importDepositAccounts(
     Long externalApplicationId, String broker, byte[] csvDatas)
     throws CvqModelException, CvqObjectNotFoundException {
   ExternalDepositAccountItem edai;
   ExternalHomeFolder ehf;
   ExternalApplication ea = getExternalApplicationById(externalApplicationId);
   Map<String, Integer> report = new HashMap<String, Integer>();
   report.put("created", 0);
   report.put("updated", 0);
   report.put("ignored", 0);
   try {
     CSVReader csvReader = new CSVReader(new StringReader(new String(csvDatas)), ',', '"', 1);
     for (Object o : csvReader.readAll()) {
       boolean updated = false;
       String[] line = (String[]) o;
       ehf =
           genericDAO
               .simpleSelect(ExternalHomeFolder.class)
               .and("externalId", line[4])
               .and("externalApplication", ea)
               .unique();
       if (ehf == null) {
         report.put("ignored", report.get("ignored") + 1);
         continue;
       }
       edai =
           genericDAO
               .simpleSelect(ExternalDepositAccountItem.class)
               .and("externalItemId", line[0])
               .and("externalApplicationId", String.valueOf(externalApplicationId))
               .unique();
       if (edai != null) {
         genericDAO.delete(edai);
         report.put("updated", report.get("updated") + 1);
         updated = true;
       }
       edai =
           new ExternalDepositAccountItem(
               line[3],
               Double.valueOf(line[1]),
               EXTERNAL_APPLICATION_LABEL,
               line[0],
               DateUtils.parseIso(line[2]),
               Double.valueOf(line[1]),
               broker);
       edai.setExternalApplicationId(ea.getId().toString());
       edai.setExternalHomeFolderId(ehf.getExternalId());
       genericDAO.create(edai);
       if (!updated) report.put("created", report.get("created") + 1);
     }
   } catch (Exception e) {
     logger.error(e.getMessage());
     e.printStackTrace();
     HibernateUtil.getSession().getTransaction().rollback();
     throw new CvqModelException("external.error.csvImport");
   }
   return report;
 }