/*
 * Copyright 2014 WSO2, Inc. (http://wso2.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dataMapper.diagram.custom.persistence;

import dataMapper.DataMapperRoot;
import dataMapper.diagram.custom.configuration.function.Function;

/**
 * Transform mapping model into mapping 
 * configuration. 
 *
 */
public class DataMapperModelTransformer {
	
	private static DataMapperModelTransformer instance;
	
	private DataMapperModelTransformer(){
		
	}
	
	public static DataMapperModelTransformer getInstance() {
		if (instance == null) {
			instance = new DataMapperModelTransformer();
		}
		return instance;
	}

	public String transform(DataMapperRoot rootDiagram) {
		DataMapperConfiguration mappingConfig = new DataMapperConfiguration();
		MappingModelTraverser.getInstance().traverse(rootDiagram, mappingConfig);

		StringBuilder result = new StringBuilder();
		for(Function function : mappingConfig.getFunctionList()){
			result.append(function.toString());
		}
		return result.toString();

		}
}

@@ -1126,16 +1126,209 @@
 ce;%0A%09%7D%0A%0A
+%09/**%0A%09 * traverse in datamapper map model and generate DataMapperConfigurtion config  %0A%09 * @param rootDiagram datamapper graphical model root%0A%09 * @return complete configuration of mapping%0A%09 */%0A
 %09public 
@@ -1570,16 +1570,75 @@
 lder();%0A
+%09%09if(mappingConfig.getFunctionList().get(0) != null)%7B%0A%09%09%09%0A%09
 %09%09for(Fu
@@ -1692,16 +1692,17 @@
 ())%7B%0A%09%09%09
+%09
 result.a
@@ -1727,26 +1727,28 @@
 tring());%0A%09%09
+%09
 %7D%0A
+%09
 %09%09return res
@@ -1763,15 +1763,47 @@
 ring();%0A
+%09%09%7D%0A%0A%09%09return result.toString();
 %0A%09%09%7D%0A%7D%0A

fix TOOLS-2433