Skip to content

Commit

Permalink
logging handling improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
timhilgert committed Oct 23, 2019
1 parent 11b7485 commit d32e53d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
27 changes: 18 additions & 9 deletions src/main/java/edu/kit/ifv/mobitopp/actitopp/CSVExportLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public class CSVExportLogger
{
File basepath;

FileWriter activitywriter;
FileWriter tripwriter;
Expand All @@ -22,21 +23,21 @@ public class CSVExportLogger
*/
public CSVExportLogger(File basepath) throws IOException
{
activitywriter = new FileWriter(new File(basepath, "actitopp_activities.csv"));
tripwriter = new FileWriter(new File(basepath, "actitopp_trips.csv"));
personwriter = new FileWriter(new File(basepath, "actitopp_persons.csv"));
this.basepath = basepath;
openLogging(false);

writeActivityData_header();
writeTripData_header();
writePersonData_header();

closeLogging();
}


public void writeLogging(HashMap<Integer,?> maptoexport) throws IOException
{
openLogging(true);
for(Object referenceobject : maptoexport.values())
{

{
// Householdmap
if (referenceobject instanceof ActiToppHousehold)
{
Expand All @@ -45,18 +46,26 @@ public void writeLogging(HashMap<Integer,?> maptoexport) throws IOException
{
exportsinglePerson(actperson);
}
}

}
// Personmap
if (referenceobject instanceof ActitoppPerson)
{
ActitoppPerson actperson = ((ActitoppPerson) referenceobject);
exportsinglePerson(actperson);
}
}
closeLogging();
}


private void openLogging(boolean appendToExistingFile) throws IOException
{
activitywriter = new FileWriter(new File(basepath, "actitopp_activities.csv"), appendToExistingFile);
tripwriter = new FileWriter(new File(basepath, "actitopp_trips.csv"), appendToExistingFile);
personwriter = new FileWriter(new File(basepath, "actitopp_persons.csv"), appendToExistingFile);
}

public void closeLogging() throws IOException
private void closeLogging() throws IOException
{
activitywriter.close();
tripwriter.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ public static void createAndModelMultiplePersons_Example2()
// Output information as csv files
CSVExportLogger logger = new CSVExportLogger(new File ("D:"));
logger.writeLogging(householdmap);
logger.closeLogging();
}
catch (IOException e)
{
Expand Down

0 comments on commit d32e53d

Please sign in to comment.