package uk.ac.ebi.spot.goci.curation.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import uk.ac.ebi.spot.goci.model.Event;
import uk.ac.ebi.spot.goci.model.EventType;
import uk.ac.ebi.spot.goci.model.SecureUser;
import uk.ac.ebi.spot.goci.repository.EventRepository;

import java.util.Date;

/**
 * Created by emma on 06/05/2016.
 *
 * @author emma
 *         <p>
 *         Service class to handle common operations regarding events
 */
@Service
public class EventOperationsService {

    private EventRepository eventRepository;

    @Autowired
    public EventOperationsService(EventRepository eventRepository) {
        this.eventRepository = eventRepository;
    }

    /**
     * Create an event
     *
     * @param eventType Event type to create
     * @return Event object
     */
    public synchronized Event createEvent(EventType eventType, SecureUser user) {
        // Create and save event
        Event event = new Event();
        event.setEventDate(new Date());
        event.setEventType(eventType);
        event.setUser(user);
        eventRepository.save(event);
        return event;
    }

    /**
     * Create an event with a description
     *
     * @param eventType Event type to create
     * @return Event object
     */
    public synchronized Event createEvent(EventType eventType, SecureUser user, String eventDescription) {
        // todo add description
        // Create and save event
        Event event = new Event();
        event.setEventDate(new Date());
        event.setEventType(eventType);
        event.setUser(user);
        eventRepository.save(event);
        return event;
    }


}

@@ -813,32 +813,78 @@
  type to create%0A
+     * @param user      User Initiating event%0A
      * @return E
@@ -887,32 +887,32 @@
 rn Event object%0A
-
      */%0A    publ
@@ -1300,32 +1300,39 @@
 param eventType 
+       
 Event type to cr
@@ -1328,32 +1328,144 @@
  type to create%0A
+     * @param user             User Initiating event%0A     * @param eventDescription Description of update event%0A
      * @return E
@@ -1595,40 +1595,8 @@
 ) %7B%0A
-        // todo add description%0A
     
@@ -1759,32 +1759,85 @@
 .setUser(user);%0A
+        event.setEventDescription(eventDescription);%0A
         eventRep
@@ -1889,8 +1889,5 @@
   %7D%0A
-%0A%0A%7D%0A
+%7D

Update comments