package com.gsos.dimiter_robin;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import com.gsos.dimiter_robin.ibanInterface.Fault;
import com.gsos.dimiter_robin.ibanInterface.Fault_Exception;
import com.gsos.dimiter_robin.ibanInterface.IbanResponse;
import com.gsos.dimiter_robin.ibanInterface.IbanServiceInterface;
import com.gsos.dimiter_robin.ibanInterface.Ibanrequest;
import com.gsos.dimiter_robin.ibanInterface.ValidationResponse;

@WebService(endpointInterface = "com.gsos.dimiter_robin.ibanInterface.IbanServiceInterface")
public class IbanServiceImplementation implements IbanServiceInterface {
	@WebMethod(operationName = "toIban")
	@Override
	public IbanResponse toIban(@WebParam(name = "ibanrequest") Ibanrequest request) {
		String bankcode = request.getBankcode().value();
		int rekeningnummer = request.getRekeningnummer().intValue();
		System.out.println("New request with bankcode "+bankcode+" and number "+rekeningnummer);
		
		String partialCode = valueFromLetters(bankcode) + Integer.toString(rekeningnummer);
		
		IbanResponse response = new IbanResponse();
		response.setIban("NL48INGB008829939");
		return response;
	}
	@WebMethod(operationName = "validateIban")
	@Override
	public ValidationResponse validateIban(Fault arg0) throws Fault_Exception {
		// TODO Auto-generated method stub
		return null;
	}
	
	private String valueFromLetters (String letters) {
		String value = "";
		for (Character letter : letters.toCharArray()) {
			value += Integer.toString(letter - 'A' + 10);
		}
		return value;
		
	}
}

@@ -26,16 +26,46 @@
 robin;%0A%0A
+import java.math.BigInteger;%0A%0A
 import j
@@ -850,19 +850,26 @@
 ue();%0A%09%09
-int
+BigInteger
  rekenin
@@ -909,19 +909,8 @@
 er()
-.intValue()
 ;%0A%09%09
@@ -1057,39 +1057,57 @@
 ) + 
-Integer.toString(rekeningnummer
+addZeroes(rekeningnummer) + valueFromLetters(%22NL%22
 );%0A%09
@@ -1217,16 +1217,18 @@
 nse;%0A%09%7D%0A
+%09%0A
 %09@WebMet
@@ -1388,16 +1388,16 @@
 od stub%0A
-
 %09%09return
@@ -1408,16 +1408,217 @@
 l;%0A%09%7D%0A%09%0A
+%09private String addZeroes (BigInteger nummer) %7B%0A%09%09String stringNummer = nummer.toString();%0A%09%09while (stringNummer.length() %3C 10) %7B%0A%09%09%09stringNummer = %220%22 + stringNummer; %0A%09%09%7D%0A%09%09return new String();%0A%09%7D%0A%09%0A
 %09private

Update Implementation