Skip to content

Commit

Permalink
Admin XMl koble
Browse files Browse the repository at this point in the history
Creted Route :api/admin/get-xml/ that returns the xml
  • Loading branch information
MARINOSAG committed Sep 30, 2018
1 parent 94fc0e0 commit bef8b7f
Show file tree
Hide file tree
Showing 17 changed files with 362 additions and 54 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ dependencies {
compile(group: 'com.opencsv', name: 'opencsv', version: '4.0')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}
compile('com.fasterxml.jackson.dataformat:jackson-dataformat-xml')
}

101 changes: 101 additions & 0 deletions database_files/Experience.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
ExperienceId,UserId,StartDate,EndDate,Company,Visible,Title
1,7,7/23/2018,12/7/2017,Wordify,0,0
2,3,7/5/2018,7/20/2018,BlogXS,0,0
3,7,5/15/2018,10/6/2017,Skibox,0,0
4,8,7/3/2018,7/16/2018,Latz,0,0
5,1,4/6/2018,4/10/2018,Jabbercube,0,0
6,1,11/21/2017,8/11/2018,Camido,0,0
7,9,5/30/2018,12/20/2017,Katz,0,0
8,3,7/3/2018,3/18/2018,Vitz,0,0
9,1,8/25/2018,8/10/2018,Twinte,0,0
10,7,12/19/2017,7/15/2018,Realbridge,0,0
11,5,12/20/2017,12/22/2017,Bubbletube,0,0
12,5,12/15/2017,11/22/2017,Eabox,0,0
13,8,2/1/2018,9/13/2018,Jayo,0,0
14,8,2/23/2018,9/25/2018,Skalith,0,0
15,8,6/27/2018,5/24/2018,Zoomzone,0,0
16,1,10/3/2017,7/16/2018,Realmix,0,0
17,2,6/28/2018,7/17/2018,Agivu,0,0
18,8,8/27/2018,12/12/2017,Yombu,0,0
19,1,10/9/2017,4/21/2018,Shufflebeat,0,0
20,8,2/9/2018,1/15/2018,Quinu,0,0
21,7,10/31/2017,10/28/2017,Yadel,0,0
22,3,7/19/2018,9/1/2018,Miboo,0,0
23,4,7/10/2018,4/23/2018,Dynabox,0,0
24,3,9/15/2018,4/19/2018,Twimm,0,0
25,1,12/25/2017,2/4/2018,Thoughtworks,0,0
26,3,12/3/2017,1/25/2018,Latz,0,0
27,1,9/17/2018,1/7/2018,Jaxbean,0,0
28,2,5/13/2018,7/30/2018,Edgepulse,0,0
29,7,10/12/2017,2/3/2018,Skinder,0,0
30,1,1/7/2018,3/13/2018,Flipstorm,0,0
31,9,10/28/2017,1/11/2018,Zoonoodle,0,0
32,7,9/11/2018,11/17/2017,Twitterbridge,0,0
33,7,1/27/2018,11/29/2017,Youopia,0,0
34,1,11/9/2017,3/27/2018,Meemm,0,0
35,5,4/10/2018,7/24/2018,Yodel,0,0
36,1,5/27/2018,5/26/2018,Jetwire,0,0
37,8,10/25/2017,2/10/2018,Bluezoom,0,0
38,5,11/27/2017,11/4/2017,Zooveo,0,0
39,5,1/17/2018,11/5/2017,Oyope,0,0
40,6,8/23/2018,12/15/2017,Voolia,0,0
41,9,10/20/2017,4/1/2018,Meetz,0,0
42,3,10/31/2017,11/29/2017,Gabvine,0,0
43,9,9/5/2018,6/25/2018,Aibox,0,0
44,1,5/16/2018,8/25/2018,Yabox,0,0
45,4,5/22/2018,4/15/2018,Realbridge,0,0
46,1,12/20/2017,12/16/2017,Thoughtbeat,0,0
47,7,2/18/2018,9/8/2018,Kwilith,0,0
48,5,9/3/2018,10/2/2017,Geba,0,0
49,1,12/27/2017,8/13/2018,Zoozzy,0,0
50,5,11/16/2017,11/7/2017,Oozz,0,0
51,2,11/14/2017,6/2/2018,Viva,0,0
52,6,8/30/2018,7/19/2018,Miboo,0,0
53,6,5/18/2018,1/9/2018,Kimia,0,0
54,9,1/20/2018,7/27/2018,Jetpulse,0,0
55,5,7/20/2018,5/14/2018,Agimba,0,0
56,5,5/5/2018,4/24/2018,LiveZ,0,0
57,8,1/24/2018,6/15/2018,Twitterlist,0,0
58,5,12/31/2017,9/1/2018,Gigaclub,0,0
59,7,8/18/2018,7/21/2018,Eabox,0,0
60,4,7/26/2018,9/21/2018,Photobug,0,0
61,6,8/25/2018,11/14/2017,Jaxbean,0,0
62,6,6/1/2018,5/17/2018,Ntag,0,0
63,9,3/30/2018,9/4/2018,Kazio,0,0
64,9,10/14/2017,4/7/2018,Browsecat,0,0
65,5,4/4/2018,2/25/2018,Snaptags,0,0
66,3,9/30/2017,1/25/2018,Cogidoo,0,0
67,4,10/3/2017,11/3/2017,Twitterlist,0,0
68,4,12/16/2017,4/8/2018,Quaxo,0,0
69,9,12/23/2017,12/16/2017,Voolith,0,0
70,6,2/14/2018,8/28/2018,Yoveo,0,0
71,4,9/10/2018,10/7/2017,Voolith,0,0
72,2,8/10/2018,8/31/2018,Eamia,0,0
73,4,5/30/2018,9/4/2018,Oyoyo,0,0
74,4,9/14/2018,1/10/2018,Yakidoo,0,0
75,8,2/25/2018,1/2/2018,Innojam,0,0
76,1,5/21/2018,10/9/2017,Gabspot,0,0
77,1,12/26/2017,6/15/2018,Twiyo,0,0
78,4,5/30/2018,10/9/2017,Trupe,0,0
79,1,8/10/2018,4/28/2018,Quinu,0,0
80,7,10/4/2017,10/29/2017,Browseblab,0,0
81,5,9/8/2018,7/31/2018,Pixoboo,0,0
82,5,9/1/2018,11/26/2017,Meembee,0,0
83,3,5/15/2018,2/12/2018,Dynabox,0,0
84,1,7/3/2018,5/24/2018,Jatri,0,0
85,9,10/17/2017,5/13/2018,Katz,0,0
86,3,2/24/2018,1/18/2018,Flashpoint,0,0
87,8,1/4/2018,1/15/2018,Eayo,0,0
88,6,9/13/2018,7/5/2018,Dabjam,0,0
89,8,5/16/2018,10/31/2017,Photobug,0,0
90,5,11/27/2017,5/14/2018,Realcube,0,0
91,5,6/7/2018,7/28/2018,Oyoloo,0,0
92,8,10/29/2017,4/28/2018,Wordpedia,0,0
93,3,2/26/2018,4/1/2018,Oyope,0,0
94,7,7/28/2018,2/27/2018,Twitterlist,0,0
95,1,8/20/2018,9/17/2018,Buzzshare,0,0
96,7,3/7/2018,11/22/2017,Oyope,0,0
97,1,3/20/2018,2/17/2018,Meezzy,0,0
98,1,12/25/2017,8/8/2018,Fadeo,0,0
99,1,6/9/2018,12/13/2017,Twitterworks,0,0
100,9,3/29/2018,9/1/2018,Shuffledrive,0,0
2 changes: 1 addition & 1 deletion src/main/java/com/linkedin/config/WebSecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void configure(WebSecurity web) throws Exception {
"/swagger-ui.html",
"/downloadFile/**",
"/webjars/**");
//"/**");//here we allow all routes without security
//here we allow all routes without security
//TODO remove this because security doesnt work with this
}

Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/linkedin/controller/AdminController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.linkedin.controller;

import com.linkedin.entities.model.AdminXmlDto;
import com.linkedin.entities.model.UserDto;
import com.linkedin.service.AdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = AdminController.tag)
@RestController
@RequestMapping("/api/admin/")
public class AdminController {
public static final String tag = "Admin Controller";

private final AdminService adminService;


@Autowired
public AdminController(AdminService adminService){
this.adminService = adminService;
}


@ApiOperation(value = "Profile", notes = "Returns User's profile info", response = UserDto.class )
@RequestMapping(value = "/get-xml/", method = RequestMethod.GET, produces=MediaType.APPLICATION_XML_VALUE, consumes = MediaType.ALL_VALUE )
@ResponseBody
public List<AdminXmlDto> getXml()throws Exception {
return adminService.getXml();
// return new UserDto(userService.getUser(login.getUserId()));
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/linkedin/controller/CommentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public List<CommentDto> getPostComments(){
return commentService.getAllComments();
}

@GetMapping("/post/user/{userId}")
@ApiOperation(value = "Comment", notes = "Returns all Comments a user made in all posts", response = Comment.class)
public List<CommentDto> getPostUserComments(@PathVariable Long userId) throws Exception{
return commentService.getPostUserComments(userId);
}

@GetMapping("/post/{postId}")
@ApiOperation(value = "Comment", notes = "Returns all Comments of a Post", response = Comment.class)
public List<CommentDto> getPostComments(@PathVariable Long postId) throws Exception {
Expand Down
68 changes: 37 additions & 31 deletions src/main/java/com/linkedin/controller/ExperienceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,50 @@
@RestController
@RequestMapping("/api/profile/experience/")
public class ExperienceController {
public static final String tag = "Experience Controller";
private final ExperienceService experienceService;
public static final String tag = "Experience Controller";
private final ExperienceService experienceService;

@Autowired
public ExperienceController(ExperienceService experienceService) {
this.experienceService = experienceService;
}
@Autowired
public ExperienceController(ExperienceService experienceService) {
this.experienceService = experienceService;
}

@ApiOperation(value = "Returns all Experiences of the user", response = ExperienceDto.class)
@GetMapping("/{userId}")
public List<ExperienceDto> getExperiences(@PathVariable Long userId) {
return experienceService.getUsersExperiences(userId);
}
@ApiOperation(value = "Returns all Experiences of the user", response = ExperienceDto.class)
@GetMapping("/{userId}")
public List<ExperienceDto> getExperiences(@PathVariable Long userId) {
return experienceService.getUsersExperiences(userId);
}

@ApiOperation(value = "Returns all Experiences of the user", response = ExperienceDto.class)
@GetMapping("/")
public List<ExperienceDto> getExperiences() {
return experienceService.getExperiences();
}
@ApiOperation(value = "Returns all Experiences of the user", response = ExperienceDto.class)
@GetMapping("/")
public List<ExperienceDto> getExperiences() {
return experienceService.getExperiences();
}

@ApiOperation(value = "Creates a new Experience", response = ExperienceDto.class)
@PostMapping("/")
public ExperienceDto createExperiences(@Valid @RequestBody ExperienceRequestDto experienceRequestDto) {
return experienceService.createExperience(experienceRequestDto);
}
@ApiOperation(value = "Returns all Experiences from database", response = ExperienceDto.class)
@GetMapping("/all-experience/")
public List<ExperienceDto> getAllExperiences() {
return experienceService.getAllExperiences();
}

@PutMapping("/{experienceId}")
@ApiOperation(value = "Experience", notes = "Updates an experience of the User", response = ExperienceDto.class)
public ExperienceDto updateExperience(@PathVariable Long experienceId, @Valid @RequestBody ExperienceRequestDto experienceRequestDto) throws Exception {
@ApiOperation(value = "Creates a new Experience", response = ExperienceDto.class)
@PostMapping("/")
public ExperienceDto createExperiences(@Valid @RequestBody ExperienceRequestDto experienceRequestDto) {
return experienceService.createExperience(experienceRequestDto);
}

return experienceService.updateExperience(experienceId, experienceRequestDto);
@PutMapping("/{experienceId}")
@ApiOperation(value = "Experience", notes = "Updates an experience of the User", response = ExperienceDto.class)
public ExperienceDto updateExperience(@PathVariable Long experienceId, @Valid @RequestBody ExperienceRequestDto experienceRequestDto) throws Exception {

}
return experienceService.updateExperience(experienceId, experienceRequestDto);

@ApiOperation(value = "Deletes a Users Experience", response = ExperienceDto.class)
@DeleteMapping("/{experienceId}")
public void deleteExperience(@PathVariable Long experienceId) throws Exception {
experienceService.removeExperience(experienceId);
}
}

@ApiOperation(value = "Deletes a Users Experience", response = ExperienceDto.class)
@DeleteMapping("/{experienceId}")
public void deleteExperience(@PathVariable Long experienceId) throws Exception {
experienceService.removeExperience(experienceId);
}

}
10 changes: 8 additions & 2 deletions src/main/java/com/linkedin/controller/ProfileController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.linkedin.converter.UserConverter;
import com.linkedin.entities.database.Login;
import com.linkedin.entities.database.User;
import com.linkedin.entities.database.repo.UserRepository;
import com.linkedin.entities.model.UploadFileResponse;
import com.linkedin.entities.model.UserDto;
import com.linkedin.entities.model.UserRequestDto;
Expand All @@ -26,6 +26,9 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.stream.Collectors;


@Api(tags = ProfileController.tag)
@RestController
Expand All @@ -37,12 +40,14 @@ public class ProfileController {
private final UserService userService;
private final ProfileService profileService;
private final UserConverter userConverter;
private final UserRepository userRepository;

@Autowired
public ProfileController(UserService userService, ProfileService profileService, UserConverter userConverter) {
public ProfileController(UserService userService, ProfileService profileService, UserConverter userConverter, UserRepository userRepository) {
this.userService = userService;
this.profileService = profileService;
this.userConverter = userConverter;
this.userRepository = userRepository;
}

@GetMapping("/")
Expand Down Expand Up @@ -93,4 +98,5 @@ public void changeEmail(@RequestBody ChangeEmailRequestDto changeEmailRequestDto
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public ExperienceDto toExperienceDto(Experience experience) {
experienceDto.setEndDate(experience.getEndDate());
experienceDto.setExperienceId(experience.getExperienceId());
experienceDto.setVisible(experience.getVisible());
experienceDto.setUserId(experience.getUserId());
return experienceDto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
@Component
public class DatabaseCsvReader {
private final String[] FILE_ARRAY = new String[]{"database_files/Login.csv","database_files/Notification.csv", "database_files/Job.csv", "database_files/Connection.csv","database_files/User.csv" , "database_files/Post.csv" ,"database_files/Comment.csv" ,"database_files/Like.csv" ,"database_files/ConnectionRequest.csv", "database_files/Message.csv"};
private final String[] FILE_ARRAY = new String[]{"database_files/Experience.csv","database_files/Login.csv","database_files/Notification.csv", "database_files/Job.csv", "database_files/Connection.csv","database_files/User.csv" , "database_files/Post.csv" ,"database_files/Comment.csv" ,"database_files/Like.csv" ,"database_files/ConnectionRequest.csv", "database_files/Message.csv"};
private final String ENTITIES_PACKAGE_NAME = "com.linkedin.entities.database";

private final Repositories repositories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
@Repository
public interface CommentRepository extends JpaRepository<Comment, Long> {
List<Comment> findAllByPostId(Long postId);
List<Comment> findAllByCommenterId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface JobRepository extends JpaRepository<Job, Long> {
List<Job> findAllByAuthorId(Long userId);
}
51 changes: 51 additions & 0 deletions src/main/java/com/linkedin/entities/model/AdminXmlDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.linkedin.entities.model;

import com.linkedin.entities.model.Comment.CommentDto;
import com.linkedin.entities.model.Post.PostDto;
import com.linkedin.entities.model.connection.ConnectionDto;
import com.linkedin.entities.model.experience.ExperienceDto;
import com.linkedin.entities.model.jobs.JobDto;
import com.linkedin.entities.model.likes.LikeDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.ElementCollection;
import java.util.ConcurrentModificationException;
import java.util.List;

@Data
@ApiModel(description = "Admin xml response")

public class AdminXmlDto {
@ApiModelProperty(value = "userId", example = "1", position = 1)
private Long userId;

@ApiModelProperty(value = "userDto", example = "UserDto", position = 2)
private UserDto userDto;

@ElementCollection
@ApiModelProperty(value = "list of PostDto", example = "[PostDto1, PostDto2]", position = 3)
public List<PostDto> posts;

@ElementCollection
@ApiModelProperty(value = "list of PostDto", example = "[ExperienceDto1, ExperienceDto2]", position = 4)
public List<ExperienceDto> experiences;

@ElementCollection
@ApiModelProperty(value = "list of JobDto of jobs he created", example = "[JobDto1, JobDto2]", position = 5)
public List<JobDto> jobs;

@ElementCollection
@ApiModelProperty(value = "list of CommentDto", example = "[CommentDto1, CommentDto2]", position = 6)
public List<CommentDto> comments;


@ElementCollection
@ApiModelProperty(value = "list of LikeDto", example = "[LikeDto1, LikeDto2]", position = 7)
public List<LikeDto> likes;

@ElementCollection
@ApiModelProperty(value = "list of ConnectionDto", example = "[ConnectionDto1, ConnectionDto2]", position = 8)
public List<ConnectionDto> connectionDtoList;
}
Loading

0 comments on commit bef8b7f

Please sign in to comment.