use of org.c4sg.dto.OrganizationDTO in project c4sg-services by Code4SocialGood.
the class OrganizationController method updateOrganization.
@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ApiOperation(value = "Update an existing organization")
public Map<String, Object> updateOrganization(@ApiParam(value = "Updated organization object", required = true) @PathVariable("id") int id, @RequestBody @Valid OrganizationDTO organizationDTO) {
System.out.println("**************Update : id=" + organizationDTO.getId() + "**************");
Map<String, Object> responseData = null;
try {
OrganizationDTO updatedOrganization = organizationService.updateOrganization(id, organizationDTO);
responseData = Collections.synchronizedMap(new HashMap<>());
responseData.put("organization", updatedOrganization);
} catch (Exception e) {
System.err.println(e);
}
return responseData;
}
use of org.c4sg.dto.OrganizationDTO in project c4sg-services by Code4SocialGood.
the class OrganizationController method createOrganization.
// TODO Define error codes: required input missing, etc
@CrossOrigin
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "Create organization", notes = "Creates an organization, and returns the organization created.", response = OrganizationDTO.class)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Internal server error") })
public Map<String, Object> createOrganization(@ApiParam(value = "Organization to create", required = true) @RequestBody @Valid CreateOrganizationDTO createOrganizationDTO) {
System.out.println("**************Create Organization: Begin**************");
System.out.println("Organization Name = " + createOrganizationDTO.getName());
Map<String, Object> responseData = null;
// organizationDTO.setLogo(organizationService.getLogoUploadPath(organizationDTO.getId()));
try {
OrganizationDTO createdOrganization = organizationService.createOrganization(createOrganizationDTO);
responseData = Collections.synchronizedMap(new HashMap<>());
responseData.put("organization", createdOrganization);
} catch (Exception e) {
System.err.println(e);
}
System.out.println("**************Create Organization: End**************");
return responseData;
}
use of org.c4sg.dto.OrganizationDTO in project c4sg-services by Code4SocialGood.
the class OrganizationServiceImpl method findByUser.
@Override
public List<OrganizationDTO> findByUser(Integer userId) {
User user = userDAO.findById(userId);
requireNonNull(user, "Invalid User Id");
List<UserOrganization> userOrganizations = userOrganizationDAO.findByUserId(userId);
List<OrganizationDTO> organizationDtos = new ArrayList<OrganizationDTO>();
for (UserOrganization userOrganization : userOrganizations) {
organizationDtos.add(organizationMapper.getOrganizationDtoFromEntity(userOrganization));
}
return organizationDtos;
}
use of org.c4sg.dto.OrganizationDTO in project c4sg-services by Code4SocialGood.
the class UserServiceImpl method deleteUser.
public void deleteUser(Integer id) {
User user = userDAO.findById(id);
user.setStatus(Constants.USER_STATUS_DELETED);
user.setEmail(user.getEmail() + "-deleted");
user.setAvatarUrl(null);
userDAO.save(user);
userDAO.deleteUserProjects(id);
userDAO.deleteUserSkills(id);
List<OrganizationDTO> organizations = organizationService.findByUser(id);
for (OrganizationDTO org : organizations) {
organizationService.deleteOrganization(org.getId());
}
}
Aggregations