Search in sources :

Example 1 with ProjectDTO

use of org.c4sg.dto.ProjectDTO in project c4sg-services by Code4SocialGood.

the class ProjectMapper method getProjectDtoFromEntity.

public ProjectDTO getProjectDtoFromEntity(UserProject userProject) {
    Type projectTypeDTO = new TypeToken<ProjectDTO>() {
    }.getType();
    ProjectDTO projectDTO = map(userProject.getProject(), projectTypeDTO);
    return projectDTO;
}
Also used : ProjectDTO(org.c4sg.dto.ProjectDTO) CreateProjectDTO(org.c4sg.dto.CreateProjectDTO) Type(java.lang.reflect.Type)

Example 2 with ProjectDTO

use of org.c4sg.dto.ProjectDTO in project c4sg-services by Code4SocialGood.

the class ProjectController method createProject.

@CrossOrigin
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "Add a new project")
public Map<String, Object> createProject(@ApiParam(value = "Project object to return", required = true) @RequestBody @Valid CreateProjectDTO createProjectDTO) {
    System.out.println("************** Add **************");
    Map<String, Object> responseData = null;
    try {
        ProjectDTO createProject = projectService.createProject(createProjectDTO);
        responseData = Collections.synchronizedMap(new HashMap<>());
        responseData.put("project", createProject);
    } catch (Exception e) {
        System.out.println(e);
    }
    return responseData;
}
Also used : ProjectDTO(org.c4sg.dto.ProjectDTO) CreateProjectDTO(org.c4sg.dto.CreateProjectDTO) HashMap(java.util.HashMap) NotFoundException(org.c4sg.exception.NotFoundException) UserProjectException(org.c4sg.exception.UserProjectException) ProjectServiceException(org.c4sg.exception.ProjectServiceException) IOException(java.io.IOException) BadRequestException(org.c4sg.exception.BadRequestException)

Example 3 with ProjectDTO

use of org.c4sg.dto.ProjectDTO in project c4sg-services by Code4SocialGood.

the class ProjectController method updateProject.

@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ApiOperation(value = "Update an existing project")
public Map<String, Object> updateProject(@ApiParam(value = "Updated project object", required = true) @RequestBody @Valid ProjectDTO project) {
    System.out.println("**************Update : id=" + project.getId() + "**************");
    Map<String, Object> responseData = null;
    try {
        ProjectDTO updateProject = projectService.updateProject(project);
        responseData = Collections.synchronizedMap(new HashMap<>());
        responseData.put("project", updateProject);
    } catch (Exception e) {
        System.out.println(e);
    }
    return responseData;
}
Also used : ProjectDTO(org.c4sg.dto.ProjectDTO) CreateProjectDTO(org.c4sg.dto.CreateProjectDTO) HashMap(java.util.HashMap) NotFoundException(org.c4sg.exception.NotFoundException) UserProjectException(org.c4sg.exception.UserProjectException) ProjectServiceException(org.c4sg.exception.ProjectServiceException) IOException(java.io.IOException) BadRequestException(org.c4sg.exception.BadRequestException)

Example 4 with ProjectDTO

use of org.c4sg.dto.ProjectDTO in project c4sg-services by Code4SocialGood.

the class OrganizationServiceImpl method deleteOrganization.

public void deleteOrganization(int id) {
    Organization organization = organizationDAO.findOne(id);
    if (organization != null) {
        organization.setStatus(Constants.ORGANIZATION_STATUS_CLOSED);
        organization.setLogoUrl(null);
        organizationDAO.save(organization);
        List<ProjectDTO> projects = projectService.findByOrganization(id);
        for (ProjectDTO project : projects) {
            projectService.deleteProject(project.getId());
        }
        organizationDAO.deleteUserOrganizations(id);
    //TODO: Local or Timezone?
    //TODO: Format date
    //organization.setDeleteTime(LocalDateTime.now().toString());
    //organization.setDeleteBy(user.getUsername());
    }
}
Also used : ProjectDTO(org.c4sg.dto.ProjectDTO) Organization(org.c4sg.entity.Organization) UserOrganization(org.c4sg.entity.UserOrganization)

Example 5 with ProjectDTO

use of org.c4sg.dto.ProjectDTO in project c4sg-services by Code4SocialGood.

the class ProjectMapper method getProjectDtoFromEntity.

public ProjectDTO getProjectDtoFromEntity(Project project) {
    getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
    ProjectDTO projectDTO = map(project, ProjectDTO.class);
    projectDTO.setOrganizationId(project.getOrganization().getId().toString());
    projectDTO.setOrganizationName(project.getOrganization().getName());
    return projectDTO;
}
Also used : ProjectDTO(org.c4sg.dto.ProjectDTO) CreateProjectDTO(org.c4sg.dto.CreateProjectDTO)

Aggregations

ProjectDTO (org.c4sg.dto.ProjectDTO)5 CreateProjectDTO (org.c4sg.dto.CreateProjectDTO)4 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 BadRequestException (org.c4sg.exception.BadRequestException)2 NotFoundException (org.c4sg.exception.NotFoundException)2 ProjectServiceException (org.c4sg.exception.ProjectServiceException)2 UserProjectException (org.c4sg.exception.UserProjectException)2 Type (java.lang.reflect.Type)1 Organization (org.c4sg.entity.Organization)1 UserOrganization (org.c4sg.entity.UserOrganization)1