Commit 1980f3d838895768e356fc5503a4cc4297fc6cc5

Authored by Pierrick
2 parents aae797e6 19deafe3

Fix conflicts

Showing 22 changed files with 426 additions and 156 deletions
skilldr-data_access/src/main/java/eu/totoandco/entitymanager/ModelAccess.java
... ... @@ -55,7 +55,7 @@ public class ModelAccess <T>{
55 55 * Entity manager to act on database
56 56 */
57 57 @PersistenceContext(unitName="eu_totoandco_hibernate")
58   - EntityManager em;
  58 + protected EntityManager em;
59 59  
60 60 /**
61 61 * Save an object in database using an EntityManager
... ...
skilldr-data_access/src/main/java/eu/totoandco/entitymanager/SkillAccess.java 0 → 100644
  1 +/**
  2 + * This file and all its content is share under Creative Commons
  3 + * Attribution 4.0 International License
  4 + * http://creativecommons.org/licenses/by/4.0/
  5 + *
  6 + * You are free to :
  7 + * Share - copy and redistribute the material in any medium
  8 + * or format
  9 + * Adapt - remix, transform, and build upon the material
  10 + * Under the folloawing terms :
  11 + * Attribution - You must give the appropriate credit, provide
  12 + * a link to the license, and indicate if changes were made.
  13 + * You may do so in any reasonable manner, but not in any way
  14 + * that suggests the licensor endorses you or your use.
  15 + * No additional restrictions
  16 + */
  17 +package eu.totoandco.entitymanager;
  18 +
  19 +import java.util.List;
  20 +
  21 +import javax.ejb.LocalBean;
  22 +import javax.ejb.Stateless;
  23 +import javax.persistence.PersistenceException;
  24 +import javax.persistence.TypedQuery;
  25 +
  26 +import org.apache.commons.logging.Log;
  27 +import org.apache.commons.logging.LogFactory;
  28 +
  29 +import eu.totoandco.exception.DataAccessException;
  30 +import eu.totoandco.exception.ExceptionLevel;
  31 +import eu.totoandco.exception.MessageCarrier;
  32 +import eu.totoandco.exception.MessageText;
  33 +import eu.totoandco.model.Skill;
  34 +
  35 +/**
  36 + * Provide methods to act on database concerning skill
  37 + * @author Ronan Presle (ronan.presle@ttmail.eu)
  38 + */
  39 +@Stateless
  40 +@LocalBean
  41 +public class SkillAccess extends ModelAccess<Skill> {
  42 + /**
  43 + * Instance of logger
  44 + */
  45 + private static final Log LOG = LogFactory.getLog("eu.totoandco.entitymanager");
  46 +
  47 + /**
  48 + * Get All instance of Skill for one user
  49 + * @param userId owner of the UserSkill
  50 + * @return list of Skill of same idSkill
  51 + */
  52 + public List<Skill> getAllUserSkills(int userId) {
  53 + List<Skill> skills;
  54 + TypedQuery<Skill> query = em.createQuery("SELECT s FROM UserSkill us JOIN us.idUserSkill.skill s WHERE us.idUserSkill.idUser = :userId GROUP BY us.idUserSkill.skill ORDER BY s.name", Skill.class);
  55 + query.setParameter("userId", userId);
  56 + try {
  57 + skills = query.getResultList();
  58 + } catch (PersistenceException e){
  59 + LOG.error(MessageText.ERROR_QUERY_TIMEOUT, e);
  60 + throw new DataAccessException(MessageCarrier.message(MessageText.ERROR_QUERY_TIMEOUT).level(ExceptionLevel.DANGER).exception(e).build());
  61 + }
  62 + return skills;
  63 + }
  64 +}
... ...
skilldr-data_access/src/main/java/eu/totoandco/entitymanager/UserAccess.java
... ... @@ -16,14 +16,10 @@
16 16 */
17 17 package eu.totoandco.entitymanager;
18 18  
19   -import java.util.List;
20   -
21 19 import javax.ejb.LocalBean;
22 20 import javax.ejb.Stateless;
23 21 import javax.persistence.NoResultException;
24 22 import javax.persistence.NonUniqueResultException;
25   -import javax.persistence.PersistenceException;
26   -import javax.persistence.TypedQuery;
27 23 import javax.persistence.criteria.CriteriaBuilder;
28 24 import javax.persistence.criteria.CriteriaQuery;
29 25 import javax.persistence.criteria.Root;
... ... @@ -35,7 +31,6 @@ import eu.totoandco.exception.DataAccessException;
35 31 import eu.totoandco.exception.ExceptionLevel;
36 32 import eu.totoandco.exception.MessageCarrier;
37 33 import eu.totoandco.exception.MessageText;
38   -import eu.totoandco.model.Skill;
39 34 import eu.totoandco.model.User;
40 35  
41 36 /**
... ... @@ -72,22 +67,4 @@ public class UserAccess extends ModelAccess&lt;User&gt;{
72 67 }
73 68 return user;
74 69 }
75   -
76   - /**
77   - * Get all skills that belongs to a user
78   - * @param userId id of the user
79   - * @return list of Skills
80   - */
81   - public List<Skill> getUserSkills(int userId) {
82   - List<Skill> skills;
83   - TypedQuery<Skill> query = em.createQuery("SELECT s FROM UserSkill us JOIN us.idUserSkill.skill s WHERE us.idUserSkill.idUser = :userId", Skill.class);
84   - query.setParameter("userId", userId);
85   - try {
86   - skills = query.getResultList();
87   - } catch (PersistenceException e){
88   - LOG.error(MessageText.ERROR_QUERY_TIMEOUT, e);
89   - throw new DataAccessException(MessageCarrier.message(MessageText.ERROR_QUERY_TIMEOUT).level(ExceptionLevel.DANGER).exception(e).build());
90   - }
91   - return skills;
92   - }
93 70 }
... ...
skilldr-data_access/src/main/java/eu/totoandco/entitymanager/UserSkillAccess.java 0 → 100644
  1 +/**
  2 + * This file and all its content is share under Creative Commons
  3 + * Attribution 4.0 International License
  4 + * http://creativecommons.org/licenses/by/4.0/
  5 + *
  6 + * You are free to :
  7 + * Share - copy and redistribute the material in any medium
  8 + * or format
  9 + * Adapt - remix, transform, and build upon the material
  10 + * Under the folloawing terms :
  11 + * Attribution - You must give the appropriate credit, provide
  12 + * a link to the license, and indicate if changes were made.
  13 + * You may do so in any reasonable manner, but not in any way
  14 + * that suggests the licensor endorses you or your use.
  15 + * No additional restrictions
  16 + */
  17 +package eu.totoandco.entitymanager;
  18 +
  19 +import java.util.List;
  20 +
  21 +import javax.ejb.LocalBean;
  22 +import javax.ejb.Stateless;
  23 +import javax.persistence.NoResultException;
  24 +import javax.persistence.NonUniqueResultException;
  25 +import javax.persistence.PersistenceException;
  26 +import javax.persistence.TypedQuery;
  27 +import javax.transaction.Transactional;
  28 +
  29 +import org.apache.commons.logging.Log;
  30 +import org.apache.commons.logging.LogFactory;
  31 +
  32 +import eu.totoandco.exception.DataAccessException;
  33 +import eu.totoandco.exception.ExceptionLevel;
  34 +import eu.totoandco.exception.MessageCarrier;
  35 +import eu.totoandco.exception.MessageText;
  36 +import eu.totoandco.model.Skill;
  37 +import eu.totoandco.model.UserSkill;
  38 +import eu.totoandco.model.UserSkillId;
  39 +
  40 +/**
  41 + * Provide methods to act on database concerning UserSkill
  42 + * @author Ronan Presle (ronan.presle@ttmail.eu)
  43 + */
  44 +@Stateless
  45 +@LocalBean
  46 +public class UserSkillAccess extends ModelAccess<UserSkill>{
  47 + /**
  48 + * Instance of logger
  49 + */
  50 + private static final Log LOG = LogFactory.getLog("eu.totoandco.entitymanager");
  51 +
  52 + /**
  53 + * Get the last inserted UserSkill object
  54 + * @param id UserSkillId object with userId and Skill set
  55 + * @return the last inserted UserSkill
  56 + */
  57 + @Override
  58 + @Transactional
  59 + public UserSkill get(Object id, Class<UserSkill> type) {
  60 + UserSkill ret = null;
  61 + TypedQuery<UserSkill> query = em.createQuery("SELECT us FROM UserSkill us JOIN us.idUserSkill.skill s WHERE us.idUserSkill.idUser = :userId AND us.idUserSkill.skill = :skillId AND us.idUserSkill.date in (SELECT MAX(us.idUserSkill.date) FROM UserSkill us GROUP BY us.idUserSkill.skill)", UserSkill.class);
  62 + query.setParameter("userId", ((UserSkillId) id).getIdUser());
  63 + query.setParameter("skillId", ((UserSkillId) id).getSkill());
  64 + try {
  65 + ret = query.getSingleResult();
  66 + } catch (NoResultException e) {
  67 + LOG.debug("No UserSkill found", e);
  68 + } catch (NonUniqueResultException e) {
  69 + LOG.debug(MessageText.ERROR_NO_USER_SKILL_FOUND.getMessage(), e);
  70 + throw new DataAccessException(MessageCarrier.message(MessageText.ERROR_NO_USER_SKILL_FOUND).level(ExceptionLevel.WARNING).exception(e).build());
  71 + }
  72 + return ret;
  73 + }
  74 + /**
  75 + * Remove the last UserSkill entity added
  76 + * @param entity user Skill containing at least idSkill and idUser
  77 + */
  78 + @Override
  79 + @Transactional
  80 + public void remove(UserSkill entity) {
  81 + TypedQuery<UserSkill> query = em.createQuery("SELECT us FROM UserSkill us WHERE us.idUserSkill.idUser = :userId AND us.idUserSkill.skill = :skillId AND us.idUserSkill.date in (SELECT MAX(us.idUserSkill.date) FROM UserSkill us GROUP BY us.idUserSkill.skill)", UserSkill.class);
  82 + query.setParameter("userId", entity.getidUserSkill().getIdUser());
  83 + query.setParameter("skillId", entity.getidUserSkill().getSkill());
  84 + try {
  85 + UserSkill ret = query.getSingleResult();
  86 + if (ret != null) {
  87 + super.remove(ret);
  88 + }
  89 + } catch (NoResultException e) {
  90 + LOG.debug("No UserSkill found", e);
  91 + } catch (NonUniqueResultException e) {
  92 + LOG.debug(MessageText.ERROR_NO_USER_SKILL_FOUND.getMessage(), e);
  93 + throw new DataAccessException(MessageCarrier.message(MessageText.ERROR_NO_USER_SKILL_FOUND).level(ExceptionLevel.WARNING).exception(e).build());
  94 + }
  95 + }
  96 +
  97 + /**
  98 + * Update the last UserSkill in database
  99 + * @param obj object to update. Must be an Entity
  100 + * @return the updated entity
  101 + */
  102 + @Override
  103 + @Transactional
  104 + public UserSkill update(UserSkill entity) {
  105 + TypedQuery<UserSkill> query = em.createQuery("SELECT us FROM UserSkill us WHERE us.idUserSkill.idUser = :userId AND us.idUserSkill.skill = :skillId AND us.idUserSkill.date in (SELECT MAX(us.idUserSkill.date) FROM UserSkill us GROUP BY us.idUserSkill.skill)", UserSkill.class);
  106 + query.setParameter("userId", entity.getidUserSkill().getIdUser());
  107 + query.setParameter("skillId", entity.getidUserSkill().getSkill());
  108 + try {
  109 + UserSkill ret = query.getSingleResult();
  110 + if (ret != null) {
  111 + ret.setPeriod(entity.getPeriod());
  112 + if (entity.getExperienceType() != null) {
  113 + ret.setExperienceType(entity.getExperienceType());
  114 + super.update(ret);
  115 + }
  116 + }
  117 + } catch (NoResultException e) {
  118 + LOG.debug("No UserSkill found", e);
  119 + } catch (NonUniqueResultException e) {
  120 + LOG.error(MessageText.ERROR_TOO_MANY_RESULT_USER_SKILL.getMessage(), e);
  121 + throw new DataAccessException(MessageCarrier.message(MessageText.ERROR_TOO_MANY_RESULT_USER_SKILL).level(ExceptionLevel.DANGER).exception(e).build());
  122 + }
  123 + return entity;
  124 + }
  125 +
  126 + /**
  127 + * Get all UserSkills that belongs to a user
  128 + * NOT the history of all skills
  129 + * @param userId id of the user
  130 + * @return list of Skills
  131 + */
  132 + public List<UserSkill> getAllUserSkillsByUser(int userId) {
  133 + List<UserSkill> skills;
  134 + TypedQuery<UserSkill> query = em.createQuery("SELECT us FROM UserSkill us WHERE us.idUserSkill.idUser = :userId", UserSkill.class);
  135 + query.setParameter("userId", userId);
  136 + try {
  137 + skills = query.getResultList();
  138 + } catch (PersistenceException e){
  139 + LOG.error(MessageText.ERROR_QUERY_TIMEOUT, e);
  140 + throw new DataAccessException(MessageCarrier.message(MessageText.ERROR_QUERY_TIMEOUT).level(ExceptionLevel.DANGER).exception(e).build());
  141 + }
  142 + return skills;
  143 + }
  144 +
  145 + /**
  146 + * Get All instance of UserSkill for ONE skill for one user
  147 + * Consider History for one skill
  148 + * @param userId owner of the UserSkill
  149 + * @param idSkill id of the Skill
  150 + * @return list of Skill of same idSkill
  151 + */
  152 + public List<UserSkill> getAllUserSkillsBySkill(int userId, Skill skill) {
  153 + List<UserSkill> skills;
  154 + TypedQuery<UserSkill> query = em.createQuery("SELECT us FROM UserSkill us WHERE us.idUserSkill.idUser = :userId AND us.idUserSkill.skill = :skillId ORDER BY us.idUserSkill.skill", UserSkill.class);
  155 + query.setParameter("userId", userId);
  156 + query.setParameter("skillId", skill);
  157 + try {
  158 + skills = query.getResultList();
  159 + } catch (PersistenceException e){
  160 + LOG.error(MessageText.ERROR_QUERY_TIMEOUT, e);
  161 + throw new DataAccessException(MessageCarrier.message(MessageText.ERROR_QUERY_TIMEOUT).level(ExceptionLevel.DANGER).exception(e).build());
  162 + }
  163 + return skills;
  164 + }
  165 +}
... ...
skilldr-data_access/src/test/java/eu/totoandco/entitymanager/UserModelTest.java
... ... @@ -75,6 +75,7 @@ public class UserModelTest {
75 75 domain = new Domain("domain");
76 76 modelDomain.save(domain);
77 77 job = new Job("jobName", domain);
  78 + modelJob.save(job);
78 79 }
79 80  
80 81 @Test
... ...
skilldr-data_access/src/test/java/eu/totoandco/entitymanager/UserSkillModelTest.java
... ... @@ -54,7 +54,7 @@ public class UserSkillModelTest {
54 54 @EJB
55 55 ModelAccess<ExperienceType> modelExperienceType;
56 56 @EJB
57   - ModelAccess<UserSkill> model;
  57 + UserSkillAccess userSkillAccess;
58 58  
59 59 User user;
60 60 Domain domain;
... ... @@ -78,34 +78,37 @@ public class UserSkillModelTest {
78 78 }
79 79  
80 80 @Test
81   - public void saveUpdateGetRemoveUserSkill(){
  81 + public void saveUpdateGetRemoveUserSkill() throws InterruptedException{
82 82 // Save
83   - UserSkill userSkill = new UserSkill(user, skill, 10, experienceType);
84   - Assert.assertTrue("Starting Id is equal to 0", userSkill.getUser() != 0 && userSkill.getSkill() != null);
85   - model.save(userSkill);
86   - Assert.assertTrue("Saved entity has no date", userSkill.getDate() != null);
  83 + UserSkill userSkill1 = new UserSkill(user, skill, 10, experienceType);
  84 + UserSkill userSkill2 = new UserSkill(user, skill, 10, experienceType);
  85 + userSkillAccess.save(userSkill1);
  86 + Thread.sleep(1000);
  87 + userSkillAccess.save(userSkill2);
  88 + Assert.assertTrue("Saved entity has no date", userSkill1.getDate() != null);
87 89  
88 90 // Get
89   - UserSkill userSkill2 = model.get(userSkill.getidUserSkill(), UserSkill.class);
90   - System.out.println("idSkill : " + userSkill2.getidUserSkill().getSkill().getId());
  91 + UserSkill inserted = userSkillAccess.get(userSkill1.getidUserSkill(), UserSkill.class);
91 92 Assert.assertNotNull("This entity is null after persist", userSkill2);
92   - Assert.assertEquals("Object returned from database is not equal to the saved one", userSkill, userSkill2);
  93 + Assert.assertEquals("Object returned from database is not equal to the saved one", inserted, userSkill2);
93 94  
94 95 // Update
95 96 userSkill2.setPeriod(20);
96   - userSkill = model.update(userSkill2);
97   - Assert.assertNotNull("This entity is null after update", userSkill);
98   - Assert.assertEquals("Object update in database is not equal to the expected one", userSkill, userSkill2);
  97 + UserSkill updated = userSkillAccess.update(userSkill2);
  98 + Assert.assertNotNull("This entity is null after update", updated);
  99 + Assert.assertEquals("Object update in database is not equal to the expected one", updated, userSkill2);
  100 + Assert.assertFalse("Object update in database is equal to an old one", updated.equals(userSkill1));
99 101  
100 102 // GetAll
101   - List<UserSkill> userSkills = model.getAll(UserSkill.class);
  103 + List<UserSkill> userSkills = userSkillAccess.getAll(UserSkill.class);
102 104 Assert.assertNotNull("The list is null after getAll", userSkills);
103   - Assert.assertTrue(userSkills.contains(userSkill));
  105 + Assert.assertTrue(userSkills.contains(userSkill1));
  106 + Assert.assertTrue(userSkills.contains(userSkill2));
104 107  
105 108 // Remove
106   - model.remove(userSkill2);
107   - userSkill = model.get(userSkill.getidUserSkill(), UserSkill.class);
108   - Assert.assertNull("The entity has not been removed", userSkill);
  109 + userSkillAccess.remove(userSkill2);
  110 + UserSkill userSkillOld = userSkillAccess.get(userSkill2.getidUserSkill(), UserSkill.class);
  111 + Assert.assertFalse("The entity has not been removed", userSkillOld.equals(userSkill2));
109 112 }
110 113  
111 114 @After
... ...
skilldr-data_model/src/main/java/eu/totoandco/data/parameter/ParameterName.java
... ... @@ -17,6 +17,9 @@
17 17 package eu.totoandco.data.parameter;
18 18  
19 19 /**
  20 + * Enum defining the different Parameter of the application
  21 + * The id correspond to the one in database.
  22 + * The value is a String containing parameter's value
20 23 * @author Ronan Presle
21 24 *
22 25 */
... ...
skilldr-data_model/src/main/java/eu/totoandco/exception/MessageText.java
... ... @@ -80,6 +80,14 @@ public enum MessageText {
80 80 */
81 81 ERROR_URL_NOT_AVAILABLE("This URL is not available on Skilldr. Check with you admin."),
82 82 /**
  83 + * Error when no UserSkill is found by the query based on idSkill
  84 + */
  85 + ERROR_NO_USER_SKILL_FOUND("No skill found for the associated user and skill"),
  86 + /**
  87 + * Too many Results for one couple user/Skill
  88 + */
  89 + ERROR_TOO_MANY_RESULT_USER_SKILL("Too many Results for one couple user/Skill"),
  90 + /**
83 91 * User is not connected
84 92 */
85 93 DISCONNECTED_USER("You must initialize a connection before doing this");
... ...
skilldr-data_model/src/main/java/eu/totoandco/model/User.java
... ... @@ -18,7 +18,6 @@ package eu.totoandco.model;
18 18  
19 19 import java.util.Date;
20 20  
21   -import javax.persistence.CascadeType;
22 21 import javax.persistence.Column;
23 22 import javax.persistence.Entity;
24 23 import javax.persistence.EnumType;
... ... @@ -67,7 +66,7 @@ public class User {
67 66 @Enumerated(EnumType.ORDINAL)
68 67 @Column(name="idRole")
69 68 private Role role;
70   - @ManyToOne(cascade={CascadeType.PERSIST})
  69 + @ManyToOne
71 70 @JoinColumn(name="idJob")
72 71 private Job job;
73 72  
... ...
skilldr-data_model/src/main/java/eu/totoandco/model/UserSkill.java
... ... @@ -17,7 +17,6 @@
17 17 package eu.totoandco.model;
18 18  
19 19 import java.io.Serializable;
20   -import java.text.DateFormat;
21 20 import java.util.Date;
22 21  
23 22 import javax.persistence.AssociationOverride;
... ... @@ -34,8 +33,6 @@ import javax.persistence.PreUpdate;
34 33 import javax.persistence.Table;
35 34 import javax.persistence.Transient;
36 35  
37   -import com.fasterxml.jackson.annotation.JsonFormat;
38   -
39 36 /**
40 37 * Container class concerning UserSkills Data
41 38 * @author Ronan Presle
... ... @@ -47,7 +44,9 @@ import com.fasterxml.jackson.annotation.JsonFormat;
47 44 @AssociationOverride(name = "idUserSkill.idUser",
48 45 joinColumns = @JoinColumn(name = "idUser")),
49 46 @AssociationOverride(name = "idUserSkill.skill",
50   - joinColumns = @JoinColumn(name = "idSkill")) })
  47 + joinColumns = @JoinColumn(name = "idSkill")),
  48 + @AssociationOverride(name = "idUserSkill.date",
  49 + joinColumns = @JoinColumn(name = "date")), })
51 50 public class UserSkill implements Serializable{
52 51 /**
53 52 *
... ... @@ -59,8 +58,6 @@ public class UserSkill implements Serializable{
59 58  
60 59 @Column(name="period")
61 60 private int period;
62   - @Column(name="date")
63   - private Date date;
64 61 @ManyToOne
65 62 @JoinColumn(name="idType")
66 63 private ExperienceType experienceType;
... ... @@ -77,7 +74,6 @@ public class UserSkill implements Serializable{
77 74 * @param user
78 75 * @param skill
79 76 * @param period
80   - * @param date
81 77 * @param experienceType
82 78 */
83 79 public UserSkill(User user, Skill skill, int period, ExperienceType experienceType) {
... ... @@ -89,10 +85,9 @@ public class UserSkill implements Serializable{
89 85  
90 86 /**
91 87 * Constructor to complete all data but the id
92   - * @param user
  88 + * @param idUser
93 89 * @param skill
94 90 * @param period
95   - * @param date
96 91 * @param experienceType
97 92 */
98 93 public UserSkill(int idUser, Skill skill, int period, ExperienceType experienceType) {
... ... @@ -104,7 +99,6 @@ public class UserSkill implements Serializable{
104 99  
105 100 /**
106 101 * Constructor to complete all data but the id and user
107   - * @param user
108 102 * @param skill
109 103 * @param period
110 104 * @param experienceType
... ... @@ -120,7 +114,7 @@ public class UserSkill implements Serializable{
120 114 */
121 115 @PrePersist
122 116 protected void onCreate() {
123   - this.date = new Date();
  117 + this.idUserSkill.setDate(new Date());
124 118 }
125 119  
126 120 /**
... ... @@ -128,7 +122,7 @@ public class UserSkill implements Serializable{
128 122 */
129 123 @PreUpdate
130 124 protected void onUpdate() {
131   - this.date = new Date();
  125 + this.idUserSkill.setDate(new Date());
132 126 }
133 127  
134 128 /**
... ... @@ -165,31 +159,30 @@ public class UserSkill implements Serializable{
165 159 public UserSkillId getidUserSkill() {
166 160 return this.idUserSkill;
167 161 }
168   -
169 162 /**
170   - * @return the period
  163 + * @return the date
171 164 */
172   - public int getPeriod() {
173   - return period;
  165 + @Transient
  166 + public Date getDate() {
  167 + return this.idUserSkill.getDate();
174 168 }
175 169 /**
176   - * @param period the period to set
  170 + * @param date the date to set
177 171 */
178   - public void setPeriod(int period) {
179   - this.period = period;
  172 + public void setDate(Date date) {
  173 + this.idUserSkill.setDate(date);
180 174 }
181 175 /**
182   - * @return the date
  176 + * @return the period
183 177 */
184   - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
185   - public Date getDate() {
186   - return date;
  178 + public int getPeriod() {
  179 + return period;
187 180 }
188 181 /**
189   - * @param date the date to set
  182 + * @param period the period to set
190 183 */
191   - public void setDate(Date date) {
192   - this.date = date;
  184 + public void setPeriod(int period) {
  185 + this.period = period;
193 186 }
194 187 /**
195 188 * @return the experienceType
... ... @@ -208,7 +201,6 @@ public class UserSkill implements Serializable{
208 201 public int hashCode() {
209 202 final int prime = 31;
210 203 int result = 1;
211   - result = prime * result + ((date == null) ? 0 : date.hashCode());
212 204 result = prime * result
213 205 + ((experienceType == null) ? 0 : experienceType.hashCode());
214 206 result = prime * result + period;
... ... @@ -229,14 +221,6 @@ public class UserSkill implements Serializable{
229 221 return false;
230 222 }
231 223 UserSkill other = (UserSkill) obj;
232   - DateFormat df = DateFormat.getDateInstance();
233   - if (date == null) {
234   - if (other.date != null) {
235   - return false;
236   - }
237   - } else if (!(df.format(date).equals(df.format(other.date)))){
238   - return false;
239   - }
240 224 if (experienceType == null) {
241 225 if (other.experienceType != null) {
242 226 return false;
... ...
skilldr-data_model/src/main/java/eu/totoandco/model/UserSkillId.java
... ... @@ -17,11 +17,15 @@
17 17 package eu.totoandco.model;
18 18  
19 19 import java.io.Serializable;
  20 +import java.text.DateFormat;
  21 +import java.util.Date;
20 22  
21 23 import javax.persistence.Column;
22 24 import javax.persistence.Embeddable;
23 25 import javax.persistence.ManyToOne;
24 26  
  27 +import com.fasterxml.jackson.annotation.JsonFormat;
  28 +
25 29 /**
26 30 * @author Ronan Presle
27 31 * Embeddable Key for UserSKill table
... ... @@ -33,6 +37,8 @@ public class UserSkillId implements Serializable{
33 37 private Skill skill;
34 38 @Column(name="idUser")
35 39 private int idUser;
  40 + @Column(name="date")
  41 + private Date date;
36 42 /**
37 43 * @return the skill
38 44 */
... ... @@ -57,6 +63,19 @@ public class UserSkillId implements Serializable{
57 63 public void setIdUser(int idUser) {
58 64 this.idUser = idUser;
59 65 }
  66 + /**
  67 + * @return the date
  68 + */
  69 + @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
  70 + public Date getDate() {
  71 + return date;
  72 + }
  73 + /**
  74 + * @param date the date to set
  75 + */
  76 + public void setDate(Date date) {
  77 + this.date = date;
  78 + }
60 79 /* (non-Javadoc)
61 80 * @see java.lang.Object#hashCode()
62 81 */
... ... @@ -64,6 +83,7 @@ public class UserSkillId implements Serializable{
64 83 public int hashCode() {
65 84 final int prime = 31;
66 85 int result = 1;
  86 + result = prime * result + ((date == null) ? 0 : date.hashCode());
67 87 result = prime * result + idUser;
68 88 result = prime * result + ((skill == null) ? 0 : skill.hashCode());
69 89 return result;
... ... @@ -83,6 +103,14 @@ public class UserSkillId implements Serializable{
83 103 return false;
84 104 }
85 105 UserSkillId other = (UserSkillId) obj;
  106 + DateFormat df = DateFormat.getDateInstance();
  107 + if (date == null) {
  108 + if (other.date != null) {
  109 + return false;
  110 + }
  111 + } else if (!(df.format(date).equals(df.format(other.date)))){
  112 + return false;
  113 + }
86 114 if (idUser != other.idUser) {
87 115 return false;
88 116 }
... ...
skilldr-properties/src/main/resources/buildScript.sql
... ... @@ -67,7 +67,7 @@ CREATE TABLE IF NOT EXISTS `userSkill` (
67 67 `period` int(8) NOT NULL,
68 68 `date` TIMESTAMP NOT NULL,
69 69 `idType` int(8) NOT NULL,
70   - PRIMARY KEY (`idUser`,`idSkill`),
  70 + PRIMARY KEY (`idUser`,`idSkill`, `date`),
71 71 FOREIGN KEY FK_userSkill_experienceType (`idType`) REFERENCES experienceType(`id`) ON DELETE CASCADE,
72 72 FOREIGN KEY FK_userSkill_user (`idUser`) REFERENCES user(`id`) ON DELETE CASCADE,
73 73 FOREIGN KEY FK_userSkill_skill (`idSkill`) REFERENCES skill(`id`) ON DELETE CASCADE
... ... @@ -90,4 +90,4 @@ INSERT INTO experienceType (`id`, `name`, `weight`) VALUES (2, &quot;Travail&quot;, 1);
90 90 INSERT INTO userSkill (`idUser`, `idSkill`, `period`, `date`, `idType`) VALUES (1, 1, 2, "2015-01-05 14:54:27", 1);
91 91 INSERT INTO parameterSkilldr (`id`, `value`, `descriptor`) VALUES (1, "0","Ability to signin for extern user");
92 92 INSERT INTO parameterSkilldr (`id`, `value`, `descriptor`) VALUES (2, "0","Ability to upgrade an USER to RH");
93   -INSERT INTO parameterSkilldr (`id`, `value`, `descriptor`) VALUES (3, "3650","Total skill mastery reference value");
94 93 \ No newline at end of file
  94 +INSERT INTO parameterSkilldr (`id`, `value`, `descriptor`) VALUES (3, "3650","Total skill mastery reference value");
... ...
skilldr-rs/src/main/java/eu/totoandco/rs/SkillEndPoint.java
... ... @@ -141,4 +141,17 @@ public class SkillEndPoint extends EndPoint {
141 141 RestParameterCheck.checkNotNegativeOrZero(idJob);
142 142 return skillManager.getJobSkill(idJob);
143 143 }
  144 +
  145 + /**
  146 + * Get all the skill of the current user
  147 + * @param request User's context
  148 + * @return the list of the user's skills
  149 + */
  150 + @GET
  151 + @Path("/p/userSkills")
  152 + public List<Skill> getUserSkills(@Context HttpServletRequest request) {
  153 + List<Skill> skills = null;
  154 + skills = skillManager.getAllSkillByUser(((User) request.getSession(false).getAttribute(USERSESSION)).getId());
  155 + return skills;
  156 + }
144 157 }
... ...
skilldr-rs/src/main/java/eu/totoandco/rs/UserEndPoint.java
... ... @@ -16,8 +16,6 @@
16 16 */
17 17 package eu.totoandco.rs;
18 18  
19   -import java.util.List;
20   -
21 19 import javax.ejb.EJB;
22 20 import javax.ejb.Stateless;
23 21 import javax.servlet.http.HttpServletRequest;
... ... @@ -36,7 +34,6 @@ import eu.totoandco.exception.ExceptionLevel;
36 34 import eu.totoandco.exception.MessageCarrier;
37 35 import eu.totoandco.exception.MessageText;
38 36 import eu.totoandco.exception.RestException;
39   -import eu.totoandco.model.Skill;
40 37 import eu.totoandco.model.User;
41 38  
42 39 /**
... ... @@ -52,7 +49,7 @@ public class UserEndPoint extends EndPoint {
52 49 * UserAccess EJB that provides business method
53 50 */
54 51 @EJB
55   - UserManager userAccess;
  52 + UserManager userManager;
56 53  
57 54 /**
58 55 * Method used to connect user to server
... ... @@ -74,8 +71,8 @@ public class UserEndPoint extends EndPoint {
74 71 throw new RestException(MessageCarrier
75 72 .message(MessageText.ERROR_STRING_EMPTY)
76 73 .level(ExceptionLevel.INFO).build());
77   - }
78   - User userSession = userAccess.connectUser(login, pwd);
  74 + }
  75 + User userSession = userManager.connectUser(login, pwd);
79 76 if (userSession != null) {
80 77 request.getSession(true).setAttribute(USERSESSION, userSession);
81 78 }
... ... @@ -125,7 +122,7 @@ public class UserEndPoint extends EndPoint {
125 122 .message(MessageText.ERROR_STRING_EMPTY)
126 123 .level(ExceptionLevel.INFO).build());
127 124 }
128   - User userSession = userAccess.addUser(login, pwd, firstname, name);
  125 + User userSession = userManager.addUser(login, pwd, firstname,name);
129 126 if (userSession != null) {
130 127 request.getSession(true).setAttribute(USERSESSION, userSession);
131 128 }
... ... @@ -149,7 +146,7 @@ public class UserEndPoint extends EndPoint {
149 146 .message(MessageText.ERROR_OBJECT_NULL)
150 147 .level(ExceptionLevel.INFO).build());
151 148 }
152   - return userAccess.removeUser((User) request.getSession(false)
  149 + return userManager.removeUser((User) request.getSession(false)
153 150 .getAttribute(USERSESSION), idUser);
154 151 }
155 152  
... ... @@ -162,7 +159,7 @@ public class UserEndPoint extends EndPoint {
162 159 @POST
163 160 @Path("/userTmp")
164 161 public User addUserTmp(@Context HttpServletRequest request) {
165   - User userSession = userAccess.addUser(null, null, null, null);
  162 + User userSession = userManager.addUser(null,null,null,null);
166 163 if (userSession != null) {
167 164 request.getSession(true).setAttribute(USERSESSION, userSession);
168 165 }
... ... @@ -189,7 +186,7 @@ public class UserEndPoint extends EndPoint {
189 186 .message(MessageText.ERROR_STRING_EMPTY)
190 187 .level(ExceptionLevel.INFO).build());
191 188 }
192   - return userAccess.grantPermission((User) request.getSession(false)
  189 + return userManager.grantPermission((User) request.getSession(false)
193 190 .getAttribute(USERSESSION), login, role);
194 191 }
195 192  
... ... @@ -222,22 +219,8 @@ public class UserEndPoint extends EndPoint {
222 219 .message(MessageText.ERROR_STRING_EMPTY)
223 220 .level(ExceptionLevel.INFO).build());
224 221 }
225   - return userAccess.updateUser((User) request.getSession(false)
226   - .getAttribute(USERSESSION), login, pwd, firstname, name);
227   - }
228   -
229   - /**
230   - * Get all the skill of the current user
231   - *
232   - * @param request
233   - * User's context
234   - * @return the list of the user's skills
235   - */
236   - @GET
237   - @Path("/p/userSkills")
238   - public List<Skill> getUserSkills(@Context HttpServletRequest request) {
239   - List<Skill> skills = null;
240   - skills = userAccess.getUserSkills(1);
241   - return skills;
  222 + return userManager.updateUser(
  223 + (User) request.getSession(false).getAttribute(USERSESSION), login,
  224 + pwd, firstname, name);
242 225 }
243 226 }
... ...
skilldr-service/src/main/java/eu/totoandco/business/SkillManager.java
... ... @@ -6,7 +6,8 @@ import javax.ejb.EJB;
6 6 import javax.ejb.LocalBean;
7 7 import javax.ejb.Stateless;
8 8  
9   -import eu.totoandco.entitymanager.ModelAccess;
  9 +import eu.totoandco.entitymanager.SkillAccess;
  10 +import eu.totoandco.entitymanager.UserSkillAccess;
10 11 import eu.totoandco.model.ExperienceType;
11 12 import eu.totoandco.model.Job;
12 13 import eu.totoandco.model.Skill;
... ... @@ -21,10 +22,10 @@ import eu.totoandco.model.UserSkill;
21 22 public class SkillManager {
22 23  
23 24 @EJB
24   - ModelAccess<Skill> modelSkill;
  25 + SkillAccess skillAccess;
25 26  
26 27 @EJB
27   - ModelAccess<UserSkill> modelUserSkill;
  28 + UserSkillAccess userSkillAccess;
28 29  
29 30 /**
30 31 * Add a new skill in DB
... ... @@ -36,7 +37,7 @@ public class SkillManager {
36 37 Job j = new Job();
37 38 j.setId(idJob);
38 39 Skill s = new Skill(nameSkill, j);
39   - modelSkill.save(s);
  40 + skillAccess.save(s);
40 41  
41 42 return s;
42 43 }
... ... @@ -48,7 +49,7 @@ public class SkillManager {
48 49 public void removeSkill(int idSkill){
49 50 Skill s = new Skill();
50 51 s.setId(idSkill);
51   - modelSkill.remove(s);
  52 + skillAccess.remove(s);
52 53 }
53 54  
54 55 /**
... ... @@ -66,7 +67,7 @@ public class SkillManager {
66 67 ExperienceType et = new ExperienceType();
67 68 et.setId(idExperienceType);
68 69 UserSkill us = new UserSkill(idUser, s, period, et);
69   - modelUserSkill.save(us);
  70 + userSkillAccess.save(us);
70 71 return us;
71 72 }
72 73  
... ... @@ -85,7 +86,7 @@ public class SkillManager {
85 86 ExperienceType et = new ExperienceType();
86 87 et.setId(idExperienceType);
87 88 UserSkill us = new UserSkill(idUser, s, period, et);
88   - return modelUserSkill.update(us);
  89 + return userSkillAccess.update(us);
89 90 }
90 91  
91 92 /**
... ... @@ -102,7 +103,37 @@ public class SkillManager {
102 103 sk.setId(idSkill);
103 104 uk.setSkill(sk);
104 105  
105   - modelUserSkill.remove(uk);
  106 + userSkillAccess.remove(uk);
  107 + }
  108 +
  109 + /**
  110 + * Get all the skill of a specific user from dataAccess
  111 + * @param userId id of the user
  112 + * @return a List of Skill
  113 + */
  114 + public List<Skill> getAllSkillByUser(int userId) {
  115 + return skillAccess.getAllUserSkills(userId);
  116 + }
  117 +
  118 + /**
  119 + * Get All instance of UserSkill for one user
  120 + * @param userId owner of the UserSkill
  121 + * @return list of Skill of same idSkill
  122 + */
  123 + public List<UserSkill> getAllUserSkillsByUser(int userId) {
  124 + return userSkillAccess.getAllUserSkillsByUser(userId);
  125 + }
  126 +
  127 + /**
  128 + * Get All instance of UserSkill for ONE skill for one user
  129 + * @param userId owner of the UserSkill
  130 + * @param idSkill id of the Skill
  131 + * @return list of Skill of same idSkill
  132 + */
  133 + public List<UserSkill> getAllUserSkillsBySkill(int userId, int skillId) {
  134 + Skill skill = new Skill();
  135 + skill.setId(skillId);
  136 + return userSkillAccess.getAllUserSkillsBySkill(userId, skill);
106 137 }
107 138  
108 139 /**
... ... @@ -111,6 +142,6 @@ public class SkillManager {
111 142 * @return List of Skill
112 143 */
113 144 public List<Skill> getJobSkill (int idJob){
114   - return modelSkill.search(Skill.class, "idJob", idJob);
  145 + return skillAccess.search(Skill.class, "idJob", idJob);
115 146 }
116 147 }
... ...
skilldr-service/src/main/java/eu/totoandco/business/UserManager.java
... ... @@ -15,7 +15,6 @@ import eu.totoandco.exception.ExceptionLevel;
15 15 import eu.totoandco.exception.MessageCarrier;
16 16 import eu.totoandco.exception.MessageText;
17 17 import eu.totoandco.exception.ServiceException;
18   -import eu.totoandco.model.Skill;
19 18 import eu.totoandco.model.User;
20 19  
21 20 /**
... ... @@ -164,14 +163,4 @@ public class UserManager {
164 163 }
165 164 return result;
166 165 }
167   -
168   - /**
169   - * Get all the skill of a specific user from dataAccess
170   - * @param userId id of the user
171   - * @return a List of Skill
172   - */
173   - public List<Skill> getUserSkills(int userId) {
174   - return modelUser.getUserSkills(userId);
175   - }
176   -
177 166 }
... ...
skilldr-service/src/test/java/eu/totoandco/business/DomainAddRemoveManagerTest.java
... ... @@ -31,7 +31,6 @@ import eu.totoandco.cache.ParameterCache;
31 31 import eu.totoandco.data.Role;
32 32 import eu.totoandco.data.parameter.Parameter;
33 33 import eu.totoandco.entitymanager.ModelAccess;
34   -import eu.totoandco.entitymanager.UserAccess;
35 34 import eu.totoandco.exception.MessageException;
36 35 import eu.totoandco.model.Domain;
37 36  
... ... @@ -45,13 +44,12 @@ public class DomainAddRemoveManagerTest {
45 44 public static WebArchive createTestArchive() {
46 45 WebArchive war = ShrinkWrap
47 46 .create(WebArchive.class, "test.war")
48   - .addClasses(ModelAccess.class, UserAccess.class, DomainManager.class)
  47 + .addClasses(ModelAccess.class, DomainManager.class)
49 48 .addPackage(MessageException.class.getPackage())
50 49 .addPackage(Parameter.class.getPackage())
51 50 .addPackage(ParameterCache.class.getPackage())
52 51 .addPackage(Domain.class.getPackage())
53 52 .addPackage(Role.class.getPackage())
54   - .addPackage(SkillManager.class.getPackage())
55 53 .addAsResource(
56 54 new ClassLoaderAsset("META-INF/persistence.xml"),
57 55 "META-INF/persistence.xml");
... ...
skilldr-service/src/test/java/eu/totoandco/business/ExperienceTypeAddRemoveManagerTest.java
... ... @@ -31,7 +31,6 @@ import eu.totoandco.cache.ParameterCache;
31 31 import eu.totoandco.data.Role;
32 32 import eu.totoandco.data.parameter.Parameter;
33 33 import eu.totoandco.entitymanager.ModelAccess;
34   -import eu.totoandco.entitymanager.UserAccess;
35 34 import eu.totoandco.exception.MessageException;
36 35 import eu.totoandco.model.ExperienceType;
37 36  
... ... @@ -45,13 +44,12 @@ public class ExperienceTypeAddRemoveManagerTest {
45 44 public static WebArchive createTestArchive() {
46 45 WebArchive war = ShrinkWrap
47 46 .create(WebArchive.class, "test.war")
48   - .addClasses(ModelAccess.class, UserAccess.class)
  47 + .addClasses(ModelAccess.class,ExperienceTypeManager.class)
49 48 .addPackage(MessageException.class.getPackage())
50 49 .addPackage(Parameter.class.getPackage())
51 50 .addPackage(ParameterCache.class.getPackage())
52 51 .addPackage(ExperienceType.class.getPackage())
53 52 .addPackage(Role.class.getPackage())
54   - .addPackage(SkillManager.class.getPackage())
55 53 .addAsResource(
56 54 new ClassLoaderAsset("META-INF/persistence.xml"),
57 55 "META-INF/persistence.xml");
... ...
skilldr-service/src/test/java/eu/totoandco/business/UserGetSkillTest.java renamed to skilldr-service/src/test/java/eu/totoandco/business/GetAllSkillsTest.java
... ... @@ -35,7 +35,8 @@ import eu.totoandco.cache.ParameterCache;
35 35 import eu.totoandco.data.Role;
36 36 import eu.totoandco.data.parameter.Parameter;
37 37 import eu.totoandco.entitymanager.ModelAccess;
38   -import eu.totoandco.entitymanager.UserAccess;
  38 +import eu.totoandco.entitymanager.SkillAccess;
  39 +import eu.totoandco.entitymanager.UserSkillAccess;
39 40 import eu.totoandco.exception.MessageException;
40 41 import eu.totoandco.model.Domain;
41 42 import eu.totoandco.model.ExperienceType;
... ... @@ -49,26 +50,25 @@ import eu.totoandco.model.UserSkill;
49 50 * @author Ronan Presle (ronan.presle@ttmail.eu)
50 51 */
51 52 @RunWith(Arquillian.class)
52   -public class UserGetSkillTest {
  53 +public class GetAllSkillsTest {
53 54  
54 55 @Deployment
55 56 public static WebArchive createTestArchive() {
56 57 WebArchive war = ShrinkWrap
57 58 .create(WebArchive.class, "test.war")
58   - .addClasses(ModelAccess.class, UserAccess.class)
  59 + .addClasses(ModelAccess.class, SkillAccess.class, SkillManager.class, UserSkillAccess.class)
59 60 .addPackage(MessageException.class.getPackage())
60 61 .addPackage(Parameter.class.getPackage())
61 62 .addPackage(ParameterCache.class.getPackage())
62 63 .addPackage(Domain.class.getPackage())
63 64 .addPackage(Role.class.getPackage())
64   - .addPackage(SkillManager.class.getPackage())
65 65 .addAsResource(
66 66 new ClassLoaderAsset("META-INF/persistence.xml"),
67 67 "META-INF/persistence.xml");
68 68 return war;
69 69 }
70 70 @EJB
71   - UserAccess userManager;
  71 + SkillManager skillManager;
72 72  
73 73 @EJB
74 74 ModelAccess<Domain> modelDomain;
... ... @@ -85,42 +85,72 @@ public class UserGetSkillTest {
85 85  
86 86 Domain domain;
87 87 Job job;
88   - Skill skill;
  88 + Skill skill1;
  89 + Skill skill2;
89 90 User user;
90 91 ExperienceType experienceType;
91 92 UserSkill userSkill;
  93 + UserSkill userSkillSameSkill;
  94 + UserSkill userSkillDiffSkill;
92 95  
93 96 @Before
94   - public void init() {
  97 + public void init() throws InterruptedException {
95 98 domain = new Domain("TestDomain");
96 99 modelDomain.save(domain);
97 100 job = new Job("TestJob", domain);
98 101 modelJob.save(job);
99   - skill = new Skill("TestSkill", job);
100   - modelSkill.save(skill);
  102 + skill1 = new Skill("TestSkill1", job);
  103 + modelSkill.save(skill1);
  104 + skill2 = new Skill("TestSkill2", job);
  105 + modelSkill.save(skill2);
101 106 user = new User();
102 107 user.setTag("TAG");
103 108 modelUser.save(user);
104 109 experienceType = new ExperienceType("TestExperienceType", 0.5);
105 110 modelExperienceType.save(experienceType);
106   - userSkill = new UserSkill(user, skill, 2, experienceType);
  111 + userSkill = new UserSkill(user, skill1, 2, experienceType);
107 112 modelUserSkill.save(userSkill);
  113 + Thread.sleep(1000);
  114 + userSkillSameSkill = new UserSkill(user, skill1, 3, experienceType);
  115 + modelUserSkill.save(userSkillSameSkill);
  116 + Thread.sleep(1000);
  117 + userSkillDiffSkill = new UserSkill(user, skill2, 3, experienceType);
  118 + modelUserSkill.save(userSkillDiffSkill);
108 119 }
109 120  
110 121 @Test
111   - public void test() {
112   - List<Skill> skills = userManager.getUserSkills(user.getId());
  122 + public void getAllSkillTest() {
  123 + // getAllSkillByUser
  124 + List<Skill> skills = skillManager.getAllSkillByUser(user.getId());
113 125 Assert.assertNotNull("The found list is null", skills);
114 126 Assert.assertTrue("No skills found in database", !skills.isEmpty());
115   - Assert.assertTrue("First skill is not the inserted one", skills.get(0).equals(skill));
  127 + Assert.assertTrue("Number of skill different from two skill Found", skills.size() == 2);
  128 + Assert.assertTrue("First skill is an inserted one", skills.get(0).equals(skill1) || skills.get(0).equals(skill2));
  129 +
  130 + // getAllUserSkillsByUser
  131 + List<UserSkill> userSkills = skillManager.getAllUserSkillsByUser(user.getId());
  132 + Assert.assertNotNull("The found list is null", userSkills);
  133 + Assert.assertTrue("No skills found in database", !userSkills.isEmpty());
  134 + Assert.assertTrue("Number of skill different from three userSkill Found", userSkills.size() == 3);
  135 + Assert.assertTrue("First Userkill is not the inserted one", userSkills.get(0).equals(userSkill) || userSkills.get(0).equals(userSkillDiffSkill) || userSkills.get(0).equals(userSkillSameSkill));
  136 +
  137 + // getAllUserSkillsBySkill
  138 + userSkills = skillManager.getAllUserSkillsBySkill(user.getId(), skill1.getId());
  139 + Assert.assertNotNull("The found list is null", userSkills);
  140 + Assert.assertTrue("No skills found in database", !userSkills.isEmpty());
  141 + Assert.assertTrue("Number of skill different from two userSkill Found", userSkills.size() == 2);
  142 + Assert.assertTrue("First Userkill is not the inserted one", userSkills.get(0).equals(userSkill) || userSkills.get(0).equals(userSkillDiffSkill));
116 143 }
117 144  
118 145 @After
119 146 public void close() {
120 147 modelUserSkill.remove(userSkill);
  148 + modelUserSkill.remove(userSkillSameSkill);
  149 + modelUserSkill.remove(userSkillDiffSkill);
121 150 modelExperienceType.remove(experienceType);
122 151 modelUser.remove(user);
123   - modelSkill.remove(skill);
  152 + modelSkill.remove(skill1);
  153 + modelSkill.remove(skill2);
124 154 modelJob.remove(job);
125 155 modelDomain.remove(domain);
126 156 }
... ...
skilldr-service/src/test/java/eu/totoandco/business/JobAddRemoveManagerTest.java
... ... @@ -33,7 +33,6 @@ import eu.totoandco.cache.ParameterCache;
33 33 import eu.totoandco.data.Role;
34 34 import eu.totoandco.data.parameter.Parameter;
35 35 import eu.totoandco.entitymanager.ModelAccess;
36   -import eu.totoandco.entitymanager.UserAccess;
37 36 import eu.totoandco.exception.MessageException;
38 37 import eu.totoandco.model.Domain;
39 38 import eu.totoandco.model.Job;
... ... @@ -48,13 +47,12 @@ public class JobAddRemoveManagerTest {
48 47 public static WebArchive createTestArchive() {
49 48 WebArchive war = ShrinkWrap
50 49 .create(WebArchive.class, "test.war")
51   - .addClasses(ModelAccess.class, UserAccess.class)
  50 + .addClasses(ModelAccess.class, JobManager.class)
52 51 .addPackage(MessageException.class.getPackage())
53 52 .addPackage(Parameter.class.getPackage())
54 53 .addPackage(ParameterCache.class.getPackage())
55 54 .addPackage(Job.class.getPackage())
56 55 .addPackage(Role.class.getPackage())
57   - .addPackage(SkillManager.class.getPackage())
58 56 .addAsResource(
59 57 new ClassLoaderAsset("META-INF/persistence.xml"),
60 58 "META-INF/persistence.xml");
... ...
skilldr-service/src/test/java/eu/totoandco/business/JobGetDomainJobTest.java
... ... @@ -35,7 +35,6 @@ import eu.totoandco.cache.ParameterCache;
35 35 import eu.totoandco.data.Role;
36 36 import eu.totoandco.data.parameter.Parameter;
37 37 import eu.totoandco.entitymanager.ModelAccess;
38   -import eu.totoandco.entitymanager.UserAccess;
39 38 import eu.totoandco.exception.MessageException;
40 39 import eu.totoandco.model.Domain;
41 40 import eu.totoandco.model.Job;
... ... @@ -51,13 +50,12 @@ public class JobGetDomainJobTest {
51 50 public static WebArchive createTestArchive() {
52 51 return ShrinkWrap
53 52 .create(WebArchive.class, "test.war")
54   - .addClasses(ModelAccess.class, UserAccess.class)
  53 + .addClasses(ModelAccess.class, JobManager.class)
55 54 .addPackage(MessageException.class.getPackage())
56 55 .addPackage(Parameter.class.getPackage())
57 56 .addPackage(ParameterCache.class.getPackage())
58 57 .addPackage(Job.class.getPackage())
59 58 .addPackage(Role.class.getPackage())
60   - .addPackage(SkillManager.class.getPackage())
61 59 .addAsResource(
62 60 new ClassLoaderAsset("META-INF/persistence.xml"),
63 61 "META-INF/persistence.xml");
... ...
skilldr-service/src/test/java/eu/totoandco/business/SkillAddRemoveManagerTest.java
... ... @@ -17,7 +17,8 @@ import eu.totoandco.cache.ParameterCache;
17 17 import eu.totoandco.data.Role;
18 18 import eu.totoandco.data.parameter.Parameter;
19 19 import eu.totoandco.entitymanager.ModelAccess;
20   -import eu.totoandco.entitymanager.UserAccess;
  20 +import eu.totoandco.entitymanager.SkillAccess;
  21 +import eu.totoandco.entitymanager.UserSkillAccess;
21 22 import eu.totoandco.exception.MessageException;
22 23 import eu.totoandco.model.Domain;
23 24 import eu.totoandco.model.ExperienceType;
... ... @@ -39,13 +40,12 @@ public class SkillAddRemoveManagerTest {
39 40 public static WebArchive createTestArchive() {
40 41 WebArchive war = ShrinkWrap
41 42 .create(WebArchive.class, "test.war")
42   - .addClasses(ModelAccess.class, UserAccess.class)
  43 + .addClasses(ModelAccess.class, SkillManager.class, SkillAccess.class, UserSkillAccess.class)
43 44 .addPackage(MessageException.class.getPackage())
44 45 .addPackage(Parameter.class.getPackage())
45 46 .addPackage(ParameterCache.class.getPackage())
46 47 .addPackage(Domain.class.getPackage())
47 48 .addPackage(Role.class.getPackage())
48   - .addPackage(SkillManager.class.getPackage())
49 49 .addAsResource(
50 50 new ClassLoaderAsset("META-INF/persistence.xml"),
51 51 "META-INF/persistence.xml");
... ...