Commit e37c8c37 authored by feelback's avatar feelback

finished

parent e247ca1b
Pipeline #8390 failed
{
"name": "Feelback",
"fields": [
{
"fieldName": "generalMood",
"fieldType": "Mood",
"fieldValues": "SAD,SOSO,GOOD,AWESOME"
},
{
"fieldName": "ipponMood",
"fieldType": "Mood",
"fieldValues": "SAD,SOSO,GOOD,AWESOME"
},
{
"fieldName": "missionMood",
"fieldType": "Mood",
"fieldValues": "SAD,SOSO,GOOD,AWESOME"
},
{
"fieldName": "date",
"fieldType": "LocalDate"
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipName": "mission",
"otherEntityName": "mission",
"otherEntityField": "id"
},
{
"relationshipType": "many-to-one",
"relationshipName": "employee",
"otherEntityName": "user",
"otherEntityField": "id"
}
],
"changelogDate": "20181129125404",
"entityTableName": "feelback",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}
\ No newline at end of file
{
"name": "Mission",
"fields": [
{
"fieldName": "client",
"fieldType": "String"
},
{
"fieldName": "missionName",
"fieldType": "String"
},
{
"fieldName": "location",
"fieldType": "String"
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipName": "salesperson",
"otherEntityName": "user",
"otherEntityField": "id"
}
],
"changelogDate": "20181129125405",
"entityTableName": "mission",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}
\ No newline at end of file
entity Feelback {
generalMood Mood,
ipponMood Mood,
missionMood Mood,
date LocalDate
}
entity Mission {
client String,
missionName String,
location String
}
enum Mood {
SAD, SOSO, GOOD, AWESOME
}
relationship ManyToOne {
Feelback{mission} to Mission,
Feelback{employee} to User,
Mission{salesperson} to User
}
......@@ -38,6 +38,8 @@ public class CacheConfiguration {
cm.createCache(fr.ippon.feelback.domain.User.class.getName(), jcacheConfiguration);
cm.createCache(fr.ippon.feelback.domain.Authority.class.getName(), jcacheConfiguration);
cm.createCache(fr.ippon.feelback.domain.User.class.getName() + ".authorities", jcacheConfiguration);
cm.createCache(fr.ippon.feelback.domain.Feelback.class.getName(), jcacheConfiguration);
cm.createCache(fr.ippon.feelback.domain.Mission.class.getName(), jcacheConfiguration);
// jhipster-needle-ehcache-add-entry
};
}
......
package fr.ippon.feelback.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Objects;
import fr.ippon.feelback.domain.enumeration.Mood;
/**
* A Feelback.
*/
@Entity
@Table(name = "feelback")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Feelback implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@Enumerated(EnumType.STRING)
@Column(name = "general_mood")
private Mood generalMood;
@Enumerated(EnumType.STRING)
@Column(name = "ippon_mood")
private Mood ipponMood;
@Enumerated(EnumType.STRING)
@Column(name = "mission_mood")
private Mood missionMood;
@Column(name = "jhi_date")
private LocalDate date;
@ManyToOne
@JsonIgnoreProperties("")
private Mission mission;
@ManyToOne
@JsonIgnoreProperties("")
private User employee;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Mood getGeneralMood() {
return generalMood;
}
public Feelback generalMood(Mood generalMood) {
this.generalMood = generalMood;
return this;
}
public void setGeneralMood(Mood generalMood) {
this.generalMood = generalMood;
}
public Mood getIpponMood() {
return ipponMood;
}
public Feelback ipponMood(Mood ipponMood) {
this.ipponMood = ipponMood;
return this;
}
public void setIpponMood(Mood ipponMood) {
this.ipponMood = ipponMood;
}
public Mood getMissionMood() {
return missionMood;
}
public Feelback missionMood(Mood missionMood) {
this.missionMood = missionMood;
return this;
}
public void setMissionMood(Mood missionMood) {
this.missionMood = missionMood;
}
public LocalDate getDate() {
return date;
}
public Feelback date(LocalDate date) {
this.date = date;
return this;
}
public void setDate(LocalDate date) {
this.date = date;
}
public Mission getMission() {
return mission;
}
public Feelback mission(Mission mission) {
this.mission = mission;
return this;
}
public void setMission(Mission mission) {
this.mission = mission;
}
public User getEmployee() {
return employee;
}
public Feelback employee(User user) {
this.employee = user;
return this;
}
public void setEmployee(User user) {
this.employee = user;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Feelback feelback = (Feelback) o;
if (feelback.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), feelback.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Feelback{" +
"id=" + getId() +
", generalMood='" + getGeneralMood() + "'" +
", ipponMood='" + getIpponMood() + "'" +
", missionMood='" + getMissionMood() + "'" +
", date='" + getDate() + "'" +
"}";
}
}
package fr.ippon.feelback.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
/**
* A Mission.
*/
@Entity
@Table(name = "mission")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Mission implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@Column(name = "client")
private String client;
@Column(name = "mission_name")
private String missionName;
@Column(name = "location")
private String location;
@ManyToOne
@JsonIgnoreProperties("")
private User salesperson;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getClient() {
return client;
}
public Mission client(String client) {
this.client = client;
return this;
}
public void setClient(String client) {
this.client = client;
}
public String getMissionName() {
return missionName;
}
public Mission missionName(String missionName) {
this.missionName = missionName;
return this;
}
public void setMissionName(String missionName) {
this.missionName = missionName;
}
public String getLocation() {
return location;
}
public Mission location(String location) {
this.location = location;
return this;
}
public void setLocation(String location) {
this.location = location;
}
public User getSalesperson() {
return salesperson;
}
public Mission salesperson(User user) {
this.salesperson = user;
return this;
}
public void setSalesperson(User user) {
this.salesperson = user;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Mission mission = (Mission) o;
if (mission.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), mission.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Mission{" +
"id=" + getId() +
", client='" + getClient() + "'" +
", missionName='" + getMissionName() + "'" +
", location='" + getLocation() + "'" +
"}";
}
}
package fr.ippon.feelback.domain.enumeration;
/**
* The Mood enumeration.
*/
public enum Mood {
SAD, SOSO, GOOD, AWESOME
}
package fr.ippon.feelback.repository;
import fr.ippon.feelback.domain.Feelback;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Spring Data repository for the Feelback entity.
*/
@SuppressWarnings("unused")
@Repository
public interface FeelbackRepository extends JpaRepository<Feelback, Long> {
@Query("select feelback from Feelback feelback where feelback.employee.login = ?#{principal.username}")
List<Feelback> findByEmployeeIsCurrentUser();
}
package fr.ippon.feelback.repository;
import fr.ippon.feelback.domain.Mission;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Spring Data repository for the Mission entity.
*/
@SuppressWarnings("unused")
@Repository
public interface MissionRepository extends JpaRepository<Mission, Long> {
@Query("select mission from Mission mission where mission.salesperson.login = ?#{principal.username}")
List<Mission> findBySalespersonIsCurrentUser();
}
package fr.ippon.feelback.web.rest;
import com.codahale.metrics.annotation.Timed;
import fr.ippon.feelback.domain.Feelback;
import fr.ippon.feelback.repository.FeelbackRepository;
import fr.ippon.feelback.repository.UserRepository;
import fr.ippon.feelback.security.SecurityUtils;
import fr.ippon.feelback.web.rest.errors.BadRequestAlertException;
import fr.ippon.feelback.web.rest.util.HeaderUtil;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing Feelback.
*/
@RestController
@RequestMapping("/api")
public class FeelbackResource {
private final Logger log = LoggerFactory.getLogger(FeelbackResource.class);
private static final String ENTITY_NAME = "feelback";
private final FeelbackRepository feelbackRepository;
private final UserRepository userRepository;
public FeelbackResource(FeelbackRepository feelbackRepository, UserRepository userRepository) {
this.feelbackRepository = feelbackRepository;
this.userRepository = userRepository;
}
/**
* POST /feelbacks : Create a new feelback.
*
* @param feelback the feelback to create
* @return the ResponseEntity with status 201 (Created) and with body the new feelback, or with status 400 (Bad Request) if the feelback has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/feelbacks")
@Timed
public ResponseEntity<Feelback> createFeelback(@RequestBody Feelback feelback) throws URISyntaxException {
log.debug("REST request to save Feelback : {}", feelback);
if (feelback.getId() != null) {
throw new BadRequestAlertException("A new feelback cannot already have an ID", ENTITY_NAME, "idexists");
}
feelback.date(LocalDate.now());
String currentUserLogin = SecurityUtils.getCurrentUserLogin().orElse(null);
feelback.employee(userRepository.findOneByLogin(currentUserLogin).orElse(null));
if(feelback.getEmployee() == null)
return ResponseEntity.badRequest().body(null);
Feelback result = feelbackRepository.save(feelback);
return ResponseEntity.created(new URI("/api/feelbacks/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /feelbacks : Updates an existing feelback.
*
* @param feelback the feelback to update
* @return the ResponseEntity with status 200 (OK) and with body the updated feelback,
* or with status 400 (Bad Request) if the feelback is not valid,
* or with status 500 (Internal Server Error) if the feelback couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/feelbacks")
@Timed
public ResponseEntity<Feelback> updateFeelback(@RequestBody Feelback feelback) throws URISyntaxException {
log.debug("REST request to update Feelback : {}", feelback);
if (feelback.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
Feelback result = feelbackRepository.save(feelback);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, feelback.getId().toString()))
.body(result);
}
/**
* GET /feelbacks : get all the feelbacks.
*
* @return the ResponseEntity with status 200 (OK) and the list of feelbacks in body
*/
@GetMapping("/feelbacks")
@Timed
public List<Feelback> getAllFeelbacks() {
log.debug("REST request to get all Feelbacks");
return feelbackRepository.findAll();
}
/**
* GET /feelbacks/:id : get the "id" feelback.
*
* @param id the id of the feelback to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the feelback, or with status 404 (Not Found)
*/
@GetMapping("/feelbacks/{id}")
@Timed
public ResponseEntity<Feelback> getFeelback(@PathVariable Long id) {
log.debug("REST request to get Feelback : {}", id);
Optional<Feelback> feelback = feelbackRepository.findById(id);
return ResponseUtil.wrapOrNotFound(feelback);
}
@GetMapping("/feelbacks/user")
@Timed
public List<Feelback> getFeelbacksByUser() {
return feelbackRepository.findByEmployeeIsCurrentUser();
}
/**
* DELETE /feelbacks/:id : delete the "id" feelback.
*
* @param id the id of the feelback to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/feelbacks/{id}")
@Timed
public ResponseEntity<Void> deleteFeelback(@PathVariable Long id) {
log.debug("REST request to delete Feelback : {}", id);
feelbackRepository.deleteById(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}
package fr.ippon.feelback.web.rest;
import com.codahale.metrics.annotation.Timed;
import fr.ippon.feelback.domain.Mission;
import fr.ippon.feelback.repository.MissionRepository;
import fr.ippon.feelback.web.rest.errors.BadRequestAlertException;
import fr.ippon.feelback.web.rest.util.HeaderUtil;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing Mission.
*/
@RestController
@RequestMapping("/api")
public class MissionResource {
private final Logger log = LoggerFactory.getLogger(MissionResource.class);
private static final String ENTITY_NAME = "mission";
private final MissionRepository missionRepository;
public MissionResource(MissionRepository missionRepository) {
this.missionRepository = missionRepository;
}
/**
* POST /missions : Create a new mission.
*
* @param mission the mission to create
* @return the ResponseEntity with status 201 (Created) and with body the new mission, or with status 400 (Bad Request) if the mission has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/missions")
@Timed
public ResponseEntity<Mission> createMission(@RequestBody Mission mission) throws URISyntaxException {
log.debug("REST request to save Mission : {}", mission);
if (mission.getId() != null) {
throw new BadRequestAlertException("A new mission cannot already have an ID", ENTITY_NAME, "idexists");
}
Mission result = missionRepository.save(mission);
return ResponseEntity.created(new URI("/api/missions/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /missions : Updates an existing mission.
*
* @param mission the mission to update
* @return the ResponseEntity with status 200 (OK) and with body the updated mission,
* or with status 400 (Bad Request) if the mission is not valid,
* or with status 500 (Internal Server Error) if the mission couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect