Java Code Examples for org.springframework.beans.BeanUtils#copyProperties()

The following examples show how to use org.springframework.beans.BeanUtils#copyProperties() . 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: TopicOrderBo.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public Topic buildTopic() {
    Topic topic = new Topic();
    BeanUtils.copyProperties(this, topic);
    topic.setId(this.getTopicId());
    topic.setTopicAlarmGroup(this.getAlarmGroup());
    topic.setTopicExtraParams(this.getExtraParams());
    topic.setTopicSchema(this.getSchema());

    String contacters = getContacters();
    if (!";".equals(contacters.substring(contacters.length() - 1))) {
        setContacters(getContacters() + ";");
        topic.setContacters(getContacters());
    }

    return topic;
}
 
Example 2
Source File: DutiesServiceImpl.java    From SuperBoot with MIT License 6 votes vote down vote up
@Override
public BaseResponse addDuties(ReqDuties duties) throws BaseException {
    QSuperbootDuties qSuperbootDuties = QSuperbootDuties.superbootDuties;

    SuperbootDuties impDuties = dutiesDAO.findOne(qSuperbootDuties.pkGroup.isNull()
            .and(qSuperbootDuties.dr.eq(BaseConstants.DATA_STATUS_OK))
            .and(qSuperbootDuties.dutiesCode.eq(duties.getDutiesCode())));

    if (null != impDuties) {
        throw new BaseException(StatusCode.ADD_ERROR_EXISTS, "职务编号不能重复");
    }
    impDuties = new SuperbootDuties();
    BeanUtils.copyProperties(duties, impDuties);
    impDuties.setDutiesType(0);
    impDuties = dutiesDAO.save(impDuties);

    ResDuties resDuties = new ResDuties();
    BeanUtils.copyProperties(impDuties, resDuties);

    return new BaseResponse(StatusCode.ADD_SUCCESS, resDuties);
}
 
Example 3
Source File: CustomApiController.java    From app-version with Apache License 2.0 6 votes vote down vote up
@ApiOperation(
        value = "编辑自定义接口",
        notes = "修改自定义接口"
)
@ApiImplicitParams({
        @ApiImplicitParam(name = "Authorization", value = "用户登录凭证", paramType = "header", dataType = "string", defaultValue = "Bearer ", required = true),
})
@PutMapping("/update/{id}")
@OperationRecord(type = OperationRecordLog.OperationType.UPDATE, resource = OperationRecordLog.OperationResource.CUSTOM_API, description = OperationRecordLog.OperationDescription.UPDATE_CUSTOM_API)
public ServiceResult updateCustomApi(@PathVariable Integer id, @Valid @RequestBody CustomApiRequestDTO customApiRequestDTO) {
    if (1 > id) {
        return ServiceResult.failed(40001, "id不正确");
    }
    //校验版本区间
    ServiceResult serviceResult = basicService.checkVersion(customApiRequestDTO);
    if (serviceResult.getCode() != 200) {
        return serviceResult;
    }

    CustomApi customApi = new CustomApi();
    BeanUtils.copyProperties(customApiRequestDTO, customApi);
    customApi.setId(id);
    return customApiService.updateCustomApi(customApi);
}
 
Example 4
Source File: DmsNonDrugServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
/**
 * 描述:新增一个非药品
 * <p>author:王思阳
 * <p>author:赵煜     封装param中没有的数据
 * <p>author:赵煜     修复科室名字错误bug
 */
@Override
public int create(DmsNonDrugParam dmsNonDrugParam) {
    DmsNonDrugExample example = new DmsNonDrugExample();//根据code查询非药品是否存在
    example.createCriteria().andCodeEqualTo(dmsNonDrugParam.getCode());
    List<DmsNonDrug> dmsNonDrugList =dmsNonDrugMapper.selectByExample(example);
    if(dmsNonDrugList.size()>0){//如果存在相同的code,则插入失败
        return 0;
    }

    DmsNonDrug dmsNonDrug = new DmsNonDrug();//插入
    BeanUtils.copyProperties(dmsNonDrugParam, dmsNonDrug);
    dmsNonDrug.setStatus(1);  // 正常
    dmsNonDrug.setCreateDate(new Date());
    dmsNonDrugMapper.insertSelective(dmsNonDrug);

    //插入成功,在redis修改flag
    redisUtil.setObj("nonDrugChangeStatus","1");

    return 1;

}
 
Example 5
Source File: OmsPromotionServiceImpl.java    From mall with Apache License 2.0 6 votes vote down vote up
/**
 * 对没满足优惠条件的商品进行处理
 */
private void handleNoReduce(List<CartPromotionItem> cartPromotionItemList, List<OmsCartItem> itemList,PromotionProduct promotionProduct) {
    for (OmsCartItem item : itemList) {
        CartPromotionItem cartPromotionItem = new CartPromotionItem();
        BeanUtils.copyProperties(item,cartPromotionItem);
        cartPromotionItem.setPromotionMessage("无优惠");
        cartPromotionItem.setReduceAmount(new BigDecimal(0));
        PmsSkuStock skuStock = getOriginalPrice(promotionProduct,item.getProductSkuId());
        if(skuStock!=null){
            cartPromotionItem.setRealStock(skuStock.getStock()-skuStock.getLockStock());
        }
        cartPromotionItem.setIntegration(promotionProduct.getGiftPoint());
        cartPromotionItem.setGrowth(promotionProduct.getGiftGrowth());
        cartPromotionItemList.add(cartPromotionItem);
    }
}
 
Example 6
Source File: TravelDocumentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 *
 * @see org.kuali.kfs.module.tem.document.service.TravelDocumentService#copySpecialCircumstances(java.util.List, java.lang.String)
 */
@Override
public List<SpecialCircumstances> copySpecialCircumstances(List<SpecialCircumstances> specialCircumstancesList, String documentNumber) {
    List<SpecialCircumstances> newSpecialCircumstancesList = new ArrayList<SpecialCircumstances>();
    if (specialCircumstancesList != null) {
        for (SpecialCircumstances specialCircumstances : specialCircumstancesList){
            SpecialCircumstances newSpecialCircumstances = new SpecialCircumstances();
            BeanUtils.copyProperties(specialCircumstances, newSpecialCircumstances);
            newSpecialCircumstances.setDocumentNumber(documentNumber);
            newSpecialCircumstances.setVersionNumber(new Long(1));
            newSpecialCircumstances.setObjectId(null);
            newSpecialCircumstances.setId(null);
            newSpecialCircumstancesList.add(newSpecialCircumstances);
        }
    }
    return newSpecialCircumstancesList;
}
 
Example 7
Source File: DmsDrugServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
/**
 * 描述:1.调用DmsDrugDao查询所有记录(不包括status=0)
 * <p>author: ma
 * <p>author: 赵煜 修改越界错误
 */
@Override
public List<DmsDrugResult> selectAllDrug(){
    DmsDrugExample example = new DmsDrugExample();
    example.createCriteria().andStatusNotEqualTo(0);
    //返回数据包装成Result
    List<DmsDrug> dmsDrugs = dmsDrugMapper.selectByExample(example);
    List<DmsDrugResult> dmsDrugResultList = new ArrayList<>();
    for (DmsDrug dmsDrug   : dmsDrugs) {
        DmsDrugResult dmsDrugResult = new DmsDrugResult();
        BeanUtils.copyProperties(dmsDrug, dmsDrugResult);

        DmsDosageExample dmsDosageExample = new DmsDosageExample();
        //封装剂型
        dmsDosageExample.createCriteria().andIdEqualTo(dmsDrug.getDosageId());
        List<DmsDosage> dmsDosageList = dmsDosageMapper.selectByExample(dmsDosageExample);
        if(!CollectionUtil.isEmpty(dmsDosageList)){
            dmsDrugResult.setDosage(dmsDosageList.get(0));
        }
        dmsDrugResultList.add(dmsDrugResult);
    }
    return dmsDrugResultList;
}
 
Example 8
Source File: IterationTransform.java    From onboard with Apache License 2.0 6 votes vote down vote up
public static IterationDTO iterationToIterationDTO(Iteration iteration) {
    IterationDTO iterationDTO = new IterationDTO();
    BeanUtils.copyProperties(iteration, iterationDTO);
    List<DTO> iterables = Lists.newArrayList();
    if (iteration.getIterables() != null) {
        for (Iterable iterable : iteration.getIterables()) {
            if (iterable instanceof Story) {
                iterables.add(StoryTransform.storyToStoryDTO((Story) iterable));
            } else if (iterable instanceof Bug) {
                iterables.add(BugTransForm.bugToBugDTO((Bug) iterable));
            } else if (iterable instanceof Step) {
                iterables.add(StepTransform.stepToStepDTO((Step) iterable));
            }
        }
    }
    iterationDTO.setIterables(iterables);
    return iterationDTO;
}
 
Example 9
Source File: SysNetworkServiceImpl.java    From paas with Apache License 2.0 6 votes vote down vote up
@Override
public ResultVO listByContainerId(String containerId) {
    List<ContainerNetwork> list = containerNetworkMapper.selectList(
            new EntityWrapper<ContainerNetwork>().eq("container_id", containerId));
    List<ContainerNetworkVO> res = new ArrayList<>();

    for(ContainerNetwork containerNetwork : list) {
        ContainerNetworkVO vo = new ContainerNetworkVO();
        BeanUtils.copyProperties(containerNetwork, vo);
        // 设置网络
        vo.setNetwork(networkMapper.selectById(containerNetwork.getNetworkId()));
        res.add(vo);
    }

    return ResultVOUtils.success(res);
}
 
Example 10
Source File: RoleRepositoryTest.java    From DrivingAgency with MIT License 5 votes vote down vote up
@Test
public void saveRoleTest(){
    RoleDto roleDto=RoleDto.builder().roleName("二级代理")
            .operator("Admin")
            .remark("二级代理只能招收学员,必须受管理员和相应的一级代理的管理")
            .status(1)
            .type(2).build();
    Role role=new Role();
    BeanUtils.copyProperties(roleDto,role);
    roleRepository.save(role);
}
 
Example 11
Source File: SprintSearchAssembler.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
public SprintSearchVO dtoToVO(SprintSearchDTO sprintSearchDTO, Map<Long, UserMessageDTO> usersMap, Map<Long, PriorityVO> priorityMap, Map<Long, StatusVO> statusMapDTOMap, Map<Long, IssueTypeVO> issueTypeDTOMap) {
    if (sprintSearchDTO == null) {
        return null;
    }
    SprintSearchVO sprintSearchVO = new SprintSearchVO();
    BeanUtils.copyProperties(sprintSearchDTO, sprintSearchVO);
    if (usersMap != null) {
        sprintSearchVO.setAssigneeIssues(issueSearchAssembler.dtoListToAssigneeIssueVO(sprintSearchDTO.getAssigneeIssueDTOList(), usersMap));
        sprintSearchVO.setIssueSearchVOList(issueSearchAssembler.dtoListToVO(sprintSearchDTO.getIssueSearchDTOList(), usersMap, priorityMap, statusMapDTOMap, issueTypeDTOMap));
    }
    return sprintSearchVO;
}
 
Example 12
Source File: LogApplicationImpl.java    From timer with Apache License 2.0 5 votes vote down vote up
@Override
public LogDto getLogInfoById(Integer logId) {
    LogPO logPO = logDomain.getLogInfoById(logId);
    if(logPO != null) {
        LogDto logDto = new LogDto();
        BeanUtils.copyProperties(logPO, logDto);
        return logDto;
    }
    return null;
}
 
Example 13
Source File: AbstractFlowParser.java    From DataSphereStudio with Apache License 2.0 5 votes vote down vote up
public SchedulerFlow resolveDWSJSONFlow(DWSJSONFlow jsonFlow){
    SchedulerFlow schedulerFlow = createSchedulerFlow();
    BeanUtils.copyProperties(jsonFlow,schedulerFlow,"children");
    JsonParser parser = new JsonParser();
    JsonObject jsonObject = parser.parse(jsonFlow.getJson()).getAsJsonObject();
    JsonArray nodeJsonArray = jsonObject.getAsJsonArray("nodes");
    Gson gson = new Gson();
    List<DWSNode> dwsNodes = gson.fromJson(nodeJsonArray, new TypeToken<List<DWSNodeDefault>>() {
    }.getType());
    List<SchedulerNode> schedulerNodeList = new ArrayList<>();
    List<SchedulerEdge> schedulerEdgeList = new ArrayList<>();
    for (DWSNode dwsNode : dwsNodes) {
        Optional<NodeParser> firstNodeParser = Arrays.stream(getNodeParsers())
                .filter(p -> p.ifNodeCanParse(dwsNode))
                .sorted((p1, p2) -> p2.getOrder() - p1.getOrder())
                .findFirst();
        SchedulerNode schedulerNode = firstNodeParser.orElseThrow(()->new IllegalArgumentException("NodeParser个数应该大于0")).parseNode(dwsNode);
        schedulerNodeList.add(schedulerNode);
    }
    JsonArray edgeJsonArray = jsonObject.getAsJsonArray("edges");
    List<DWSEdge> dwsEdges = gson.fromJson(edgeJsonArray, new TypeToken<List<DWSEdgeDefault>>() {
    }.getType());
    for (DWSEdge dwsEdge : dwsEdges) {
        SchedulerEdge schedulerEdge = new SchedulerEdgeDefault();
        schedulerEdge.setDWSEdge(dwsEdge);
        schedulerEdgeList.add(schedulerEdge);

    }
    JsonArray proJsonArray = jsonObject.getAsJsonArray("props");
    List<Map<String, Object>> props = gson.fromJson(proJsonArray, new TypeToken<List<Map<String, Object>>>() {
    }.getType());
    JsonArray resourcesJsonArray = jsonObject.getAsJsonArray("resources");
    List<Resource> resources = gson.fromJson(resourcesJsonArray, new TypeToken<List<Resource>>() {
    }.getType());
    schedulerFlow.setFlowResources(resources);
    schedulerFlow.setFlowProperties(props);
    schedulerFlow.setSchedulerEdges(schedulerEdgeList);
    schedulerFlow.setSchedulerNodes(schedulerNodeList);
    return schedulerFlow;
}
 
Example 14
Source File: DmsDiseServiceImpl.java    From HIS with Apache License 2.0 5 votes vote down vote up
@Override
public List<DmsDiseResult> selectAll() {
    List<DmsDiseResult> list = new ArrayList<>();
    DmsDiseExample example = new DmsDiseExample();
    example.createCriteria().andStatusNotEqualTo(0);
    for (DmsDise dmsDise:dmsDiseMapper.selectByExample(example)) {
        DmsDiseResult dmsDiseResult = new DmsDiseResult();
        BeanUtils.copyProperties(dmsDise,dmsDiseResult);
        list.add(dmsDiseResult);
    }
    return list;
}
 
Example 15
Source File: OrderProducer.java    From match-trade with Apache License 2.0 5 votes vote down vote up
public void onData(MatchOrder input) {
	long sequence = ringBuffer.next();
	try {
		MatchOrder order = ringBuffer.get(sequence);
		BeanUtils.copyProperties(input, order);
	} finally {
		ringBuffer.publish(sequence);
	}
}
 
Example 16
Source File: FlowableUserWorkflowAdapter.java    From syncope with Apache License 2.0 4 votes vote down vote up
protected User lazyLoad(final User user) {
    // using BeanUtils to access all user's properties and trigger lazy loading - we are about to
    // serialize a User instance for availability within workflow tasks, and this breaks transactions
    BeanUtils.copyProperties(user, entityFactory.newEntity(User.class));
    return user;
}
 
Example 17
Source File: PicturesGroupRequest.java    From cms with Apache License 2.0 4 votes vote down vote up
public PicturesGroup toPicturesGroup() {
    PicturesGroup group = new PicturesGroup();
    BeanUtils.copyProperties(this, group);
    return group;
}
 
Example 18
Source File: PointInfoDto.java    From iot-dc3 with Apache License 2.0 4 votes vote down vote up
@Override
public void convertToDo(PointInfo info) {
    BeanUtils.copyProperties(this, info);
}
 
Example 19
Source File: AnswerService.java    From spring-microservice-exam with MIT License 4 votes vote down vote up
/**
 * 答题详情
 *
 * @param recordId         recordId
 * @param currentSubjectId currentSubjectId
 * @param nextSubjectType  nextSubjectType
 * @param nextType         nextType
 * @return AnswerDto
 * @author tangyi
 * @date 2019/06/18 23:05
 */
public AnswerDto answerInfo(Long recordId, Long currentSubjectId, Integer nextSubjectType, Integer nextType) {
    ExaminationRecord record = examRecordService.get(recordId);
    SubjectDto subjectDto;
    // 题目为空,则加载第一题
    if (currentSubjectId == null) {
        subjectDto = subjectService.findFirstSubjectByExaminationId(record.getExaminationId());
    } else {
        ExaminationSubject examinationSubject = new ExaminationSubject();
        examinationSubject.setExaminationId(record.getExaminationId());
        examinationSubject.setSubjectId(currentSubjectId);

        // 查询该考试和指定序号的题目的关联信息
        // 下一题
        if (AnswerConstant.NEXT.equals(nextType)) {
            examinationSubject = examinationSubjectService.getByPreviousId(examinationSubject);
        } else if (AnswerConstant.PREVIOUS.equals(nextType)) {
            // 上一题
            examinationSubject = examinationSubjectService.getPreviousByCurrentId(examinationSubject);
        } else {
            examinationSubject = examinationSubjectService.findByExaminationIdAndSubjectId(examinationSubject);
        }
        if (examinationSubject == null)
            throw new CommonException("ID为" + currentSubjectId + "的题目不存在");
        // 查询题目的详细信息
        subjectDto = subjectService.get(examinationSubject.getSubjectId(), examinationSubject.getType());
    }
    AnswerDto answerDto = new AnswerDto();
    answerDto.setSubject(subjectDto);
    // 查询答题
    Answer answer = new Answer();
    answer.setSubjectId(subjectDto.getId());
    answer.setExamRecordId(recordId);
    Answer userAnswer = this.getAnswer(answer);
    if (userAnswer == null)
        userAnswer = answer;
    BeanUtils.copyProperties(userAnswer, answerDto);
    answerDto.setDuration(ExamRecordUtil.getExamDuration(userAnswer.getStartTime(), userAnswer.getEndTime()));
    // 判断正误
    SubjectTypeEnum subjectType = SubjectTypeEnum.matchByValue(subjectDto.getType());
    if (subjectType != null) {
        switch (subjectType) {
            case CHOICES:
                choicesHandler.judgeOptionRight(userAnswer, subjectDto);
                break;
            case MULTIPLE_CHOICES:
                multipleChoicesHandler.judgeOptionRight(userAnswer, subjectDto);
                break;
            case SHORT_ANSWER:
                shortAnswerHandler.judgeRight(userAnswer, subjectDto);
                break;
            case JUDGEMENT:
                judgementHandler.judgeRight(userAnswer, subjectDto);
                break;
            default:
                break;
        }
    }
    ResponseBean<List<UserVo>> userVoResponseBean = userServiceClient.findUserById(new Long[] {record.getUserId()});
    if (ResponseUtil.isSuccess(userVoResponseBean) && CollectionUtils.isNotEmpty(userVoResponseBean.getData())) {
        UserVo userVo = userVoResponseBean.getData().get(0);
        answerDto.setUserName(userVo.getName());
    }
    return answerDto;
}
 
Example 20
Source File: UserServiceImpl.java    From learning-code with Apache License 2.0 4 votes vote down vote up
@Override
public void insertUser(UserAddDTO userVO) {
    User user = new User();
    BeanUtils.copyProperties(userVO, user);
    insertUser(user);
}