package com.ebmwebsourcing.easybpel.usecase.veolia;

import javax.xml.namespace.QName;

import com.ebmwebsourcing.easybpel.model.bpel.api.BPELException;
import com.ebmwebsourcing.easybpel.model.bpel.api.message.BPELExternalMessage;
import com.ebmwebsourcing.easybpel.model.bpel.impl.message.BPELExternalMessageImpl;
import com.ebmwebsourcing.easyviper.core.api.CoreException;
import com.ebmwebsourcing.easyviper.environment.test.env.api.Operation;
import com.ebmwebsourcing.easyviper.environment.test.env.api.ProviderEndpoint;
import com.ebmwebsourcing.easyviper.environment.test.env.api.Service;
import com.ebmwebsourcing.easyviper.environment.test.env.impl.AbstractServiceImpl;
import com.ebmwebsourcing.easyviper.environment.test.env.impl.OperationImpl;

public class AccountService extends AbstractServiceImpl implements Service {


	public AccountService(ProviderEndpoint pep) throws BPELException {
		super(pep);
		this.setName(new QName("urn:crmondemand/ws/account/10/2004", "Account"));

		// Create operation
		Account();
	}

	private void Account() throws BPELException {
		try {
			Operation account = new OperationImpl("AccountQueryPage", Operation.IN_OUT, this);
			this.addOperation(account);


			BPELExternalMessage in = new BPELExternalMessageImpl();
			in.setService(this.getName());
			in.setEndpoint(this.getProviderEndpoint().getName());
			in.setQName(new QName("urn:crmondemand/ws/account/10/2004", "AccountWS_AccountQueryPage_Input"));
			in.setMessage("" +
						"<tns:AccountWS_AccountQueryPage_Input xmlns:tns=\"urn:crmondemand/ws/account/10/2004\">"+
						"<tns:UseChildAnd xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xsd:string\">true</tns:UseChildAnd>"+
						"<tns:PageSize xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xsd:string\">1</tns:PageSize>"+
						"<xsdLocal1:ListOfAccount xmlns:xsdLocal1=\"urn:/crmondemand/xml/account\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xsdLocal1:ListOfAccount\">"+
						"<xsdLocal1:Account xsi:type=\"xsdLocal1:Account\">"+
						"<xsdLocal1:ExternalSystemId xsi:type=\"xsdLocal1:string30\">46546</xsdLocal1:ExternalSystemId>"+
						"</xsdLocal1:Account>"+
						"</xsdLocal1:ListOfAccount>"+
						"<tns:StartRowNum xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xsd:string\">0</tns:StartRowNum>"+
						"</tns:AccountWS_AccountQueryPage_Input> "
			);
			BPELExternalMessage out = new BPELExternalMessageImpl();
			out.setService(this.getName());
			out.setEndpoint(this.getProviderEndpoint().getName());
			out.setQName(new QName("urn:crmondemand/ws/account/10/2004", "AccountWS_AccountQueryPage_Output"));
			out.setMessage("" +
				      "<ns:AccountWS_AccountQueryPage_Output xmlns:ns=\"urn:crmondemand/ws/account/10/2004\">"+
	         "<ns:LastPage>true</ns:LastPage>"+
	         "<ListOfAccount xmlns=\"urn:/crmondemand/xml/account\">"+
	            "<Account>"+
	               "<ExternalSystemId>6699648</ExternalSystemId>"+
	               "<AccountType>Abonnement</AccountType>"+
	               "<ListOfPartner>"+
	                  "<Partner>"+
	                     "<CreatedBy>EAI EAI,  01/23/2009 15:23:30</CreatedBy>"+
	                     "<ModifiedBy>EAI EAI,  10/23/2009 12:23:24</ModifiedBy>"+
	                     "<AccountPartnerId>ADBA-2XAWS1</AccountPartnerId>"+
	                     "<CreatedDate>01/23/2009 15:23:30</CreatedDate>"+
	                     "<ModifiedDate>10/23/2009 12:23:24</ModifiedDate>"+
"                 <ModId>4</ModId>"+
"                 <Comments/>"+
"                 <PrimaryContactName/>"+
"                 <PrimaryContactId/>"+
"                 <EndDate/>"+
"                 <PartnerId>ABWA-EGGXH</PartnerId>"+
"                 <ReverseRelationshipRole>ABO_ACTIF</ReverseRelationshipRole>"+
"                 <RelationshipRole>PDS</RelationshipRole>"+
"                 <StartDate>01/23/2009 12:23:24</StartDate>"+
"                 <Strengths/>"+
"                 <CreatedById>ABWA-DC7AV</CreatedById>"+
"                 <Weaknesses/>"+
"                 <ModifiedById>ABWA-DC7AV</ModifiedById>"+
"                 <PartnerExternalSystemId>022101503600001</PartnerExternalSystemId>"+
"                 <PartnerIntegrationId>ABWA-EGGXH</PartnerIntegrationId>"+
"              </Partner>"+
"           </ListOfPartner>"+
"           <ListOfContactRole>"+
"              <ContactRole>"+
"                 <ModId>0</ModId>"+
"                 <ContactRole>ABO</ContactRole>"+
"                 <ContactId>ADBA-2XAWRU</ContactId>"+
"                 <ModifiedDate>10/23/2009 12:23:26</ModifiedDate>"+
"                 <ModifiedById>ABWA-DC7AV</ModifiedById>"+
"                 <ModifiedBy>EAI EAI,  10/23/2009 12:23:26</ModifiedBy>"+
"                 <CreatedDate>10/23/2009 12:23:26</CreatedDate>"+
"                <CreatedById>ABWA-DC7AV</CreatedById>"+
"                 <CreatedBy>EAI EAI,  10/23/2009 12:23:26</CreatedBy>"+
"                 <ContactIntegrationId>ADBA-2XAWRU</ContactIntegrationId>"+
"                 <ContactExternalId>25722947</ContactExternalId>"+
"              </ContactRole>"+
"              <ContactRole>"+
"                 <ModId>0</ModId>"+
"                 <ContactRole>OLD_ABO</ContactRole>"+
"                 <ContactId>ADBA-3AT9NY</ContactId>"+
"                 <ModifiedDate>10/23/2009 12:23:26</ModifiedDate>"+
"                 <ModifiedById>ABWA-DC7AV</ModifiedById>"+
"                 <ModifiedBy>EAI EAI,  10/23/2009 12:23:26</ModifiedBy>"+
"                 <CreatedDate>10/23/2009 12:23:26</CreatedDate>"+
"                 <CreatedById>ABWA-DC7AV</CreatedById>"+
"                 <CreatedBy>EAI EAI,  10/23/2009 12:23:26</CreatedBy>"+
"                 <ContactIntegrationId>ADBA-3AT9NY</ContactIntegrationId>"+
"                 <ContactExternalId>25741148</ContactExternalId>"+
"              </ContactRole>"+
"              <ContactRole>"+
"                 <ModId>0</ModId>"+
"                 <ContactRole>OLD_QUE</ContactRole>"+
"                 <ContactId>ADBA-3AT9NY</ContactId>"+
"                 <ModifiedDate>10/23/2009 12:23:26</ModifiedDate>"+
"                 <ModifiedById>ABWA-DC7AV</ModifiedById>"+
"                 <ModifiedBy>EAI EAI,  10/23/2009 12:23:26</ModifiedBy>"+
"                 <CreatedDate>10/23/2009 12:23:26</CreatedDate>"+
"                 <CreatedById>ABWA-DC7AV</CreatedById>"+
"                 <CreatedBy>EAI EAI,  10/23/2009 12:23:26</CreatedBy>"+
"                 <ContactIntegrationId>ADBA-3AT9NY</ContactIntegrationId>"+
"                 <ContactExternalId>25741148</ContactExternalId>"+
"              </ContactRole>"+
"              <ContactRole>"+
"                 <ModId>0</ModId>"+
"                 <ContactRole>QUE</ContactRole>"+
"                 <ContactId>ADBA-2XAWRU</ContactId>"+
"                 <ModifiedDate>10/23/2009 12:23:26</ModifiedDate>"+
"                 <ModifiedById>ABWA-DC7AV</ModifiedById>"+
"                 <ModifiedBy>EAI EAI,  10/23/2009 12:23:26</ModifiedBy>"+
"                 <CreatedDate>10/23/2009 12:23:26</CreatedDate>"+
"                 <CreatedById>ABWA-DC7AV</CreatedById>"+
"                 <CreatedBy>EAI EAI,  10/23/2009 12:23:26</CreatedBy>"+
"                 <ContactIntegrationId>ADBA-2XAWRU</ContactIntegrationId>"+
"                 <ContactExternalId>25722947</ContactExternalId>"+
"              </ContactRole>"+
"           </ListOfContactRole>"+
"        </Account>"+
"     </ListOfAccount>"+
"  </ns:AccountWS_AccountQueryPage_Output>"
			);
			account.addMessageExchangeInstances(in, out, null);



			
			
			BPELExternalMessage in2 = new BPELExternalMessageImpl();
			in2.setService(this.getName());
			in2.setEndpoint(this.getProviderEndpoint().getName());
			in2.setQName(new QName("urn:crmondemand/ws/account/10/2004", "AccountWS_AccountQueryPage_Input"));
			in2.setMessage("" +
						"<tns:AccountWS_AccountQueryPage_Input xmlns:tns=\"urn:crmondemand/ws/account/10/2004\">"+
						"<tns:UseChildAnd xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xsd:string\">true</tns:UseChildAnd>"+
						"<tns:PageSize xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xsd:string\">1</tns:PageSize>"+
						"<xsdLocal1:ListOfAccount xmlns:xsdLocal1=\"urn:/crmondemand/xml/account\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xsdLocal1:ListOfAccount\">"+
						"<xsdLocal1:Account xsi:type=\"xsdLocal1:Account\">"+
						"<xsdLocal1:ExternalSystemId xsi:type=\"xsdLocal1:string30\">022101503600001</xsdLocal1:ExternalSystemId>"+
						"</xsdLocal1:Account>"+
						"</xsdLocal1:ListOfAccount>"+
						"<tns:StartRowNum xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xsd:string\">0</tns:StartRowNum>"+
						"</tns:AccountWS_AccountQueryPage_Input> "
			);
			BPELExternalMessage out2 = new BPELExternalMessageImpl();
			out2.setService(this.getName());
			out2.setEndpoint(this.getProviderEndpoint().getName());
			out2.setQName(new QName("urn:crmondemand/ws/account/10/2004", "AccountWS_AccountQueryPage_Output"));
			out2.setMessage("" +
				      "<ns:AccountWS_AccountQueryPage_Output xmlns:ns=\"urn:crmondemand/ws/account/10/2004\">"+
	         "<ns:LastPage>true</ns:LastPage>"+
	         "<ListOfAccount xmlns=\"urn:/crmondemand/xml/account\">"+
	            "<Account>"+
	               "<ExternalSystemId>022101503600001</ExternalSystemId>"+
	               "<AccountType>Abonnement de test </AccountType>"+
	               "<ListOfPartner>"+
	                  "<Partner>"+
	                     "<CreatedBy>EAI EAI,  01/23/2009 15:23:30</CreatedBy>"+
	                     "<ModifiedBy>EAI EAI,  10/23/2009 12:23:24</ModifiedBy>"+
	                     "<AccountPartnerId>ADBA-2XAWS1</AccountPartnerId>"+
	                     "<CreatedDate>01/23/2009 15:23:30</CreatedDate>"+
	                     "<ModifiedDate>10/23/2009 12:23:24</ModifiedDate>"+
"                 <ModId>4</ModId>"+
"                 <Comments/>"+
"                 <PrimaryContactName/>"+
"                 <PrimaryContactId/>"+
"                 <EndDate/>"+
"                 <PartnerId>ABWA-EGGXH</PartnerId>"+
"                 <ReverseRelationshipRole>ABO_ACTIF</ReverseRelationshipRole>"+
"                 <RelationshipRole>PDS</RelationshipRole>"+
"                 <StartDate>01/23/2009 12:23:24</StartDate>"+
"                 <Strengths/>"+
"                 <CreatedById>ABWA-DC7AV</CreatedById>"+
"                 <Weaknesses/>"+
"                 <ModifiedById>ABWA-DC7AV</ModifiedById>"+
"                 <PartnerExternalSystemId>022101503600001</PartnerExternalSystemId>"+
"                 <PartnerIntegrationId>ABWA-EGGXH</PartnerIntegrationId>"+
"              </Partner>"+
"           </ListOfPartner>"+
"           <ListOfContactRole/>"+
"           <ListOfShippingAddress>"+
"           <ShippingAddress>"+
"              <ShippingCity>NEUILLY PLAISANCE</ShippingCity>"+
"              <ShippingCountry>France</ShippingCountry>"+
"             <ShippingZipCode>93360</ShippingZipCode>"+
"              <ShippingStateProvince/>"+
"              <ShippingAddress>92T AV G CLEMENCEAU</ShippingAddress>"+
"              <ShippingAddressId>ABWA-EGGXJ</ShippingAddressId>"+
"              <AddressName>ABWA-EGGXJ</AddressName>"+
"              <IntegrationId>ABWA-EGGXJ</IntegrationId>"+
"              <ShippingCounty/>"+
"              <ShippingProvince/>"+
"              <ShippingAddress2/>"+
"              <ShippingAddress3/>"+
"           </ShippingAddress>"+
"           </ListOfShippingAddress>"+
"        </Account>"+
"     </ListOfAccount>"+
"  </ns:AccountWS_AccountQueryPage_Output>"
			);
			account.addMessageExchangeInstances(in2, out2, null);
			
			

			
		} catch (CoreException e) {
			throw new BPELException(e);
		}
	}


}
