<commit_before>package il.co.topq.report.business.execution;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import il.co.topq.difido.model.execution.Execution;
import il.co.topq.difido.model.execution.MachineNode;
import il.co.topq.difido.model.execution.Node;
import il.co.topq.difido.model.execution.ScenarioNode;
import il.co.topq.difido.model.execution.TestNode;
import il.co.topq.difido.model.remote.ExecutionDetails;
import il.co.topq.report.Common;
import il.co.topq.report.Configuration;
import il.co.topq.report.Configuration.ConfigProps;
import il.co.topq.report.events.ExecutionDeletedEvent;
import il.co.topq.report.events.ExecutionEndedEvent;
import il.co.topq.report.events.ExecutionUpdatedEvent;
import il.co.topq.report.events.FileAddedToTestEvent;
import il.co.topq.report.events.MachineCreatedEvent;
import il.co.topq.report.events.TestDetailsCreatedEvent;

@Component
public class MetadataController implements MetadataProvider, MetadataCreator {

	private final Logger log = LoggerFactory.getLogger(MetadataController.class);

	MetadataPersistency persistency;

	@Autowired
	public MetadataController(MetadataPersistency persistency) {
		this.persistency = persistency;
	}

	/**
	 * Adding new execution. Execution can have multiple machines that can have
	 * scenarios with tests.
	 * 
	 * @param executionDetails
	 *            The description of the execution.
	 * @return The execution metadata
	 */
	@Override
	public ExecutionMetadata createMetadata(ExecutionDetails executionDetails) {
		Execution execution = new Execution();
		final Date executionDate = new Date();
		final ExecutionMetadata metaData = new ExecutionMetadata(
				Common.ELASTIC_SEARCH_TIMESTAMP_STRING_FORMATTER.format(executionDate), execution);
		metaData.setTime(Common.API_TIME_FORMATTER.format(executionDate));
		metaData.setDate(Common.API_DATE_FORMATTER.format(executionDate));

		metaData.setId(persistency.advanceId());
		metaData.setFolderName(Common.EXECUTION_REPORT_FOLDER_PREFIX + "_" + metaData.getId());
		metaData.setUri(Common.REPORTS_FOLDER_NAME + "/" + metaData.getFolderName() + "/index.html");
		metaData.setComment("");
		metaData.setActive(true);
		if (executionDetails != null) {
			metaData.setDescription(executionDetails.getDescription());
			metaData.setShared(executionDetails.isShared());
			setAllowedPropertiesToMetaData(metaData, executionDetails);<commit_msg>Trace messages for helping in fixing date bug<commit_after>package il.co.topq.report.business.execution;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import il.co.topq.difido.model.execution.Execution;
import il.co.topq.difido.model.execution.MachineNode;
import il.co.topq.difido.model.execution.Node;
import il.co.topq.difido.model.execution.ScenarioNode;
import il.co.topq.difido.model.execution.TestNode;
import il.co.topq.difido.model.remote.ExecutionDetails;
import il.co.topq.report.Common;
import il.co.topq.report.Configuration;
import il.co.topq.report.Configuration.ConfigProps;
import il.co.topq.report.events.ExecutionDeletedEvent;
import il.co.topq.report.events.ExecutionEndedEvent;
import il.co.topq.report.events.ExecutionUpdatedEvent;
import il.co.topq.report.events.FileAddedToTestEvent;
import il.co.topq.report.events.MachineCreatedEvent;
import il.co.topq.report.events.TestDetailsCreatedEvent;

@Component
public class MetadataController implements MetadataProvider, MetadataCreator {

	private final Logger log = LoggerFactory.getLogger(MetadataController.class);

	MetadataPersistency persistency;

	@Autowired
	public MetadataController(MetadataPersistency persistency) {
		this.persistency = persistency;
	}

	/**
	 * Adding new execution. Execution can have multiple machines that can have
	 * scenarios with tests.
	 * 
	 * @param executionDetails
	 *            The description of the execution.
	 * @return The execution metadata
	 */
	@Override
	public ExecutionMetadata createMetadata(ExecutionDetails executionDetails) {
		Execution execution = new Execution();
		final Date executionDate = new Date();
		final ExecutionMetadata metaData = new ExecutionMetadata(
				Common.ELASTIC_SEARCH_TIMESTAMP_STRING_FORMATTER.format(executionDate), execution);
		metaData.setTime(Common.API_TIME_FORMATTER.format(executionDate));
		log.trace("Time for new Execution: " + executionDate.getTime() + " is: " + metaData.getTime());
		metaData.setDate(Common.API_DATE_FORMATTER.format(executionDate));
		log.trace("Date for new Execution: " + executionDate.getTime() + " is: " + metaData.getDate());
		metaData.setId(persistency.advanceId());
		metaData.setFolderName(Common.EXECUTION_REPORT_FOLDER_PREFIX + "_" + metaData.getId());
		metaData.setUri(Common.REPORTS_FOLDER_NAME + "/" + metaData.getFolderName() + "/index.html");
		metaData.setComment("");
		metaData.setActive(true);
		if (executionDetails != null) {
			metaData.setDescription(executionDetails.getDescription());
			metaData.setShared(executionDetails.isShared());
			setAllowedPropertiesToMetaData(metaData, executionDetails);
{'fraction_non_alphanumeric': 0.10614425645592164, 'fraction_numerical': 0.0010685663401602849, 'mean_word_length': 5.9763975155279505, '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': '5941040', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1685, 'n_words': 286}