<commit_before>package taskDo;

import Parser.ParsedResult;
import commandFactory.CommandAction;
import commandFactory.CommandFactory;
import commandFactory.CommandType;
import commonClasses.Constants;
import commonClasses.StorageList;
import commonClasses.SummaryReport;

public class Executor {

	public Executor() {
		StorageList.getInstance().loadFile();
	}

	public void execute(ParsedResult parsedResult) {		
		CommandFactory commandFactory = new CommandFactory();
		CommandType commandType = parsedResult.getCommandType();

		if (commandType.equals(CommandType.UNDO)) {
			executeUndo(parsedResult);

		}else	if(commandType.equals(CommandType.REDO)){
			executeRedo(parsedResult);
		}else{
			executeCommand(parsedResult, commandFactory, commandType);
		}
		StorageList.getInstance().saveToFile();
	}

	private void executeUndo(ParsedResult parsedResult) {
		if(!History.getUndoActionHistory().empty()){
			CommandAction commandAction = History.getUndoActionHistory().pop();
			Task lastTask = History.getUndoTaskHistory().pop();

			History.getRedoActionHistory().push(commandAction);
			History.getRedoTaskHistory().push(lastTask);

			commandAction.undo(lastTask);
			parsedResult.setTask(lastTask);

			CategoryList.updateCategoryList(StorageList.getInstance().getTaskList());
			UpdateSummaryReport.update(parsedResult);
		}else{SummaryReport.setFeedBackMsg(Constants.MESSAGE_FAIL_UNDO);}
	}

	private void executeRedo(ParsedResult parsedResult) {
		if(!History.getRedoActionHistory().empty()){
			CommandAction commandAction = History.getRedoActionHistory().pop();
			Task lastTask = History.getRedoTaskHistory().pop();
			
			parsedResult.setTask(lastTask);
			commandAction.execute(parsedResult);
			

			CategoryList.updateCategoryList(StorageList.getInstance().getTaskList());
			UpdateSummaryReport.update(parsedResult);
		}
	}

	private void executeCommand(ParsedResult parsedResult,
			CommandFactory commandFactory, CommandType commandType) {
		CommandAction commandAction = commandFactory.getCommandAction(commandType);			
		commandAction.execute(parsedResult);
		if(!commandType.equals(CommandType.DISPLAY)){
			History.getUndoActionHistory().push(commandAction);
		}
		CategoryList.updateCategoryList(StorageList.getInstance().getTaskList());
	}<commit_msg>not to store file while display and search<commit_after>package taskDo;

import Parser.ParsedResult;
import commandFactory.CommandAction;
import commandFactory.CommandFactory;
import commandFactory.CommandType;
import commonClasses.Constants;
import commonClasses.StorageList;
import commonClasses.SummaryReport;

public class Executor {

	public Executor() {
		StorageList.getInstance().loadFile();
	}

	public void execute(ParsedResult parsedResult) {		
		CommandFactory commandFactory = new CommandFactory();
		CommandType commandType = parsedResult.getCommandType();

		if (commandType.equals(CommandType.UNDO)) {
			executeUndo(parsedResult);

		}else	if(commandType.equals(CommandType.REDO)){
			executeRedo(parsedResult);
		}else{
			executeCommand(parsedResult, commandFactory, commandType);
		}
	}

	private void executeUndo(ParsedResult parsedResult) {
		if(!History.getUndoActionHistory().empty()){
			CommandAction commandAction = History.getUndoActionHistory().pop();
			Task lastTask = History.getUndoTaskHistory().pop();

			History.getRedoActionHistory().push(commandAction);
			History.getRedoTaskHistory().push(lastTask);

			commandAction.undo(lastTask);
			parsedResult.setTask(lastTask);

			CategoryList.updateCategoryList(StorageList.getInstance().getTaskList());
			UpdateSummaryReport.update(parsedResult);
		}else{SummaryReport.setFeedBackMsg(Constants.MESSAGE_FAIL_UNDO);}
	}

	private void executeRedo(ParsedResult parsedResult) {
		if(!History.getRedoActionHistory().empty()){
			CommandAction commandAction = History.getRedoActionHistory().pop();
			Task lastTask = History.getRedoTaskHistory().pop();
			
			parsedResult.setTask(lastTask);
			commandAction.execute(parsedResult);
			

			CategoryList.updateCategoryList(StorageList.getInstance().getTaskList());
			UpdateSummaryReport.update(parsedResult);
		}
	}

	private void executeCommand(ParsedResult parsedResult,
			CommandFactory commandFactory, CommandType commandType) {
		CommandAction commandAction = commandFactory.getCommandAction(commandType);			
		commandAction.execute(parsedResult);
		if(!commandType.equals(CommandType.DISPLAY)&&!commandType.equals(CommandType.SEARCH)){
			History.getUndoActionHistory().push(commandAction);
			StorageList.getInstance().saveToFile();
		}
		CategoryList.updateCategoryList(StorageList.getInstance().getTaskList());
	}
{'fraction_non_alphanumeric': 0.10813727606302612, 'fraction_numerical': 0.0, 'mean_word_length': 6.710482529118137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1427799', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1279, 'n_words': 191}