Package org.supercsv.io

Examples of org.supercsv.io.CsvListReader


        }
    }

    public static List<String> parseHintedHandoffEnabledDCs(final String dcNames) throws IOException
    {
        final CsvListReader csvListReader = new CsvListReader(new StringReader(dcNames), STANDARD_SURROUNDING_SPACES_NEED_QUOTES);
        return csvListReader.read();
    }
View Full Code Here


     *
     * @return the SUCCESS result
     */
    public String importCSV() throws Exception {
        File file = this.getUpload();
        CsvListReader reader = new CsvListReader(new FileReader(file),
                CsvPreference.EXCEL_PREFERENCE);
        int failedNum = 0;
        int successfulNum = 0;
        try {
            final String[] header = reader.getCSVHeader(true);

            List<String> line = new ArrayList<String>();
            Map<String, String> failedMsg = new HashMap<String, String>();
            while ((line = reader.read()) != null) {

                Map<String, String> row = new HashMap<String, String>();
                for (int i = 0; i < line.size(); i++) {
                    row.put(header[i], line.get(i));
                }

                Task task = new Task();
                try {
                    String id = row.get(getText("entity.id.label"));
                    if (!CommonUtil.isNullOrEmpty(id)) {
                        task.setId(Integer.parseInt(id));
                    }
                    task.setSubject(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.subject.label"))));
                    String statusID = row
                            .get(getText("entity.status_id.label"));
                    if (CommonUtil.isNullOrEmpty(statusID)) {
                        task.setStatus(null);
                    } else {
                        TaskStatus status = taskStatusService.getEntityById(
                                TaskStatus.class, Integer.parseInt(statusID));
                        task.setStatus(status);
                    }
                    SimpleDateFormat dateFormat = new SimpleDateFormat(
                            Constant.DATE_TIME_FORMAT);
                    String startDateS = row
                            .get(getText("entity.start_date.label"));
                    if (startDateS != null) {
                        Date startDate = dateFormat.parse(startDateS);
                        task.setStart_date(startDate);
                    } else {
                        task.setStart_date(null);
                    }
                    String dueDateS = row.get(getText("task.due_date.label"));
                    if (dueDateS != null) {
                        Date dueDate = dateFormat.parse(dueDateS);
                        task.setDue_date(dueDate);
                    } else {
                        task.setDue_date(null);
                    }
                    task.setRelated_object(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.related_object.label"))));
                    String relatedRecord = row
                            .get(getText("entity.related_record_id.label"));
                    if (CommonUtil.isNullOrEmpty(relatedRecord)) {
                        task.setRelated_record(0);
                    } else {
                        task.setRelated_record(Integer.parseInt(relatedRecord));
                    }
                    String contactID = row
                            .get(getText("entity.contact_id.label"));
                    if (CommonUtil.isNullOrEmpty(contactID)) {
                        task.setContact(null);
                    } else {
                        Contact contact = contactService.getEntityById(
                                Contact.class, Integer.parseInt(contactID));
                        task.setContact(contact);
                    }
                    String priorityID = row
                            .get(getText("entity.priority_id.label"));
                    if (CommonUtil.isNullOrEmpty(priorityID)) {
                        task.setPriority(null);
                    } else {
                        TaskPriority priority = taskPriorityService
                                .getEntityById(TaskPriority.class,
                                        Integer.parseInt(priorityID));
                        task.setPriority(priority);
                    }
                    task.setDescription(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.description.label"))));
                    task.setNotes(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.notes.label"))));
                    String assignedToID = row
                            .get(getText("entity.assigned_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(assignedToID)) {
                        task.setAssigned_to(null);
                    } else {
                        User assignedTo = userService.getEntityById(User.class,
                                Integer.parseInt(assignedToID));
                        task.setAssigned_to(assignedTo);
                    }
                    baseService.makePersistent(task);
                    successfulNum++;
                } catch (Exception e) {
                    failedNum++;
                    failedMsg.put(task.getSubject(), e.getMessage());
                }

            }

            this.setFailedMsg(failedMsg);
            this.setFailedNum(failedNum);
            this.setSuccessfulNum(successfulNum);
            this.setTotalNum(successfulNum + failedNum);
        } finally {
            reader.close();
        }
        return SUCCESS;
    }
View Full Code Here

     *
     * @return the SUCCESS result
     */
    public String importCSV() throws Exception {
        File file = this.getUpload();
        CsvListReader reader = new CsvListReader(new FileReader(file),
                CsvPreference.EXCEL_PREFERENCE);
        int failedNum = 0;
        int successfulNum = 0;
        try {
            final String[] header = reader.getCSVHeader(true);

            List<String> line = new ArrayList<String>();
            Map<String, String> failedMsg = new HashMap<String, String>();
            while ((line = reader.read()) != null) {

                Map<String, String> row = new HashMap<String, String>();
                for (int i = 0; i < line.size(); i++) {
                    row.put(header[i], line.get(i));
                }

                Opportunity opportunity = new Opportunity();
                try {
                    String id = row.get(getText("entity.id.label"));
                    if (!CommonUtil.isNullOrEmpty(id)) {
                        opportunity.setId(Integer.parseInt(id));
                    }
                    opportunity.setName(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.name.label"))));
                    String accountID = row
                            .get(getText("entity.account_id.label"));
                    if (CommonUtil.isNullOrEmpty(accountID)) {
                        opportunity.setAccount(null);
                    } else {
                        Account account = accountService.getEntityById(
                                Account.class, Integer.parseInt(accountID));
                        opportunity.setAccount(account);
                    }
                    String currencyID = row
                            .get(getText("entity.currency_id.label"));
                    if (CommonUtil.isNullOrEmpty(currencyID)) {
                        opportunity.setCurrency(null);
                    } else {
                        Currency currency = currencyService.getEntityById(
                                Currency.class, Integer.parseInt(currencyID));
                        opportunity.setCurrency(currency);
                    }
                    SimpleDateFormat dateFormat = new SimpleDateFormat(
                            Constant.DATE_EDIT_FORMAT);
                    String expectCloseDateS = row
                            .get(getText("opportunity.expect_close_date.label"));

                    if (expectCloseDateS != null) {
                        Date expectCloseDate = dateFormat
                                .parse(expectCloseDateS);
                        opportunity.setExpect_close_date(expectCloseDate);
                    } else {
                        opportunity.setExpect_close_date(null);
                    }
                    opportunity
                            .setOpportunity_amount(CommonUtil.fromNullToEmpty(row
                                    .get(getText("opportunity.opportunity_amount.label"))));
                    String typeID = row.get(getText("entity.type_id.label"));
                    if (CommonUtil.isNullOrEmpty(typeID)) {
                        opportunity.setType(null);
                    } else {
                        OpportunityType opportunityType = opportunityTypeService
                                .getEntityById(OpportunityType.class,
                                        Integer.parseInt(typeID));
                        opportunity.setType(opportunityType);
                    }
                    String salesStageID = row
                            .get(getText("entity.salesStage_id.label"));
                    if (CommonUtil.isNullOrEmpty(salesStageID)) {
                        opportunity.setSales_stage(null);
                    } else {
                        SalesStage salesStage = salesStageService
                                .getEntityById(SalesStage.class,
                                        Integer.parseInt(salesStageID));
                        opportunity.setSales_stage(salesStage);
                    }
                    String leadSourceID = row
                            .get(getText("entity.leadSource_id.label"));
                    if (CommonUtil.isNullOrEmpty(leadSourceID)) {
                        opportunity.setLead_source(null);
                    } else {
                        LeadSource leadSource = leadSourceService
                                .getEntityById(LeadSource.class,
                                        Integer.parseInt(leadSourceID));
                        opportunity.setLead_source(leadSource);
                    }
                    String probability = row
                            .get(getText("opportunity.probability.label"));
                    if (CommonUtil.isNullOrEmpty(probability)) {
                        opportunity.setProbability(0);
                    } else {
                        opportunity.setProbability(Double
                                .parseDouble(probability));
                    }
                    String campaignID = row
                            .get(getText("entity.campaign_id.label"));
                    if (CommonUtil.isNullOrEmpty(campaignID)) {
                        opportunity.setCampaign(null);
                    } else {
                        Campaign campaign = campaignService.getEntityById(
                                Campaign.class, Integer.parseInt(campaignID));
                        opportunity.setCampaign(campaign);
                    }
                    opportunity.setNext_step(CommonUtil.fromNullToEmpty(row
                            .get(getText("opportunity.next_step.label"))));
                    opportunity.setNotes(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.notes.label"))));
                    String assignedToID = row
                            .get(getText("entity.assigned_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(assignedToID)) {
                        opportunity.setAssigned_to(null);
                    } else {
                        User assignedTo = userService.getEntityById(User.class,
                                Integer.parseInt(assignedToID));
                        opportunity.setAssigned_to(assignedTo);
                    }
                    baseService.makePersistent(opportunity);
                    successfulNum++;
                } catch (Exception e) {
                    failedNum++;
                    failedMsg.put(opportunity.getName(), e.getMessage());
                }

            }

            this.setFailedMsg(failedMsg);
            this.setFailedNum(failedNum);
            this.setSuccessfulNum(successfulNum);
            this.setTotalNum(successfulNum + failedNum);
        } finally {
            reader.close();
        }
        return SUCCESS;
    }
View Full Code Here

     *
     * @return the SUCCESS result
     */
    public String importCSV() throws Exception {
        File file = this.getUpload();
        CsvListReader reader = new CsvListReader(new FileReader(file),
                CsvPreference.EXCEL_PREFERENCE);
        int failedNum = 0;
        int successfulNum = 0;
        try {
            final String[] header = reader.getCSVHeader(true);

            List<String> line = new ArrayList<String>();
            Map<String, String> failedMsg = new HashMap<String, String>();
            while ((line = reader.read()) != null) {

                Map<String, String> row = new HashMap<String, String>();
                for (int i = 0; i < line.size(); i++) {
                    row.put(header[i], line.get(i));
                }
                CaseInstance caseInstance = new CaseInstance();
                try {
                    String id = row.get(getText("entity.id.label"));
                    if (!CommonUtil.isNullOrEmpty(id)) {
                        caseInstance.setId(Integer.parseInt(id));
                        UserUtil.permissionCheck("update_case");
                    } else {
                        UserUtil.permissionCheck("create_case");
                    }
                    String priorityID = row
                            .get(getText("entity.priority_id.label"));
                    if (CommonUtil.isNullOrEmpty(priorityID)) {
                        caseInstance.setPriority(null);
                    } else {
                        CasePriority priority = casePriorityService
                                .getEntityById(CasePriority.class,
                                        Integer.parseInt(priorityID));
                        caseInstance.setPriority(priority);
                    }
                    String statusID = row
                            .get(getText("entity.status_id.label"));
                    if (CommonUtil.isNullOrEmpty(statusID)) {
                        caseInstance.setStatus(null);
                    } else {
                        CaseStatus status = caseStatusService.getEntityById(
                                CaseStatus.class, Integer.parseInt(statusID));
                        caseInstance.setStatus(status);
                    }
                    String typeID = row.get(getText("case.type_id.label"));
                    if (CommonUtil.isNullOrEmpty(typeID)) {
                        caseInstance.setType(null);
                    } else {
                        CaseType type = caseTypeService.getEntityById(
                                CaseType.class, Integer.parseInt(typeID));
                        caseInstance.setType(type);
                    }
                    String originID = row.get(getText("case.origin_id.label"));
                    if (CommonUtil.isNullOrEmpty(originID)) {
                        caseInstance.setOrigin(null);
                    } else {
                        CaseOrigin origin = caseOriginService.getEntityById(
                                CaseOrigin.class, Integer.parseInt(originID));
                        caseInstance.setOrigin(origin);
                    }
                    String reasonID = row.get(getText("case.reason_id.label"));
                    if (CommonUtil.isNullOrEmpty(reasonID)) {
                        caseInstance.setReason(null);
                    } else {
                        CaseReason reason = caseReasonService.getEntityById(
                                CaseReason.class, Integer.parseInt(reasonID));
                        caseInstance.setReason(reason);
                    }
                    caseInstance.setSubject(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.subject.label"))));
                    caseInstance.setNotes(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.notes.label"))));
                    caseInstance.setResolution(CommonUtil.fromNullToEmpty(row
                            .get(getText("case.resolution.label"))));
                    String assignedToID = row
                            .get(getText("entity.assigned_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(assignedToID)) {
                        caseInstance.setAssigned_to(null);
                    } else {
                        User assignedTo = userService.getEntityById(User.class,
                                Integer.parseInt(assignedToID));
                        caseInstance.setAssigned_to(assignedTo);
                    }
                    baseService.makePersistent(caseInstance);
                    successfulNum++;
                } catch (Exception e) {
                    failedNum++;
                    failedMsg.put(String.valueOf(caseInstance.getSubject()),
                            e.getMessage());
                }

            }

            this.setFailedMsg(failedMsg);
            this.setFailedNum(failedNum);
            this.setSuccessfulNum(successfulNum);
            this.setTotalNum(successfulNum + failedNum);
        } finally {
            reader.close();
        }
        return SUCCESS;
    }
View Full Code Here

     *
     * @return the SUCCESS result
     */
    public String importCSV() throws Exception {
        File file = this.getUpload();
        CsvListReader reader = new CsvListReader(new FileReader(file),
                CsvPreference.EXCEL_PREFERENCE);
        int failedNum = 0;
        int successfulNum = 0;
        try {
            final String[] header = reader.getCSVHeader(true);

            List<String> line = new ArrayList<String>();
            Map<String, String> failedMsg = new HashMap<String, String>();
            while ((line = reader.read()) != null) {

                Map<String, String> row = new HashMap<String, String>();
                for (int i = 0; i < line.size(); i++) {
                    row.put(header[i], line.get(i));
                }
                Meeting meeting = new Meeting();
                try {
                    String id = row.get(getText("entity.id.label"));
                    if (!CommonUtil.isNullOrEmpty(id)) {
                        meeting.setId(Integer.parseInt(id));
                    }
                    meeting.setSubject(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.subject.label"))));
                    String statusID = row
                            .get(getText("entity.status_id.label"));
                    if (CommonUtil.isNullOrEmpty(statusID)) {
                        meeting.setStatus(null);
                    } else {
                        MeetingStatus status = meetingStatusService
                                .getEntityById(MeetingStatus.class,
                                        Integer.parseInt(statusID));
                        meeting.setStatus(status);
                    }
                    SimpleDateFormat dateFormat = new SimpleDateFormat(
                            Constant.DATE_TIME_FORMAT);
                    String startDateS = row
                            .get(getText("entity.start_date.label"));
                    if (startDateS != null) {
                        Date startDate = dateFormat.parse(startDateS);
                        meeting.setStart_date(startDate);
                    } else {
                        meeting.setStart_date(null);
                    }
                    String endDateS = row.get(getText("entity.end_date.label"));
                    if (endDateS != null) {
                        Date endDate = dateFormat.parse(endDateS);
                        meeting.setEnd_date(endDate);
                    } else {
                        meeting.setEnd_date(null);
                    }
                    meeting.setRelated_object(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.related_object.label"))));
                    String relatedRecord = row
                            .get(getText("entity.related_record_id.label"));
                    if (CommonUtil.isNullOrEmpty(relatedRecord)) {
                        meeting.setRelated_record(0);
                    } else {
                        meeting.setRelated_record(Integer
                                .parseInt(relatedRecord));
                    }
                    meeting.setLocation(CommonUtil.fromNullToEmpty(row
                            .get(getText("meeting.location.label"))));
                    String reminderWayEmail = row
                            .get(getText("entity.reminder_email.label"));
                    if (CommonUtil.isNullOrEmpty(reminderWayEmail)) {
                        meeting.setReminder_email(false);
                    } else {
                        meeting.setReminder_email(Boolean
                                .parseBoolean(reminderWayEmail));
                    }
                    String reminderOptionEmailID = row
                            .get(getText("entity.reminder_option_email_id.label"));
                    if (CommonUtil.isNullOrEmpty(reminderOptionEmailID)) {
                        meeting.setReminder_option_email(null);
                    } else {
                        ReminderOption reminderOption = reminderOptionService
                                .getEntityById(ReminderOption.class,
                                        Integer.parseInt(reminderOptionEmailID));
                        meeting.setReminder_option_email(reminderOption);
                    }
                    meeting.setNotes(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.notes.label"))));
                    String assignedToID = row
                            .get(getText("entity.assigned_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(assignedToID)) {
                        meeting.setAssigned_to(null);
                    } else {
                        User assignedTo = userService.getEntityById(User.class,
                                Integer.parseInt(assignedToID));
                        meeting.setAssigned_to(assignedTo);
                    }
                    baseService.makePersistent(meeting);
                    successfulNum++;
                } catch (Exception e) {
                    failedNum++;
                    failedMsg.put(meeting.getSubject(), e.getMessage());
                }

            }

            this.setFailedMsg(failedMsg);
            this.setFailedNum(failedNum);
            this.setSuccessfulNum(successfulNum);
            this.setTotalNum(successfulNum + failedNum);
        } finally {
            reader.close();
        }
        return SUCCESS;
    }
View Full Code Here

     *
     * @return the SUCCESS result
     */
    public String importCSV() throws Exception {
        File file = this.getUpload();
        CsvListReader reader = new CsvListReader(new FileReader(file),
                CsvPreference.EXCEL_PREFERENCE);
        int failedNum = 0;
        int successfulNum = 0;
        try {
            final String[] header = reader.getCSVHeader(true);

            List<String> line = new ArrayList<String>();
            Map<String, String> failedMsg = new HashMap<String, String>();
            while ((line = reader.read()) != null) {

                Map<String, String> row = new HashMap<String, String>();
                for (int i = 0; i < line.size(); i++) {
                    row.put(header[i], line.get(i));
                }

                Campaign campaign = new Campaign();
                try {
                    String id = row.get(getText("entity.id.label"));
                    if (!CommonUtil.isNullOrEmpty(id)) {
                        campaign.setId(Integer.parseInt(id));
                        UserUtil.permissionCheck("update_campaign");
                    } else {
                        UserUtil.permissionCheck("create_campaign");
                    }
                    campaign.setName(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.name.label"))));
                    String statusID = row
                            .get(getText("entity.status_id.label"));
                    if (CommonUtil.isNullOrEmpty(statusID)) {
                        campaign.setStatus(null);
                    } else {
                        CampaignStatus status = campaignStatusService
                                .getEntityById(CampaignStatus.class,
                                        Integer.parseInt(statusID));
                        campaign.setStatus(status);
                    }
                    String typeID = row.get(getText("entity.type_id.label"));
                    if (CommonUtil.isNullOrEmpty(typeID)) {
                        campaign.setType(null);
                    } else {
                        CampaignType type = campaignTypeService.getEntityById(
                                CampaignType.class, Integer.parseInt(typeID));
                        campaign.setType(type);
                    }
                    SimpleDateFormat dateFormat = new SimpleDateFormat(
                            Constant.DATE_EDIT_FORMAT);
                    String startDateS = row
                            .get(getText("entity.start_date.label"));
                    if (startDateS != null) {
                        Date startDate = dateFormat.parse(startDateS);
                        campaign.setStart_date(startDate);
                    } else {
                        campaign.setStart_date(null);
                    }
                    String endDateS = row.get(getText("entity.end_date.label"));
                    if (startDateS != null) {
                        Date endDate = dateFormat.parse(endDateS);
                        campaign.setEnd_date(endDate);
                    } else {
                        campaign.setEnd_date(null);
                    }
                    String currencyID = row
                            .get(getText("entity.currency_id.label"));
                    if (CommonUtil.isNullOrEmpty(currencyID)) {
                        campaign.setCurrency(null);
                    } else {
                        Currency currency = currencyService.getEntityById(
                                Currency.class, Integer.parseInt(currencyID));
                        campaign.setCurrency(currency);
                    }
                    String impressions = row
                            .get(getText("campaign.impressions.label"));
                    if (CommonUtil.isNullOrEmpty(impressions)) {
                        campaign.setImpressions(0);
                    } else {
                        campaign.setImpressions(Double.parseDouble(impressions));
                    }
                    String budget = row.get(getText("campaign.budget.label"));
                    if (CommonUtil.isNullOrEmpty(budget)) {
                        campaign.setBudget(0);
                    } else {
                        campaign.setBudget(Double.parseDouble(budget));
                    }
                    String expectedCost = row
                            .get(getText("campaign.expected_cost.label"));
                    if (CommonUtil.isNullOrEmpty(expectedCost)) {
                        campaign.setExpected_cost(0);
                    } else {
                        campaign.setExpected_cost(Double
                                .parseDouble(expectedCost));
                    }
                    String actualCost = row
                            .get(getText("campaign.actual_cost.label "));
                    if (CommonUtil.isNullOrEmpty(actualCost)) {
                        campaign.setActual_cost(0);
                    } else {
                        campaign.setActual_cost(Double.parseDouble(actualCost));
                    }
                    String expectedRevenue = row
                            .get(getText("campaign.expected_revenue.label"));
                    if (CommonUtil.isNullOrEmpty(expectedRevenue)) {
                        campaign.setExpected_revenue(0);
                    } else {
                        campaign.setExpected_revenue(Double
                                .parseDouble(expectedRevenue));
                    }
                    String expectedRespone = row
                            .get(getText("campaign.expected_respone.label"));
                    if (CommonUtil.isNullOrEmpty(expectedRespone)) {
                        campaign.setExpected_respone(0);
                    } else {
                        campaign.setExpected_respone(Double
                                .parseDouble(expectedRespone));
                    }

                    campaign.setObjective(CommonUtil.fromNullToEmpty(row
                            .get(getText("campaign.objective.label"))));
                    campaign.setNotes(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.notes.label"))));
                    String assignedToID = row
                            .get(getText("entity.assigned_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(assignedToID)) {
                        campaign.setAssigned_to(null);
                    } else {
                        User assignedTo = userService.getEntityById(User.class,
                                Integer.parseInt(assignedToID));
                        campaign.setAssigned_to(assignedTo);
                    }
                    baseService.makePersistent(campaign);
                    successfulNum++;
                } catch (Exception e) {
                    failedNum++;
                    failedMsg.put(campaign.getName(), e.getMessage());
                }

            }

            this.setFailedMsg(failedMsg);
            this.setFailedNum(failedNum);
            this.setSuccessfulNum(successfulNum);
            this.setTotalNum(successfulNum + failedNum);
        } finally {
            reader.close();
        }
        return SUCCESS;
    }
View Full Code Here

     *
     * @return the SUCCESS result
     */
    public String importCSV() throws Exception {
        File file = this.getUpload();
        CsvListReader reader = new CsvListReader(new FileReader(file),
                CsvPreference.EXCEL_PREFERENCE);
        int failedNum = 0;
        int successfulNum = 0;
        try {
            final String[] header = reader.getCSVHeader(true);

            List<String> line = new ArrayList<String>();
            Map<String, String> failedMsg = new HashMap<String, String>();
            while ((line = reader.read()) != null) {

                Map<String, String> row = new HashMap<String, String>();
                for (int i = 0; i < line.size(); i++) {
                    row.put(header[i], line.get(i));
                }

                Account account = new Account();
                try {
                    String id = row.get(getText("entity.id.label"));
                    if (!CommonUtil.isNullOrEmpty(id)) {
                        account.setId(Integer.parseInt(id));
                        UserUtil.permissionCheck("update_account");
                    } else {
                        UserUtil.permissionCheck("create_account");
                    }
                    account.setName(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.name.label"))));
                    String typeID = row.get(getText("account.type_id.label"));
                    if (CommonUtil.isNullOrEmpty(typeID)) {
                        account.setAccount_type(null);
                    } else {
                        AccountType accountType = accountTypeService
                                .getEntityById(AccountType.class,
                                        Integer.parseInt(typeID));
                        account.setAccount_type(accountType);
                    }
                    String accountLevelID = row
                            .get(getText("entity.account_level_id.label"));
                    if (CommonUtil.isNullOrEmpty(accountLevelID)) {
                        account.setAccount_type(null);
                    } else {
                        AccountLevel accountLevel = accountLevelService
                                .getEntityById(AccountLevel.class,
                                        Integer.parseInt(accountLevelID));
                        account.setAccount_level(accountLevel);
                    }
                    String currencyID = row
                            .get(getText("entity.currency_id.label"));
                    if (CommonUtil.isNullOrEmpty(currencyID)) {
                        account.setCurrency(null);
                    } else {
                        Currency currency = currencyService.getEntityById(
                                Currency.class, Integer.parseInt(currencyID));
                        account.setCurrency(currency);
                    }
                    String capitalID = row
                            .get(getText("entity.capital_id.label"));
                    if (CommonUtil.isNullOrEmpty(capitalID)) {
                        account.setCapital(null);
                    } else {
                        Capital capital = capitalService.getEntityById(
                                Capital.class, Integer.parseInt(capitalID));
                        account.setCapital(capital);
                    }
                    String annualRevenueID = row
                            .get(getText("entity.annual_revenue_id.label"));
                    if (CommonUtil.isNullOrEmpty(annualRevenueID)) {
                        account.setAnnual_revenue(null);
                    } else {
                        AnnualRevenue annualRevenue = annualRevenueService
                                .getEntityById(AnnualRevenue.class,
                                        Integer.parseInt(annualRevenueID));
                        account.setAnnual_revenue(annualRevenue);
                    }
                    String companySizeID = row
                            .get(getText("entity.company_size_id.label"));
                    if (CommonUtil.isNullOrEmpty(companySizeID)) {
                        account.setCompany_size(null);
                    } else {
                        CompanySize companySize = companySizeService
                                .getEntityById(CompanySize.class,
                                        Integer.parseInt(companySizeID));
                        account.setCompany_size(companySize);
                    }
                    String accountTypeID = row
                            .get(getText("entity.account_type_id.label"));
                    if (CommonUtil.isNullOrEmpty(accountTypeID)) {
                        account.setAccount_type(null);
                    } else {
                        AccountType accountType = accountTypeService
                                .getEntityById(AccountType.class,
                                        Integer.parseInt(accountTypeID));
                        account.setAccount_type(accountType);
                    }
                    String industryID = row
                            .get(getText("entity.industry_id.label"));
                    if (CommonUtil.isNullOrEmpty(industryID)) {
                        account.setIndustry(null);
                    } else {
                        Industry industry = industryService.getEntityById(
                                Industry.class, Integer.parseInt(industryID));
                        account.setIndustry(industry);
                    }
                    account.setEmail(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.email.label"))));
                    account.setOffice_phone(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.office_phone.label"))));
                    account.setWebsite(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.website.label"))));
                    account.setFax(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.fax.label"))));
                    account.setBill_street(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.billing_street.label"))));
                    account.setBill_city(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.billing_city.label"))));
                    account.setBill_state(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.billing_state.label"))));
                    account.setBill_postal_code(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.billing_postal_code.label"))));
                    account.setBill_country(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.billing_country.label"))));
                    account.setShip_street(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.shipping_street.label"))));
                    account.setShip_city(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.shipping_city.label"))));
                    account.setShip_state(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.shipping_state.label"))));
                    account.setShip_postal_code(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.shipping_postal_code.label"))));
                    account.setShip_country(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.shipping_country.label"))));
                    String accountNatureID = row
                            .get(getText("entity.account_nature_id.label"));
                    if (CommonUtil.isNullOrEmpty(accountNatureID)) {
                        account.setAccount_nature(null);
                    } else {
                        AccountNature accountNature = accountNatureService
                                .getEntityById(AccountNature.class,
                                        Integer.parseInt(accountNatureID));
                        account.setAccount_nature(accountNature);
                    }
                    account.setLegal_representative(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.legal_representative.label"))));
                    account.setBusiness_scope(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.business_scope.label"))));
                    SimpleDateFormat dateFormat = new SimpleDateFormat(
                            Constant.DATE_EDIT_FORMAT);
                    String createDateS = row
                            .get(getText("entity.create_date.label"));
                    if (createDateS != null) {
                        Date createDate = dateFormat.parse(createDateS);
                        account.setCreate_date(createDate);
                    } else {
                        account.setCreate_date(null);
                    }
                    account.setCredit(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.credit.label"))));
                    account.setMarket_position(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.market_position.label"))));
                    account.setDevelopment_potential(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.development_potential.label"))));
                    account.setOperational_characteristics(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.operational_characteristics.label"))));
                    account.setOperational_direction(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.operational_direction.label"))));
                    account.setSic_code(CommonUtil.fromNullToEmpty(row
                            .get(getText("account.sic_code.label"))));
                    account.setTicket_symbol(CommonUtil.fromNullToEmpty(row
                            .get(getText("account.ticket_symbol.label"))));
                    String managerID = row
                            .get(getText("account.manager_id.label"));
                    if (CommonUtil.isNullOrEmpty(managerID)) {
                        account.setManager(null);
                    } else {
                        Account manager = baseService.getEntityById(
                                Account.class, Integer.parseInt(managerID));
                        account.setManager(manager);
                    }
                    String assignedToID = row
                            .get(getText("entity.assigned_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(assignedToID)) {
                        account.setAssigned_to(null);
                    } else {
                        User assignedTo = userService.getEntityById(User.class,
                                Integer.parseInt(assignedToID));
                        account.setAssigned_to(assignedTo);
                    }
                    baseService.makePersistent(account);
                    successfulNum++;
                } catch (Exception e) {
                    failedNum++;
                    failedMsg.put(account.getName(), e.getMessage());
                }

            }

            this.setFailedMsg(failedMsg);
            this.setFailedNum(failedNum);
            this.setSuccessfulNum(successfulNum);
            this.setTotalNum(successfulNum + failedNum);
        } finally {
            reader.close();
        }
        return SUCCESS;
    }
View Full Code Here

     *
     * @return the SUCCESS result
     */
    public String importCSV() throws Exception {
        File file = this.getUpload();
        CsvListReader reader = new CsvListReader(new FileReader(file),
                CsvPreference.EXCEL_PREFERENCE);
        int failedNum = 0;
        int successfulNum = 0;
        try {
            final String[] header = reader.getCSVHeader(true);

            List<String> line = new ArrayList<String>();
            Map<String, String> failedMsg = new HashMap<String, String>();
            while ((line = reader.read()) != null) {

                Map<String, String> row = new HashMap<String, String>();
                for (int i = 0; i < line.size(); i++) {
                    row.put(header[i], line.get(i));
                }

                Contact contact = new Contact();
                try {
                    String id = row.get(getText("entity.id.label"));
                    if (!CommonUtil.isNullOrEmpty(id)) {
                        contact.setId(Integer.parseInt(id));
                        UserUtil.permissionCheck("update_contact");
                    } else {
                        UserUtil.permissionCheck("create_contact");
                    }
                    String salutationID = row
                            .get(getText("entity.salutation_id.label"));
                    if (CommonUtil.isNullOrEmpty(salutationID)) {
                        contact.setSalutation(null);
                    } else {
                        Salutation salutation = salutationService
                                .getEntityById(Salutation.class,
                                        Integer.parseInt(salutationID));
                        contact.setSalutation(salutation);
                    }
                    contact.setFirst_name(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.first_name.label"))));
                    contact.setLast_name(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.last_name.label"))));
                    contact.setEmail(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.email.label"))));
                    contact.setOffice_phone(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.office_phone.label"))));
                    contact.setTitle(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.title.label"))));
                    contact.setMobile(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.mobile.label"))));
                    contact.setSkype_id(CommonUtil.fromNullToEmpty(row
                            .get(getText("contact.skype_id.label"))));
                    contact.setDepartment(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.department.label"))));
                    contact.setFax(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.fax.label"))));
                    String accountID = row
                            .get(getText("entity.account_id.label"));
                    if (CommonUtil.isNullOrEmpty(accountID)) {
                        contact.setAccount(null);
                    } else {
                        Account account = accountService.getEntityById(
                                Account.class, Integer.parseInt(accountID));
                        contact.setAccount(account);
                    }
                    contact.setWebsite(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.website.label"))));
                    contact.setPrimary_street(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_street.label"))));
                    contact.setPrimary_city(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_city.label"))));
                    contact.setPrimary_state(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_state.label"))));
                    contact.setPrimary_postal_code(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_postal_code.label"))));
                    contact.setPrimary_country(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_country.label"))));
                    contact.setOther_street(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_street.label"))));
                    contact.setOther_city(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_city.label"))));
                    contact.setOther_state(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_state.label"))));
                    contact.setOther_postal_code(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_postal_code.label"))));
                    contact.setOther_country(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_country.label"))));
                    contact.setOrigo(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.origo.label"))));
                    String height = row.get(getText("entity.height.label"));
                    if (CommonUtil.isNullOrEmpty(height)) {
                        contact.setHeight(0);
                    } else {
                        contact.setHeight(Double.parseDouble(height));
                    }
                    String weight = row.get(getText("entity.weight.label"));
                    if (CommonUtil.isNullOrEmpty(weight)) {
                        contact.setWeight(0);
                    } else {
                        contact.setWeight(Double.parseDouble(weight));
                    }
                    contact.setRelationship(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.relationship.label"))));
                    contact.setCharacter(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.character.label"))));
                    contact.setInterest(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.interest.label"))));
                    contact.setTaboo(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.taboo.label"))));
                    String religiousID = row
                            .get(getText("entity.religious_id.label"));
                    if (CommonUtil.isNullOrEmpty(religiousID)) {
                        contact.setReligious(null);
                    } else {
                        Religious religious = religiousService.getEntityById(
                                Religious.class, Integer.parseInt(religiousID));
                        contact.setReligious(religious);
                    }
                    contact.setHabit(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.habit.label"))));
                    contact.setDiet(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.diet.label"))));
                    contact.setNotes(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.notes.label"))));
                    String reportToID = row
                            .get(getText("contact.report_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(reportToID)) {
                        contact.setReport_to(null);
                    } else {
                        Contact reportTo = baseService.getEntityById(
                                Contact.class, Integer.parseInt(reportToID));
                        contact.setReport_to(reportTo);
                    }
                    String doNotCall = row
                            .get(getText("entity.not_call.label"));
                    if (CommonUtil.isNullOrEmpty(doNotCall)) {
                        contact.setNot_call(false);
                    } else {
                        contact.setNot_call(Boolean.parseBoolean(doNotCall));
                    }

                    String leadSourceID = row
                            .get(getText("entity.leadSource_id.label"));
                    if (CommonUtil.isNullOrEmpty(leadSourceID)) {
                        contact.setLeadSource(null);
                    } else {
                        LeadSource leadSource = leadSourceService
                                .getEntityById(LeadSource.class,
                                        Integer.parseInt(leadSourceID));
                        contact.setLeadSource(leadSource);
                    }
                    String campaignID = row
                            .get(getText("entity.campaign_id.label"));
                    if (CommonUtil.isNullOrEmpty(campaignID)) {
                        contact.setCampaign(null);
                    } else {
                        Campaign campaign = campaignService.getEntityById(
                                Campaign.class, Integer.parseInt(campaignID));
                        contact.setCampaign(campaign);
                    }
                    String assignedToID = row
                            .get(getText("entity.assigned_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(assignedToID)) {
                        contact.setAssigned_to(null);
                    } else {
                        User assignedTo = userService.getEntityById(User.class,
                                Integer.parseInt(assignedToID));
                        contact.setAssigned_to(assignedTo);
                    }
                    baseService.makePersistent(contact);
                    successfulNum++;
                } catch (Exception e) {
                    failedNum++;
                    String firstName = CommonUtil.fromNullToEmpty(contact
                            .getFirst_name());
                    String lastName = CommonUtil.fromNullToEmpty(contact
                            .getLast_name());
                    failedMsg.put(firstName + " " + lastName, e.getMessage());
                }

            }

            this.setFailedMsg(failedMsg);
            this.setFailedNum(failedNum);
            this.setSuccessfulNum(successfulNum);
            this.setTotalNum(successfulNum + failedNum);
        } finally {
            reader.close();
        }
        return SUCCESS;
    }
View Full Code Here

     *
     * @return the SUCCESS result
     */
    public String importCSV() throws Exception {
        File file = this.getUpload();
        CsvListReader reader = new CsvListReader(new FileReader(file),
                CsvPreference.EXCEL_PREFERENCE);
        int failedNum = 0;
        int successfulNum = 0;
        try {
            final String[] header = reader.getCSVHeader(true);

            List<String> line = new ArrayList<String>();
            Map<String, String> failedMsg = new HashMap<String, String>();
            while ((line = reader.read()) != null) {

                Map<String, String> row = new HashMap<String, String>();
                for (int i = 0; i < line.size(); i++) {
                    row.put(header[i], line.get(i));
                }

                Call call = new Call();
                try {
                    String id = row.get(getText("entity.id.label"));
                    if (!CommonUtil.isNullOrEmpty(id)) {
                        call.setId(Integer.parseInt(id));
                        UserUtil.permissionCheck("update_call");
                    } else {
                        UserUtil.permissionCheck("create_call");
                    }
                    call.setSubject(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.subject.label"))));
                    String directionID = row
                            .get(getText("call.direction_id.label"));
                    if (CommonUtil.isNullOrEmpty(directionID)) {
                        call.setDirection(null);
                    } else {
                        CallDirection callDirection = callDirectionService
                                .getEntityById(CallDirection.class,
                                        Integer.parseInt(directionID));
                        call.setDirection(callDirection);
                    }
                    String statusID = row
                            .get(getText("entity.status_id.label"));
                    if (CommonUtil.isNullOrEmpty(statusID)) {
                        call.setStatus(null);
                    } else {
                        CallStatus status = callStatusService.getEntityById(
                                CallStatus.class, Integer.parseInt(statusID));
                        call.setStatus(status);
                    }
                    SimpleDateFormat dateFormat = new SimpleDateFormat(
                            Constant.DATE_TIME_FORMAT);
                    String startDateS = row
                            .get(getText("entity.start_date.label"));
                    if (startDateS != null) {
                        Date startDate = dateFormat.parse(startDateS);
                        call.setStart_date(startDate);
                    } else {
                        call.setStart_date(null);
                    }
                    String reminderWayEmail = row
                            .get(getText("entity.reminder_email.label"));
                    if (CommonUtil.isNullOrEmpty(reminderWayEmail)) {
                        call.setReminder_email(false);
                    } else {
                        call.setReminder_email(Boolean
                                .parseBoolean(reminderWayEmail));
                    }
                    String reminderOptionEmailID = row
                            .get(getText("entity.reminder_option_email_id.label"));
                    if (CommonUtil.isNullOrEmpty(reminderOptionEmailID)) {
                        call.setReminder_option_email(null);
                    } else {
                        ReminderOption reminderOption = reminderOptionService
                                .getEntityById(ReminderOption.class,
                                        Integer.parseInt(reminderOptionEmailID));
                        call.setReminder_option_email(reminderOption);
                    }
                    call.setNotes(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.notes.label"))));
                    String assignedToID = row
                            .get(getText("entity.assigned_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(assignedToID)) {
                        call.setAssigned_to(null);
                    } else {
                        User assignedTo = userService.getEntityById(User.class,
                                Integer.parseInt(assignedToID));
                        call.setAssigned_to(assignedTo);
                    }
                    baseService.makePersistent(call);
                    successfulNum++;
                } catch (Exception e) {
                    failedNum++;
                    failedMsg.put(call.getSubject(), e.getMessage());
                }

            }

            this.setFailedMsg(failedMsg);
            this.setFailedNum(failedNum);
            this.setSuccessfulNum(successfulNum);
            this.setTotalNum(successfulNum + failedNum);
        } finally {
            reader.close();
        }
        return SUCCESS;
    }
View Full Code Here

     *
     * @return the SUCCESS result
     */
    public String importCSV() throws Exception {
        File file = this.getUpload();
        CsvListReader reader = new CsvListReader(new FileReader(file),
                CsvPreference.EXCEL_PREFERENCE);
        int failedNum = 0;
        int successfulNum = 0;
        try {
            final String[] header = reader.getCSVHeader(true);

            List<String> line = new ArrayList<String>();
            Map<String, String> failedMsg = new HashMap<String, String>();
            while ((line = reader.read()) != null) {

                Map<String, String> row = new HashMap<String, String>();
                for (int i = 0; i < line.size(); i++) {
                    row.put(header[i], line.get(i));
                }

                Lead lead = new Lead();
                try {
                    String id = row.get(getText("entity.id.label"));
                    if (!CommonUtil.isNullOrEmpty(id)) {
                        lead.setId(Integer.parseInt(id));
                    }
                    String salutationID = row
                            .get(getText("entity.salutation_id.label"));
                    if (CommonUtil.isNullOrEmpty(salutationID)) {
                        lead.setSalutation(null);
                    } else {
                        Salutation salutation = salutationService
                                .getEntityById(Salutation.class,
                                        Integer.parseInt(salutationID));
                        lead.setSalutation(salutation);
                    }
                    lead.setFirst_name(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.first_name.label"))));
                    lead.setLast_name(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.last_name.label"))));
                    lead.setOffice_phone(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.office_phone.label"))));
                    lead.setCompany(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.company.label"))));
                    lead.setTitle(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.title.label"))));
                    lead.setMobile(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.mobile.label"))));
                    lead.setDepartment(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.department.label"))));
                    lead.setFax(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.fax.label"))));
                    String accountID = row
                            .get(getText("entity.account_id.label"));
                    if (CommonUtil.isNullOrEmpty(accountID)) {
                        lead.setAccount(null);
                    } else {
                        Account account = accountService.getEntityById(
                                Account.class, Integer.parseInt(accountID));
                        lead.setAccount(account);
                    }
                    lead.setPrimary_street(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_street.label"))));
                    lead.setPrimary_city(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_city.label"))));
                    lead.setPrimary_state(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_state.label"))));
                    lead.setPrimary_postal_code(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_postal_code.label"))));
                    lead.setPrimary_country(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.primary_country.label"))));
                    lead.setOther_street(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_street.label"))));
                    lead.setOther_city(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_city.label"))));
                    lead.setOther_state(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_state.label"))));
                    lead.setOther_postal_code(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_postal_code.label"))));
                    lead.setOther_country(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.other_country.label"))));
                    lead.setEmail(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.email.label"))));
                    lead.setNotes(CommonUtil.fromNullToEmpty(row
                            .get(getText("entity.notes.label"))));
                    String statusID = row
                            .get(getText("entity.status_id.label"));
                    if (CommonUtil.isNullOrEmpty(statusID)) {
                        lead.setStatus(null);
                    } else {
                        LeadStatus leadStatus = leadStatusService
                                .getEntityById(LeadStatus.class,
                                        Integer.parseInt(statusID));
                        lead.setStatus(leadStatus);
                    }
                    lead.setStatus_description(CommonUtil.fromNullToEmpty(row
                            .get(getText("lead.status_description.label"))));
                    String leadSourceID = row
                            .get(getText("entity.leadSource_id.label"));
                    if (CommonUtil.isNullOrEmpty(leadSourceID)) {
                        lead.setLead_source(null);
                    } else {
                        LeadSource leadSource = leadSourceService
                                .getEntityById(LeadSource.class,
                                        Integer.parseInt(leadSourceID));
                        lead.setLead_source(leadSource);
                    }
                    lead.setLead_source_description(CommonUtil.fromNullToEmpty(row
                            .get(getText("lead.lead_source_description.label"))));
                    lead.setOpportunity_amount(CommonUtil.fromNullToEmpty(row
                            .get(getText("lead.opportunity_amount.label"))));
                    lead.setReferred_by(CommonUtil.fromNullToEmpty(row
                            .get(getText("lead.referred_by.label"))));
                    String campaignID = row
                            .get(getText("entity.campaign_id.label"));
                    if (CommonUtil.isNullOrEmpty(campaignID)) {
                        lead.setCampaign(null);
                    } else {
                        Campaign campaign = campaignService.getEntityById(
                                Campaign.class, Integer.parseInt(campaignID));
                        lead.setCampaign(campaign);
                    }
                    String doNotCall = row
                            .get(getText("entity.not_call.label"));
                    if (CommonUtil.isNullOrEmpty(doNotCall)) {
                        lead.setNot_call(false);
                    } else {
                        lead.setNot_call(Boolean.parseBoolean(doNotCall));
                    }
                    String assignedToID = row
                            .get(getText("entity.assigned_to_id.label"));
                    if (CommonUtil.isNullOrEmpty(assignedToID)) {
                        lead.setAssigned_to(null);
                    } else {
                        User assignedTo = userService.getEntityById(User.class,
                                Integer.parseInt(assignedToID));
                        lead.setAssigned_to(assignedTo);
                    }
                    baseService.makePersistent(lead);
                    successfulNum++;
                } catch (Exception e) {
                    failedNum++;
                    String firstName = CommonUtil.fromNullToEmpty(lead
                            .getFirst_name());
                    String lastName = CommonUtil.fromNullToEmpty(lead
                            .getLast_name());
                    failedMsg.put(firstName + " " + lastName, e.getMessage());
                }

            }

            this.setFailedMsg(failedMsg);
            this.setFailedNum(failedNum);
            this.setSuccessfulNum(successfulNum);
            this.setTotalNum(successfulNum + failedNum);
        } finally {
            reader.close();
        }
        return SUCCESS;
    }
View Full Code Here

TOP

Related Classes of org.supercsv.io.CsvListReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.