⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 leadconverter.java

📁 国外的一套开源CRM
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			List partyIdentifiers = delegator.findByAnd("PartyIdentifier", UtilMisc.toMap("partyId", leadId), null);
			String partyId = contactId;
			String partyType = "Contact";
			if ( hasAccountInfo )
			{
			    partyType = "Account";
			    partyId = accountId;

			    Iterator identIter = partyIdentifiers.iterator();
				while ( identIter.hasNext())
				{
				    GenericValue gv = (GenericValue) identIter.next();
				    gv.set("partyId", accountId);
				}
				delegator.storeAll(partyIdentifiers);
			}
			if ( getCreateContact() )
			{
				Iterator identIter = partyIdentifiers.iterator();
				while ( identIter.hasNext())
				{
				    GenericValue gv = (GenericValue) identIter.next();
				    gv.set("partyId", contactId);
				}
				delegator.storeAll(partyIdentifiers);
			}
			
			delegator.removeByAnd("PartyIdentifier", UtilMisc.toMap("partyId", leadId));
			
			//Activities are mapped to the contact and account
			List activities = delegator.findByAnd("Activity", UtilMisc.toMap("leadId", leadId), null);
			Iterator actIter = activities.iterator();
			while ( actIter.hasNext())
			{
			    GenericValue gv = (GenericValue) actIter.next();
			    gv.set("accountId", accountId);
			    gv.set("contactId", contactId);
			}
			delegator.storeAll(activities);
			
			//Notes are mapped to the account
			List notes = delegator.findByAnd("NoteLink", UtilMisc.toMap("noteLinkType", "Lead", "noteLinkId", leadId), null);
			delegator.removeByAnd("NoteLink", UtilMisc.toMap("noteLinkType", "Lead", "noteLinkId", leadId));
			Iterator noteIter = notes.iterator();
			while ( noteIter.hasNext())
			{
			    GenericValue gv = (GenericValue) noteIter.next();
			    gv.set("noteLinkType", partyType);
			    gv.set("noteLinkId", partyId);
			}
			delegator.storeAll(notes);
			
			//File attachments are mapped to account and contact
			List leadFiles = delegator.findByAnd("LeadFile", UtilMisc.toMap("leadId", leadId), null);
			delegator.removeByAnd("LeadFile", UtilMisc.toMap("leadId", leadId));
			Iterator fileIter = leadFiles.iterator();
			while ( fileIter.hasNext())
			{
			    GenericValue gv = (GenericValue) fileIter.next();
			    
			    if ( hasAccountInfo )
			    {
				    GenericValue accountFile = new GenericValue(delegator.getModelEntity("AccountFile"));
				    accountFile.setDelegator(delegator);
				    accountFile.set("accountId", accountId);
				    accountFile.set("fileId", gv.get("fileId"));
				    accountFile.set("createdBy", gv.get("createdBy"));
				    accountFile.set("modifiedBy",gv.get("modifiedBy"));
				    accountFile.set("createdDate", gv.get("createdDate"));
				    accountFile.set("modifiedDate",gv.get("modifiedDate"));
				    accountFile.create();
			    }
			    
			    if ( getCreateContact() )
			    {
				    GenericValue contactFile = new GenericValue(delegator.getModelEntity("ContactFile"));
				    contactFile.setDelegator(delegator);
				    contactFile.set("contactId", contactId);
				    contactFile.set("fileId", gv.get("fileId"));
				    contactFile.set("createdBy", gv.get("createdBy"));
				    contactFile.set("modifiedBy",gv.get("modifiedBy"));
				    contactFile.set("createdDate", gv.get("createdDate"));
				    contactFile.set("modifiedDate",gv.get("modifiedDate"));
				    contactFile.create();
			    }			    
			}
			
			// update the converted date on the lead.
			Timestamp now = new Timestamp(Calendar.getInstance().getTime().getTime());
			leadGV.set("convertedDate", now);
			leadGV.set("convertedAccountId", accountId);
			leadGV.set("convertedContactId", contactId);
			delegator.store(leadGV);
			
			return true;

		}
		catch ( Exception e)
		{
			Debug.logError(e, module);
		    return false;
		}
	}

	
	public class MappingInfo {
		public String fromEntity;
		public String fromAttribute;
		public String toEntity;
		public String toAttribute;
		public String toParamName;
		public String screenName;
		public String screenSection;
		
		public MappingInfo( String fromEntityStr, String fromAttributeStr, String screenNameStr, String screenSectionStr, String toEntityStr, String toAttributeStr)
		{
			fromEntity = fromEntityStr;
			fromAttribute = fromAttributeStr;
			toEntity = toEntityStr;
			toAttribute = toAttributeStr;
			screenName = screenNameStr;
			screenSection = screenSectionStr;
			toParamName = UIWebUtility.getParamName("", screenSection, toEntity, toAttribute, 0);
		}
	}
	
	public class DataInfo
	{
		UIWebScreenSection uiWebScreenSection;
		DataMatrix dataMatrix;
		Vector values;
		Vector fields;
		GenericDelegator delegator;
		String[] valuesA;
		
		public DataInfo( GenericDelegator delegator_, UIWebScreenSection uiWebScreenSection_ )
		{
			delegator = delegator_;
			uiWebScreenSection = uiWebScreenSection_;
			dataMatrix = new DataMatrix(delegator, uiWebScreenSection.getEntityParamVector());	
			values = new Vector();
			fields = new Vector();
		}
		
		public void add(String field, String value)
		{
			fields.add(field);
			values.add(value);
		}
	
		public DataMatrix retrieveFromDB(UserInfo userInfo, GenericEventProcessor eventProcessor, GenericPK primaryKey)
			throws GenericEntityException
		{	
			dataMatrix = DataMatrix.fillFromDB(delegator, userInfo, uiWebScreenSection, eventProcessor, primaryKey );
			dataMatrix.addRowFromArray(0, values, fields, uiWebScreenSection);		
			return dataMatrix;
		}

		public DataMatrix loadData(UserInfo userInfo, GenericEventProcessor eventProcessor)
			throws GenericEntityException
		{
			eventProcessor.processCreate( userInfo, uiWebScreenSection.getEntityNameList(), delegator, dataMatrix);
			dataMatrix.addRowFromArray(0, values, fields, uiWebScreenSection);		
			return dataMatrix;	
		}
		
		public void processInsert( UserInfo userInfo, GenericDelegator delegator, GenericEventProcessor eventProcessor)
			throws GenericEntityException
		{
			eventProcessor.processInsert( userInfo, delegator, dataMatrix );
		}

		public void processUpdate( UserInfo userInfo, GenericDelegator delegator, GenericEventProcessor eventProcessor)
			throws GenericEntityException
		{
			eventProcessor.processUpdate( userInfo, delegator, dataMatrix );
		}
	}

	/**
	 * @return
	 */
	public String getAccountId()
	{
		return accountId;
	}

	/**
	 * @return
	 */
	public String getContactId()
	{
		return contactId;
	}

	/**
	 * @return
	 */
	public String getOpportunityName()
	{
		return opportunityName;
	}

	/**
	 * @return
	 */
	public String getOpportunityStageId()
	{
		return opportunityStageId;
	}

	/**
	 * @param string
	 */
	public void setAccountId(String string)
	{
		accountId = string;
	}

	/**
	 * @param string
	 */
	public void setContactId(String string)
	{
		contactId = string;
	}

	/**
	 * @param string
	 */
	public void setOpportunityName(String string)
	{
		opportunityName = string;
	}

	/**
	 * @param string
	 */
	public void setOpportunityStageId(String string)
	{
		opportunityStageId = string;
	}

	/**
	 * @return
	 */
	public String getOpportunityId()
	{
		return opportunityId;
	}

	/**
	 * @param string
	 */
	public void setOpportunityId(String string)
	{
		opportunityId = string;
	}

	/**
	 * @return
	 */
	public boolean getCreateContact()
	{
		return createContact;
	}

	/**
	 * @return
	 */
	public boolean getCreateOpportunity()
	{
		return createOpportunity;
	}

	/**
	 * @param b
	 */
	public void setCreateContact(boolean b)
	{
		createContact = b;
	}

	/**
	 * @param b
	 */
	public void setCreateOpportunity(boolean b)
	{
		createOpportunity = b;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -