Package com.gcrm.domain

Examples of com.gcrm.domain.Lead


     * Saves the entity.
     *
     * @return the SUCCESS result
     */
    public String save() throws Exception {
        Lead originalLead = saveEntity();
        final Collection<ChangeLog> changeLogs = changeLog(originalLead, lead);
        lead = this.getBaseService().makePersistent(lead);
        this.setId(lead.getId());
        this.setSaveFlag("true");
        if (changeLogs != null) {
View Full Code Here


            User user = userService
                    .getEntityById(User.class, loginUser.getId());
            Collection<ChangeLog> allChangeLogs = new ArrayList<ChangeLog>();
            for (String IDString : selectIDArray) {
                int id = Integer.parseInt(IDString);
                Lead leadInstance = this.baseService.getEntityById(Lead.class,
                        id);
                Lead originalLead = leadInstance.clone();
                for (String fieldName : fieldNames) {
                    Object value = BeanUtil.getFieldValue(lead, fieldName);
                    BeanUtil.setFieldValue(leadInstance, fieldName, value);
                }
                leadInstance.setUpdated_by(user);
View Full Code Here

     *
     * @return original lead record
     * @throws Exception
     */
    private Lead saveEntity() throws Exception {
        Lead originalLead = null;
        if (lead.getId() == null) {
            UserUtil.permissionCheck("create_lead");
        } else {
            UserUtil.permissionCheck("update_lead");
            originalLead = baseService.getEntityById(Lead.class, lead.getId());
            lead.setContacts(originalLead.getContacts());
            lead.setOpportunities(originalLead.getOpportunities());
            lead.setTargetLists(originalLead.getTargetLists());
            lead.setCalls(originalLead.getCalls());
            lead.setMeetings(originalLead.getMeetings());
            lead.setCreated_on(originalLead.getCreated_on());
            lead.setCreated_by(originalLead.getCreated_by());
        }

        Account account = null;
        if (accountID != null) {
            account = accountService.getEntityById(Account.class, accountID);
View Full Code Here

                .append(getJsonHeader(totalRecords, searchCondition, isList));

        String assignedTo = null;
        String accountName = null;
        while (leads.hasNext()) {
            Lead instance = leads.next();
            int id = instance.getId();
            String firstName = CommonUtil.fromNullToEmpty(instance
                    .getFirst_name());
            String lastName = CommonUtil.fromNullToEmpty(instance
                    .getLast_name());
            String name = instance.getName();
            String title = CommonUtil.fromNullToEmpty(instance.getTitle());

            Account account = instance.getAccount();
            if (account != null) {
                accountName = CommonUtil.fromNullToEmpty(account.getName());
            } else {
                accountName = "";
            }
            String email = CommonUtil.fromNullToEmpty(instance.getEmail());
            String officePhone = CommonUtil.fromNullToEmpty(instance
                    .getOffice_phone());
            User user = instance.getAssigned_to();
            if (user != null) {
                assignedTo = CommonUtil.fromNullToEmpty(user.getName());
            } else {
                assignedTo = "";
            }
            if (isList) {
                User createdBy = instance.getCreated_by();
                String createdByName = "";
                if (createdBy != null) {
                    createdByName = CommonUtil.fromNullToEmpty(createdBy
                            .getName());
                }
                User updatedBy = instance.getUpdated_by();
                String updatedByName = "";
                if (updatedBy != null) {
                    updatedByName = CommonUtil.fromNullToEmpty(updatedBy
                            .getName());
                }
                SimpleDateFormat dateFormat = new SimpleDateFormat(
                        Constant.DATE_TIME_FORMAT);
                Date createdOn = instance.getCreated_on();
                String createdOnName = "";
                if (createdOn != null) {
                    createdOnName = dateFormat.format(createdOn);
                }
                Date updatedOn = instance.getUpdated_on();
                String updatedOnName = "";
                if (updatedOn != null) {
                    updatedOnName = dateFormat.format(updatedOn);
                }
View Full Code Here

        UserUtil.permissionCheck("create_lead");
        if (this.getSeleteIDs() != null) {
            String[] ids = seleteIDs.split(",");
            for (int i = 0; i < ids.length; i++) {
                String copyid = ids[i];
                Lead oriRecord = baseService.getEntityById(Lead.class,
                        Integer.valueOf(copyid));
                Lead targetRecord = oriRecord.clone();
                targetRecord.setId(null);
                this.getbaseService().makePersistent(targetRecord);
            }
        }
        return SUCCESS;
    }
View Full Code Here

            writer.writeHeader(header);
            if (!isTemplate) {
                String[] ids = seleteIDs.split(",");
                for (int i = 0; i < ids.length; i++) {
                    String id = ids[i];
                    Lead lead = baseService.getEntityById(Lead.class,
                            Integer.parseInt(id));
                    final HashMap<String, ? super Object> data1 = new HashMap<String, Object>();
                    data1.put(header[0], lead.getId());
                    Salutation salutation = lead.getSalutation();
                    if (salutation != null) {
                        data1.put(header[1], salutation.getId());
                    } else {
                        data1.put(header[1], "");
                    }
                    data1.put(header[2], CommonUtil.getOptionLabel(salutation));
                    data1.put(header[3],
                            CommonUtil.fromNullToEmpty(lead.getFirst_name()));
                    data1.put(header[4],
                            CommonUtil.fromNullToEmpty(lead.getLast_name()));
                    data1.put(header[5],
                            CommonUtil.fromNullToEmpty(lead.getOffice_phone()));
                    data1.put(header[6],
                            CommonUtil.fromNullToEmpty(lead.getCompany()));
                    data1.put(header[7],
                            CommonUtil.fromNullToEmpty(lead.getTitle()));
                    data1.put(header[8],
                            CommonUtil.fromNullToEmpty(lead.getMobile()));
                    data1.put(header[9],
                            CommonUtil.fromNullToEmpty(lead.getDepartment()));
                    data1.put(header[10],
                            CommonUtil.fromNullToEmpty(lead.getFax()));
                    if (lead.getAccount() != null) {
                        data1.put(header[11], lead.getAccount().getId());
                        data1.put(header[12], lead.getAccount().getName());
                    } else {
                        data1.put(header[11], "");
                        data1.put(header[12], "");
                    }
                    data1.put(header[13], CommonUtil.fromNullToEmpty(lead
                            .getPrimary_street()));
                    data1.put(header[14],
                            CommonUtil.fromNullToEmpty(lead.getPrimary_city()));
                    data1.put(header[15],
                            CommonUtil.fromNullToEmpty(lead.getPrimary_state()));
                    data1.put(header[16], CommonUtil.fromNullToEmpty(lead
                            .getPrimary_postal_code()));
                    data1.put(header[17], CommonUtil.fromNullToEmpty(lead
                            .getPrimary_country()));
                    data1.put(header[18],
                            CommonUtil.fromNullToEmpty(lead.getOther_street()));
                    data1.put(header[19],
                            CommonUtil.fromNullToEmpty(lead.getOther_city()));
                    data1.put(header[20],
                            CommonUtil.fromNullToEmpty(lead.getOther_state()));
                    data1.put(header[21], CommonUtil.fromNullToEmpty(lead
                            .getOther_postal_code()));
                    data1.put(header[22],
                            CommonUtil.fromNullToEmpty(lead.getOther_country()));
                    data1.put(header[23],
                            CommonUtil.fromNullToEmpty(lead.getEmail()));
                    data1.put(header[24],
                            CommonUtil.fromNullToEmpty(lead.getNotes()));
                    LeadStatus leadStatus = lead.getStatus();
                    if (leadStatus != null) {
                        data1.put(header[25], leadStatus.getId());
                    } else {
                        data1.put(header[25], "");
                    }
                    data1.put(header[26], CommonUtil.getOptionLabel(leadStatus));
                    data1.put(header[27], CommonUtil.fromNullToEmpty(lead
                            .getStatus_description()));
                    LeadSource leadSource = lead.getLead_source();
                    if (leadSource != null) {
                        data1.put(header[28], leadSource.getId());
                    } else {
                        data1.put(header[28], "");
                    }
                    data1.put(header[29], CommonUtil.getOptionLabel(leadSource));
                    data1.put(header[30], CommonUtil.fromNullToEmpty(lead
                            .getLead_source_description()));
                    data1.put(header[31], CommonUtil.fromNullToEmpty(lead
                            .getOpportunity_amount()));
                    data1.put(header[32],
                            CommonUtil.fromNullToEmpty(lead.getReferred_by()));
                    if (lead.getCampaign() != null) {
                        data1.put(header[33], lead.getCampaign().getId());
                        data1.put(header[34], lead.getCampaign().getName());
                    } else {
                        data1.put(header[33], "");
                        data1.put(header[34], "");
                    }
                    data1.put(header[35], lead.isNot_call());
                    if (lead.getAssigned_to() != null) {
                        data1.put(header[36], lead.getAssigned_to().getId());
                        data1.put(header[37], lead.getAssigned_to().getName());
                    } else {
                        data1.put(header[36], "");
                        data1.put(header[37], "");
                    }
                    writer.write(data1, header);
View Full Code Here

                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());
                }

            }
View Full Code Here

     *
     * @see com.gcrm.service.ITargetService#convert(java.lang.Integer)
     */
    public void convert(Integer id) throws Exception {
        Target target = this.getEntityById(Target.class, id);
        Lead lead = new Lead();
        lead.setSalutation(target.getSalutation());
        lead.setFirst_name(target.getFirst_name());
        lead.setLast_name(target.getLast_name());
        lead.setOffice_phone(target.getOffice_phone());
        lead.setCompany(target.getCompany());
        lead.setTitle(target.getTitle());
        lead.setMobile(target.getMobile());
        lead.setDepartment(target.getDepartment());
        lead.setFax(target.getFax());
        lead.setAccount(target.getAccount());
        lead.setPrimary_street(target.getPrimary_street());
        lead.setPrimary_city(target.getPrimary_city());
        lead.setPrimary_country(target.getPrimary_country());
        lead.setPrimary_postal_code(target.getPrimary_postal_code());
        lead.setPrimary_state(target.getPrimary_state());
        lead.setOther_street(target.getOther_street());
        lead.setOther_city(target.getOther_city());
        lead.setOther_country(target.getOther_country());
        lead.setOther_postal_code(target.getOther_postal_code());
        lead.setOther_state(target.getOther_state());
        lead.setEmail(target.getEmail());
        lead.setNotes(target.getNotes());
        lead.setNot_call(target.isNot_call());
        lead.setAssigned_to(target.getAssigned_to());
        lead.setOwner(target.getOwner());
        LeadStatus status = this.getLeadStatusService().findByName(
                LeadStatus.class.getSimpleName(), "New");
        lead.setStatus(status);
        lead = this.getLeadService().makePersistent(lead);
        target.setLead_id(lead.getId());
        this.makePersistent(target);

    }
View Full Code Here

     * @see com.gcrm.service.ILeadService#convert(java.lang.Integer, boolean,
     * boolean, boolean)
     */
    public void convert(Integer id, boolean accountCheck, boolean contactCheck,
            boolean opportunityCheck) throws Exception {
        Lead lead = this.getEntityById(Lead.class, id);
        if (accountCheck) {
            Account account = new Account();
            String firstName = CommonUtil.fromNullToEmpty(lead.getFirst_name());
            String lastName = CommonUtil.fromNullToEmpty(lead.getLast_name());
            account.setName(firstName + " " + lastName);
            account.setOffice_phone(lead.getOffice_phone());
            account.setFax(lead.getFax());
            account.setBill_street(lead.getPrimary_street());
            account.setBill_city(lead.getPrimary_city());
            account.setBill_country(lead.getPrimary_country());
            account.setBill_postal_code(lead.getPrimary_postal_code());
            account.setBill_state(lead.getPrimary_state());
            account.setShip_street(lead.getOther_street());
            account.setShip_city(lead.getOther_city());
            account.setShip_country(lead.getOther_country());
            account.setShip_postal_code(lead.getOther_postal_code());
            account.setShip_state(lead.getOther_state());
            account.setEmail(lead.getEmail());
            account.setNotes(lead.getNotes());
            account.setAssigned_to(lead.getAssigned_to());
            account.setOwner(lead.getOwner());
            this.getAccountService().makePersistent(account);
        }
        if (contactCheck) {
            Contact contact = new Contact();
            contact.setSalutation(lead.getSalutation());
            contact.setFirst_name(lead.getFirst_name());
            contact.setLast_name(lead.getLast_name());
            contact.setOffice_phone(lead.getOffice_phone());
            contact.setTitle(lead.getTitle());
            contact.setMobile(lead.getMobile());
            contact.setDepartment(lead.getDepartment());
            contact.setFax(lead.getFax());
            contact.setAccount(lead.getAccount());
            contact.setPrimary_street(lead.getPrimary_street());
            contact.setPrimary_city(lead.getPrimary_city());
            contact.setPrimary_country(lead.getPrimary_country());
            contact.setPrimary_postal_code(lead.getPrimary_postal_code());
            contact.setPrimary_state(lead.getPrimary_state());
            contact.setOther_street(lead.getOther_street());
            contact.setOther_city(lead.getOther_city());
            contact.setOther_country(lead.getOther_country());
            contact.setOther_postal_code(lead.getOther_postal_code());
            contact.setOther_state(lead.getOther_state());
            contact.setEmail(lead.getEmail());
            contact.setNotes(lead.getNotes());
            contact.setCampaign(lead.getCampaign());
            contact.setNot_call(lead.isNot_call());
            contact.setAssigned_to(lead.getAssigned_to());
            contact.setOwner(lead.getOwner());
            this.getContactService().makePersistent(contact);
        }
        if (opportunityCheck) {
            Opportunity opportunity = new Opportunity();
            String firstName = CommonUtil.fromNullToEmpty(lead.getFirst_name());
            String lastName = CommonUtil.fromNullToEmpty(lead.getLast_name());
            opportunity.setName(firstName + " " + lastName);
            opportunity.setCampaign(lead.getCampaign());
            opportunity.setAssigned_to(lead.getAssigned_to());
            opportunity.setOwner(lead.getOwner());
            this.getOpportunityService().makePersistent(opportunity);
        }
        LeadStatus status = this.getLeadStatusService().findByValue(
                LeadStatus.class.getSimpleName(), "Converted");
        lead.setStatus(status);
        this.makePersistent(lead);
    }
View Full Code Here

TOP

Related Classes of com.gcrm.domain.Lead

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.