package linprogMPC.helper;

import java.util.ArrayList;
import java.util.TreeMap;

import linprogMPC.messages.OptimizationResultMessage;

public abstract class DirectoryManager {

	/**
	 * Add a sub-directory to the directory tree map
	 * 
	 * @param folderName Name of new sub-directory
	 * @param parent     Directory where sub-directory should be created
	 */
	private static TreeMap<String, Object> addSubDirectory(String folderName, TreeMap<String, Object> parent) {

		TreeMap<String, Object> newFolder = new TreeMap<String, Object>();
		parent.put(folderName, newFolder);

		return parent;
	}

	/**
	 * Creates a directory hierarchy for simulation results
	 * 
	 * @param folderName Name of new sub-directory
	 * @param parent     Directory where sub-directory should be created
	 */
	public static void createDirectoryHierarchy(ArrayList<String> nameCategories, OptimizationResultMessage optResult) {

		for (int i = 0; i < nameCategories.size(); i++) {

			TreeMap<String, Object> buildingFolder = new TreeMap<String, Object>();
			addSubDirectory("ClientStorageCharge", buildingFolder);
			addSubDirectory("ClientStorageDischarge", buildingFolder);
			addSubDirectory("ClientCoupler", buildingFolder);
			addSubDirectory("ClientVolatileProducer", buildingFolder);
			addSubDirectory("CSVStorageCharge", buildingFolder);
			addSubDirectory("CSVStorageDischarge", buildingFolder);
			addSubDirectory("CSVCoupler", buildingFolder);
			addSubDirectory("CSVVolatileProducer", buildingFolder);

			optResult.buildingResultsMap.put(nameCategories.get(i), buildingFolder);
		}
	}

}

@@ -19,17 +19,19 @@
 .helper;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -50,16 +50,17 @@
 rayList;
+%0D
 %0Aimport 
@@ -77,17 +77,17 @@
 TreeMap;
-%0A
+%0D
 %0Aimport 
@@ -132,17 +132,19 @@
 Message;
-%0A
+%0D%0A%0D
 %0Apublic 
@@ -176,24 +176,29 @@
 anager %7B
-%0A%0A%09/**%0A%09
+%0D%0A%0D%0A  /**%0D%0A  
  * Add a
@@ -237,23 +237,27 @@
 tree map
-%0A%09 * %0A%09
+%0D%0A   * %0D%0A  
  * @para
@@ -286,34 +286,36 @@
 ew sub-directory
-%0A%09
+%0D%0A  
  * @param parent
@@ -307,36 +307,32 @@
 * @param parent 
-    
 Directory where 
@@ -362,23 +362,27 @@
  created
-%0A%09 */%0A%09
+%0D%0A   */%0D%0A  
 private 
@@ -446,16 +446,23 @@
 derName,
+%0D%0A     
  TreeMap
@@ -487,20 +487,24 @@
 arent) %7B
-%0A%0A%09%09
+%0D%0A%0D%0A    
 TreeMap%3C
@@ -561,19 +561,22 @@
 ject%3E();
-%0A%09%09
+%0D%0A    
 parent.p
@@ -601,20 +601,24 @@
 Folder);
-%0A%0A%09%09
+%0D%0A%0D%0A    
 return p
@@ -627,19 +627,26 @@
 ent;
-%0A%09%7D%0A%0A%09/**%0A%09
+%0D%0A  %7D%0D%0A%0D%0A  /**%0D%0A  
  * C
@@ -700,15 +700,19 @@
 ults
-%0A%09 * %0A%09
+%0D%0A   * %0D%0A  
  * @
@@ -753,18 +753,20 @@
 irectory
-%0A%09
+%0D%0A  
  * @para
@@ -774,20 +774,16 @@
  parent 
-    
 Director
@@ -825,15 +825,19 @@
 ated
-%0A%09 */%0A%09
+%0D%0A   */%0D%0A  
 publ
@@ -909,16 +909,23 @@
 egories,
+%0D%0A     
  Optimiz
@@ -955,20 +955,24 @@
 esult) %7B
-%0A%0A%09%09
+%0D%0A%0D%0A    
 for (int
@@ -1012,21 +1012,26 @@
 ; i++) %7B
-%0A%0A%09%09%09
+%0D%0A%0D%0A      
 TreeMap%3C
@@ -1093,20 +1093,82 @@
 ject%3E();
-%0A%09%09%09
+%0D%0A      addSubDirectory(%22ClientProducer%22, buildingFolder);%0D%0A      
 addSubDi
@@ -1206,36 +1206,40 @@
 buildingFolder);
-%0A%09%09%09
+%0D%0A      
 addSubDirectory(
@@ -1272,36 +1272,40 @@
 buildingFolder);
-%0A%09%09%09
+%0D%0A      
 addSubDirectory(
@@ -1329,36 +1329,40 @@
 buildingFolder);
-%0A%09%09%09
+%0D%0A      
 addSubDirectory(
@@ -1395,36 +1395,95 @@
 buildingFolder);
-%0A%09%09%09
+%0D%0A      addSubDirectory(%22CSVProducer%22, buildingFolder);%0D%0A      
 addSubDirectory(
@@ -1510,36 +1510,40 @@
 buildingFolder);
-%0A%09%09%09
+%0D%0A      
 addSubDirectory(
@@ -1573,36 +1573,40 @@
 buildingFolder);
-%0A%09%09%09
+%0D%0A      
 addSubDirectory(
@@ -1635,20 +1635,24 @@
 Folder);
-%0A%09%09%09
+%0D%0A      
 addSubDi
@@ -1702,13 +1702,18 @@
 er);
-%0A%0A%09%09%09
+%0D%0A%0D%0A      
 optR
@@ -1784,15 +1784,23 @@
 er);
-%0A%09%09%7D%0A%09%7D%0A
+%0D%0A    %7D%0D%0A  %7D%0D%0A%0D
 %0A%7D
+%0D
 %0A

Add CSVProducer and ClientProducer to DirectoryManager