Java Code Examples for org.dozer.Mapper#map()
The following examples show how to use
org.dozer.Mapper#map() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LOVResourceTest.java From eplmp with Eclipse Public License 1.0 | 6 votes |
@Test public void createLOVTest() throws ApplicationException, UnsupportedEncodingException { ListOfValuesDTO lovDTO = new ListOfValuesDTO(); lovDTO.setName("lov"); List<NameValuePairDTO> values = new ArrayList<>(); NameValuePairDTO value = new NameValuePairDTO(); value.setName("k"); value.setValue("v"); values.add(value); lovDTO.setValues(values); Mapper mapper = DozerBeanMapperSingletonWrapper.getInstance(); ListOfValues lov = mapper.map(lovDTO, ListOfValues.class); Mockito.doNothing().when(lovManager) .createLov(workspaceId, lov.getName(), lov.getValues()); Response res = lovResource.createLOV(workspaceId, lovDTO); Assert.assertEquals(Response.Status.CREATED.getStatusCode(), res.getStatus()); }
Example 2
Source File: LOVResourceTest.java From eplmp with Eclipse Public License 1.0 | 6 votes |
@Test public void updateLOVTest() throws ApplicationException { String name = "foo"; ListOfValuesDTO lovDTO = new ListOfValuesDTO(); lovDTO.setWorkspaceId(workspaceId); lovDTO.setName(name); List<NameValuePairDTO> values = new ArrayList<>(); NameValuePairDTO value = new NameValuePairDTO(); value.setName("k"); value.setValue("v"); values.add(value); lovDTO.setValues(values); Mapper mapper = DozerBeanMapperSingletonWrapper.getInstance(); ListOfValues lov = mapper.map(lovDTO, ListOfValues.class); Mockito.when(lovManager.updateLov(Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any())) .thenReturn(lov); ListOfValuesDTO result = lovResource.updateLOV(workspaceId, name, lovDTO); Assert.assertEquals(lovDTO.getName(), result.getName()); Assert.assertEquals(lovDTO.getValues().get(0).getName(), result.getValues().get(0).getName()); Assert.assertEquals(lovDTO.getValues().get(0).getValue(), result.getValues().get(0).getValue()); }
Example 3
Source File: Tools.java From eplmp with Eclipse Public License 1.0 | 5 votes |
public static ModificationNotificationDTO mapModificationNotificationToModificationNotificationDTO(ModificationNotification pNotification) { ModificationNotificationDTO dto = new ModificationNotificationDTO(); Mapper mapper = DozerBeanMapperSingletonWrapper.getInstance(); UserDTO userDTO = mapper.map(pNotification.getModifiedPart().getAuthor(), UserDTO.class); dto.setAuthor(userDTO); dto.setId(pNotification.getId()); dto.setImpactedPartNumber(pNotification.getImpactedPart().getNumber()); dto.setImpactedPartVersion(pNotification.getImpactedPart().getVersion()); User ackAuthor = pNotification.getAcknowledgementAuthor(); if (ackAuthor != null) { UserDTO ackDTO = mapper.map(ackAuthor, UserDTO.class); dto.setAckAuthor(ackDTO); } dto.setAcknowledged(pNotification.isAcknowledged()); dto.setAckComment(pNotification.getAcknowledgementComment()); dto.setAckDate(pNotification.getAcknowledgementDate()); dto.setCheckInDate(pNotification.getModifiedPart().getCheckInDate()); dto.setIterationNote(pNotification.getModifiedPart().getIterationNote()); dto.setModifiedPartIteration(pNotification.getModifiedPart().getIteration()); dto.setModifiedPartNumber(pNotification.getModifiedPart().getPartNumber()); dto.setModifiedPartName(pNotification.getModifiedPart().getPartName()); dto.setModifiedPartVersion(pNotification.getModifiedPart().getPartVersion()); return dto; }
Example 4
Source File: Tools.java From eplmp with Eclipse Public License 1.0 | 5 votes |
public static PartIterationDTO mapPartIterationToPartIterationDTO(PartIteration partIteration) { Mapper mapper = DozerBeanMapperSingletonWrapper.getInstance(); List<PartUsageLinkDTO> usageLinksDTO = new ArrayList<>(); PartIterationDTO partIterationDTO = mapper.map(partIteration, PartIterationDTO.class); for (PartUsageLink partUsageLink : partIteration.getComponents()) { PartUsageLinkDTO partUsageLinkDTO = mapper.map(partUsageLink, PartUsageLinkDTO.class); List<CADInstanceDTO> cadInstancesDTO = new ArrayList<>(); for (CADInstance cadInstance : partUsageLink.getCadInstances()) { CADInstanceDTO cadInstanceDTO = mapper.map(cadInstance, CADInstanceDTO.class); cadInstanceDTO.setMatrix(cadInstance.getRotationMatrix().getValues()); cadInstancesDTO.add(cadInstanceDTO); } List<PartSubstituteLinkDTO> substituteLinkDTOs = new ArrayList<>(); for (PartSubstituteLink partSubstituteLink : partUsageLink.getSubstitutes()) { PartSubstituteLinkDTO substituteLinkDTO = mapper.map(partSubstituteLink, PartSubstituteLinkDTO.class); substituteLinkDTOs.add(substituteLinkDTO); } partUsageLinkDTO.setCadInstances(cadInstancesDTO); partUsageLinkDTO.setSubstitutes(substituteLinkDTOs); usageLinksDTO.add(partUsageLinkDTO); } partIterationDTO.setComponents(usageLinksDTO); partIterationDTO.setNumber(partIteration.getPartRevision().getPartNumber()); partIterationDTO.setVersion(partIteration.getPartRevision().getVersion()); if (!partIteration.getGeometries().isEmpty()) { partIterationDTO.setGeometryFileURI("/api/files/" + partIteration.getSortedGeometries().get(0).getFullName()); } return partIterationDTO; }
Example 5
Source File: BeanConverter.java From tutorial with MIT License | 4 votes |
/** * TvSeriesDto --> TvSeries (DTO -> PO) * @param source * @return */ public static TvSeries toTvSeries(TvSeriesDto source) { Mapper mapper = new DozerBeanMapper(); TvSeries dest = (TvSeries) mapper.map(source, TvSeries.class); return dest; }
Example 6
Source File: BeanConverter.java From tutorial with MIT License | 4 votes |
/** * TvSeries --> TvSeriesDto (PO -> DTO) * @param source * @return */ public static TvSeriesDto toTvSeriesDto(TvSeries source) { Mapper mapper = new DozerBeanMapper(); TvSeriesDto dest = (TvSeriesDto) mapper.map(source, TvSeriesDto.class); return dest; }
Example 7
Source File: BeanConverter.java From tutorial with MIT License | 4 votes |
/** * TvCharacterDto -> TvCharacter (DTO -> PO) * @param source * @return */ public static TvCharacter toTvCharacter(TvCharacterDto source) { Mapper mapper = new DozerBeanMapper(); TvCharacter dest = (TvCharacter) mapper.map(source, TvCharacter.class); return dest; }
Example 8
Source File: BeanConverter.java From tutorial with MIT License | 4 votes |
/** * TvCharacter -> TvCharacterDto (PO -> DTO) * @param source * @return */ public static TvCharacterDto toTvCharacterDto(TvCharacter source) { Mapper mapper = new DozerBeanMapper(); TvCharacterDto dest = (TvCharacterDto) mapper.map(source, TvCharacterDto.class); return dest; }
Example 9
Source File: Tools.java From eplmp with Eclipse Public License 1.0 | 4 votes |
public static PartRevisionDTO mapPartRevisionToPartDTO(PartRevision partRevision) { Mapper mapper = DozerBeanMapperSingletonWrapper.getInstance(); PartRevisionDTO partRevisionDTO = mapper.map(partRevision, PartRevisionDTO.class); partRevisionDTO.setNumber(partRevision.getPartNumber()); partRevisionDTO.setPartKey(partRevision.getPartNumber() + "-" + partRevision.getVersion()); partRevisionDTO.setName(partRevision.getPartMaster().getName()); partRevisionDTO.setStandardPart(partRevision.getPartMaster().isStandardPart()); partRevisionDTO.setType(partRevision.getPartMaster().getType()); if (partRevision.isObsolete()) { partRevisionDTO.setObsoleteDate(partRevision.getObsoleteDate()); UserDTO obsoleteUserDTO = mapper.map(partRevision.getObsoleteAuthor(), UserDTO.class); partRevisionDTO.setObsoleteAuthor(obsoleteUserDTO); } if (partRevision.getReleaseAuthor() != null) { partRevisionDTO.setReleaseDate(partRevision.getReleaseDate()); UserDTO releaseUserDTO = mapper.map(partRevision.getReleaseAuthor(), UserDTO.class); partRevisionDTO.setReleaseAuthor(releaseUserDTO); } List<PartIterationDTO> partIterationDTOs = new ArrayList<>(); for (PartIteration partIteration : partRevision.getPartIterations()) { partIterationDTOs.add(mapPartIterationToPartIterationDTO(partIteration)); } partRevisionDTO.setPartIterations(partIterationDTOs); if (partRevision.isCheckedOut()) { partRevisionDTO.setCheckOutDate(partRevision.getCheckOutDate()); UserDTO checkoutUserDTO = mapper.map(partRevision.getCheckOutUser(), UserDTO.class); partRevisionDTO.setCheckOutUser(checkoutUserDTO); } if (partRevision.hasWorkflow()) { partRevisionDTO.setLifeCycleState(partRevision.getWorkflow().getLifeCycleState()); partRevisionDTO.setWorkflow(mapper.map(partRevision.getWorkflow(), WorkflowDTO.class)); } ACL acl = partRevision.getACL(); if (acl != null) { partRevisionDTO.setAcl(Tools.mapACLtoACLDTO(acl)); } else { partRevisionDTO.setAcl(null); } return partRevisionDTO; }