Package com.gcrm.domain

Examples of com.gcrm.domain.Opportunity


     * Saves the entity.
     *
     * @return the SUCCESS result
     */
    public String save() throws Exception {
        Opportunity originalOpportunity = saveEntity();
        final Collection<ChangeLog> changeLogs = changeLog(originalOpportunity,
                opportunity);
        opportunity = getBaseService().makePersistent(opportunity);
        this.setId(opportunity.getId());
        this.setSaveFlag("true");
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);
                Opportunity opportunityInstance = this.baseService
                        .getEntityById(Opportunity.class, id);
                Opportunity originalOpportunity = opportunityInstance.clone();
                for (String fieldName : fieldNames) {
                    Object value = BeanUtil.getFieldValue(opportunity,
                            fieldName);
                    BeanUtil.setFieldValue(opportunityInstance, fieldName,
                            value);
View Full Code Here

     *
     * @return original opportunity record
     * @throws ParseException
     */
    private Opportunity saveEntity() throws Exception {
        Opportunity originalOpportunity = null;
        if (opportunity.getId() == null) {
            UserUtil.permissionCheck("create_opportunity");
        } else {
            UserUtil.permissionCheck("update_opportunity");
            originalOpportunity = baseService.getEntityById(Opportunity.class,
                    opportunity.getId());
            opportunity.setContacts(originalOpportunity.getContacts());
            opportunity.setLeads(originalOpportunity.getLeads());
            opportunity.setDocuments(originalOpportunity.getDocuments());
            opportunity.setCreated_on(originalOpportunity.getCreated_on());
            opportunity.setCreated_by(originalOpportunity.getCreated_by());
        }

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

        String assignedTo = null;
        String accountName = null;
        String stageName = null;
        while (opportunitys.hasNext()) {
            Opportunity instance = opportunitys.next();
            int id = instance.getId();
            String name = CommonUtil.fromNullToEmpty(instance.getName());
            Account account = instance.getAccount();
            if (account != null) {
                accountName = CommonUtil.fromNullToEmpty(account.getName());
            } else {
                accountName = "";
            }
            SalesStage salesStage = instance.getSales_stage();
            stageName = CommonUtil.getOptionLabel(salesStage);
            String amount = CommonUtil.fromNullToEmpty(instance
                    .getOpportunity_amount());
            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_opportunity");
        if (this.getSeleteIDs() != null) {
            String[] ids = seleteIDs.split(",");
            for (int i = 0; i < ids.length; i++) {
                String copyid = ids[i];
                Opportunity oriRecord = baseService.getEntityById(
                        Opportunity.class, Integer.valueOf(copyid));
                Opportunity 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];
                    Opportunity opportunity = baseService.getEntityById(
                            Opportunity.class, Integer.parseInt(id));
                    final HashMap<String, ? super Object> data1 = new HashMap<String, Object>();
                    data1.put(header[0], opportunity.getId());
                    data1.put(header[1],
                            CommonUtil.fromNullToEmpty(opportunity.getName()));
                    if (opportunity.getAccount() != null) {
                        data1.put(header[2], opportunity.getAccount().getId());
                        data1.put(header[3], opportunity.getAccount().getName());
                    } else {
                        data1.put(header[2], "");
                        data1.put(header[3], "");
                    }
                    if (opportunity.getCurrency() != null) {
                        data1.put(header[4], opportunity.getCurrency().getId());
                        data1.put(header[5], opportunity.getCurrency()
                                .getName());
                    } else {
                        data1.put(header[4], "");
                        data1.put(header[5], "");
                    }
                    Date expectCloseDate = opportunity.getExpect_close_date();
                    SimpleDateFormat dateFormat = new SimpleDateFormat(
                            Constant.DATE_EDIT_FORMAT);
                    if (expectCloseDate != null) {
                        data1.put(header[6], dateFormat.format(expectCloseDate));
                    } else {
                        data1.put(header[6], "");
                    }
                    data1.put(header[7], CommonUtil.fromNullToEmpty(opportunity
                            .getOpportunity_amount()));
                    OpportunityType opportunityType = opportunity.getType();
                    if (opportunityType != null) {
                        data1.put(header[8], opportunityType.getId());
                    } else {
                        data1.put(header[8], "");
                    }
                    data1.put(header[9],
                            CommonUtil.getOptionLabel(opportunityType));
                    SalesStage salesStage = opportunity.getSales_stage();
                    if (salesStage != null) {
                        data1.put(header[10], salesStage.getId());
                    } else {
                        data1.put(header[10], "");
                    }
                    data1.put(header[11], CommonUtil.getOptionLabel(salesStage));
                    LeadSource leadSource = opportunity.getLead_source();
                    if (leadSource != null) {
                        data1.put(header[12], leadSource.getId());
                    } else {
                        data1.put(header[12], "");
                    }
                    data1.put(header[13], CommonUtil.getOptionLabel(leadSource));
                    data1.put(header[14], opportunity.getProbability());

                    if (opportunity.getCampaign() != null) {
                        data1.put(header[15], opportunity.getCampaign().getId());
                        data1.put(header[16], opportunity.getCampaign()
                                .getName());
                    } else {
                        data1.put(header[15], "");
                        data1.put(header[16], "");
                    }
                    data1.put(header[17], CommonUtil
                            .fromNullToEmpty(opportunity.getNext_step()));
                    data1.put(header[18],
                            CommonUtil.fromNullToEmpty(opportunity.getNotes()));
                    if (opportunity.getAssigned_to() != null) {
                        data1.put(header[19], opportunity.getAssigned_to()
                                .getId());
                        data1.put(header[20], opportunity.getAssigned_to()
                                .getName());
                    } else {
                        data1.put(header[21], "");
                        data1.put(header[22], "");
                    }
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));
                }

                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);
View Full Code Here

            contact.setFileName(this.uploadFileName);
            attachment.setContent(input);
        }

        if ("Opportunity".equals(this.getRelationKey())) {
            Opportunity opportunity = opportunityService
                    .getEntityById(Opportunity.class,
                            Integer.valueOf(this.getRelationValue()));
            Set<Opportunity> opportunities = contact.getOpportunities();
            if (opportunities == null) {
                opportunities = new HashSet<Opportunity>();
View Full Code Here

            if (contacts == null) {
                contacts = new HashSet<Contact>();
            }
            contacts.add(contact);
        } else if ("Opportunity".equals(this.getRelationKey())) {
            Opportunity opportunity = opportunityService
                    .getEntityById(Opportunity.class,
                            Integer.valueOf(this.getRelationValue()));
            Set<Opportunity> opportunities = document.getOpportunities();
            if (opportunities == null) {
                opportunities = new HashSet<Opportunity>();
View Full Code Here

     * @return the SUCCESS result
     */
    public String select() throws ServiceException {
        Account account = null;
        Contact contact = null;
        Opportunity opportunity = null;
        CaseInstance caseInstance = null;
        Document document = null;
        Set<Document> documents = null;
        if ("Account".equals(this.getRelationKey())) {
            account = accountService.getEntityById(Account.class,
                    Integer.valueOf(this.getRelationValue()));
            documents = account.getDocuments();
        } else if ("Contact".equals(this.getRelationKey())) {
            contact = contactService.getEntityById(Contact.class,
                    Integer.valueOf(this.getRelationValue()));
            documents = contact.getDocuments();
        } else if ("Opportunity".equals(this.getRelationKey())) {
            opportunity = opportunityService.getEntityById(Opportunity.class,
                    Integer.valueOf(this.getRelationValue()));
            documents = opportunity.getDocuments();
        } else if ("CaseInstance".equals(this.getRelationKey())) {
            caseInstance = caseService.getEntityById(CaseInstance.class,
                    Integer.valueOf(this.getRelationValue()));
            documents = caseInstance.getDocuments();
        }
View Full Code Here

TOP

Related Classes of com.gcrm.domain.Opportunity

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.