All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.svea.businessobjects.pmtadmin.SveaPmtAdminBusinessObjectFactory Maven / Gradle / Ivy

The newest version!
package com.svea.businessobjects.pmtadmin;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.notima.api.webpay.pmtapi.PmtApiClientCollection;
import org.notima.api.webpay.pmtapi.PmtApiCredential;
import org.notima.api.webpay.pmtapi.exception.NoSuchOrderException;
import org.notima.generic.businessobjects.BasicBusinessObjectFactory;
import org.notima.generic.businessobjects.BusinessPartner;
import org.notima.generic.businessobjects.BusinessPartnerList;
import org.notima.generic.businessobjects.DunningRun;
import org.notima.generic.businessobjects.Invoice;
import org.notima.generic.businessobjects.Order;
import org.notima.generic.businessobjects.PaymentTerm;
import org.notima.generic.businessobjects.PriceList;
import org.notima.generic.businessobjects.Product;
import org.notima.generic.businessobjects.ProductCategory;
import org.notima.generic.businessobjects.Tax;
import org.notima.generic.ifacebusinessobjects.FactoringReservation;

/**
 * Business object factory used to convert orders from 
 * 
 * 
 * @author Daniel Tamm
 *
 */
public class SveaPmtAdminBusinessObjectFactory extends BasicBusinessObjectFactory<
		PmtApiClientCollection, 
		org.notima.api.webpay.pmtapi.entity.Invoice, 
		org.notima.api.webpay.pmtapi.CheckoutOrder,
		Object,
		Object,
		Object
		> {

	private PmtApiClientCollection clients;
	
	public SveaPmtAdminBusinessObjectFactory() {
		clients = new PmtApiClientCollection();
	}

	/**
	 * Initializes the business object factory
	 * 
	 * @param serverName
	 * @param orgNo				The orgno this merchant id belongs to.
	 * @param merchantId
	 * @param secretWord
	 */
	public void addCredential(String serverName, String orgNo, String merchantId, String secretWord) {
		
		PmtApiCredential credential = new PmtApiCredential();
		credential.setServer(serverName);
		credential.setOrgNo(orgNo);
		credential.setMerchantId(merchantId);
		credential.setSecret(secretWord);
		clients.addPmtApiClient(credential);

	}

	@Override
	public Order lookupOrder(String key) throws Exception {
		org.notima.api.webpay.pmtapi.CheckoutOrder o = null;
		try {
			o = lookupNativeOrder(key);
		} catch (NoSuchOrderException nsoe) {
			
		}
		if (o==null) return null;
		Order result = SveaPmtAdminConverter.convert(o);
		result.setNativeOrder(o);
		// Add merchantId as attribute
		result.addAttribute("merchantId", o.getMerchantId());
		return result;
	}

	@Override
	public PmtApiClientCollection getClient() {
		return clients;
	}

	@Override
	public org.notima.api.webpay.pmtapi.CheckoutOrder lookupNativeOrder(String key)
			throws Exception {
		
		return clients.getCheckoutOrder(Long.parseLong(key));
		
	}

	@Override
	public BusinessPartner lookupBusinessPartner(String key)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List> lookupAllBusinessPartners()
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public DunningRun lookupDunningRun(String key, Date dueDateUntil) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public org.notima.api.webpay.pmtapi.entity.Invoice lookupNativeInvoice(
			String key) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public org.notima.api.webpay.pmtapi.entity.Invoice persistNativeInvoice(
			org.notima.api.webpay.pmtapi.entity.Invoice invoice)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public org.notima.api.webpay.pmtapi.CheckoutOrder persistNativeOrder(
			org.notima.api.webpay.pmtapi.CheckoutOrder order) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Invoice lookupInvoice(
			String key) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Product lookupProduct(String key) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Product lookupProductByEan(String ean) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List> lookupProductByName(String name)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Map lookupList(String listName) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Product lookupRoundingProduct() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Tax lookupTax(String key) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public PaymentTerm lookupPaymentTerm(String key) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public FactoringReservation lookupFactoringReservation(String key)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List lookupFactoringReservationForOrder(
			String orderKey) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List lookupFactoringReservationForInvoice(
			String invoiceKey) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object persist(Object o) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean isConnected() throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void destroy() throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public PriceList lookupPriceForProduct(String productKey, String currency,
			Boolean salesPriceList) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List lookupProductCategory(String key)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BusinessPartner lookupThisCompanyInformation() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List> lookupBusinessPartners(int maxCount,
			boolean customers, boolean suppliers) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BusinessPartnerList listTenants() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSystemName() {
		return "Webpay-PmtAdmin";
	}


}