PartResource { public List<PartUsageLink> createComponents(String workspaceId, List<PartUsageLinkDTO> pComponents) throws EntityNotFoundException, EntityAlreadyExistsException, AccessRightException, NotAllowedException, CreationException, UserNotActiveException, WorkspaceNotEnabledException { List<PartUsageLink> components = new ArrayList<>(); for (PartUsageLinkDTO partUsageLinkDTO : pComponents) { PartMaster component = findOrCreatePartMaster(workspaceId, partUsageLinkDTO.getComponent()); if (component != null) { PartUsageLink partUsageLink = new PartUsageLink(); List<CADInstance> cadInstances = new ArrayList<>(); List<PartSubstituteLink> partSubstituteLinks = new ArrayList<>(); if (partUsageLinkDTO.getCadInstances() != null) { for (CADInstanceDTO cadInstanceDTO : partUsageLinkDTO.getCadInstances()) { CADInstance cadInstance = mapper.map(cadInstanceDTO, CADInstance.class); cadInstance.setRotationMatrix(new RotationMatrix(cadInstanceDTO.getMatrix())); if (cadInstance.getRotationType() == null) { cadInstance.setRotationType(RotationType.ANGLE); } cadInstances.add(cadInstance); } } else if (partUsageLinkDTO.getUnit() == null || partUsageLinkDTO.getUnit().isEmpty()) { for (double i = 0; i < partUsageLinkDTO.getAmount(); i++) { cadInstances.add(new CADInstance(0, 0, 0, 0, 0, 0)); } } else { cadInstances.add(new CADInstance(0, 0, 0, 0, 0, 0)); } for (PartSubstituteLinkDTO substituteLinkDTO : partUsageLinkDTO.getSubstitutes()) { PartMaster substitute = findOrCreatePartMaster(workspaceId, substituteLinkDTO.getSubstitute()); if (substitute != null) { PartSubstituteLink partSubstituteLink = new PartSubstituteLink(); partSubstituteLink.setAmount(substituteLinkDTO.getAmount()); partSubstituteLink.setComment(partUsageLinkDTO.getComment()); partSubstituteLink.setReferenceDescription(partUsageLinkDTO.getReferenceDescription()); partSubstituteLink.setUnit(substituteLinkDTO.getUnit()); partSubstituteLink.setId(partUsageLinkDTO.getId()); List<CADInstance> subCADInstances = new ArrayList<>(); if (substituteLinkDTO.getCadInstances() != null) { for (CADInstanceDTO cadInstanceDTO : substituteLinkDTO.getCadInstances()) { CADInstance cadInstance = mapper.map(cadInstanceDTO, CADInstance.class); cadInstance.setRotationMatrix(new RotationMatrix(cadInstanceDTO.getMatrix())); if (cadInstance.getRotationType() == null) { cadInstance.setRotationType(RotationType.ANGLE); } subCADInstances.add(cadInstance); } } else if (substituteLinkDTO.getUnit() == null || substituteLinkDTO.getUnit().isEmpty()) { for (double i = 0; i < substituteLinkDTO.getAmount(); i++) { subCADInstances.add(new CADInstance(0, 0, 0, 0, 0, 0)); } } else { subCADInstances.add(new CADInstance(0, 0, 0, 0, 0, 0)); } partSubstituteLink.setCadInstances(subCADInstances); partSubstituteLink.setSubstitute(substitute); partSubstituteLinks.add(partSubstituteLink); } } partUsageLink.setComponent(component); partUsageLink.setAmount(partUsageLinkDTO.getAmount()); partUsageLink.setComment(partUsageLinkDTO.getComment()); partUsageLink.setReferenceDescription(partUsageLinkDTO.getReferenceDescription()); partUsageLink.setCadInstances(cadInstances); partUsageLink.setUnit(partUsageLinkDTO.getUnit()); partUsageLink.setOptional(partUsageLinkDTO.isOptional()); partUsageLink.setSubstitutes(partSubstituteLinks); partUsageLink.setId(partUsageLinkDTO.getId()); components.add(partUsageLink); } } return components; } PartResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get part revision", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) Response getPartRevision(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @GET @ApiOperation(value = "Get product instance where part revision is in use", response = ProductInstanceMasterDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of ProductInstanceMasterDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/used-by-product-instance-masters") @Produces(MediaType.APPLICATION_JSON) Response getProductInstanceMasters(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @GET @ApiOperation(value = "Get part revisions where given part revision is used as a component", response = PartRevisionDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of PartRevisionDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/used-by-as-component") @Produces(MediaType.APPLICATION_JSON) Response getUsedByAsComponent(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @GET @ApiOperation(value = "Get part revisions where given part revision is used as a substitute", response = PartRevisionDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of PartRevisionDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/used-by-as-substitute") @Produces(MediaType.APPLICATION_JSON) Response getUsedByAsSubstitute(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @PUT @ApiOperation(value = "Update part iteration", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/iterations/{partIteration}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Response updatePartIteration(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "Part iteration") @PathParam("partIteration") int partIteration,
            @ApiParam(required = true, value = "Part iteration to update") PartIterationDTO data); @GET @ApiOperation(value = "Get part iteration conversion status", response = ConversionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of ConversionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/iterations/{partIteration}/conversion") @Produces(MediaType.APPLICATION_JSON) ConversionDTO getConversionStatus(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "Part iteration") @PathParam("partIteration") int partIteration); @PUT @ApiOperation(value = "Retry part iteration conversion", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful conversion retry"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/iterations/{partIteration}/conversion") Response retryConversion(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "Part iteration") @PathParam("partIteration") int iteration); @PUT @ApiOperation(value = "Checkin part revision", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of checked in PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/checkin") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) PartRevisionDTO checkIn(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @PUT @ApiOperation(value = "Checkout part revision", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of checked out PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/checkout") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) PartRevisionDTO checkOut(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @PUT @ApiOperation(value = "Undo checkout part revision", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of undo checked out PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/undocheckout") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) PartRevisionDTO undoCheckOut(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @PUT @ApiOperation(value = "Update part revision ACL", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful ACL removal of PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/acl") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response updatePartRevisionACL(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "ACL rules to set") ACLDTO acl); @PUT @ApiOperation(value = "Create new part version", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful retrieval of the new version of PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/newVersion") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createNewPartVersion(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "New version of part to create") PartCreationDTO partCreationDTO); @PUT @ApiOperation(value = "Release part revision", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of released PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/release") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) PartRevisionDTO releasePartRevision(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @PUT @ApiOperation(value = "Set part revision as obsolete", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of obsolete PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/obsolete") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) PartRevisionDTO markPartRevisionAsObsolete(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @DELETE @ApiOperation(value = "Delete part revision", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) Response deletePartRevision(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @DELETE @ApiOperation(value = "Remove file from part iteration", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of file of PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Path("/iterations/{partIteration}/files/{subType}/{fileName}") Response removeFile(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "Part iteration") @PathParam("partIteration") int partIteration,
            @ApiParam(required = true, value = "Sub type") @PathParam("subType") String subType,
            @ApiParam(required = true, value = "File name") @PathParam("fileName") String fileName); @PUT @ApiOperation(value = "Rename attached file from part iteration", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful renaming of file of PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/iterations/{partIteration}/files/{subType}/{fileName}") FileDTO renameAttachedFileInPartIteration(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "Part iteration") @PathParam("partIteration") int partIteration,
            @ApiParam(required = true, value = "Sub type") @PathParam("subType") String subType,
            @ApiParam(required = true, value = "File name") @PathParam("fileName") String fileName,
            @ApiParam(required = true, value = "File to rename") FileDTO fileDTO); @POST @ApiOperation(value = "Create a new shared part from part revision", response = SharedPartDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created SharedPartDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/share") Response createSharedPart(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "Shared part to create") SharedPartDTO pSharedPartDTO); @PUT @ApiOperation(value = "Publish part revision", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful publish of PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Path("/publish") Response publishPartRevision(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @PUT @ApiOperation(value = "Un-publish part revision", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful un-publish of PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Path("/unpublish") Response unPublishPartRevision(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @GET @ApiOperation(value = "Get part revision's aborted workflow list", response = WorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkflowDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/aborted-workflows") @Produces(MediaType.APPLICATION_JSON) Response getAbortedWorkflowListInPart(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @PUT @ApiOperation(value = "Save part revision tags", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/tags") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) PartRevisionDTO savePartTags(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "Tag list to add") TagListDTO tagListDTO); @POST @ApiOperation(value = "Add tags to part revision", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/tags") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) PartRevisionDTO addPartTag(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "Tag list to add") TagListDTO tagListDTO); @DELETE @ApiOperation(value = "Delete tags from part revision", response = PartRevisionDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated PartRevisionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/tags/{tagName}") PartRevisionDTO removePartTags(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion,
            @ApiParam(required = true, value = "Tag name") @PathParam("tagName") String tagName); @GET @ApiOperation(value = "Get instances under given part revision (latest checked-in view)", response = LeafDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of instance nodes"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/instances") @Produces(MediaType.APPLICATION_JSON) Response getInstancesUnderPart(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); @GET @ApiOperation(value = "Get product baselines where part revision is involved", response = ProductBaselineDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of ProductBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("/baselines") @Produces(MediaType.APPLICATION_JSON) Response getBaselinesWherePartRevisionHasIterations(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Part number") @PathParam("partNumber") String partNumber,
            @ApiParam(required = true, value = "Part version") @PathParam("partVersion") String partVersion); List<PartUsageLink> createComponents(String workspaceId, List<PartUsageLinkDTO> pComponents); PartMaster findOrCreatePartMaster(String workspaceId, ComponentDTO componentDTO);  }
@Test public void createComponents() { PartIterationDTO data = new PartIterationDTO(ResourceUtil.WORKSPACE_ID, "partName", "partNumber", "A", 1); List<PartUsageLinkDTO> partUsageLinkDTOs = new ArrayList<>(); PartUsageLinkDTO partUsageLinkDTO = new PartUsageLinkDTO(); partUsageLinkDTO.setAmount(2); partUsageLinkDTO.setUnit(""); partUsageLinkDTO.setOptional(true); partUsageLinkDTO.setComment("comment part usage link"); partUsageLinkDTO.setReferenceDescription("description part usage link"); ComponentDTO componentDTO = new ComponentDTO("component01"); componentDTO.setStandardPart(false); partUsageLinkDTO.setComponent(componentDTO); List<PartSubstituteLinkDTO> substituteDTOs = new ArrayList<>(); PartSubstituteLinkDTO substituteLinkDTO = new PartSubstituteLinkDTO(); substituteLinkDTO.setAmount(3); substituteLinkDTO.setUnit("Kg"); ComponentDTO subComponentDTO = new ComponentDTO("subComponent01"); substituteLinkDTO.setSubstitute(subComponentDTO); List<CADInstanceDTO> cadInstanceDTOs = new ArrayList<>(); List<CADInstanceDTO> subCadInstanceDTOs = new ArrayList<>(); cadInstanceDTOs.add(new CADInstanceDTO(12.0, 12.0, 12.0, 62.0, 24.0, 95.0)); cadInstanceDTOs.add(new CADInstanceDTO(22.0, 12.0, 72.0, 52.0, 14.0, 45.0)); subCadInstanceDTOs.add(new CADInstanceDTO(10.0, 11.0, 12.0, 13.0, 14.0, 15.0)); subCadInstanceDTOs.add(new CADInstanceDTO(110.0, 10.0, 10.0, 52.0, 14.0, 45.0)); subCadInstanceDTOs.add(new CADInstanceDTO(120.0, 10.0, 10.0, 52.0, 14.0, 45.0)); substituteLinkDTO.setCadInstances(subCadInstanceDTOs); substituteDTOs.add(substituteLinkDTO); partUsageLinkDTO.setSubstitutes(substituteDTOs); partUsageLinkDTO.setCadInstances(cadInstanceDTOs); partUsageLinkDTOs.add(partUsageLinkDTO); data.setComponents(partUsageLinkDTOs); List<PartUsageLink> newComponents = new ArrayList<>(); try { Mockito.when(productService.partMasterExists(Matchers.any(PartMasterKey.class))).thenReturn(false); Mockito.when(userManager.checkWorkspaceWriteAccess(ResourceUtil.WORKSPACE_ID)).thenReturn(user); Mockito.when(partResource.findOrCreatePartMaster(ResourceUtil.WORKSPACE_ID, componentDTO)).thenReturn(partMaster); Mockito.when(partResource.findOrCreatePartMaster(ResourceUtil.WORKSPACE_ID, subComponentDTO)).thenReturn(subPartMaster); newComponents = partResource.createComponents(ResourceUtil.WORKSPACE_ID, partUsageLinkDTOs); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); fail("Part Creation failed"); } assertNotNull(newComponents); assertTrue(newComponents.size() == 1); assertTrue("description part usage link".equals(newComponents.get(0).getReferenceDescription())); assertTrue("partNumber".equals(newComponents.get(0).getComponent().getNumber())); assertTrue(newComponents.get(0).getAmount() == 2); assertTrue(newComponents.get(0).getUnit().isEmpty()); assertTrue(newComponents.get(0).isOptional()); assertTrue(newComponents.get(0).getCadInstances().size() == 2); assertTrue(newComponents.get(0).getCadInstances().get(0).getRx() == 12.0); assertTrue(newComponents.get(0).getCadInstances().get(0).getRy() == 12.0); assertTrue(newComponents.get(0).getCadInstances().get(0).getRz() == 12.0); assertTrue(newComponents.get(0).getCadInstances().get(0).getTx() == 62.0); assertTrue(newComponents.get(0).getCadInstances().get(0).getTy() == 24.0); assertTrue(newComponents.get(0).getCadInstances().get(0).getTz() == 95.0); assertTrue(newComponents.get(0).getCadInstances().get(1).getRx() == 22.0); assertTrue(newComponents.get(0).getCadInstances().get(1).getRy() == 12.0); assertTrue(newComponents.get(0).getCadInstances().get(1).getRz() == 72.0); assertTrue(newComponents.get(0).getCadInstances().get(1).getTx() == 52.0); assertTrue(newComponents.get(0).getCadInstances().get(1).getTy() == 14.0); assertTrue(newComponents.get(0).getCadInstances().get(1).getTz() == 45.0); assertTrue(newComponents.get(0).getSubstitutes().get(0).getCadInstances().size() == 3); assertTrue(newComponents.get(0).getSubstitutes().get(0).getCadInstances().get(0).getRx() == 10); assertTrue(newComponents.get(0).getSubstitutes().get(0).getCadInstances().get(0).getRy() == 11); assertTrue(newComponents.get(0).getSubstitutes().get(0).getCadInstances().get(0).getRz() == 12); assertTrue(newComponents.get(0).getSubstitutes().get(0).getCadInstances().get(0).getTx() == 13.0); assertTrue(newComponents.get(0).getSubstitutes().get(0).getCadInstances().get(0).getTy() == 14.0); assertTrue(newComponents.get(0).getSubstitutes().get(0).getCadInstances().get(0).getTz() == 15.0); }