org.dozer.DozerBeanMapperSingletonWrapper Java Examples

The following examples show how to use org.dozer.DozerBeanMapperSingletonWrapper. 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 vote down vote up
@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 #2
Source File: LOVResourceTest.java    From eplmp with Eclipse Public License 1.0 6 votes vote down vote up
@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 #3
Source File: Tools.java    From eplmp with Eclipse Public License 1.0 6 votes vote down vote up
public static PathChoiceDTO mapPathChoiceDTO(PathChoice choice) {
    PathChoiceDTO pathChoiceDTO = new PathChoiceDTO();
    ArrayList<ResolvedPartLinkDTO> resolvedPath = new ArrayList<>();
    for (ResolvedPartLink resolvedPartLink : choice.getResolvedPath()) {
        ResolvedPartLinkDTO resolvedPartLinkDTO = new ResolvedPartLinkDTO();
        PartIteration resolvedIteration = resolvedPartLink.getPartIteration();
        resolvedPartLinkDTO.setPartIteration(new PartIterationDTO(resolvedIteration.getWorkspaceId(), resolvedIteration.getName(), resolvedIteration.getNumber(), resolvedIteration.getVersion(), resolvedIteration.getIteration()));
        PartLink partLink = resolvedPartLink.getPartLink();
        resolvedPartLinkDTO.setPartLink(new LightPartLinkDTO(partLink.getComponent().getNumber(), partLink.getComponent().getName(), partLink.getReferenceDescription(), partLink.getFullId()));
        resolvedPath.add(resolvedPartLinkDTO);
    }
    pathChoiceDTO.setResolvedPath(resolvedPath);
    Mapper mapper = DozerBeanMapperSingletonWrapper.getInstance();
    pathChoiceDTO.setPartUsageLink(mapper.map(choice.getPartUsageLink(), PartUsageLinkDTO.class));
    return pathChoiceDTO;
}
 
Example #4
Source File: Tools.java    From eplmp with Eclipse Public License 1.0 5 votes vote down vote up
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 #5
Source File: Tools.java    From eplmp with Eclipse Public License 1.0 5 votes vote down vote up
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 #6
Source File: AttributesResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #7
Source File: WorkflowModelResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #8
Source File: Tools.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
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;
    }
 
Example #9
Source File: QueryResultMessageBodyWriter.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #10
Source File: WorkspaceResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #11
Source File: ChangeIssuesResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #12
Source File: LOVResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #13
Source File: PartsResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #14
Source File: UserResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #15
Source File: InstanceAttributeDozerConverter.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
public InstanceAttributeDozerConverter() {
    super(InstanceAttribute.class, InstanceAttributeDTO.class);
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #16
Source File: ActivityModelDozerConverter.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
public ActivityModelDozerConverter() {
    super(ActivityModel.class, ActivityModelDTO.class);
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #17
Source File: ActivityDozerConverter.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
public ActivityDozerConverter() {
    super(Activity.class, ActivityDTO.class);
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #18
Source File: PartResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #19
Source File: WorkspaceMembershipResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #20
Source File: PartTemplateResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #21
Source File: FolderResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #22
Source File: RoleResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #23
Source File: WorkspaceWorkflowResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #24
Source File: TagResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #25
Source File: DocumentResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #26
Source File: AuthResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #27
Source File: TaskResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #28
Source File: WorkflowResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #29
Source File: AdminResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}
 
Example #30
Source File: ProductResource.java    From eplmp with Eclipse Public License 1.0 4 votes vote down vote up
@PostConstruct
public void init() {
    mapper = DozerBeanMapperSingletonWrapper.getInstance();
}