package jp.ac.nii.prl.mape.autoscaling.analysis.model.dto;

import jp.ac.nii.prl.mape.autoscaling.analysis.model.Adaptation;
import jp.ac.nii.prl.mape.autoscaling.analysis.model.Deployment;
import jp.ac.nii.prl.mape.autoscaling.analysis.model.Instance;
import jp.ac.nii.prl.mape.autoscaling.analysis.model.InstanceType;

public class DeploymentFactory {

	public static Deployment createDeployment(DeploymentDTO dto) {
		return null;
	}
	
	public static DeploymentDTO createDeploymentDTO(Deployment deployment) {
		return null;
	}
	
	public static Adaptation createAdaptation(AdaptationDTO dto, Deployment deployment) {
		Adaptation adaptation = new Adaptation();
		
		adaptation.setAdapt(dto.isAdapt());
		adaptation.setCpuCount(dto.getCpuCount());
		adaptation.setScaleUp(dto.isScaleUp());
		adaptation.setDeployment(deployment);
		
		return adaptation;
	}
	
	public static AdaptationDTO createAdaptationDTO(Adaptation adaptation) {
		AdaptationDTO dto = new AdaptationDTO();
		
		dto.setAdapt(adaptation.isAdapt());
		dto.setCpuCount(adaptation.getCpuCount());
		dto.setScaleUp(adaptation.isScaleUp());
		
		return dto;
	}
	
	public static Instance createInstance(InstanceDTO dto, 
			Deployment deployment, 
			InstanceType instanceType) {
		Instance instance = new Instance();
		
		instance.setDeployment(deployment);
		instance.setInstanceType(instanceType);
		instance.setInstID(dto.getInstID());
		instance.setInstLoad(dto.getInstLoad());
		instance.setInstType(dto.getInstType());
				
		return instance;
	}
	
	public static InstanceDTO createInstanceDTO(Instance instance) {
		InstanceDTO dto = new InstanceDTO();
		
		dto.setInstID(instance.getInstID());
		dto.setInstLoad(instance.getInstLoad());
		dto.setInstType(instance.getInstType());
		
		return dto;
	}
	
	public static InstanceType createInstanceType(InstanceTypeDTO dto) {
		return null;
	}
	
	public static InstanceTypeDTO createInstanceTypeDTO(InstanceType instanceType) {
		return null;
	}

}

@@ -53,16 +53,40 @@
 l.dto;%0A%0A
+import java.util.List;%0A%0A
 import j
@@ -1861,113 +1861,731 @@
  dto
-) %7B%0A%09%09return null;%0A%09%7D%0A%09%0A%09public static InstanceTypeDTO createInstanceTypeDTO(InstanceType instanceType) %7B
+,%0A%09%09%09Deployment deployment,%0A%09%09%09List%3CInstance%3E instances) %7B%0A%09%09InstanceType instanceType = new InstanceType();%0A%09%09%0A%09%09instanceType.setDeployment(deployment);%0A%09%09instanceType.setInstances(instances);%0A%09%09instanceType.setTypeCost(dto.getTypeCost());%0A%09%09instanceType.setTypeCPUs(dto.getTypeCPUs());%0A%09%09instanceType.setTypeID(dto.getTypeID());%0A%09%09instanceType.setTypeRAM(dto.getTypeRAM());%0A%09%09%0A%09%09return instanceType;%0A%09%7D%0A%09%0A%09public static InstanceTypeDTO createInstanceTypeDTO(InstanceType instanceType) %7B%0A%09%09InstanceTypeDTO dto = new InstanceTypeDTO();%0A%09%09%0A%09%09dto.setTypeCost(instanceType.getTypeCost());%0A%09%09dto.setTypeCPUs(instanceType.getTypeCPUs());%0A%09%09dto.setTypeID(instanceType.getTypeID());%0A%09%09dto.setTypeRAM(instanceType.getTypeRAM());%0A%09%09
 %0A%09%09r
@@ -2586,24 +2586,23 @@
 %09%09%0A%09%09return 
-null
+dto
 ;%0A%09%7D%0A%0A%7D%0A

Implement InstanceType to InstanceTypeDTO and back