org.dozer.Mapper Java Examples

The following examples show how to use org.dozer.Mapper. 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: 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 #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: 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 #4
Source File: AbstractWicketTest.java    From AppStash with Apache License 2.0 5 votes vote down vote up
private Mapper createDozerMapper() {
    return new DozerBeanMapper(Arrays.asList("/io/github/zutherb/appstash/shop/service/user/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/service/checkout/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/service/order/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/service/product/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/service/rule/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/ui/dozer-mapping.xml"));
}
 
Example #5
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 #6
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 #7
Source File: AbstractWicketTest.java    From the-app with Apache License 2.0 5 votes vote down vote up
private Mapper createDozerMapper() {
    return new DozerBeanMapper(Arrays.asList("/io/github/zutherb/appstash/shop/service/user/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/service/checkout/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/service/order/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/service/product/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/service/rule/dozer-mapping.xml",
            "/io/github/zutherb/appstash/shop/ui/dozer-mapping.xml"));
}
 
Example #8
Source File: OrderServiceImpl.java    From the-app with Apache License 2.0 5 votes vote down vote up
@Autowired
public OrderServiceImpl(@Qualifier("orderRepository") OrderRepository repository,
                        @Qualifier("dozerMapper") Mapper dozerMapper,
                        @Qualifier("orderIdProvider") OrderIdProvider orderIdProvider,
                        @Qualifier("cart") Cart cart,
                        @Qualifier("supplierCsvReader") SupplierCsvReader supplierCsvReader,
                        @Qualifier("userService") UserService userService) {
    super(repository, dozerMapper, OrderInfo.class, Order.class);
    orderRepository = repository;
    this.dozerMapper = dozerMapper;
    this.orderIdProvider = orderIdProvider;
    this.cart = cart;
    this.supplierCsvReader = supplierCsvReader;
    this.userService = userService;
}
 
Example #9
Source File: UserServiceImpl.java    From the-app with Apache License 2.0 5 votes vote down vote up
@Autowired
public UserServiceImpl(@Qualifier("userRepository") UserRepository repository,
                       @Qualifier("dozerMapper") Mapper dozerMapper,
                       @Qualifier("userPasswordEncoder") ShaPasswordEncoder passwordEncoder) {
    super(repository, dozerMapper, UserInfo.class, User.class);
    this.userRepository = repository;
    this.passwordEncoder = passwordEncoder;
}
 
Example #10
Source File: UserServiceImpl.java    From AppStash with Apache License 2.0 5 votes vote down vote up
@Autowired
public UserServiceImpl(@Qualifier("userRepository") UserRepository repository,
                       @Qualifier("dozerMapper") Mapper dozerMapper,
                       @Qualifier("userPasswordEncoder") ShaPasswordEncoder passwordEncoder) {
    super(repository, dozerMapper, UserInfo.class, User.class);
    this.userRepository = repository;
    this.passwordEncoder = passwordEncoder;
}
 
Example #11
Source File: OrderServiceImpl.java    From AppStash with Apache License 2.0 5 votes vote down vote up
@Autowired
public OrderServiceImpl(@Qualifier("orderRepository") OrderRepository repository,
                        @Qualifier("dozerMapper") Mapper dozerMapper,
                        @Qualifier("orderIdProvider") OrderIdProvider orderIdProvider,
                        @Qualifier("cart") Cart cart,
                        @Qualifier("supplierCsvReader") SupplierCsvReader supplierCsvReader,
                        @Qualifier("userService") UserService userService) {
    super(repository, dozerMapper, OrderInfo.class, Order.class);
    orderRepository = repository;
    this.dozerMapper = dozerMapper;
    this.orderIdProvider = orderIdProvider;
    this.cart = cart;
    this.supplierCsvReader = supplierCsvReader;
    this.userService = userService;
}
 
Example #12
Source File: TwitterServiceImpl.java    From WTFDYUM with Apache License 2.0 5 votes vote down vote up
@Autowired
public TwitterServiceImpl(final TwitterFactoryHolder twitterFactory, final Mapper mapper,
        @Value("${wtfdyum.server-base-url}") final String baseUrl,
        @Value("${wtfdyum.twitter.appId}") final String appId,
        @Value("${wtfdyum.twitter.appSecret}") final String appSecret) {
    this.twitterFactory = twitterFactory;
    this.mapper = mapper;
    this.baseUrl = baseUrl;
    this.appId = appId;
    this.appSecret = appSecret;
}
 
Example #13
Source File: BaseService.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
public Mapper getMapper() {
	return mapper;
}
 
Example #14
Source File: AbstractServiceImpl.java    From the-app with Apache License 2.0 4 votes vote down vote up
protected Mapper getDozerMapper() {
    return dozerMapper;
}
 
Example #15
Source File: BaseService.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
@Autowired
@Resource(name="mapper")	
public void setMapper(Mapper mapper) {
	this.mapper = mapper;
}
 
Example #16
Source File: TaskStateDataCustomConverter.java    From scheduling with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setMapper(Mapper mapper) {
    this.mapper = mapper;
}
 
Example #17
Source File: ProductServiceImpl.java    From AppStash with Apache License 2.0 4 votes vote down vote up
@Autowired
public ProductServiceImpl(@Qualifier("productRepository") ProductRepository productRepository,
                          @Qualifier("dozerMapper") Mapper dozerMapper) {
    super(productRepository, dozerMapper, ProductInfo.class, Product.class);
    this.productRepository = productRepository;
}
 
Example #18
Source File: RedisMicroserviceCartFulfillmentProviderImpl.java    From AppStash with Apache License 2.0 4 votes vote down vote up
@Autowired
public RedisMicroserviceCartFulfillmentProviderImpl(CartRepository cartRepository,
                                                    @Qualifier("dozerMapper") Mapper mapper) {
    this.cartRepository = cartRepository;
    this.mapper = mapper;
}
 
Example #19
Source File: CheckoutImpl.java    From AppStash with Apache License 2.0 4 votes vote down vote up
@Autowired
public CheckoutImpl(@Qualifier("cart") Cart cart,
                    @Qualifier("dozerMapper") Mapper mapper) {
    this.cart = cart;
    this.mapper = mapper;
}
 
Example #20
Source File: AbstractServiceImpl.java    From AppStash with Apache License 2.0 4 votes vote down vote up
public AbstractServiceImpl(AbstractRepository<S> repository, Mapper dozerMapper, Class<D> destinationClass, Class<S> sourceClass) {
    this.repository = repository;
    this.dozerMapper = dozerMapper;
    this.destinationClass = destinationClass;
    this.sourceClass = sourceClass;
}
 
Example #21
Source File: AbstractServiceImpl.java    From AppStash with Apache License 2.0 4 votes vote down vote up
protected Mapper getDozerMapper() {
    return dozerMapper;
}
 
Example #22
Source File: BaseService.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
@Autowired
@Resource(name="mapper")	
public void setMapper(Mapper mapper) {
	this.mapper = mapper;
}
 
Example #23
Source File: BaseService.java    From bamboobsc with Apache License 2.0 4 votes vote down vote up
public Mapper getMapper() {
	return mapper;
}
 
Example #24
Source File: MappingUtils.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
public static Mapper getMapper() {
	return mapper;
}
 
Example #25
Source File: BeanConverter.java    From tutorial with MIT License 4 votes vote down vote up
/**
 * 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 #26
Source File: AbstractServiceImpl.java    From the-app with Apache License 2.0 4 votes vote down vote up
public AbstractServiceImpl(AbstractRepository<S> repository, Mapper dozerMapper, Class<D> destinationClass, Class<S> sourceClass) {
    this.repository = repository;
    this.dozerMapper = dozerMapper;
    this.destinationClass = destinationClass;
    this.sourceClass = sourceClass;
}
 
Example #27
Source File: CheckoutImpl.java    From the-app with Apache License 2.0 4 votes vote down vote up
@Autowired
public CheckoutImpl(@Qualifier("cart") Cart cart,
                    @Qualifier("dozerMapper") Mapper mapper) {
    this.cart = cart;
    this.mapper = mapper;
}
 
Example #28
Source File: RedisMicroserviceCartFulfillmentProviderImpl.java    From the-app with Apache License 2.0 4 votes vote down vote up
@Autowired
public RedisMicroserviceCartFulfillmentProviderImpl(CartRepository cartRepository,
                                                    @Qualifier("dozerMapper") Mapper mapper) {
    this.cartRepository = cartRepository;
    this.mapper = mapper;
}
 
Example #29
Source File: ProductServiceImpl.java    From the-app with Apache License 2.0 4 votes vote down vote up
@Autowired
public ProductServiceImpl(@Qualifier("productRepository") ProductRepository productRepository,
                          @Qualifier("dozerMapper") Mapper dozerMapper) {
    super(productRepository, dozerMapper, ProductInfo.class, Product.class);
    this.productRepository = productRepository;
}
 
Example #30
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;
    }