Commit 221093e8 authored by Anastasios Poimenidis's avatar Anastasios Poimenidis
Browse files

fix: introduce OrganizationDTO and OrganizationResponse to code

parent 85c12046
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public class ServiceSpecificationHelpers {
                serviceSpecificationService.getRelatedPartyBySpecificationId(serviceSpecificationId);

        Optional<Organization> organization =
                organizationService.getPeeredOrganizationForSpecification(relatedPartyBySpecificationId);
                organizationService.getPeeredOrganizationForRelatedPartySet(relatedPartyBySpecificationId);
        organization.ifPresent(organizationPresent -> hasPeeredOrganization.set(Boolean.TRUE));
    }

@@ -172,7 +172,7 @@ public class ServiceSpecificationHelpers {
                serviceSpecificationService.getRelatedPartyBySpecificationId(serviceSpecificationId);

        Optional<Organization> organization =
                organizationService.getPeeredOrganizationForSpecification(relatedPartyBySpecificationId);
                organizationService.getPeeredOrganizationForRelatedPartySet(relatedPartyBySpecificationId);
        organization.ifPresent(organizationPresent -> hasPeeredOrganization.set(Boolean.TRUE));
    }

+2 −2
Original line number Diff line number Diff line
@@ -179,12 +179,12 @@ public class PeeringHelper {
    }

    private void updatePeeredOrganizationCharacteristicForSuccess(String organizationId) {
        organizationService.updatePeeredOrganizationCharacteristic(
        organizationService.updateOrganizationCharacteristicById(
                organizationId, PEERED_ORGANIZATION, "true");
    }

    private void updatePeeredOrganizationCharacteristicForFailure(String organizationId) {
        organizationService.updatePeeredOrganizationCharacteristic(
        organizationService.updateOrganizationCharacteristicById(
                organizationId, PEERED_ORGANIZATION, "false");
    }

+2 −3
Original line number Diff line number Diff line
@@ -30,17 +30,16 @@ public class RelatedPartyService {
    }

    @Transactional
    public RelatedPartyEntity findOrCreateRelatedPartyEntity(RelatedPartyEntity relatedPartyEntity) {
    public void findOrCreateRelatedPartyEntity(RelatedPartyEntity relatedPartyEntity) {
        String relatedPartyId = relatedPartyEntity.getId();
        if (relatedPartyId != null) {
            Optional<RelatedPartyEntity> optionalRelatedPartyEntity =
                    getRelatedPartyEntityById(relatedPartyId);
            if (optionalRelatedPartyEntity.isPresent()) {
                return optionalRelatedPartyEntity.get();
                return;
            }
        }
        persistRelatedParty(relatedPartyEntity);
        return relatedPartyEntity;
    }

    @Transactional
+8 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@ package org.etsi.osl.hypo.api.tmf.party.api.mapper;

import org.etsi.osl.hypo.api.tmf.common.schema.RelatedPartyEntity;
import org.etsi.osl.hypo.api.tmf.party.individual.schema.Individual;
import org.etsi.osl.hypo.api.tmf.party.organization.model.OrganizationDTO;
import org.etsi.osl.hypo.api.tmf.party.organization.model.OrganizationResponse;
import org.etsi.osl.hypo.api.tmf.party.organization.schema.Organization;
import org.mapstruct.BeanMapping;
import org.mapstruct.InjectionStrategy;
@@ -27,6 +29,12 @@ public interface OrganizationMapper {
    Organization updateOrganization(
            Organization newOrganization, @MappingTarget Organization oldOrganization);

    Organization organizationDTOtoEntity(OrganizationDTO organizationDTO);

    OrganizationResponse organizationEntityToResponse(Organization organization);

    OrganizationDTO organizationResponseToDTO(OrganizationResponse organizationResponse);

    @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
    Organization cloneOrganization(Organization organization);

+19 −25
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
import java.util.List;
import java.util.Map;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
@@ -28,6 +27,8 @@ import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.etsi.osl.hypo.api.tmf.common.api.services.UtilService;
import org.etsi.osl.hypo.api.tmf.common.model.ErrorMessage;
import org.etsi.osl.hypo.api.tmf.party.api.services.OrganizationService;
import org.etsi.osl.hypo.api.tmf.party.organization.model.OrganizationDTO;
import org.etsi.osl.hypo.api.tmf.party.organization.model.OrganizationResponse;
import org.etsi.osl.hypo.api.tmf.party.organization.schema.ApplicationProperties;
import org.etsi.osl.hypo.api.tmf.party.organization.schema.Organization;
import org.jboss.logging.Logger;
@@ -54,7 +55,7 @@ public class OrganizationResource {
            summary = "Creates a valid Organization",
            description = "This operation creates a Organization entity.")
    @APIResponse(
            responseCode = "200",
            responseCode = "201",
            description = "Created",
            content =
                    @Content(
@@ -69,16 +70,16 @@ public class OrganizationResource {
                            mediaType = APPLICATION_JSON,
                            schema = @Schema(implementation = ErrorMessage.class)))
    public Response createOrganization(
            @Valid Organization organizationRequest, @HeaderParam(AUTHORIZATION) String authHeader) {
            OrganizationDTO organizationRequest, @HeaderParam(AUTHORIZATION) String authHeader) {
        logger.debugf(
                "POST Organization Request Received with name %s", organizationRequest.toString());
        logger.infof("POST Organization Request Received with name %s", organizationRequest.getName());
        Organization createdOrganization =
                organizationService.createOrganization(organizationRequest, authHeader);
        OrganizationResponse createdOrganization =
                organizationService.handlePostRequest(organizationRequest, authHeader);
        logger.debugf("POST Organization Response : %s", createdOrganization.toString());
        logger.debugf(
                "POST Organization Operation with name: %s is Successful", createdOrganization.getName());
        return Response.ok(createdOrganization).status(201).build();
        return Response.ok(createdOrganization).status(Response.Status.CREATED).build();
    }

    @GET
@@ -94,9 +95,9 @@ public class OrganizationResource {
                    @Content(
                            mediaType = APPLICATION_JSON,
                            schema = @Schema(implementation = Organization.class, type = SchemaType.ARRAY)))
    public List<Organization> getAll(@RestQuery String fields, @Context UriInfo uriInfo) {
    public Response getAll(@RestQuery String fields, @Context UriInfo uriInfo) {
        Map<String, String> criteriaParams = UtilService.getRequestedCriteriaForFiltering(uriInfo);
        return organizationService.getByCriteria(fields, criteriaParams);
        return Response.ok(organizationService.getByCriteria(fields, criteriaParams)).build();
    }

    @GET
@@ -121,14 +122,13 @@ public class OrganizationResource {
                    @Content(
                            mediaType = APPLICATION_JSON,
                            schema = @Schema(implementation = ErrorMessage.class)))
    public Organization getById(
            @RestPath String id, @RestQuery String fields, @Context UriInfo uriInfo) {
    public Response getById(@RestPath String id, @RestQuery String fields, @Context UriInfo uriInfo) {
        logger.infof("Get Request: organization with id : %s", id);
        Map<String, String> criteriaParams = UtilService.getRequestedCriteriaForFiltering(uriInfo);
        Organization retrievedOrganization =
        OrganizationResponse retrievedOrganization =
                organizationService.getByIdAndCriteria(id, fields, criteriaParams);
        logger.infof("Get Response for id %s: %s", id, retrievedOrganization);
        return retrievedOrganization;
        return Response.ok(retrievedOrganization).build();
    }

    @PATCH
@@ -164,10 +164,10 @@ public class OrganizationResource {
                    @Content(
                            mediaType = APPLICATION_JSON,
                            schema = @Schema(implementation = ErrorMessage.class)))
    public Organization update(@Valid Organization organizationRequest, @RestPath String id) {
    public Response update(@Valid Organization organizationRequest, @RestPath String id) {
        logger.infof("Update Request for organization with id : %s", id);
        logger.infof("Update Request Order Body : %s", organizationRequest.toString());
        return organizationService.updateOrganization(id, organizationRequest);
        return Response.ok(organizationService.updateOrganization(id, organizationRequest)).build();
    }

    @DELETE
@@ -177,13 +177,7 @@ public class OrganizationResource {
    @Operation(
            summary = "Deletes a Organization by ID",
            description = "This operation deletes a Organization entity.")
    @APIResponse(
            responseCode = "200",
            description = "Deleted",
            content =
                    @Content(
                            mediaType = APPLICATION_JSON,
                            schema = @Schema(implementation = Organization.class)))
    @APIResponse(responseCode = "204", description = "Deleted")
    @APIResponse(
            responseCode = "404",
            description = "Not Found",
@@ -192,9 +186,9 @@ public class OrganizationResource {
                            mediaType = APPLICATION_JSON,
                            schema = @Schema(implementation = ErrorMessage.class)))
    public Response delete(@RestPath String id, @HeaderParam(AUTHORIZATION) String authHeader) {
        logger.infof("Delete Request for organization with id : %s", id);
        Organization deletedOrganization = organizationService.deleteOrganization(id, authHeader);
        logger.infof("Successful Delete operation for organization with id : %s", id);
        return Response.ok(deletedOrganization).build();
        logger.infof("DELETE Request for organization with id : %s", id);
        organizationService.deleteOrganization(id, authHeader);
        logger.infof("DELETE operation SUCCESS for organization with id : %s", id);
        return Response.noContent().build();
    }
}
Loading