Java Code Examples for org.springframework.beans.BeanUtils

The following are top voted examples for showing how to use org.springframework.beans.BeanUtils. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: TITAN   File: LinkServiceImpl.java   View source code 7 votes vote down vote up
/**
 * @desc 分页查询所有链路列表
 *
 * @author liuliang
 *
 * @param pageIndex 当前页
 * @param pageSize 每页条数
 * @return List<LinkBO> 链路BO集合
 * @throws Exception
 */
@Override
public List<LinkBO> getLinkList(String linkName,int pageIndex, int pageSize) throws Exception{
	//1、查询
	List<Link> linkList = null;
	if(StringUtils.isBlank(linkName)){
		linkList = linkDao.queryLinkByPage(pageIndex, pageSize);
	}else{
		linkList = linkDao.queryLinkByPage(linkName,pageIndex, pageSize);
	}
	//2、转换
	List<LinkBO> linkBOList = new ArrayList<LinkBO>();
	if((null != linkList) && (0 < linkList.size())){
		LinkBO linkBO = null;
		for(Link link:linkList){
			linkBO = new LinkBO();
			BeanUtils.copyProperties(link, linkBO);
			linkBOList.add(linkBO);
		}
	}
	//3、返回
	return linkBOList;
}
 
Example 2
Project: X-mall   File: UserServiceImpl.java   View source code 6 votes vote down vote up
@Override
public ServerResponse<List<UserVo>> getUsers() {
    List<User> userList = userMapper.selectAll();
    List<UserVo> userVoList = new ArrayList<>();
    for (User user : userList) {
        UserVo userVo = new UserVo();
        BeanUtils.copyProperties(user, userVo);
        userVoList.add(userVo);
    }
    return ServerResponse.createBySuccess("获取用户成功", userVoList);
}
 
Example 3
Project: lams   File: HandlerMethodInvoker.java   View source code 6 votes vote down vote up
private WebDataBinder resolveModelAttribute(String attrName, MethodParameter methodParam,
		ExtendedModelMap implicitModel, NativeWebRequest webRequest, Object handler) throws Exception {

	// Bind request parameter onto object...
	String name = attrName;
	if ("".equals(name)) {
		name = Conventions.getVariableNameForParameter(methodParam);
	}
	Class<?> paramType = methodParam.getParameterType();
	Object bindObject;
	if (implicitModel.containsKey(name)) {
		bindObject = implicitModel.get(name);
	}
	else if (this.methodResolver.isSessionAttribute(name, paramType)) {
		bindObject = this.sessionAttributeStore.retrieveAttribute(webRequest, name);
		if (bindObject == null) {
			raiseSessionRequiredException("Session attribute '" + name + "' required - not found in session");
		}
	}
	else {
		bindObject = BeanUtils.instantiateClass(paramType);
	}
	WebDataBinder binder = createBinder(webRequest, bindObject, name);
	initBinder(handler, name, binder, webRequest);
	return binder;
}
 
Example 4
Project: configx   File: ConfigBeanFactory.java   View source code 6 votes vote down vote up
/**
 * 创建配置Bean
 *
 * @param propertyName               属性名
 * @param beanType                   配置Bean类型
 * @param converterType              转换器类型
 * @param configBeanPropertyResolver 属性解析器
 * @param conversionService          转换服务
 * @param <T>
 * @return
 */
public static <T> T createConfigBean(String propertyName, Class<T> beanType,
                                     Class<? extends ConfigBeanConverter> converterType,
                                     ConfigPropertyResolver configBeanPropertyResolver,
                                     ConfigBeanConversionService conversionService) {

    PropertyResolver propertyResolver = configBeanPropertyResolver.getObject();
    String propertyValue = propertyResolver.getRequiredProperty(propertyName);

    if (converterType != null && !converterType.isInterface()) {
        ConfigBeanConverter converter = BeanUtils.instantiate(converterType);
        return (T) converter.convert(propertyName, propertyValue, TypeDescriptor.valueOf(beanType));

    } else {
        return (T) conversionService.convert(propertyName, propertyValue, TypeDescriptor.valueOf(beanType));
    }
}
 
Example 5
Project: Mastering-Microservices-with-Java-9-Second-Edition   File: BookingController.java   View source code 6 votes vote down vote up
/**
 * Add booking with the specified information.
 *
 * @param bookingVO
 * @return A non-null booking.
 */
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Booking> add(@RequestBody BookingVO bookingVO) {
    logger.info(String.format("booking-service add() invoked: %s for %s", bookingService.getClass().getName(), bookingVO.getName()));
    System.out.println(bookingVO);
    Booking booking = new Booking(null, null, null, null, null, null, null);
    BeanUtils.copyProperties(bookingVO, booking);
    try {
        bookingService.add(booking);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised add Booking REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}
 
Example 6
Project: document-management-store-app   File: DocumentContentVersionHalResource.java   View source code 6 votes vote down vote up
public DocumentContentVersionHalResource(DocumentContentVersion documentContentVersion) {
    BeanUtils.copyProperties(documentContentVersion, this);

    add(linkTo(methodOn(StoredDocumentController.class)
            .getMetaData(documentContentVersion.getStoredDocument().getId())).withRel("document"));

    add(linkTo(methodOn(DocumentContentVersionController.class).getDocumentContentVersionDocument(
            documentContentVersion.getStoredDocument().getId(),
            documentContentVersion.getId())).withRel("self"));

    add(linkTo(methodOn(DocumentContentVersionController.class).getDocumentContentVersionDocumentBinary(
            documentContentVersion.getStoredDocument().getId(),
            documentContentVersion.getId())).withRel("binary"));

    add(linkTo(methodOn(DocumentContentVersionController.class).getDocumentContentVersionDocumentPreviewThumbnail(
            documentContentVersion.getStoredDocument().getId(),
        documentContentVersion.getId())).withRel("thumbnail"));
}
 
Example 7
Project: sucok-framework   File: QueryResult.java   View source code 6 votes vote down vote up
public QueryResult<T> treeSorted(String keyField, String parentKeyField, Object rootValue) {
	try {
		List<T> list = getData();
		if (list.size() <= 0) {
			return this;
		}
		Class<?> itemClass = list.get(0).getClass();
		PropertyDescriptor keyProp = BeanUtils.getPropertyDescriptor(itemClass, keyField);
		PropertyDescriptor parentKeyProp = BeanUtils.getPropertyDescriptor(itemClass, parentKeyField);
		List<T> newList = new ArrayList<>(list.size());
		addTreeNode(newList, list, rootValue, keyProp, parentKeyProp);
		setData(newList);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
	return this;
}
 
Example 8
Project: Yidu   File: ArticleListAction.java   View source code 6 votes vote down vote up
@Override
protected void loadData() {
    ArticleSearchBean searchBean = new ArticleSearchBean();
    BeanUtils.copyProperties(this, searchBean, new String[] { "articleno" });
    searchBean.setPageType(ArticleSearchBean.PageType.adminPage);
    if (StringUtils.isEmpty(pagination.getSortColumn())) {
        pagination.setSortColumn("lastupdate");
        pagination.setSortOrder("DESC");
    }
    // 总件数设置
    pagination.setPreperties(articleService.getCount(searchBean));
    searchBean.setPagination(pagination);
    articleList = articleService.find(searchBean);
    // Setting number of records in the particular page
    pagination.setPageRecords(articleList.size());
}
 
Example 9
Project: Yidu   File: ChapterEditAction.java   View source code 6 votes vote down vote up
@Override
protected void loadData() {
    logger.debug("loadData start.");
    // 初始化种别下拉列表选项
    initCollections(new String[] { "collectionProperties.chapter.isvip" });
    if (chapterno == 0 && articleno == 0) {
        addActionError(getText("errors.unknown"));
        return;
    }

    // 编辑
    if (chapterno != 0) {
        TChapter chapter = chapterService.getByNo(chapterno);
        BeanUtils.copyProperties(chapter, this);
        content = Utils.getContext(chapter, false);
    } else {
        // 追加的话取小说信息
        TArticle article = articleService.getByNo(articleno);
        BeanUtils.copyProperties(article, this);
    }
    logger.debug("loadData normally end.");
}
 
Example 10
Project: sporticus   File: IUserProfile.java   View source code 6 votes vote down vote up
static IUserProfile COPY(final IUserProfile from, final IUserProfile to) {
    if(from == null) {
        return null;
    }
    if(to == null) {
        return null;
    }
    BeanUtils.copyProperties(from, to);
    if(from.isEnabled() != null) {
        to.setEnabled(from.isEnabled());
    }
    if(from.isVerified() != null) {
        to.setVerified(from.isVerified());
    }

    return to;
}
 
Example 11
Project: sporticus   File: IGroupMember.java   View source code 6 votes vote down vote up
static IGroupMember COPY(final IGroupMember from, final IGroupMember to) {
    if (from == null) {
        return null;
    }
    if (to == null) {
        return null;
    }
    BeanUtils.copyProperties(from, to);
    if (from.isEnabled() != null) {
        to.setEnabled(from.isEnabled());
    }
    if (from.getStatus() != null) {
        to.setStatus(from.getStatus());
    }
    return to;
}
 
Example 12
Project: Mastering-Microservices-with-Java-9-Second-Edition   File: UserController.java   View source code 6 votes vote down vote up
/**
 * Add user with the specified information.
 *
 * @param userVO
 * @return A non-null user.
 */
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<User> add(@RequestBody UserVO userVO) {
    logger.info(String.format("user-service add() invoked: %s for %s", userService.getClass().getName(), userVO.getName()));
    System.out.println(userVO);
    User user = new User(null, null, null, null, null);
    BeanUtils.copyProperties(userVO, user);
    try {
        userService.add(user);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised add User REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}
 
Example 13
Project: FastBootWeixin   File: WxApiExecutor.java   View source code 6 votes vote down vote up
private Object getObjectBody(WxApiMethodInfo wxApiMethodInfo, Object[] args) {
    MethodParameter methodParameter = wxApiMethodInfo.getMethodParameters().stream()
            .filter(p -> !BeanUtils.isSimpleValueType(p.getParameterType()) || p.hasParameterAnnotation(WxApiBody.class))
            .findFirst().orElse(null);
    if (methodParameter == null) {
        throw new WxAppException("没有可处理的参数");
    }
    // 不是简单类型
    if (!BeanUtils.isSimpleValueType(methodParameter.getParameterType())) {
        // 暂时只支持json
        return args[methodParameter.getParameterIndex()];
    }
    if (args[methodParameter.getParameterIndex()] != null) {
        return args[methodParameter.getParameterIndex()].toString();
    } else {
        return "";
    }
}
 
Example 14
Project: gemini.blueprint   File: AbstractOsgiBundleApplicationContext.java   View source code 6 votes vote down vote up
/**
 * Takes care of enforcing the relationship between exporter and importers.
 * 
 * @param beanFactory
 */
private void enforceExporterImporterDependency(ConfigurableListableBeanFactory beanFactory) {
	Object instance = null;

	instance = AccessController.doPrivileged(new PrivilegedAction<Object>() {

		public Object run() {
			// create the service manager
			ClassLoader loader = AbstractOsgiBundleApplicationContext.class.getClassLoader();
			try {
				Class<?> managerClass = loader.loadClass(EXPORTER_IMPORTER_DEPENDENCY_MANAGER);
				return BeanUtils.instantiateClass(managerClass);
			} catch (ClassNotFoundException cnfe) {
				throw new ApplicationContextException("Cannot load class " + EXPORTER_IMPORTER_DEPENDENCY_MANAGER,
						cnfe);
			}
		}
	});

	// sanity check
	Assert.isInstanceOf(BeanFactoryAware.class, instance);
	Assert.isInstanceOf(BeanPostProcessor.class, instance);
	((BeanFactoryAware) instance).setBeanFactory(beanFactory);
	beanFactory.addBeanPostProcessor((BeanPostProcessor) instance);
}
 
Example 15
Project: YiDu-Novel   File: ChapterEditAction.java   View source code 6 votes vote down vote up
@Override
protected void loadData() {
    logger.debug("loadData start.");
    // 初始化种别下拉列表选项
    initCollections(new String[] { "collectionProperties.chapter.isvip" });
    if (chapterno == 0 && articleno == 0) {
        addActionError(getText("errors.unknown"));
        return;
    }

    // 编辑
    if (chapterno != 0) {
        TChapter chapter = chapterService.getByNo(chapterno);
        BeanUtils.copyProperties(chapter, this);
        content = Utils.getContext(chapter, false);
    } else {
        // 追加的话取小说信息
        TArticle article = articleService.getByNo(articleno);
        BeanUtils.copyProperties(article, this);
    }
    logger.debug("loadData normally end.");
}
 
Example 16
Project: YiDu-Novel   File: BlockEditAction.java   View source code 6 votes vote down vote up
/**
 * 
 * <p>
 * 保存画面的内容
 * </p>
 * 
 * @return
 */
public String save() {
    logger.debug("save start.");
    // 初始化下拉列表选项
    initCollections(new String[] { "collectionProperties.article.category", "collectionProperties.block.type",
            "collectionProperties.block.target", "collectionProperties.block.sortCol",
            "collectionProperties.boolean" });
    TSystemBlock systemBlock = new TSystemBlock();
    if (blockno != 0) {
        systemBlock = systemBlockService.getByNo(blockno);
    } else {
        systemBlock.setDeleteflag(false);
    }
    BeanUtils.copyProperties(this, systemBlock);
    systemBlock.setModifytime(new Date());
    systemBlock.setModifyuserno(LoginManager.getLoginUser().getUserno());
    systemBlockService.save(systemBlock);
    logger.debug("save normally end.");
    return REDIRECT;
}
 
Example 17
Project: lams   File: AbstractJaxWsServiceExporter.java   View source code 6 votes vote down vote up
private WebServiceFeature convertWebServiceFeature(Object feature) {
	Assert.notNull(feature, "WebServiceFeature specification object must not be null");
	if (feature instanceof WebServiceFeature) {
		return (WebServiceFeature) feature;
	}
	else if (feature instanceof Class) {
		return (WebServiceFeature) BeanUtils.instantiate((Class<?>) feature);
	}
	else if (feature instanceof String) {
		try {
			Class<?> featureClass = getBeanClassLoader().loadClass((String) feature);
			return (WebServiceFeature) BeanUtils.instantiate(featureClass);
		}
		catch (ClassNotFoundException ex) {
			throw new IllegalArgumentException("Could not load WebServiceFeature class [" + feature + "]");
		}
	}
	else {
		throw new IllegalArgumentException("Unknown WebServiceFeature specification type: " + feature.getClass());
	}
}
 
Example 18
Project: YiDu-Novel   File: ChapterOrderAction.java   View source code 6 votes vote down vote up
@Override
protected void loadData() {
    logger.debug("loadData start.");
    // 初始化种别下拉列表选项
    initCollections(new String[] { "collectionProperties.chapter.isvip" });
    if (chapterno == 0 && articleno == 0) {
        addActionError(getText("errors.unknown"));
        return;
    }

    // 编辑
    if (chapterno != 0) {
        TChapter chapter = chapterService.getByNo(chapterno);
        BeanUtils.copyProperties(chapter, this);
        content = Utils.getContext(chapter, false);
    }
    logger.debug("loadData normally end.");
}
 
Example 19
Project: Yidu   File: ArticleEditAction.java   View source code 6 votes vote down vote up
@Override
protected void loadData() {
    logger.debug("loadData start.");
    // 初始化类别下拉列表选项
    initCollections(new String[] { "collectionProperties.article.category",
            "collectionProperties.article.fullflag", "collectionProperties.article.firstflag",
            "collectionProperties.article.permission" });

    // 编辑
    if (articleno != 0) {
        TArticle article = articleService.getByNo(articleno);
        if (article == null) {
            addActionError(getText("errors.not.exsits.article"));
            return;
        }
        if (!checkRight(article)) {
            addActionError(getText("errors.right"));
            return;
        }

        BeanUtils.copyProperties(article, this);

    }
    logger.debug("loadData normally end.");
}
 
Example 20
Project: Yidu   File: UserEditAction.java   View source code 6 votes vote down vote up
/**
 * <p>
 * 保存画面的内容
 * </p>
 * 
 * @return
 * @throws Exception
 */
public String save() {
    logger.debug("save start.");
    TUser user = new TUser();
    if (userno != 0) {
        user = userService.getByNo(userno);
    } else {
        user.setRegdate(new Date());
        user.setDeleteflag(false);
    }
    BeanUtils.copyProperties(this, user, new String[] { "regdate", "lastlogin", "password" });

    if (StringUtils.isNotEmpty(password)) {
        user.setPassword(Utils.convert2MD5(password));
    }
    user.setActivedflag(true);
    user.setModifytime(new Date());
    user.setModifyuserno(LoginManager.getLoginUser().getUserno());
    userService.save(user);
    logger.debug("save normally end.");
    return REDIRECT;
}
 
Example 21
Project: gemini.blueprint   File: ExtenderConfiguration.java   View source code 6 votes vote down vote up
protected void addDefaultDependencyFactories() {
	boolean debug = log.isDebugEnabled();

	// default JDK 1.4 processor
	dependencyFactories.add(0, new MandatoryImporterDependencyFactory());

	// load through reflection the dependency and injection processors if running on JDK 1.5 and annotation
	// processing is enabled
	if (processAnnotation) {
		// dependency processor
		Class<?> annotationProcessor = null;
		try {
			annotationProcessor =
					Class.forName(ANNOTATION_DEPENDENCY_FACTORY, false, ExtenderConfiguration.class
							.getClassLoader());
		} catch (ClassNotFoundException cnfe) {
			log.warn("Gemini Blueprint extensions bundle not present, annotation processing disabled.");
			log.debug("Gemini Blueprint extensions bundle not present, annotation processing disabled.", cnfe);
			return;
		}
		Object processor = BeanUtils.instantiateClass(annotationProcessor);
		Assert.isInstanceOf(OsgiServiceDependencyFactory.class, processor);
		dependencyFactories.add(1, (OsgiServiceDependencyFactory) processor);

		if (debug)
			log.debug("Succesfully loaded annotation dependency processor [" + ANNOTATION_DEPENDENCY_FACTORY + "]");

		// add injection processor (first in line)
		postProcessors.add(0, new OsgiAnnotationPostProcessor());
		log.info("Gemini Blueprint extensions annotation processing enabled");
	} else {
		if (debug) {
			log.debug("Gemini Blueprint extensions annotation processing disabled; [" + ANNOTATION_DEPENDENCY_FACTORY
					+ "] not loaded");
		}
	}

}
 
Example 22
Project: xq_seckill_microservice   File: CrawlerServiceImpl.java   View source code 5 votes vote down vote up
@Override
@Transactional
public void saveInitializeData(byte[] dataArray) throws Exception {
    try {
        EstateItemDTO dto = ProtoStuffUtil.deserialize(dataArray, EstateItemDTO.class);
        EstateItemModel model = new EstateItemModel();

        // 先查看数据库是否已存在该记录
        dataArray = estateFeignClient.findItemByHouseCode(dto.getHouseCode());
        if (dataArray != null) {
            model = ProtoStuffUtil.deserialize(dataArray, EstateItemModel.class);
            BeanUtils.copyProperties(dto, model, "id");
            // 先删除原有图片
            estateFeignClient.deleteImagesByHouseCode(dto.getHouseCode());
        } else {
            BeanUtils.copyProperties(dto, model);
        }
        // 保存房源条目
        estateFeignClient.saveItem(ProtoStuffUtil.serialize(model));
        // 保存房源图片
        saveImages(dto);

        ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
        resolver.setCacheable(true);
        resolver.setCharacterEncoding(AppConstants.CHARSET_UTF8);
        resolver.setTemplateMode(StandardTemplateModeHandlers.LEGACYHTML5.getTemplateModeName());
        resolver.setPrefix("templates/");//模板所在目录
        resolver.setSuffix(".html");//模板文件后缀
        //构造上下文(Model)

        Context context = new Context(Locale.CHINA, BeanMapUtil.beanToMap(dto));
        GenParam genParam = new GenParam(resolver, context, "estate_detailUI", appProperties.getProducesPath(), dto.getHouseCode());
        // 生成静态页面
        PageGenerator.staticPage(genParam);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }

}
 
Example 23
Project: eventapis   File: CreateOrderCommand.java   View source code 5 votes vote down vote up
@RequestMapping(value = "/order/v1/create", method = RequestMethod.POST)
public EventKey execute(@RequestBody @Valid CreateOrderCommandDto dto) throws Exception {

    OrderCreatedEvent orderCreatedEvent = new OrderCreatedEvent();
    BeanUtils.copyProperties(dto,orderCreatedEvent);

    EventKey eventKey = eventRepository.recordAndPublish(orderCreatedEvent);
    return eventKey;
}
 
Example 24
Project: exam   File: ExamSectionQuestion.java   View source code 5 votes vote down vote up
ExamSectionQuestion copyWithAnswers() {
    ExamSectionQuestion esqCopy = new ExamSectionQuestion();
    BeanUtils.copyProperties(this, esqCopy, "id", "options", "essayAnswer", "clozeTestAnswer");
    // This is a little bit tricky. Need to map the original question options with copied ones so they can be
    // associated with both question and exam section question options :)
    Map<Long, MultipleChoiceOption> optionMap = new HashMap<>();
    Question blueprint = question.copy(optionMap);
    blueprint.setParent(question);
    blueprint.save();
    optionMap.forEach((k, optionCopy) -> {
        optionCopy.setQuestion(blueprint);
        optionCopy.save();
        Optional<ExamSectionQuestionOption> esqoo = options.stream()
                .filter(o -> o.getOption().getId().equals(k))
                .findFirst();
        if (esqoo.isPresent()) {
            ExamSectionQuestionOption esqo = esqoo.get();
            ExamSectionQuestionOption esqoCopy = esqo.copyWithAnswer();
            esqoCopy.setOption(optionCopy);
            esqCopy.getOptions().add(esqoCopy);
        } else {
            Logger.error("Failed to copy a multi-choice question option!");
            throw new RuntimeException();
        }
    });
    esqCopy.setQuestion(blueprint);
    // Essay Answer
    if (essayAnswer != null) {
        esqCopy.setEssayAnswer(essayAnswer.copy());
    }
    if (clozeTestAnswer != null) {
        esqCopy.setClozeTestAnswer(clozeTestAnswer.copy());
    }
    return esqCopy;
}
 
Example 25
Project: springboot-shiro-cas-mybatis   File: RegisteredServiceThemeBasedViewResolver.java   View source code 5 votes vote down vote up
/**
 * Uses the viewName and the theme associated with the service.
 * being requested and returns the appropriate view.
 * @param viewName the name of the view to be resolved
 * @return a theme-based UrlBasedView
 * @throws Exception an exception
 */
@Override
protected AbstractUrlBasedView buildView(final String viewName) throws Exception {
    final RequestContext requestContext = RequestContextHolder.getRequestContext();
    final WebApplicationService service = WebUtils.getService(requestContext);
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);

    final String themeId = service != null && registeredService != null
            && registeredService.getAccessStrategy().isServiceAccessAllowed()
            && StringUtils.hasText(registeredService.getTheme()) ? registeredService.getTheme() : defaultThemeId;

    final String themePrefix = String.format("%s/%s/ui/", pathPrefix, themeId);
    LOGGER.debug("Prefix {} set for service {} with theme {}", themePrefix, service, themeId);

    //Build up the view like the base classes do, but we need to forcefully set the prefix for each request.
    //From UrlBasedViewResolver.buildView
    final InternalResourceView view = (InternalResourceView) BeanUtils.instantiateClass(getViewClass());
    view.setUrl(themePrefix + viewName + getSuffix());
    final String contentType = getContentType();
    if (contentType != null) {
        view.setContentType(contentType);
    }
    view.setRequestContextAttribute(getRequestContextAttribute());
    view.setAttributesMap(getAttributesMap());

    //From InternalResourceViewResolver.buildView
    view.setAlwaysInclude(false);
    view.setExposeContextBeansAsAttributes(false);
    view.setPreventDispatchLoop(true);

    LOGGER.debug("View resolved: {}", view.getUrl());

    return view;
}
 
Example 26
Project: exam   File: AutoEvaluationConfig.java   View source code 5 votes vote down vote up
@Transient
public AutoEvaluationConfig copy() {
    AutoEvaluationConfig clone = new AutoEvaluationConfig();
    BeanUtils.copyProperties(this, clone, "id", "exam", "gradeEvaluations");
    for (GradeEvaluation ge : gradeEvaluations) {
        clone.getGradeEvaluations().add(ge.copy());
    }
    return clone;
}
 
Example 27
Project: configx   File: EnableConfigServiceImportSelector.java   View source code 5 votes vote down vote up
private List<ConfigBeanConverter> instantiateConverters(List<Class<?>> types) {
    List<ConfigBeanConverter> converters = new ArrayList<>();
    for (Class<?> type : types) {
        ConfigBeanConverter converter = (ConfigBeanConverter) BeanUtils.instantiate(type);
        converters.add(converter);
    }
    return converters;
}
 
Example 28
Project: document-management-store-app   File: FolderHalResource.java   View source code 5 votes vote down vote up
public FolderHalResource(Folder folder) {
    BeanUtils.copyProperties(folder, this);
    if (folder.getStoredDocuments() != null) {
        Resources<StoredDocumentHalResource> itemResources =
                new Resources<>(folder.getStoredDocuments()
                        .stream()
                        .map(StoredDocumentHalResource::new)
                    .collect(Collectors.toList()));
        embedResource("items", itemResources);
    }
    add(linkTo(methodOn(FolderController.class).get(folder.getId())).withSelfRel());
}
 
Example 29
Project: document-management-store-app   File: StoredDocumentAuditEntryHalResource.java   View source code 5 votes vote down vote up
public StoredDocumentAuditEntryHalResource(StoredDocumentAuditEntry storedDocumentAuditEntry) {
    BeanUtils.copyProperties(storedDocumentAuditEntry, this);
    setType(storedDocumentAuditEntry.getClass().getSimpleName());
    add(linkTo(methodOn(StoredDocumentController.class).getMetaData(storedDocumentAuditEntry.getStoredDocument().getId())).withRel("document"));
    if (storedDocumentAuditEntry instanceof DocumentContentVersionAuditEntry) {
        DocumentContentVersionAuditEntry documentContentVersionAuditEntry = (DocumentContentVersionAuditEntry) storedDocumentAuditEntry;
        add(linkTo(methodOn(DocumentContentVersionController.class)
                .getDocumentContentVersionDocument(
                        storedDocumentAuditEntry.getStoredDocument().getId(),
                        documentContentVersionAuditEntry.getDocumentContentVersion().getId())).withRel("documentContentVersion"));
    }
}
 
Example 30
Project: TITAN   File: AutomaticTaskController.java   View source code 5 votes vote down vote up
/**
 * @desc  删除
 *
 * @author liuliang
 *
 * @param automaticTaskBO
 * @param br
 * @return
 */
@RequestMapping(value = "/del")
@ResponseBody
public Result del(@Validated(Groups.Query.class) AutomaticTaskBO automaticTaskBO,BindingResult br) {
	Result result = new Result();
	//参数校验
	Result validateResult = ValidatorUtil.getValidResult(br);
	if(ResultUtil.isfail(validateResult)) {
		return ResultUtil.copy(validateResult, result);
	}
	//删除
	try {
		AutomaticTask automaticTask = automaticTaskService.getDataDetail(automaticTaskBO.getAutomaticTaskId());
		int delResult = automaticTaskService.del(automaticTaskBO.getAutomaticTaskId());
		if(0 < delResult) {
			// 同步定时任务
			AutomaticTaskBO obj = new AutomaticTaskBO();
			BeanUtils.copyProperties(automaticTask, obj);
			this.syncAutomaticTask(obj, TaskSyncTypeEnum.DELETE.value);
			
			return ResultUtil.success(result);
		}
	} catch (Exception e) {
		logger.error("删除数据异常,params:{}",automaticTaskBO.toString(),e);
	}
	//失败返回
	return ResultUtil.fail(ErrorCode.UPDATE_DB_ERROR,result);
}
 
Example 31
Project: rocket-console   File: MessageView.java   View source code 5 votes vote down vote up
/**from Message**/

    public static MessageView fromMessageExt(MessageExt messageExt) {
        MessageView messageView = new MessageView();
        BeanUtils.copyProperties(messageExt, messageView);
        if (messageExt.getBody() != null) {
            messageView.setMessageBody(new String(messageExt.getBody(), Charsets.UTF_8));
        }
        return messageView;
    }
 
Example 32
Project: TITAN   File: AutomaticTaskServiceImpl.java   View source code 5 votes vote down vote up
/**
 * 分页查询所有数据列表
 *
 * @author liuliang
 *
 * @param pageIndex 当前页
 * @param pageSize 每页条数
 * @return List<AutomaticTask> 数据集合
 * @throws Exception
 */
@Override
public List<AutomaticTaskBO> getDataList(int pageIndex, int pageSize)throws Exception {
	List<AutomaticTask> list = automaticTaskDao.queryAutomaticTaskByPage(pageIndex, pageSize);
	List<AutomaticTaskBO> automaticTaskBOList = new ArrayList<AutomaticTaskBO>();
	if((null != list) && (0 < list.size())){
		AutomaticTaskBO automaticTaskBO = null;
		for(AutomaticTask automaticTask:list){
			automaticTaskBO = new AutomaticTaskBO();
			BeanUtils.copyProperties(automaticTask, automaticTaskBO);
			automaticTaskBOList.add(automaticTaskBO);
		}
	}
	return automaticTaskBOList;
}
 
Example 33
Project: TITAN   File: MonitorSetServiceImpl.java   View source code 5 votes vote down vote up
/**
 * @desc 分页查询数据列表
 *
 * @author liuliang
 *
 * @param pageIndex
 * @param pageSize
 * @return
 */
@Override
public List<MonitorSetBO> getDataList(int pageIndex, int pageSize) throws Exception {
	List<MonitorSet> list = monitorSetDao.getDataList(pageIndex, pageSize);
	List<MonitorSetBO> boList = new ArrayList<MonitorSetBO>();
	if((null != list) && (0 < list.size())){
		MonitorSetBO monitorSetBO = null;
		for(MonitorSet monitorSet:list){
			monitorSetBO = new MonitorSetBO();
			BeanUtils.copyProperties(monitorSet, monitorSetBO);
			boList.add(monitorSetBO);
		}
	}
	return boList;
}
 
Example 34
Project: Yidu   File: UserEditAction.java   View source code 5 votes vote down vote up
@Override
protected void loadData() {
    logger.debug("loadData start.");
    // 初始化类别下拉列表选项
    initCollections(new String[] { "collectionProperties.user.sex", "collectionProperties.user.type" });
    // 编辑
    if (userno != 0) {
        TUser user = userService.getByNo(userno);
        BeanUtils.copyProperties(user, this);
    }
    logger.debug("loadData normally end.");
}
 
Example 35
Project: admin-shiro   File: JobDetailEditNotesService.java   View source code 5 votes vote down vote up
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public void addEditNote(JobDetailEditAO ao){
    JobDetailEditNotesDO jobDetailEditNotesDO = new JobDetailEditNotesDO();
    BeanUtils.copyProperties(ao, jobDetailEditNotesDO);
    jobDetailEditNotesDO.setCron(ao.getJobDetailDO().getCron());
    jobDetailEditNotesDO.setState(ao.getJobDetailDO().getState());
    jobDetailEditNotesDO.setOperatorId(SessionHolderUtils.getCurrentUid());
    jobDetailEditNotesDO.setOperatorName(SessionHolderUtils.getCurrentUname());
    daoSupport.save(jobDetailEditNotesDO);
}
 
Example 36
Project: lams   File: AbstractPropertyBindingResult.java   View source code 5 votes vote down vote up
/**
 * Retrieve the custom PropertyEditor for the given field, if any.
 * @param fixedField the fully qualified field name
 * @return the custom PropertyEditor, or {@code null}
 */
protected PropertyEditor getCustomEditor(String fixedField) {
	Class<?> targetType = getPropertyAccessor().getPropertyType(fixedField);
	PropertyEditor editor = getPropertyAccessor().findCustomEditor(targetType, fixedField);
	if (editor == null) {
		editor = BeanUtils.findEditorByConvention(targetType);
	}
	return editor;
}
 
Example 37
Project: k-framework   File: ThirdPartyRequestPayInfo.java   View source code 5 votes vote down vote up
public ThirdPartyRequestPayInfo(PaymentOrderInfo orderInfo, PrepayRequestInfo requestInfo) {
    BeanUtils.copyProperties(orderInfo, this);
    this.tradeId = orderInfo.getTradeId().toString();
    this.amount = orderInfo.getAmount().multiply(BigDecimal.valueOf(100.0)).intValue();
    this.channel = requestInfo.getPayMethod().getChannel();

    this.userIp = requestInfo.getUserIp();
    this.authCode = requestInfo.getCode();
    this.openId = requestInfo.getOpenId();
}
 
Example 38
Project: lams   File: ModelFactory.java   View source code 5 votes vote down vote up
/**
 * Whether the given attribute requires a {@link BindingResult} in the model.
 */
private boolean isBindingCandidate(String attributeName, Object value) {
	if (attributeName.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
		return false;
	}

	Class<?> attrType = (value != null) ? value.getClass() : null;
	if (this.sessionAttributesHandler.isHandlerSessionAttribute(attributeName, attrType)) {
		return true;
	}

	return (value != null && !value.getClass().isArray() && !(value instanceof Collection) &&
			!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 39
Project: YiDu-Novel   File: BlockEditAction.java   View source code 5 votes vote down vote up
@Override
protected void loadData() {
    logger.debug("loadData start.");
    // 初始化下拉列表选项
    initCollections(new String[] { "collectionProperties.article.category", "collectionProperties.block.type",
            "collectionProperties.block.target", "collectionProperties.block.sortCol",
            "collectionProperties.boolean" });
    // 编辑
    if (blockno != 0) {
        TSystemBlock systemBlock = systemBlockService.getByNo(blockno);
        BeanUtils.copyProperties(systemBlock, this);
    }
    logger.debug("loadData normally end.");
}
 
Example 40
Project: spring-backend-boilerplate   File: AuditEventPersisterImpl.java   View source code 5 votes vote down vote up
@Override
public AuditEvent saveAuditEvent(in.clouthink.daas.audit.core.AuditEvent o) {
	AuditEvent auditEvent = new AuditEvent();
	BeanUtils.copyProperties(o, auditEvent);
	if (o.getRequestedBy() != null) {
		auditEvent.setRequestedBy(o.getRequestedBy().toString());
	}
	auditEvent.setRealm("backend");
	return auditEventRepository.save(auditEvent);
}