org.apache.commons.beanutils.PropertyUtils Java Examples
The following examples show how to use
org.apache.commons.beanutils.PropertyUtils.
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: AbstractPreviewItemComp.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
private void toggleFavorite() { try { if (isFavorite()) { favoriteBtn.removeStyleName("favorite-btn-selected"); favoriteBtn.addStyleName("favorite-btn"); } else { favoriteBtn.addStyleName("favorite-btn-selected"); favoriteBtn.removeStyleName("favorite-btn"); } FavoriteItem favoriteItem = new FavoriteItem(); favoriteItem.setExtratypeid(CurrentProjectVariables.getProjectId()); favoriteItem.setType(getType()); favoriteItem.setTypeid(PropertyUtils.getProperty(beanItem, "id").toString()); favoriteItem.setSaccountid(AppUI.getAccountId()); favoriteItem.setCreateduser(UserUIContext.getUsername()); FavoriteItemService favoriteItemService = AppContextUtil.getSpringBean(FavoriteItemService.class); favoriteItemService.saveOrDelete(favoriteItem); } catch (Exception e) { LOG.error("Error while set favorite flag to bean", e); } }
Example #2
Source File: HighlightResultHelper.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
@Override public <T> T mapSearchHit(SearchHit searchHit, Class<T> clazz) { List<T> results = new ArrayList<>(); for (HighlightField field : searchHit.getHighlightFields().values()) { T result = null; if (StringUtils.hasText(searchHit.getSourceAsString())) { result = JSONObject.parseObject(searchHit.getSourceAsString(), clazz); } try { PropertyUtils.setProperty(result, field.getName(), concat(field.fragments())); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { log.error("设置高亮字段异常:{}", e.getMessage(), e); } results.add(result); } return null; }
Example #3
Source File: DefaultParameterAdapter.java From nubes with Apache License 2.0 | 6 votes |
@Override public Object adaptParams(MultiMap params, Class<?> parameterClass) { Object instance; try { instance = parameterClass.newInstance(); Field[] fields = parameterClass.getDeclaredFields(); for (Field field : fields) { String requestValue = params.get(field.getName()); if (requestValue != null) { Object value = adaptParam(requestValue, field.getType()); PropertyUtils.setProperty(instance, field.getName(), value); } } } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new IllegalArgumentException(e); } return instance; }
Example #4
Source File: Collections3.java From spring-boot-quickstart with Apache License 2.0 | 6 votes |
/** * 提取集合中的对象的两个属性(通过Getter函数), 组合成Map. * * @param collection 来源集合. * @param keyPropertyName 要提取为Map中的Key值的属性名. * @param valuePropertyName 要提取为Map中的Value值的属性名. */ public static Map extractToMap(final Collection collection, final String keyPropertyName, final String valuePropertyName) { Map map = new HashMap(collection.size()); try { for (Object obj : collection) { map.put(PropertyUtils.getProperty(obj, keyPropertyName), PropertyUtils.getProperty(obj, valuePropertyName)); } } catch (Exception e) { throw Reflections.convertReflectionExceptionToUnchecked(e); } return map; }
Example #5
Source File: BaseResourceTest.java From minnal with Apache License 2.0 | 6 votes |
public <T> boolean compare(T model1, T model2, int depth) { if (model1 == null || model2 == null) { return false; } for (PropertyDescriptor descriptor : PropertyUtils.getPropertyDescriptors(model1)) { if (PropertyUtil.isSimpleProperty(descriptor.getPropertyType())) { try { Object property1 = PropertyUtils.getProperty(model1, descriptor.getName()); Object property2 = PropertyUtils.getProperty(model2, descriptor.getName()); if (property1 != null && property2 != null && !property1.equals(property2)) { return false; } } catch (Exception e) { logger.info(e.getMessage(), e); } } } return true; }
Example #6
Source File: BeanUtils.java From frpMgr with MIT License | 6 votes |
/** * list转map(1对多) */ public static <K, V> Map<K, List<V>> list2Map2(List<V> list, String keyField) { Map<K, List<V>> map = new HashMap<>(); if (list != null && !list.isEmpty()) { try { for (V s : list) { K val = (K) PropertyUtils.getProperty(s, keyField); if (map.containsKey(val)) { map.get(val).add(s); } else { List<V> listv = new ArrayList<>(); listv.add(s); map.put(val, listv); } } } catch (Exception e) { logger.error(String.format("keyField [%s] not found !", keyField)); throw new IllegalArgumentException(String.format("keyField [%s] not found !", keyField)); } } return map; }
Example #7
Source File: JTextAreaBinding.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
public void get(IValidatable bean) { try { String text = _textArea.getText(); if (!text.equals("")) { String[] items = text.split("\n"); List<Object> list = new ArrayList<Object>(); for (int i = 0; i < items.length; i++) { list.add(items[i]); } PropertyUtils.setProperty(bean, _property, list); } else { PropertyUtils.setProperty(bean, _property, null); } } catch (Exception e) { throw new BindingException(e); } }
Example #8
Source File: OkrCenterWorkQueryService.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 查询上一页的信息数据,直接调用Factory里的方法 * @param id * @param count * @param sequence * @param wrapIn * @return * @throws Exception */ public List<OkrCenterWorkInfo> listPrevWithFilter( String id, Integer count, WorkCommonQueryFilter wrapIn ) throws Exception { Business business = null; Object sequence = null; try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { business = new Business(emc); if( id != null && !"(0)".equals(id) && id.trim().length() > 20 ){ if (!StringUtils.equalsIgnoreCase(id, StandardJaxrsAction.EMPTY_SYMBOL)) { sequence = PropertyUtils.getProperty( emc.find( id, OkrCenterWorkInfo.class ), JpaObject.sequence_FIELDNAME ); } } return business.okrCenterWorkInfoFactory().listPrevWithFilter(id, count, sequence, wrapIn); } catch ( Exception e ) { throw e; } }
Example #9
Source File: JmsRealm.java From iaf with Apache License 2.0 | 6 votes |
/** * copies matching properties to any other class */ public void copyRealm(Object destination) { String logPrefixDest=destination.getClass().getName()+" "; if (destination instanceof INamedObject) { INamedObject namedDestination = (INamedObject) destination; logPrefixDest += "["+namedDestination.getName()+"] "; } try { BeanMap thisBeanMap = new BeanMap(this); BeanMap destinationBeanMap = new BeanMap(destination); Iterator<String> iterator = thisBeanMap.keyIterator(); while (iterator.hasNext()) { String key = iterator.next(); Object value = thisBeanMap.get(key); if (value != null && !key.equals("class") && destinationBeanMap.containsKey(key)) { PropertyUtils.setProperty(destination, key, value); } } }catch (Exception e) { log.error(logPrefixDest+"unable to copy properties of JmsRealm", e); } log.info(logPrefixDest+"loaded properties from jmsRealm ["+toString()+"]"); }
Example #10
Source File: ModelItemProperties.java From MogwaiERDesignerNG with GNU General Public License v3.0 | 6 votes |
public void copyTo(T aObject) { ModelProperties theProperties = aObject.getProperties(); try { for (PropertyDescriptor theDescriptor : PropertyUtils.getPropertyDescriptors(this)) { if (theDescriptor.getReadMethod() != null && theDescriptor.getWriteMethod() != null) { Object theValue = PropertyUtils.getProperty(this, theDescriptor.getName()); if (theValue != null) { theProperties.setProperty(theDescriptor.getName(), theValue.toString()); } else { theProperties.setProperty(theDescriptor.getName(), null); } } } } catch (Exception e) { throw new RuntimeException(e); } }
Example #11
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject> List<T> fetchAll(Class<T> clz, List<String> attributes) throws Exception { List<T> list = new ArrayList<>(); List<String> fields = ListTools.trim(attributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } for (Tuple o : em.createQuery(cq.multiselect(selections)).getResultList()) { T t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, attributes.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #12
Source File: CustomTag.java From TranskribusCore with GNU General Public License v3.0 | 6 votes |
public Class<?> getAttributeType(String name) { if (!hasAttribute(name)) return null; if (isPredefinedAttribute(name)) { // get type via reflection for // predefined attributes try { return PropertyUtils.getPropertyType(this, name); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { logger.error(e.getMessage(), e); return null; } } else { CustomTagAttribute att = getAttribute(name); return att.getType(); } }
Example #13
Source File: QueryGenerator.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 根据权限相关配置 组装mp需要的权限 * @param queryWrapper * @param clazz * @return */ public static void installAuthMplus(QueryWrapper<?> queryWrapper,Class<?> clazz) { //权限查询 Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz); for (String c : ruleMap.keySet()) { if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ queryWrapper.and(i ->i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue()))); } } String name; for (int i = 0; i < origDescriptors.length; i++) { name = origDescriptors[i].getName(); if (judgedIsUselessField(name)) { continue; } if(ruleMap.containsKey(name)) { addRuleToQueryWrapper(ruleMap.get(name), name, origDescriptors[i].getPropertyType(), queryWrapper); } } }
Example #14
Source File: Collections3.java From dubai with MIT License | 6 votes |
/** * 提取集合中的对象的两个属性(通过Getter函数), 组合成Map. * * @param collection 来源集合. * @param keyPropertyName 要提取为Map中的Key值的属性名. * @param valuePropertyName 要提取为Map中的Value值的属性名. */ public static Map extractToMap(final Collection collection, final String keyPropertyName, final String valuePropertyName) { Map map = new HashMap(collection.size()); try { for (Object obj : collection) { map.put(PropertyUtils.getProperty(obj, keyPropertyName), PropertyUtils.getProperty(obj, valuePropertyName)); } } catch (Exception e) { throw Reflections.convertReflectionExceptionToUnchecked(e); } return map; }
Example #15
Source File: OkrCenterWorkQueryService.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 查询下一页的信息数据,直接调用Factory里的方法 * @param id * @param count * @param sequence * @param wrapIn * @return * @throws Exception */ public List<OkrCenterWorkInfo> listNextWithFilter( String id, Integer count, WorkCommonQueryFilter wrapIn ) throws Exception { Business business = null; Object sequence = null; try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { business = new Business(emc); if( id != null && !"(0)".equals(id) && id.trim().length() > 20 ){ if ( !StringUtils.equalsIgnoreCase(id, StandardJaxrsAction.EMPTY_SYMBOL)) { sequence = PropertyUtils.getProperty( emc.find( id, OkrCenterWorkInfo.class ), JpaObject.sequence_FIELDNAME ); } } return business.okrCenterWorkInfoFactory().listNextWithFilter(id, count, sequence, wrapIn); } catch ( Exception e ) { throw e; } }
Example #16
Source File: TestStandardBullhornApiRestAssociations.java From sdk-rest with MIT License | 6 votes |
@Test public void testAssociateCandidate() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Candidate entity = bullhornData.findEntity(Candidate.class, testEntities.getCandidateId(), getAssociationFieldSet(AssociationFactory.candidateAssociations())); for (AssociationField<Candidate, ? extends BullhornEntity> association : AssociationFactory.candidateAssociations().allAssociations()) { Set<Integer> associationIds = new HashSet<Integer>(); OneToMany<? extends BullhornEntity> linkedIds = (OneToMany<? extends BullhornEntity>) PropertyUtils.getProperty(entity, association.getAssociationFieldName()); if (linkedIds != null && !linkedIds.getData().isEmpty()) { associationIds.add(linkedIds.getData().get(0).getId()); testAssociation(Candidate.class, testEntities.getCandidateId(), associationIds, association); } } }
Example #17
Source File: ObjectUtil.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * Populate the given fields of the target object with the values of an array * * @param targetObject the target object * @param sourceObject the given array * @param keyFields the given fields of the target object that need to be popluated */ public static void buildObject(Object targetObject, Object[] sourceObject, List<String> keyFields) { int indexOfArray = 0; for (String propertyName : keyFields) { if (PropertyUtils.isWriteable(targetObject, propertyName) && indexOfArray < sourceObject.length) { try { Object value = sourceObject[indexOfArray]; String propertyValue = value != null ? value.toString() : StringUtils.EMPTY; String type = getSimpleTypeName(targetObject, propertyName); Object realPropertyValue = valueOf(type, propertyValue); if (realPropertyValue != null && !StringUtils.isEmpty(realPropertyValue.toString())) { PropertyUtils.setProperty(targetObject, propertyName, realPropertyValue); } else { PropertyUtils.setProperty(targetObject, propertyName, null); } } catch (Exception e) { LOG.debug(e); } } indexOfArray++; } }
Example #18
Source File: ClassSelector.java From bean-query with Apache License 2.0 | 6 votes |
/** * @param clazz * null will cause the select methods returning an empty Map or a * list of Empty map as the result. */ public ClassSelector(Class<?> clazz) { if (null == clazz) { logger.warn("Input class is null"); return; } PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(clazz); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { boolean propertyReadable = propertyDescriptor.getReadMethod() != null; String propertyName = propertyDescriptor.getName(); // ignore the class property if ("class".equals(propertyName)) { continue; } if (propertyReadable) { PropertySelector propertySelector = new PropertySelector(propertyDescriptor.getName()); propertySelectors.add(propertySelector); compositeSelector.addSubSelector(propertySelector); } } }
Example #19
Source File: ExcelWorkSheetHandler.java From excelReader with MIT License | 6 votes |
private void assignValue(Object targetObj, String cellReference, String value) { if (null == targetObj || StringUtils.isEmpty(cellReference) || StringUtils.isEmpty(value)) { return; } try { String propertyName = this.cellMapping.get(cellReference); if (null == propertyName) { LOG.error("Cell mapping doesn't exists!"); } else { PropertyUtils.setSimpleProperty(targetObj, propertyName, value); } } catch (IllegalAccessException iae) { LOG.error(iae.getMessage()); } catch (InvocationTargetException ite) { LOG.error(ite.getMessage()); } catch (NoSuchMethodException nsme) { LOG.error(nsme.getMessage()); } }
Example #20
Source File: PersistableHelper.java From sakai with Educational Community License v2.0 | 6 votes |
public void modifyPersistableFields(Persistable persistable) { Date now = new Date(); // time sensitive if (log.isDebugEnabled()) { log.debug("modifyPersistableFields(Persistable " + persistable + ")"); } if (persistable == null) throw new IllegalArgumentException("Illegal persistable argument passed!"); try { String actor = getActor(); PropertyUtils.setProperty(persistable, LASTMODIFIEDBY, actor); PropertyUtils.setProperty(persistable, LASTMODIFIEDDATE, now); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { log.error(e.getMessage()); throw new RuntimeException(e); } }
Example #21
Source File: MultiSelectComp.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
private boolean compareVal(T value1, T value2) { if (value1 == null && value2 == null) { return true; } else if (value1 == null || value2 == null) { return false; } else { try { Integer field1 = (Integer) PropertyUtils.getProperty(value1, "id"); Integer field2 = (Integer) PropertyUtils.getProperty(value2, "id"); return field1.equals(field2); } catch (final Exception e) { LOG.error("Error when compare value", e); return false; } } }
Example #22
Source File: OkrWorkReportQueryService.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 上一页 * @param id * @param count * @param wrapIn * @return * @throws Exception */ public List<OkrWorkReportBaseInfo> listPrevWithFilter( String id, Integer count, WrapInFilter wrapIn ) throws Exception { Business business = null; Object sequence = null; List<OkrWorkReportBaseInfo> okrWorkReportBaseInfoList = new ArrayList<OkrWorkReportBaseInfo>(); if( count == null ){ count = 20; } if( wrapIn == null ){ throw new Exception( "wrapIn is null!" ); } try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { business = new Business(emc); if( id != null && !"(0)".equals(id) && id.trim().length() > 20 ){ if (!StringUtils.equalsIgnoreCase(id, StandardJaxrsAction.EMPTY_SYMBOL)) { sequence = PropertyUtils.getProperty( emc.find( id, OkrWorkReportBaseInfo.class ), JpaObject.sequence_FIELDNAME ); } } okrWorkReportBaseInfoList = business.okrWorkReportBaseInfoFactory().listPrevWithFilter( id, count, sequence, wrapIn ); } catch ( Exception e ) { throw e; } return okrWorkReportBaseInfoList; }
Example #23
Source File: JTextAreaBinding.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
public void put(IValidatable bean) { try { List<?> list = (List<?>) PropertyUtils.getProperty(bean, _property); StringBuffer sb = new StringBuffer(); if (list != null) { for (int i = 0; i < list.size(); i++) { sb.append(list.get(i)); if (i < list.size() - 1) { sb.append("\n"); } } } _textArea.setText(sb.toString()); } catch (Exception e) { throw new BindingException(e); } }
Example #24
Source File: ListTools.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") public static <T> List<T> addWithProperty(Object obj, String propertyName, boolean ignoreNull, List<T> ts) throws Exception { List<T> list = new ArrayList<>(); ListOrderedSet<T> set = new ListOrderedSet<T>(); Object o = PropertyUtils.getProperty(obj, propertyName); if (null != o) { set.addAll((List<T>) o); } if (null != ts) { for (T t : ts) { if (null == t && ignoreNull) { continue; } if (!set.contains(t)) { set.add(t); list.add(t); } } } PropertyUtils.setProperty(obj, propertyName, set.asList()); return list; }
Example #25
Source File: OkrWorkChatService.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 查询下一页的信息数据,直接调用Factory里的方法 * * @param id * @param count * @param sequence * @param wrapIn * @return * @throws Exception */ public List<OkrWorkChat> listChatNextWithFilter(String id, Integer count, String workId, String sequenceField, String order) throws Exception { Business business = null; Object sequence = null; if (workId == null) { throw new Exception("workId is null!"); } try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { business = new Business(emc); if (id != null && !"(0)".equals(id) && id.trim().length() > 20) { if (!StringUtils.equalsIgnoreCase(id, StandardJaxrsAction.EMPTY_SYMBOL)) { sequence = PropertyUtils.getProperty(emc.find(id, OkrWorkChat.class), JpaObject.sequence_FIELDNAME); } } return business.okrWorkChatFactory().listNextWithFilter(id, count, sequence, workId, sequenceField, order); } catch (Exception e) { throw e; } }
Example #26
Source File: OkrWorkBaseInfoQueryService.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 查询下一页的信息数据,直接调用Factory里的方法 * * @param id * @param count * @param sequence * @param wrapIn * @return * @throws Exception */ public List<OkrWorkBaseInfo> listNextWithFilter(String id, Integer count, WrapInFilter wrapIn) throws Exception { Business business = null; Object sequence = null; try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { business = new Business(emc); if (id != null && !"(0)".equals(id) && id.trim().length() > 20) { if (!StringUtils.equalsIgnoreCase(id, StandardJaxrsAction.EMPTY_SYMBOL)) { sequence = PropertyUtils.getProperty(emc.find(id, OkrWorkBaseInfo.class), JpaObject.sequence_FIELDNAME); } } return business.okrWorkBaseInfoFactory().listNextWithFilter(id, count, sequence, wrapIn); } catch (Exception e) { throw e; } }
Example #27
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject> List<T> fetchIsMember(Class<T> clz, List<String> attributes, String attribute, Object value) throws Exception { List<T> list = new ArrayList<>(); List<String> fields = ListTools.trim(attributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } Predicate p = cb.isMember(value, root.get(attribute)); cq.multiselect(selections).where(p); for (Tuple o : em.createQuery(cq).getResultList()) { T t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, fields.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #28
Source File: OkrWorkReportQueryService.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 上一页 * @param id * @param count * @param wrapIn * @return * @throws Exception */ public List<OkrWorkReportBaseInfo> listPrevWithFilter( String id, Integer count, WrapInFilter wrapIn ) throws Exception { Business business = null; Object sequence = null; List<OkrWorkReportBaseInfo> okrWorkReportBaseInfoList = new ArrayList<OkrWorkReportBaseInfo>(); if( count == null ){ count = 20; } if( wrapIn == null ){ throw new Exception( "wrapIn is null!" ); } try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { business = new Business(emc); if( id != null && !"(0)".equals(id) && id.trim().length() > 20 ){ if (!StringUtils.equalsIgnoreCase(id, StandardJaxrsAction.EMPTY_SYMBOL)) { sequence = PropertyUtils.getProperty( emc.find( id, OkrWorkReportBaseInfo.class ), JpaObject.sequence_FIELDNAME ); } } okrWorkReportBaseInfoList = business.okrWorkReportBaseInfoFactory().listPrevWithFilter( id, count, sequence, wrapIn ); } catch ( Exception e ) { throw e; } return okrWorkReportBaseInfoList; }
Example #29
Source File: OkrWorkReportPersonLinkService.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 上一页 * @param id * @param count * @param wrapIn * @return * @throws Exception */ public List<OkrWorkReportPersonLink> listPrevWithFilter( String id, Integer count, WorkPersonSearchFilter wrapIn ) throws Exception { Business business = null; Object sequence = null; List<OkrWorkReportPersonLink> okrWorkReportPersonLinkList = new ArrayList<OkrWorkReportPersonLink>(); if( count == null ){ count = 20; } if( wrapIn == null ){ throw new Exception( "wrapIn is null!" ); } try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { business = new Business(emc); if( id != null && !"(0)".equals(id) && id.trim().length() > 20 ){ if (!StringUtils.equalsIgnoreCase(id, StandardJaxrsAction.EMPTY_SYMBOL)) { sequence = PropertyUtils.getProperty( emc.find( id, OkrWorkReportPersonLink.class ), JpaObject.sequence_FIELDNAME ); } } okrWorkReportPersonLinkList = business.okrWorkReportPersonLinkFactory().listPrevWithFilter( id, count, sequence, wrapIn ); } catch ( Exception e ) { throw e; } return okrWorkReportPersonLinkList; }
Example #30
Source File: OwnCreatedDataAccessHandler.java From hsweb-framework with Apache License 2.0 | 6 votes |
@SuppressWarnings("all") protected boolean matchCreatorId(Object result, String userId) { if (null == result) { return true; } if (result instanceof RecordCreationEntity) { return userId.equals(((RecordCreationEntity) result).getCreatorId()); } else if (result instanceof Collection) { Collection<?> collection = ((Collection) result); //删掉不能访问的对象 collection.removeAll(collection.stream().filter((Object o) -> !matchCreatorId(o, userId)).collect(Collectors.toList())); } else { try { return userId.equals(PropertyUtils.getProperty(result, "creatorId")); } catch (Exception ignore) { } } return true; }