Skip to content

Commit

Permalink
Remove 'Vo' from model names
Browse files Browse the repository at this point in the history
  • Loading branch information
WangLiNaruto committed Nov 22, 2023
1 parent 328f8ec commit a58c8e7
Show file tree
Hide file tree
Showing 18 changed files with 340 additions and 338 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.eclipse.xpanse.modules.models.service.common.enums.Csp;
import org.eclipse.xpanse.modules.models.service.deploy.enums.ServiceDeploymentState;
import org.eclipse.xpanse.modules.models.service.query.ServiceQueryModel;
import org.eclipse.xpanse.modules.models.service.view.ServiceDetailVo;
import org.eclipse.xpanse.modules.models.service.view.ServiceVo;
import org.eclipse.xpanse.modules.models.service.view.DeployedService;
import org.eclipse.xpanse.modules.models.service.view.DeployedServiceDetails;
import org.eclipse.xpanse.modules.security.IdentityProviderManager;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -64,7 +64,7 @@ public class IsvServiceDeployApi {
@GetMapping(value = "/isv/services",
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public List<ServiceVo> listDeployedServicesOfIsv(
public List<DeployedService> listDeployedServicesOfIsv(
@Parameter(name = "categoryName", description = "category of the service")
@RequestParam(name = "categoryName", required = false) Category category,
@Parameter(name = "cspName", description = "name of the cloud service provider")
Expand All @@ -91,7 +91,7 @@ public List<ServiceVo> listDeployedServicesOfIsv(
@GetMapping(value = "/isv/services/{id}",
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public ServiceDetailVo getServiceDetailsByIdForIsv(
public DeployedServiceDetails getServiceDetailsByIdForIsv(
@Parameter(name = "id", description = "Task id of deployed service")
@PathVariable("id") String id) {
return this.deployService.getServiceDetailsByIdForIsv(UUID.fromString(id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import java.util.Optional;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.xpanse.modules.models.policy.Policy;
import org.eclipse.xpanse.modules.models.policy.PolicyCreateRequest;
import org.eclipse.xpanse.modules.models.policy.PolicyQueryRequest;
import org.eclipse.xpanse.modules.models.policy.PolicyUpdateRequest;
import org.eclipse.xpanse.modules.models.policy.PolicyVo;
import org.eclipse.xpanse.modules.models.service.common.enums.Csp;
import org.eclipse.xpanse.modules.policy.policyman.PolicyManager;
import org.eclipse.xpanse.modules.security.IdentityProviderManager;
Expand Down Expand Up @@ -71,7 +71,7 @@ public class PolicyManageApi {
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Operation(description = "List the policies defined by the user.")
public List<PolicyVo> listPolicies(
public List<Policy> listPolicies(
@Parameter(name = "cspName", description = "Name of csp which the policy belongs to.")
@RequestParam(name = "cspName", required = false) Csp csp,
@Parameter(name = "enabled", description = "Is the policy enabled.")
Expand All @@ -92,7 +92,7 @@ public List<PolicyVo> listPolicies(
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Operation(description = "Get the details of the policy created by the user.")
public PolicyVo getPolicyDetails(@PathVariable String id) {
public Policy getPolicyDetails(@PathVariable String id) {
return policyManager.getPolicyDetails(UUID.fromString(id));
}

Expand All @@ -107,7 +107,7 @@ public PolicyVo getPolicyDetails(@PathVariable String id) {
@PostMapping(value = "/policies",
produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(description = "Add policy created by the user.")
public PolicyVo addPolicy(
public Policy addPolicy(
@Valid @RequestBody PolicyCreateRequest policyCreateRequest) {
return policyManager.addPolicy(policyCreateRequest);
}
Expand All @@ -122,7 +122,7 @@ public PolicyVo addPolicy(
@PutMapping(value = "/policies",
produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(description = "Update the policy created by the user.")
public PolicyVo updatePolicy(
public Policy updatePolicy(
@Valid @RequestBody PolicyUpdateRequest updateRequest) {
return policyManager.updatePolicy(updateRequest);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import org.eclipse.xpanse.modules.models.service.deploy.MigrateRequest;
import org.eclipse.xpanse.modules.models.service.deploy.enums.ServiceDeploymentState;
import org.eclipse.xpanse.modules.models.service.query.ServiceQueryModel;
import org.eclipse.xpanse.modules.models.service.view.ServiceDetailVo;
import org.eclipse.xpanse.modules.models.service.view.ServiceVo;
import org.eclipse.xpanse.modules.models.service.view.VendorHostedServiceDetailsVo;
import org.eclipse.xpanse.modules.models.service.view.DeployedService;
import org.eclipse.xpanse.modules.models.service.view.DeployedServiceDetails;
import org.eclipse.xpanse.modules.models.service.view.VendorHostedDeployedServiceDetails;
import org.eclipse.xpanse.modules.orchestrator.deployment.DeployTask;
import org.eclipse.xpanse.modules.orchestrator.deployment.Deployment;
import org.eclipse.xpanse.modules.security.IdentityProviderManager;
Expand Down Expand Up @@ -85,7 +85,7 @@ public class ServiceDeployerApi {
@GetMapping(value = "/services/{id}",
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public ServiceDetailVo getSelfHostedServiceDetailsById(
public DeployedServiceDetails getSelfHostedServiceDetailsById(
@Parameter(name = "id", description = "Task id of deployed service")
@PathVariable("id") String id) {
return this.deployService.getSelfHostedServiceDetailsByIdForEndUser(UUID.fromString(id));
Expand All @@ -95,14 +95,14 @@ public ServiceDetailVo getSelfHostedServiceDetailsById(
/**
* Get details of the managed vendor hosted service by id.
*
* @return VendorHostedServiceDetailsVo of the managed service.
* @return VendorHostedDeployedServiceDetails of the managed service.
*/
@Tag(name = "Service", description = "APIs to manage the service instances")
@Operation(description = "Get deployed service details by id.")
@GetMapping(value = "/isv/service/vendor_hosted/{id}",
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public VendorHostedServiceDetailsVo getVendorHostedServiceDetailsById(
public VendorHostedDeployedServiceDetails getVendorHostedServiceDetailsById(
@Parameter(name = "id", description = "Task id of deployed service")
@PathVariable("id") String id) {
return this.deployService.getVendorHostedServiceDetailsByIdForEndUser(UUID.fromString(id));
Expand All @@ -118,7 +118,7 @@ public VendorHostedServiceDetailsVo getVendorHostedServiceDetailsById(
@GetMapping(value = "/services",
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public List<ServiceVo> listDeployedServices(
public List<DeployedService> listDeployedServices(
@Parameter(name = "categoryName", description = "category of the service")
@RequestParam(name = "categoryName", required = false) Category category,
@Parameter(name = "cspName", description = "name of the cloud service provider")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.eclipse.xpanse.modules.database.resource.DeployResourceEntity;
import org.eclipse.xpanse.modules.database.service.DeployServiceEntity;
import org.eclipse.xpanse.modules.models.service.deploy.DeployResource;
import org.eclipse.xpanse.modules.models.service.view.ServiceDetailVo;
import org.eclipse.xpanse.modules.models.service.view.VendorHostedServiceDetailsVo;
import org.eclipse.xpanse.modules.models.service.view.DeployedServiceDetails;
import org.eclipse.xpanse.modules.models.service.view.VendorHostedDeployedServiceDetails;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

Expand Down Expand Up @@ -48,46 +48,48 @@ public static List<DeployResource> transResourceEntity(List<DeployResourceEntity
}

/**
* DeployServiceEntity converted to ServiceDetailVo.
* DeployServiceEntity converted to DeployedServiceDetails.
*
* @param deployServiceEntity DeployServiceEntity.
* @return serviceDetailVo
*/
public static ServiceDetailVo transDeployServiceEntityToServiceDetailVo(
public static DeployedServiceDetails transDeployServiceEntityToServiceDetailVo(
DeployServiceEntity deployServiceEntity) {
ServiceDetailVo serviceDetailVo = new ServiceDetailVo();
serviceDetailVo.setServiceHostingType(
DeployedServiceDetails deployedServiceDetails = new DeployedServiceDetails();
deployedServiceDetails.setServiceHostingType(
deployServiceEntity.getDeployRequest().getServiceHostingType());
BeanUtils.copyProperties(deployServiceEntity, serviceDetailVo);
BeanUtils.copyProperties(deployServiceEntity, deployedServiceDetails);
if (!CollectionUtils.isEmpty(deployServiceEntity.getDeployResourceList())) {
List<DeployResource> deployResources = transResourceEntity(
deployServiceEntity.getDeployResourceList());
serviceDetailVo.setDeployResources(deployResources);
deployedServiceDetails.setDeployResources(deployResources);
}
if (!CollectionUtils.isEmpty(deployServiceEntity.getProperties())) {
serviceDetailVo.setDeployedServiceProperties(deployServiceEntity.getProperties());
deployedServiceDetails.setDeployedServiceProperties(
deployServiceEntity.getProperties());
}
return serviceDetailVo;
return deployedServiceDetails;
}

/**
* DeployServiceEntity converted to VendorHostedServiceDetailsVo.
* DeployServiceEntity converted to VendorHostedDeployedServiceDetails.
*
* @param deployServiceEntity DeployServiceEntity.
* @return serviceDetailVo
*/
public static VendorHostedServiceDetailsVo transServiceEntityToVendorHostedServiceDetailsVo(
public static VendorHostedDeployedServiceDetails
transServiceEntityToVendorHostedServiceDetailsVo(
DeployServiceEntity deployServiceEntity) {
VendorHostedServiceDetailsVo vendorHostedServiceDetailsVo =
new VendorHostedServiceDetailsVo();
vendorHostedServiceDetailsVo.setServiceHostingType(
VendorHostedDeployedServiceDetails vendorHostedDeployedServiceDetails =
new VendorHostedDeployedServiceDetails();
vendorHostedDeployedServiceDetails.setServiceHostingType(
deployServiceEntity.getDeployRequest().getServiceHostingType());
BeanUtils.copyProperties(deployServiceEntity, vendorHostedServiceDetailsVo);
BeanUtils.copyProperties(deployServiceEntity, vendorHostedDeployedServiceDetails);
if (!CollectionUtils.isEmpty(deployServiceEntity.getProperties())) {
vendorHostedServiceDetailsVo.setDeployedServiceProperties(
vendorHostedDeployedServiceDetails.setDeployedServiceProperties(
deployServiceEntity.getProperties());
}
return vendorHostedServiceDetailsVo;
return vendorHostedDeployedServiceDetails;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.eclipse.xpanse.modules.database.servicetemplate.ServiceTemplateStorage;
import org.eclipse.xpanse.modules.database.utils.EntityTransUtils;
import org.eclipse.xpanse.modules.deployment.deployers.terraform.terraformboot.model.TerraformResult;
import org.eclipse.xpanse.modules.models.policy.Policy;
import org.eclipse.xpanse.modules.models.policy.PolicyQueryRequest;
import org.eclipse.xpanse.modules.models.policy.PolicyVo;
import org.eclipse.xpanse.modules.models.service.common.enums.Csp;
import org.eclipse.xpanse.modules.models.service.deploy.DeployRequest;
import org.eclipse.xpanse.modules.models.service.deploy.DeployResource;
Expand All @@ -42,9 +42,9 @@
import org.eclipse.xpanse.modules.models.service.deploy.exceptions.ServiceNotDeployedException;
import org.eclipse.xpanse.modules.models.service.query.ServiceQueryModel;
import org.eclipse.xpanse.modules.models.service.utils.ServiceVariablesJsonSchemaValidator;
import org.eclipse.xpanse.modules.models.service.view.ServiceDetailVo;
import org.eclipse.xpanse.modules.models.service.view.ServiceVo;
import org.eclipse.xpanse.modules.models.service.view.VendorHostedServiceDetailsVo;
import org.eclipse.xpanse.modules.models.service.view.DeployedService;
import org.eclipse.xpanse.modules.models.service.view.DeployedServiceDetails;
import org.eclipse.xpanse.modules.models.service.view.VendorHostedDeployedServiceDetails;
import org.eclipse.xpanse.modules.models.servicetemplate.DeployVariable;
import org.eclipse.xpanse.modules.models.servicetemplate.enums.DeployerKind;
import org.eclipse.xpanse.modules.models.servicetemplate.enums.SensitiveScope;
Expand Down Expand Up @@ -373,8 +373,8 @@ private void validateDeploymentWithPolicies(Deployment deployment, DeployTask de
queryRequest.setUserId(userId);
queryRequest.setCsp(csp);
queryRequest.setEnabled(true);
List<PolicyVo> policyVos = policyManager.listPolicies(queryRequest);
if (CollectionUtils.isEmpty(policyVos)) {
List<Policy> policies = policyManager.listPolicies(queryRequest);
if (CollectionUtils.isEmpty(policies)) {
return;
}

Expand All @@ -383,9 +383,9 @@ private void validateDeploymentWithPolicies(Deployment deployment, DeployTask de
return;
}

List<String> policies = policyVos.stream().map(PolicyVo::getPolicy)
List<String> policyList = policies.stream().map(Policy::getPolicy)
.filter(StringUtils::isNotBlank).toList();
policyManager.evaluatePolicies(policies, planJson);
policyManager.evaluatePolicies(policyList, planJson);
}

/**
Expand Down Expand Up @@ -424,7 +424,7 @@ public void asyncPurgeService(Deployment deployment, DeployTask deployTask,
* @param query service query model.
* @return serviceVos
*/
public List<ServiceVo> listDeployedServices(ServiceQueryModel query) {
public List<DeployedService> listDeployedServices(ServiceQueryModel query) {
Optional<String> userIdOptional = identityProviderManager.getCurrentLoginUserId();
query.setUserId(userIdOptional.orElse(null));
List<DeployServiceEntity> deployServices =
Expand All @@ -440,7 +440,7 @@ public List<ServiceVo> listDeployedServices(ServiceQueryModel query) {
* @param id ID of deploy service.
* @return serviceDetailVo
*/
public ServiceDetailVo getSelfHostedServiceDetailsByIdForEndUser(UUID id) {
public DeployedServiceDetails getSelfHostedServiceDetailsByIdForEndUser(UUID id) {
DeployServiceEntity deployServiceEntity = getDeployServiceEntity(id);
ServiceHostingType serviceHostingType =
deployServiceEntity.getDeployRequest().getServiceHostingType();
Expand All @@ -457,9 +457,9 @@ public ServiceDetailVo getSelfHostedServiceDetailsByIdForEndUser(UUID id) {
* Get vendor hosted service detail by id.
*
* @param id ID of deploy service.
* @return VendorHostedServiceDetailsVo
* @return VendorHostedDeployedServiceDetails
*/
public VendorHostedServiceDetailsVo getVendorHostedServiceDetailsByIdForEndUser(UUID id) {
public VendorHostedDeployedServiceDetails getVendorHostedServiceDetailsByIdForEndUser(UUID id) {
DeployServiceEntity deployServiceEntity = getDeployServiceEntity(id);
ServiceHostingType serviceHostingType =
deployServiceEntity.getDeployRequest().getServiceHostingType();
Expand Down Expand Up @@ -583,13 +583,13 @@ public Deployment getDeployment(DeployerKind deployerKind) {
return deployment;
}

private ServiceVo convertToServiceVo(DeployServiceEntity serviceEntity) {
private DeployedService convertToServiceVo(DeployServiceEntity serviceEntity) {
if (Objects.nonNull(serviceEntity)) {
ServiceVo serviceVo = new ServiceVo();
BeanUtils.copyProperties(serviceEntity, serviceVo);
serviceVo.setServiceHostingType(
DeployedService deployedService = new DeployedService();
BeanUtils.copyProperties(serviceEntity, deployedService);
deployedService.setServiceHostingType(
serviceEntity.getDeployRequest().getServiceHostingType());
return serviceVo;
return deployedService;
}
return null;
}
Expand Down Expand Up @@ -694,7 +694,7 @@ public void updateServiceStatus(UUID id, ServiceDeploymentState serviceDeploymen
* @param query service query model.
* @return serviceVos
*/
public List<ServiceVo> listDeployedServicesOfIsv(ServiceQueryModel query) {
public List<DeployedService> listDeployedServicesOfIsv(ServiceQueryModel query) {
Optional<String> namespace = identityProviderManager.getUserNamespace();
if (namespace.isEmpty()) {
return new ArrayList<>();
Expand All @@ -711,7 +711,7 @@ public List<ServiceVo> listDeployedServicesOfIsv(ServiceQueryModel query) {
* @param id ID of deploy service.
* @return serviceDetailVo
*/
public ServiceDetailVo getServiceDetailsByIdForIsv(UUID id) {
public DeployedServiceDetails getServiceDetailsByIdForIsv(UUID id) {
DeployServiceEntity deployServiceEntity = getDeployServiceEntity(id);
ServiceHostingType serviceHostingType =
deployServiceEntity.getDeployRequest().getServiceHostingType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
import org.eclipse.xpanse.modules.models.service.deploy.exceptions.ServiceNotDeployedException;
import org.eclipse.xpanse.modules.models.service.query.ServiceQueryModel;
import org.eclipse.xpanse.modules.models.service.utils.ServiceVariablesJsonSchemaValidator;
import org.eclipse.xpanse.modules.models.service.view.ServiceDetailVo;
import org.eclipse.xpanse.modules.models.service.view.ServiceVo;
import org.eclipse.xpanse.modules.models.service.view.DeployedService;
import org.eclipse.xpanse.modules.models.service.view.DeployedServiceDetails;
import org.eclipse.xpanse.modules.models.servicetemplate.DeployVariable;
import org.eclipse.xpanse.modules.models.servicetemplate.Ocl;
import org.eclipse.xpanse.modules.models.servicetemplate.enums.DeployerKind;
Expand Down Expand Up @@ -370,21 +370,21 @@ void testListDeployedServices() {
deployServices.add(deployServiceEntity);

when(deployServiceStorage.listServices(any())).thenReturn(deployServices);
List<ServiceVo> result = deployService.listDeployedServices(new ServiceQueryModel());
List<DeployedService> result = deployService.listDeployedServices(new ServiceQueryModel());

assertEquals(1, result.size());

ServiceVo serviceVo = result.get(0);
assertEquals(uuid, serviceVo.getId());
assertEquals("deployServiceEntity", serviceVo.getName());
DeployedService deployedService = result.get(0);
assertEquals(uuid, deployedService.getId());
assertEquals("deployServiceEntity", deployedService.getName());
}

@Test
void testGetDeployServiceDetails_ValidIdAndUser_ReturnsServiceDetailVo() {
when(deployServiceStorage.findDeployServiceById(uuid))
.thenReturn(deployServiceEntity);
when(identityProviderManager.getCurrentLoginUserId()).thenReturn(Optional.of(userId));
ServiceDetailVo result = deployService.getSelfHostedServiceDetailsByIdForEndUser(uuid);
DeployedServiceDetails result = deployService.getSelfHostedServiceDetailsByIdForEndUser(uuid);

assertNotNull(result);
assertEquals(uuid, result.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Define view object for detail of the policy entity.
*/
@Data
public class PolicyVo {
public class Policy {

/**
* The id of the entity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Define view object for UI Client to query deployed services.
*/
@Data
public class ServiceVo {
public class DeployedService {

@NotNull
@Schema(description = "The ID of the service")
Expand Down

0 comments on commit a58c8e7

Please sign in to comment.