Jean-Francois Leveque

Ajout de lien retour.

Corrections JPA mineures (oubli @Entity).
Ajout de méthodes de base (get/set).
Uniformisation finale userAction.
Fin adaptation méthode validate.
Adaptation setUp test validate PublisherService (répository supplémentaire)
......@@ -24,6 +24,9 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
@OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER)
private Set<PublisherVersion> versions;
@OneToMany(mappedBy = "publisher")
private Set<PublisherAction> actions;
public int getPublisherId() {
return publisherId;
}
......@@ -48,6 +51,14 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
this.versions = versions;
}
public Set<PublisherAction> getActions() {
return actions;
}
public void setActions(Set<PublisherAction> actions) {
this.actions = actions;
}
@Override
public String toString() {
return "PUBLISHER_ID = " + publisherId + ", Validated Version = " + validatedVersion;
......
......@@ -6,13 +6,14 @@ import java.sql.Timestamp;
/**
* Classe des actions sur des (versions d') éditeurs.
*/
@Entity
public class PublisherAction {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int publisherActionId;
@ManyToOne
private UserAction action;
private UserAction userAction;
@ManyToOne
private User publisherActionAuthor;
@ManyToOne
......@@ -31,4 +32,43 @@ public class PublisherAction {
public void setPublisherActionDatetime(Timestamp publisherActionDatetime) {
this.publisherActionDatetime = publisherActionDatetime;
}
public void setUserAction(UserAction userAction) {
this.userAction = userAction;
}
public void setPublisherVersion(PublisherVersion publisherVersion) {
this.publisherVersion = publisherVersion;
}
public void setPublisher(Publisher publisher) {
this.publisher = publisher;
}
public UserAction getUserAction() {
return userAction;
}
public User getPublisherActionAuthor() {
return publisherActionAuthor;
}
public PublisherVersion getPublisherVersion() {
return publisherVersion;
}
public Timestamp getPublisherActionDatetime() {
return publisherActionDatetime;
}
public Publisher getPublisher() {
return publisher;
}
@Override
public String toString() {
return "publisherActionId = " + publisherActionId + ", userAction = " + userAction +
", publisherActionAuthor = " + publisherActionAuthor + ", publisherVersion = " + publisherVersion +
", publisherActionDatetime = " + publisherActionDatetime + ", publisher = " + publisher;
}
}
\ No newline at end of file
......
package org.legrog.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
......@@ -7,6 +8,7 @@ import javax.persistence.Id;
/**
* Classe des actions possibles.
*/
@Entity
public class UserAction {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
......
package org.legrog.entities;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserActionRepository extends JpaRepository<UserAction, Integer> {
UserAction findByUserActionName(String userActionName);
}
......@@ -25,16 +25,19 @@ public class PublisherServiceSpring implements PublisherService {
PublisherRepository publisherRepository;
PublisherVersionRepository publisherVersionRepository;
PublisherActionRepository publisherActionRepository;
UserActionRepository userActionRepository;
SharedService sharedService;
@Inject
public PublisherServiceSpring(PublisherRepository publisherRepository,
PublisherVersionRepository publisherVersionRepository,
PublisherActionRepository publisherActionRepository,
UserActionRepository userActionRepository,
SharedService sharedService) {
this.publisherRepository = publisherRepository;
this.publisherVersionRepository = publisherVersionRepository;
this.publisherActionRepository = publisherActionRepository;
this.userActionRepository = userActionRepository;
this.sharedService = sharedService;
}
......@@ -73,6 +76,9 @@ public class PublisherServiceSpring implements PublisherService {
PublisherAction publisherAction = new PublisherAction();
publisherAction.setPublisherActionAuthor(sharedService.getCurrentUser());
publisherAction.setPublisherActionDatetime(new Timestamp(new Date().getTime()));
publisherAction.setUserAction(userActionRepository.findByUserActionName("Validate"));
publisherAction.setPublisherVersion(publisherVersion);
publisherAction.setPublisher(publisher);
this.savePublisher(publisher);
publisherActionRepository.save(publisherAction);
}
......
......@@ -33,9 +33,10 @@ public class PublisherServiceSpringTest {
public void setUp(@Mock PublisherRepository publisherRepository,
@Mock PublisherVersionRepository publisherVersionRepository,
@Mock PublisherActionRepository publisherActionRepository,
@Mock UserActionRepository userActionRepository,
@Mock SharedService sharedService) throws Exception {
publisherServiceSpring = new PublisherServiceSpring(publisherRepository,
publisherVersionRepository, publisherActionRepository, sharedService);
publisherVersionRepository, publisherActionRepository, userActionRepository, sharedService);
publisherVersion = new PublisherVersion();
publisherVersion1 = new PublisherVersion();
this.publisherRepository = publisherRepository;
......