本文整理汇总了Java中org.dozer.Mapper类的典型用法代码示例。如果您正苦于以下问题:Java Mapper类的具体用法?Java Mapper怎么用?Java Mapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Mapper类属于org.dozer包,在下文中一共展示了Mapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: covertTweet
import org.dozer.Mapper; //导入依赖的package包/类
private Tweet covertTweet(org.springframework.social.twitter.api.Tweet tweet) {
Mapper mapper = new DozerBeanMapper();
Tweet tweetNew = mapper.map(tweet, Tweet.class);
tweetNew.setId(index++);
Entities entities = mapper.map(tweet.getEntities(), Entities.class);
// entities.setId(index++);
tweetNew.setEntities(entities);
TwitterProfile user = mapper.map(tweet.getUser(), TwitterProfile.class);
user.setId(index++);
tweetNew.setUser(user);
return tweetNew;
}
示例2: mapPathChoiceDTO
import org.dozer.Mapper; //导入依赖的package包/类
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;
}
示例3: select
import org.dozer.Mapper; //导入依赖的package包/类
public List<T> select(String query, int limit, int offset, Map<String, Object> queryParams) {
List resultSet = (List) JPAUtils.execute(entityManager -> {
Query jpaQuery = entityManager.createQuery(query);
for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
jpaQuery.setParameter(entry.getKey(), entry.getValue());
}
return jpaQuery.setFirstResult(offset).setMaxResults(limit).getResultList();
});
Mapper mapper = ObjectMapperSingleton.getInstance();
List<T> resultList = new ArrayList<>();
resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, thriftGenericClass)));
return resultList;
}
示例4: getDozer
import org.dozer.Mapper; //导入依赖的package包/类
/**
* @return the {@link DozerBeanMapper}.
*/
@Bean
public Mapper getDozer() {
List<String> beanMappings = new ArrayList<>();
beanMappings.add(DOZER_MAPPING_XML);
return new DozerBeanMapper(beanMappings);
}
示例5: mapModificationNotificationToModificationNotificationDTO
import org.dozer.Mapper; //导入依赖的package包/类
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;
}
示例6: mapPartIterationToPartIterationDTO
import org.dozer.Mapper; //导入依赖的package包/类
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;
}
示例7: verifyCustomerMapping
import org.dozer.Mapper; //导入依赖的package包/类
@Test
public void verifyCustomerMapping() throws Exception {
Mapper mapper = DozerTestArtifactsFactory.createMapper();
Customer service = createServiceCustomer();
org.apache.camel.converter.dozer.model.Customer model = mapper.map(service, org.apache.camel.converter.dozer.model.Customer.class);
Customer roundTrip = mapper.map(model, Customer.class);
assertEquals(service, roundTrip);
}
示例8: getAllStats
import org.dozer.Mapper; //导入依赖的package包/类
@RequestMapping(value = "/sensor/{sensorId}", method = RequestMethod.GET)
public List<StatDTO> getAllStats(Principal principal, @PathVariable String sensorId) {
List<User> users = mUserRepository.findBySensorId(sensorId);
// Check if this user can access this resource
boolean allowed = false;
for(User user : users) {
if (principal.getName().equals(user.getName()))
allowed = true;
}
if (!allowed)
return null;
// Get all stats
List<PeriodStat> periodStats = mPeriodStatRepository.findBySensorId(sensorId);
List<StatDTO> stats = new ArrayList<>();
Mapper mapper = new DozerBeanMapper();
for (PeriodStat periodStat : periodStats) {
// If the period stat is complete (= all the days are present)
if (periodStat.getDaysInPeriod().size() == StatUtils.getNumberOfDaysInPeriod(periodStat.getPeriod())) {
stats.add(mapper.map(periodStat, StatDTO.class));
}
}
return stats;
}
示例9: convert
import org.dozer.Mapper; //导入依赖的package包/类
@Override
public PresentationBean convert(IntegrationBean integrationBean,
String scope) throws Exception {
return ((Mapper) dozerBeanMapperFactoryBean.getObject()).map(
integrationBean, presentationBeanClass,
scope);
}
示例10: convertIntegrationList
import org.dozer.Mapper; //导入依赖的package包/类
@Override
public void convertIntegrationList(List<IntegrationBean> integrationBeans,
List<PresentationBean> presentationBeans,
String scope) throws Exception {
if (integrationBeans.size() != presentationBeans.size()) {
throw new ListDiffersSizeException();
}
for (int i = 0; i < integrationBeans.size(); i++) {
((Mapper) dozerBeanMapperFactoryBean.getObject()).map(
integrationBeans.get(i), presentationBeans.get(i),
scope);
}
}
示例11: convertPresentationList
import org.dozer.Mapper; //导入依赖的package包/类
@Override
public void convertPresentationList(
List<PresentationBean> presentationBeans,
List<IntegrationBean> integrationBeans,
String scope) throws Exception {
if (presentationBeans.size() != integrationBeans.size()) {
throw new ListDiffersSizeException();
}
for (int i = 0; i < presentationBeans.size(); i++) {
((Mapper) dozerBeanMapperFactoryBean.getObject()).map(
presentationBeans.get(i), integrationBeans.get(i),
scope);
}
}
示例12: convert
import org.dozer.Mapper; //导入依赖的package包/类
@Override
public void convert(final BusinessBean businessBean,
PresentationBean presentationBean, String scope)
throws Exception {
((Mapper) dozerBeanMapperFactoryBean.getObject()).map(businessBean,
presentationBean, scope);
}
示例13: convertBusinessList
import org.dozer.Mapper; //导入依赖的package包/类
@Override
public List<PresentationBean> convertBusinessList(
List<BusinessBean> businessBeans, String scope)
throws Exception {
List<PresentationBean> presentationBeans = new ArrayList<PresentationBean>();
for (BusinessBean businessBean : businessBeans) {
PresentationBean presentationBean = ((Mapper) dozerBeanMapperFactoryBean
.getObject()).map(businessBean, presentationBeanClass,
scope);
presentationBeans.add(presentationBean);
}
return presentationBeans;
}
示例14: convertPresentationList
import org.dozer.Mapper; //导入依赖的package包/类
@Override
public List<BusinessBean> convertPresentationList(
List<PresentationBean> presentationBeans,
String scope) throws Exception {
List<BusinessBean> businessBeans = new ArrayList<BusinessBean>();
for (PresentationBean presentationBean : presentationBeans) {
BusinessBean businessBean = ((Mapper) dozerBeanMapperFactoryBean
.getObject()).map(presentationBean, businessBeanClass,
scope);
businessBeans.add(businessBean);
}
return businessBeans;
}
示例15: convert
import org.dozer.Mapper; //导入依赖的package包/类
@Override
public void convert(final BusinessBean businessBean,
IntegrationBean integrationBean, String scope)
throws Exception{
((Mapper) dozerBeanMapperFactoryBean.getObject()).map(businessBean,
integrationBean, scope);
}