Skip to content

Commit

Permalink
Identification implementation - MVP (#79)
Browse files Browse the repository at this point in the history
* version ++

* data model v4 + liquibase
identification Entity
api extension

* Medium as enum

* fix enuym Typo

* allow longer comments (255 -> 999 chars)

* Comment entity lenght update
  • Loading branch information
SimonDmz authored Jul 13, 2022
1 parent b1022ba commit e646968
Show file tree
Hide file tree
Showing 69 changed files with 2,675 additions and 1,958 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ Before committing code please ensure,
- `POST /api/create-dataset` : Create dataset
- `DELETE /api/delete-dataset` : Delete dataset

### Geographical-Location-Controller
- `POST /api/geographical-locations` : Create Context with Organizational Unit and users associated

### Interviewer-Controller
- `GET /api/interviewer/{id}/campaigns` : Get interviewer campaigns
- `GET /api/interviewers` : Get interviewers
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.insee.pearljam</groupId>
<artifactId>pearljam-back-office</artifactId>
<version>3.8.20</version>
<version>4.0.0</version>
<packaging>war</packaging>
<name>Pearl-Jam-Back-Office</name>
<description>Back-office services for for PearlJam</description>
Expand Down Expand Up @@ -406,4 +406,4 @@
</pluginManagement>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers(HttpMethod.PUT, Constants.API_USER_ID).hasAnyRole(adminRole)
.antMatchers(HttpMethod.DELETE, Constants.API_USER_ID).hasAnyRole(adminRole)
.antMatchers(HttpMethod.PUT, Constants.API_USER_ID_ORGANIZATIONUNIT_ID).hasAnyRole(adminRole)
.antMatchers(HttpMethod.POST, Constants.API_GEOGRAPHICALLOCATIONS).hasAnyRole(adminRole)
.antMatchers(HttpMethod.POST, Constants.API_ORGANIZATIONUNIT).hasAnyRole(adminRole)
.antMatchers(HttpMethod.POST, Constants.API_ORGANIZATIONUNITS).hasAnyRole(adminRole)
.antMatchers(HttpMethod.GET, Constants.API_ORGANIZATIONUNITS).hasAnyRole(adminRole)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers(HttpMethod.PUT, Constants.API_USER_ID).hasAnyRole(adminRole)
.antMatchers(HttpMethod.DELETE, Constants.API_USER_ID).hasAnyRole(adminRole)
.antMatchers(HttpMethod.PUT, Constants.API_USER_ID_ORGANIZATIONUNIT_ID).hasAnyRole(adminRole)
.antMatchers(HttpMethod.POST, Constants.API_GEOGRAPHICALLOCATIONS).hasAnyRole(adminRole)
.antMatchers(HttpMethod.POST, Constants.API_ORGANIZATIONUNITS).hasAnyRole(adminRole)
.antMatchers(HttpMethod.POST, Constants.API_ORGANIZATIONUNIT).hasAnyRole(adminRole)
.antMatchers(HttpMethod.GET, Constants.API_ORGANIZATIONUNITS).hasAnyRole(adminRole)
Expand Down Expand Up @@ -199,7 +198,6 @@ protected void configure(HttpSecurity http) throws Exception {
Constants.API_USER,
Constants.API_USER_ID,
Constants.API_USER_ID_ORGANIZATIONUNIT_ID,
Constants.API_GEOGRAPHICALLOCATIONS,
Constants.API_ORGANIZATIONUNIT,
Constants.API_ORGANIZATIONUNITS,
Constants.API_ORGANIZATIONUNIT_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public Docket productApi() {
new ResponseMessageBuilder().code(403).message("Forbidden!").build(),
new ResponseMessageBuilder().code(404).message("Not found!").build(),
new ResponseMessageBuilder().code(400)
.message("Bad request! Please check the feilds of your survey unit to update"
.message("Bad request! Please check the fields of your survey unit to update"
+ "\n- ID must be fielded and must be the same as parameter ID"
+ "\n- FirstName must be fielded" + "\n- LastName must be fielded"
+ "\n- PhoneNumbers must be fielded" + "\n- Campaign must be fielded"
+ "\n- Address must be fielded" + "\n- GeographicalLocation must be fielded"
+ "\n- Address must be fielded"
+ "\n- Priority must be fielded" + "\n- SampleIdentifiers must be fielded"
+ "\n- States must be fielded")
.build());
Expand All @@ -106,7 +106,7 @@ public Docket productApi() {
private ApiInfo apiInfo() {
return new ApiInfo(
buildProperties.getName(),
"Back-office services for for PearlJam",
"Back-office services for PearlJam",
buildProperties.getVersion(),
"",
new Contact("Metallica", "https://github.com/InseeFr/Pearl-Jam-Back-Office", ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ private Constants() {
public static final String API_USER = "/api/user";
public static final String API_USER_ID = "/api/user/{id}";
public static final String API_USER_ID_ORGANIZATIONUNIT_ID = "/api/user/{id}/organization-unit/{id2}";
public static final String API_GEOGRAPHICALLOCATIONS = "/api/geographical-locations";
public static final String API_ORGANIZATIONUNIT = "/api/organization-unit";
public static final String API_ORGANIZATIONUNITS = "/api/organization-units";
public static final String API_ORGANIZATIONUNIT_ID = "/api/organization-unit/{id}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import fr.insee.pearljam.api.domain.SurveyUnit;
import fr.insee.pearljam.api.dto.campaign.CampaignContextDto;
import fr.insee.pearljam.api.dto.campaign.CampaignDto;
import fr.insee.pearljam.api.dto.campaign.CollectionDatesDto;
import fr.insee.pearljam.api.dto.campaign.OngoingDto;
import fr.insee.pearljam.api.dto.count.CountDto;
import fr.insee.pearljam.api.dto.interviewer.InterviewerDto;
import fr.insee.pearljam.api.dto.referent.ReferentDto;
import fr.insee.pearljam.api.dto.state.StateCountCampaignDto;
import fr.insee.pearljam.api.dto.visibility.VisibilityContextDto;
import fr.insee.pearljam.api.dto.visibility.VisibilityDto;
Expand Down Expand Up @@ -264,28 +264,6 @@ public ResponseEntity<CountDto> getNbSUNotAttributed(HttpServletRequest request,

}

/**
* Updates the collection start and end dates for a campaign
*
* @body CampaignDto
* @param id
* @return {@link HttpStatus}
*/
@ApiOperation(value = "Put campaignCollectionDates")
@PutMapping(path = "/api/campaign/{id}/collection-dates")
public ResponseEntity<Object> putCampaignsCollectionDates(HttpServletRequest request,
@PathVariable(value = "id") String id, @RequestBody CollectionDatesDto campaign) {
String userId = utilsService.getUserId(request);
if (StringUtils.isBlank(userId)) {
LOGGER.info("Can't find caller Id");
return new ResponseEntity<>("Can't find caller Id", HttpStatus.FORBIDDEN);
} else {
HttpStatus returnCode = campaignService.updateDates(userId, id, campaign);
LOGGER.info("PUT campaignCollectionDates with id {} resulting in {}", id, returnCode.value());
return new ResponseEntity<>(returnCode);
}
}

/**
* Update the visibility dates for a given campaign and organizational unit
*
Expand Down Expand Up @@ -359,11 +337,11 @@ public ResponseEntity<Object> putCampaign(HttpServletRequest request,

if (StringUtils.isBlank(callerId)) {
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
} else {
HttpStatus returnCode = campaignService.updateCampaign(id, campaign);
LOGGER.info("PUT campaignCollectionDates with id {} resulting in {}", id, returnCode.value());
return new ResponseEntity<>(returnCode);
}
HttpStatus returnCode = campaignService.updateCampaign(id, campaign);
LOGGER.info("PUT campaignCollectionDates with id {} resulting in {}", id, returnCode.value());
return new ResponseEntity<>(returnCode);

}

/**
Expand Down Expand Up @@ -391,4 +369,22 @@ public ResponseEntity<OngoingDto> isOngoing(HttpServletRequest request,
LOGGER.info("{} checked if campaign {} is on-going : {}", callerId, id, campaignOngoing.isOngoing());
return new ResponseEntity<>(campaignOngoing, HttpStatus.OK);
}

// API for REFERENT entity

@ApiOperation(value = "Get referents of targeted campaign")
@GetMapping(path = "/campaigns/{id}/referents")
public ResponseEntity<List<ReferentDto>> getReferents(HttpServletRequest request,
@PathVariable(value = "id") String id) {
String callerId = utilsService.getUserId(request);
LOGGER.info("{} try to GET {} referents", callerId, id);
if (!campaignService.findById(id).isPresent()) {
LOGGER.warn("Campaign {} is not present, can't get referents", id);
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}

return null;
}


}

This file was deleted.

20 changes: 1 addition & 19 deletions src/main/java/fr/insee/pearljam/api/domain/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
@Entity
public abstract class Address implements Serializable {
/**
Expand All @@ -20,12 +19,6 @@ public abstract class Address implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long id;

/**
* The GeographicalLocation associated to Address
*/
@ManyToOne
protected GeographicalLocation geographicalLocation;

protected Address(){

Expand All @@ -42,16 +35,5 @@ public Long getId() {
public void setId(Long id) {
this.id = id;
}
/**
* @return the geographicalLocation
*/
public GeographicalLocation getGeographicalLocation() {
return geographicalLocation;
}
/**
* @param geographicalLocation the geographicalLocation to set
*/
public void setGeographicalLocation(GeographicalLocation geographicalLocation) {
this.geographicalLocation = geographicalLocation;
}

}
Loading

0 comments on commit e646968

Please sign in to comment.