org.dozer.DozerBeanMapper Java Examples

The following examples show how to use org.dozer.DozerBeanMapper. 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: CsvDozerBeanReaderTest.java    From super-csv with Apache License 2.0 6 votes vote down vote up
/**
 * Sets up the readers for the tests (all four constructor varieties are tested!).
 */
@Before
public void setUp() {
	reader = new StringReader(CSV);
	beanReader = new CsvDozerBeanReader(reader, PREFS);
	
	tokenizer = new Tokenizer(reader, PREFS);
	tokenizerBeanReader = new CsvDozerBeanReader(tokenizer, PREFS);
	
	beanMapper = new DozerBeanMapper();
	beanReaderWithMapper = new CsvDozerBeanReader(reader, PREFS, beanMapper);
	
	configuredBeanMapper = new DozerBeanMapper(Arrays.asList("reference.xml"));
	beanReaderWithConfiguredMapper = new CsvDozerBeanReader(reader, PREFS, configuredBeanMapper);
	
	tokenizerBeanReaderWithMapper = new CsvDozerBeanReader(tokenizer, PREFS, beanMapper);
}
 
Example #2
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInputType mapCommonInputType(CommonInput input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/dmg-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   return (CommonInputType)mapper.map(input, CommonInputType.class);
}
 
Example #3
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 #4
Source File: CheckoutImplTest.java    From the-app with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    initMocks(this);
    when(cart.getAll()).thenReturn(createCartItems());
    when(cart.getTotalSum()).thenReturn(BigDecimal.valueOf(2));
    checkout = new CheckoutImpl(cart, new DozerBeanMapper(
            Arrays.asList("io/github/zutherb/appstash/shop/service/checkout/dozer-mapping.xml")));
}
 
Example #5
Source File: ConverterUtil.java    From metacat with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param dozerTypeConverter custom dozer converter for types
 */
public ConverterUtil(@Nonnull @NonNull final DozerTypeConverter dozerTypeConverter) {
    final DozerBeanMapper dozerBeanMapper = new DozerBeanMapper();
    final BeanMappingBuilder builder = new BeanMappingBuilder() {
        @Override
        protected void configure() {
            mapping(FieldDto.class, FieldInfo.class)
                .fields("type", "type", FieldsMappingOptions.customConverterId("typeConverter"))
                .fields("partition_key", "partitionKey", FieldsMappingOptions.copyByReference())
                .fields("source_type", "sourceType", FieldsMappingOptions.copyByReference());
            mapping(TableDto.class, TableInfo.class)
                .fields("name", "name", FieldsMappingOptions.copyByReference());
            mapping(DatabaseDto.class, DatabaseInfo.class)
                .fields("name", "name", FieldsMappingOptions.copyByReference());
            mapping(PartitionDto.class, PartitionInfo.class)
                .fields("name", "name", FieldsMappingOptions.copyByReference());
            mapping(CatalogDto.class, CatalogInfo.class);
            mapping(ClusterDto.class, ClusterInfo.class);
            mapping(AuditDto.class, AuditInfo.class);
            mapping(ViewDto.class, ViewInfo.class);
            mapping(StorageDto.class, StorageInfo.class);
        }
    };
    dozerBeanMapper.addMapping(builder);
    final Map<String, CustomConverter> customConverterMap = Maps.newHashMap();
    customConverterMap.put("typeConverter", dozerTypeConverter);
    dozerBeanMapper.setCustomConvertersWithId(customConverterMap);
    this.mapper = dozerBeanMapper;
}
 
Example #6
Source File: BenchmarkTest.java    From easy-mapper with Apache License 2.0 5 votes vote down vote up
public Profiler testDozer(int invokeNum, String frameworkName) {
    DozerBeanMapper mapper = new DozerBeanMapper();
    long start = System.currentTimeMillis();
    for (int i = 0; i < invokeNum; i++) {
        Person7 p = getPerson();
        PersonDto dto = mapper.map(p, PersonDto.class);
        //System.out.println(dto);
    }
    return Profiler.apply(System.currentTimeMillis(), start)
            .setFrameworkName(frameworkName);
}
 
Example #7
Source File: CheckoutImplTest.java    From AppStash with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    initMocks(this);
    when(cart.getAll()).thenReturn(createCartItems());
    when(cart.getTotalSum()).thenReturn(BigDecimal.valueOf(2));
    checkout = new CheckoutImpl(cart, new DozerBeanMapper(
            Arrays.asList("io/github/zutherb/appstash/shop/service/checkout/dozer-mapping.xml")));
}
 
Example #8
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 #9
Source File: CsvDozerBeanWriterTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
/**
 * Sets up the writer for the tests.
 */
@Before
public void setUp() {
	writer = new StringWriter();
	beanWriter = new CsvDozerBeanWriter(writer, PREFS);
	
	beanMapper = new DozerBeanMapper();
	beanWriterWithMapper = new CsvDozerBeanWriter(writer, PREFS, beanMapper);
	
	configuredBeanMapper = new DozerBeanMapper(Arrays.asList("reference.xml"));
	beanWriterWithConfiguredMapper = new CsvDozerBeanWriter(writer, PREFS, configuredBeanMapper);
}
 
Example #10
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInput mapCommonInputType(be.ehealth.business.mycarenetdomaincommons.domain.CommonInput input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/genasync-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   CommonInput destObject = new CommonInput();
   mapper.map(input, destObject);
   return destObject;
}
 
Example #11
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInputType mapCommonInput(CommonInput input) throws TechnicalConnectorException, GenInsBusinessConnectorException, InstantiationException {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/genins-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   CommonInputType destObject = new CommonInputType();
   mapper.map(input, destObject);
   return destObject;
}
 
Example #12
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInputType mapCommonInputType(CommonInput input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/dmg-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   return (CommonInputType)mapper.map(input, CommonInputType.class);
}
 
Example #13
Source File: RoutingMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static RoutingType mapRoutingType(Routing input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/dmg-routing.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   return (RoutingType)mapper.map(input, RoutingType.class);
}
 
Example #14
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInput mapCommonInputType(be.ehealth.business.mycarenetdomaincommons.domain.CommonInput input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/genasync-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   CommonInput destObject = new CommonInput();
   mapper.map(input, destObject);
   return destObject;
}
 
Example #15
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInputType mapCommonInput(CommonInput input) throws TechnicalConnectorException, GenInsBusinessConnectorException, InstantiationException {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/genins-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   CommonInputType destObject = new CommonInputType();
   mapper.map(input, destObject);
   return destObject;
}
 
Example #16
Source File: RoutingMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static RoutingType mapRoutingType(Routing input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/dmg-routing.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   return (RoutingType)mapper.map(input, RoutingType.class);
}
 
Example #17
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInput mapCommonInputType(be.ehealth.business.mycarenetdomaincommons.domain.CommonInput input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/genasync-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   CommonInput destObject = new CommonInput();
   mapper.map(input, destObject);
   return destObject;
}
 
Example #18
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInputType mapCommonInput(CommonInput input) throws TechnicalConnectorException, GenInsBusinessConnectorException, InstantiationException {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/genins-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   CommonInputType destObject = new CommonInputType();
   mapper.map(input, destObject);
   return destObject;
}
 
Example #19
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInputType mapCommonInputType(CommonInput input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/dmg-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   return (CommonInputType)mapper.map(input, CommonInputType.class);
}
 
Example #20
Source File: RoutingMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static RoutingType mapRoutingType(Routing input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/dmg-routing.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   return (RoutingType)mapper.map(input, RoutingType.class);
}
 
Example #21
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInput mapCommonInputType(be.ehealth.business.mycarenetdomaincommons.domain.CommonInput input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/genasync-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   CommonInput destObject = new CommonInput();
   mapper.map(input, destObject);
   return destObject;
}
 
Example #22
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInputType mapCommonInput(CommonInput input) throws TechnicalConnectorException, GenInsBusinessConnectorException, InstantiationException {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/genins-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   CommonInputType destObject = new CommonInputType();
   mapper.map(input, destObject);
   return destObject;
}
 
Example #23
Source File: CommonInputMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CommonInputType mapCommonInputType(CommonInput input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/dmg-commoninput.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   return (CommonInputType)mapper.map(input, CommonInputType.class);
}
 
Example #24
Source File: RoutingMapper.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static RoutingType mapRoutingType(Routing input) {
   List<String> myMappingFiles = new ArrayList();
   myMappingFiles.add("dozer/dmg-routing.xml");
   DozerBeanMapper mapper = new DozerBeanMapper();
   mapper.setMappingFiles(myMappingFiles);
   return (RoutingType)mapper.map(input, RoutingType.class);
}
 
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: VocabularyService.java    From SciGraph with Apache License 2.0 4 votes vote down vote up
@Inject
VocabularyService(Vocabulary vocabulary, DozerBeanMapper mapper, CurieUtil curieUtil) {
  this.vocabulary = vocabulary;
  this.mapper = mapper;
  this.curieUtil = curieUtil;
}
 
Example #27
Source File: DozerConverter.java    From tutorials with MIT License 4 votes vote down vote up
public DozerConverter() {
    DozerBeanMapper mapper = new DozerBeanMapper();
    mapper.addMapping(DozerConverter.class.getResourceAsStream("/dozer-mapping.xml"));
    this.mapper = mapper;
}
 
Example #28
Source File: DozerIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void before() throws Exception {
    mapper = new DozerBeanMapper();
}
 
Example #29
Source File: DozerConfig.java    From spring-rest-server with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public DozerBeanMapper getMapper() {
    return new DozerBeanMapper(
            Arrays.asList("dozer-global-configuration.xml", "dozer-mapping.xml")
    );
}
 
Example #30
Source File: BeanConverter.java    From tutorial with MIT License 4 votes vote down vote up
/**
 * 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;
}