<commit_before>package seedu.jimi.logic.commands;

import java.util.Optional;
import seedu.jimi.commons.core.Config;
import seedu.jimi.commons.exceptions.DataConversionException;
import seedu.jimi.commons.util.ConfigUtil;

/**
 *  
 * @author <NAME> 
 * 
 * Sets save directory for the tasks and events in Jimi.
 */
public class SaveAsCommand extends Command {

    public static final String COMMAND_WORD = "saveas";

    public static final String MESSAGE_USAGE = COMMAND_WORD + ": Set a new save directory for all your tasks and events in Jimi.\n"
            + "Parameters: FILEPATH/FILENAME.xml \n"
            + "Example: " + COMMAND_WORD
            + " C:/dropbox/taskbook.xml";

    public static final String MESSAGE_SUCCESS = "Save directory changed: %1$s";
    public static final String MESSAGE_DUPLICATE_TASK = "This save directory is originally used in Jimi";
    public static final String CONFIG_FILE_NOT_FOUND = "Config file is not found. Using default config file properties...";

    private String taskBookFilePath;

    /**
     * Convenience constructor using raw values.
     */
    public SaveAsCommand(String filePath)  {
        this.taskBookFilePath = filePath;
    }
    
    @Override
    public CommandResult execute() {
        String defaultConfigFilePathUsed = Config.DEFAULT_CONFIG_FILE;
        try {
            Optional<Config> configOptional = ConfigUtil.readConfig(defaultConfigFilePathUsed);
            Config config = configOptional.orElse(new Config());
            config.setTaskBookFilePath(taskBookFilePath);
            return new CommandResult(String.format(MESSAGE_SUCCESS, taskBookFilePath));
        } catch (DataConversionException e) {
            Config config = new Config();
            config.setTaskBookFilePath(taskBookFilePath);
            return new CommandResult(String.format(CONFIG_FILE_NOT_FOUND, MESSAGE_SUCCESS, taskBookFilePath));
        }
    }

}<commit_msg>Further Implement execute of SaveAsCommand<commit_after>package seedu.jimi.logic.commands;

import java.io.IOException;
import java.util.Optional;
import seedu.jimi.commons.core.Config;
import seedu.jimi.commons.exceptions.DataConversionException;
import seedu.jimi.commons.util.ConfigUtil;
import seedu.jimi.model.ReadOnlyTaskBook;
import seedu.jimi.model.TaskBook;
import seedu.jimi.storage.Storage;
import seedu.jimi.storage.StorageManager;

/**
 *  
 * @author <NAME> 
 * 
 * Sets save directory for the tasks and events in Jimi.
 */
public class SaveAsCommand extends Command {

    public static final String COMMAND_WORD = "saveas";

    public static final String MESSAGE_USAGE = COMMAND_WORD + ": Set a new save directory for all your tasks and events in Jimi.\n"
            + "Parameters: FILEPATH/FILENAME.xml \n"
            + "Example: " + COMMAND_WORD
            + " C:/dropbox/taskbook.xml";

    public static final String MESSAGE_SUCCESS = "Save directory changed: %1$s";
    public static final String MESSAGE_DUPLICATE_TASK = "This save directory is originally used in Jimi";
    public static final String MESSAGE_CONFIG_FILE_NOT_FOUND = "Config file is not found. ";
    public static final String MESSAGE_UPDATING_SAVE_DIR = "There is an error updating the new save directory.";

    private String taskBookFilePath;

    /**
     * Convenience constructor using raw values.
     */
    public SaveAsCommand(String filePath)  {
        this.taskBookFilePath = filePath.concat(".xml");
    }
    
    @Override
    public CommandResult execute() {
        String defaultConfigFilePathUsed = Config.DEFAULT_CONFIG_FILE;
        try {
            Config config = ConfigUtil.readConfig(defaultConfigFilePathUsed).orElse(new Config());
            ConfigUtil.saveConfig(config, defaultConfigFilePathUsed);
            
            String oldTaskBookFilePath = config.getTaskBookFilePath();
            config.setTaskBookFilePath(taskBookFilePath);
            StorageManager oldStorage = new StorageManager(oldTaskBookFilePath, config.getUserPrefsFilePath());
            StorageManager newStorage = new StorageManager(taskBookFilePath, config.getUserPrefsFilePath());
            
            ReadOnlyTaskBook oldTaskBook = oldStorage.readTaskBook(oldTaskBookFilePath).orElse(new TaskBook());
            newStorage.saveTaskBook(oldTaskBook);
            
            return new CommandResult(String.format(MESSAGE_SUCCESS, newStorage.getAddressBookFilePath()));
        } catch (DataConversionException e) {
            return new CommandResult(String.format(MESSAGE_CONFIG_FILE_NOT_FOUND));
        } catch (IOException e) {
            return new CommandResult(String.format(MESSAGE_UPDATING_SAVE_DIR));
        }
    }
    

}
{'fraction_non_alphanumeric': 0.08246101260414442, 'fraction_numerical': 0.0004272591326639607, 'mean_word_length': 3.279707495429616, 'pattern_counts': {'":': 2, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, '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': '1887355', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1238, 'n_words': 321}