package com.inepex.ineForm.shared;

import java.util.ArrayList;
import java.util.List;

import com.inepex.ineom.shared.Relation;
import com.inepex.ineom.shared.assistedobject.AssistedObject;
import com.inepex.ineom.shared.descriptor.CustomKVOObjectDesc;


public abstract class BaseMapper<E> {
	
	public abstract E kvoToEntity(AssistedObject from, E to, CustomKVOObjectDesc... descs) throws Exception;
	
	public abstract AssistedObject entityToKvo(E entity);
	
	public abstract Relation toRelation(E entity, boolean includeKvo);
	
	public List<Relation> toRelationList(List<E> entityList){
		return toRelationList(entityList, false);
	}
	
	public List<Relation> toRelationList(List<E> entityList, boolean includeKvo){
		List<Relation> result = new ArrayList<Relation>();
		for (E entity : entityList) {
			result.add(toRelation(entity, includeKvo));
		}
		return result;
	}
	
	public ArrayList<AssistedObject> entityListToKvoList(List<E> entityList){
		ArrayList<AssistedObject> result = new ArrayList<AssistedObject>();
		for (E o: entityList){
			result.add(entityToKvo(o));
		}
		return result;
	}	

}

@@ -1131,14 +1131,355 @@
 t;%0D%0A%09%7D%09%0D
+%0A%09%0D%0A%09public ArrayList%3CAssistedObject%3E entityListToKvoList(List%3CE%3E entityList, boolean addId)%7B%0D%0A%09%09ArrayList%3CAssistedObject%3E result = new ArrayList%3CAssistedObject%3E();%0D%0A%09%09Long id = 0l;%0D%0A%09%09for (E o: entityList)%7B%0D%0A%09%09%09AssistedObject kvo = entityToKvo(o);%0D%0A%09%09%09if(addId)%7B%0D%0A%09%09%09%09kvo.setId(id++);%0D%0A%09%09%09%7D%0D%0A%09%09%09result.add(kvo);%0D%0A%09%09%7D%0D%0A%09%09return result;%0D%0A%09%7D%09%0D
 %0A%0D%0A%7D%0D%0A

work element creation query fixes