org.apache.wicket.core.util.lang.PropertyResolver Java Examples
The following examples show how to use
org.apache.wicket.core.util.lang.PropertyResolver.
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: MapOfListModel.java From syncope with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public List<T> getObject() { final String expression = propertyExpression(); final Object target = getInnermostModelOrObject(); if (target == null || StringUtils.isBlank(expression) || expression.startsWith(".")) { throw new IllegalArgumentException("Property expressions cannot start with a '.' character"); } final Map<String, List<T>> map = (Map<String, List<T>>) PropertyResolver.getValue(expression, target); final List<T> res; if (map.containsKey(key)) { res = map.get(key); } else { res = new ArrayList<>(); map.put(key, res); } return res; }
Example #2
Source File: OPropertyMetaPanel.java From Orienteer with Apache License 2.0 | 6 votes |
@Override protected void setValue(OProperty entity, String critery, V value) { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); db.commit(); try { CustomAttribute custom; if(OPropertyPrototyper.COLLATE.equals(critery)) { entity.setCollate((String)value); } else if((custom = CustomAttribute.getIfExists(critery))!=null) { custom.setValue(entity, value); } else { PropertyResolver.setValue(critery, entity, value, null); } } finally { db.begin(); } }
Example #3
Source File: OPropertyMetaPanel.java From Orienteer with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override protected V getValue(OProperty entity, String critery) { CustomAttribute custom; if(OPropertyPrototyper.COLLATE.equals(critery)) { OCollate collate = entity.getCollate(); return (V)(collate!=null?collate.getName():null); } else if((custom = CustomAttribute.getIfExists(critery))!=null) { return custom.getValue(entity); } else { return (V) PropertyResolver.getValue(critery, entity); } }
Example #4
Source File: OClusterMetaPanel.java From Orienteer with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override protected V getValue(OCluster entity, String critery) { if(OClustersWidget.CONFLICT_STRATEGY.equals(critery)) { ORecordConflictStrategy strategy = entity.getRecordConflictStrategy(); return (V)(strategy!=null?strategy.getName():null); } else if(OClustersWidget.COMPRESSION.equals(critery)) { return (V)entity.compression(); } else { return (V) PropertyResolver.getValue(critery, entity); } }
Example #5
Source File: AbstractAttrs.java From syncope with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private List<MembershipTO> loadMemberships() { membershipSchemas.clear(); List<MembershipTO> membs = new ArrayList<>(); try { ((List<MembershipTO>) PropertyResolver.getPropertyField("memberships", anyTO).get(anyTO)).forEach(memb -> { setSchemas(memb.getGroupKey(), anyTypeClassRestClient.list(getMembershipAuxClasses(memb, anyTO.getType())). stream().map(EntityTO::getKey).collect(Collectors.toList())); setAttrs(memb); if (this instanceof PlainAttrs && !memb.getPlainAttrs().isEmpty()) { membs.add(memb); } else if (this instanceof DerAttrs && !memb.getDerAttrs().isEmpty()) { membs.add(memb); } else if (this instanceof VirAttrs && !memb.getVirAttrs().isEmpty()) { membs.add(memb); } }); } catch (WicketRuntimeException | IllegalArgumentException | IllegalAccessException ex) { // ignore } return membs; }
Example #6
Source File: BooleanImagePropertyColumn.java From nextreports-server with Apache License 2.0 | 6 votes |
@Override public void populateItem(Item<ICellPopulator<T>> item, String componentId, final IModel<T> rowModel) { item.add(new AbstractImagePanel(componentId) { private static final long serialVersionUID = 1L; @Override public String getImageName() { if ((Boolean) PropertyResolver.getValue(getPropertyExpression(), rowModel.getObject())) { String theme = settings.getSettings().getColorTheme(); return "images/" + ThemesManager.getTickImage(theme, (NextServerApplication)getApplication()); } else { return "images/delete.gif"; } } }); }
Example #7
Source File: ListViewPanel.java From syncope with Apache License 2.0 | 6 votes |
/** * Overridable method to generate field value rendering component. * * @param key field key. * @param bean source bean. * @return field rendering component. */ protected Component getValueComponent(final String key, final T bean) { LOG.debug("Processing field {}", key); Object value; try { value = PropertyResolver.getPropertyGetter(key, bean).invoke(bean); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { LOG.error("Error retrieving value for field {}", key, e); value = StringUtils.EMPTY; } LOG.debug("Field value {}", value); return Optional.ofNullable(value) .map(o -> new Label("field", new ResourceModel(o.toString(), o.toString()))) .orElseGet(() -> new Label("field", StringUtils.EMPTY)); }
Example #8
Source File: AbstractAttrs.java From syncope with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked" }) private List<MembershipTO> loadMembershipAttrs() { List<MembershipTO> memberships = new ArrayList<>(); try { membershipSchemas.clear(); for (MembershipTO membership : (List<MembershipTO>) PropertyResolver.getPropertyField( "memberships", anyTO).get(anyTO)) { setSchemas(Pair.of(membership.getGroupKey(), membership.getGroupName()), getMembershipAuxClasses( membership, anyTO.getType())); setAttrs(membership); if (AbstractAttrs.this instanceof PlainAttrs && !membership.getPlainAttrs().isEmpty()) { memberships.add(membership); } else if (AbstractAttrs.this instanceof DerAttrs && !membership.getDerAttrs().isEmpty()) { memberships.add(membership); } else if (AbstractAttrs.this instanceof VirAttrs && !membership.getVirAttrs().isEmpty()) { memberships.add(membership); } } } catch (WicketRuntimeException | IllegalArgumentException | IllegalAccessException ex) { // ignore } return memberships; }
Example #9
Source File: AbstractUITCase.java From syncope with Apache License 2.0 | 6 votes |
protected static <V extends Serializable> Component findComponentByPropNotNull( final String property, final String path) { Component component = TESTER.getComponentFromLastRenderedPage(path); return (component instanceof MarkupContainer ? MarkupContainer.class.cast(component) : component.getPage()). visitChildren(ListItem.class, (ListItem<?> object, IVisit<Component> visit) -> { try { Method getter = PropertyResolver.getPropertyGetter(property, object.getModelObject()); if (getter != null && getter.invoke(object.getModelObject()) != null) { visit.stop(object); } } catch (Exception e) { LOG.debug("Error finding component by property {} not null on path {}", property, path, e); } }); }
Example #10
Source File: AbstractUITCase.java From syncope with Apache License 2.0 | 6 votes |
protected static <V extends Serializable> Component findComponentByProp( final String property, final String path, final V key) { Component component = TESTER.getComponentFromLastRenderedPage(path); return (component instanceof MarkupContainer ? MarkupContainer.class.cast(component) : component.getPage()). visitChildren(ListItem.class, (ListItem<?> object, IVisit<Component> visit) -> { try { Method getter = PropertyResolver.getPropertyGetter(property, object.getModelObject()); if (getter != null && getter.invoke(object.getModelObject()).equals(key)) { visit.stop(object); } } catch (Exception e) { LOG.debug("Error finding component by property ({},{}) on path {}", property, key, path, e); } }); }
Example #11
Source File: LogsITCase.java From syncope with Apache License 2.0 | 6 votes |
private static Component searchLog(final String property, final String searchPath, final String key) { Component component = TESTER.getComponentFromLastRenderedPage(searchPath); Component result = component.getPage(). visitChildren(ListItem.class, (final ListItem<LoggerTO> object, final IVisit<Component> visit) -> { try { if (object.getModelObject() instanceof LoggerTO && PropertyResolver.getPropertyGetter( property, object.getModelObject()).invoke(object.getModelObject()).equals(key)) { visit.stop(object); } } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { LOG.error("Error invoke method", ex); } }); return result; }
Example #12
Source File: AbstractJavaSortableDataProvider.java From wicket-orientdb with Apache License 2.0 | 5 votes |
protected Comparable<?> comparableValue(T input, S sortParam) { String property = getSortPropertyExpression(sortParam); if(property==null) return null; Object value = PropertyResolver.getValue(property, input); return value instanceof Comparable?(Comparable<?>)value:null; }
Example #13
Source File: AnalysisBooleanImagePropertyColumn.java From nextreports-server with Apache License 2.0 | 5 votes |
public void populateItem(Item<ICellPopulator<T>> item, String componentId, final IModel<T> rowModel) { item.add(new AbstractImagePanel(componentId) { @Override public String getImageName() { if ((Boolean) PropertyResolver.getValue(getPropertyExpression(), rowModel.getObject())) { return "images/sortascend.png"; } else { return "images/sortdescend.png"; } } }); }
Example #14
Source File: OClassMetaPanel.java From Orienteer with Apache License 2.0 | 5 votes |
@Override protected void setValue(OClass entity, String critery, V value) { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); db.commit(); try { CustomAttribute custom; if(OClassPrototyper.CLUSTER_SELECTION.equals(critery)) { if(value!=null) entity.setClusterSelection(value.toString()); } else if((CustomAttribute.ON_CREATE_FIELDS.getName().equals(critery)) && (custom = CustomAttribute.getIfExists(critery)) != null) { custom.setValue(entity, value!=null?Joiner.on(",").join((List<String>) value):null); } else if((custom = CustomAttribute.getIfExists(critery))!=null) { custom.setValue(entity, value); } else if (OClassPrototyper.SUPER_CLASSES.equals(critery)) { if(value!=null) entity.setSuperClasses((List<OClass>) value); } else { PropertyResolver.setValue(critery, entity, value, new PropertyResolverConverter(Application.get().getConverterLocator(), Session.get().getLocale())); } } finally { db.begin(); } }
Example #15
Source File: OClassMetaPanel.java From Orienteer with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override protected V getValue(OClass entity, String critery) { CustomAttribute custom; if("clusterSelection".equals(critery)) { OClusterSelectionStrategy strategy = entity.getClusterSelection(); return (V)(strategy!=null?strategy.getName():null); } else if(OClassPrototyper.SUPER_CLASSES.equals(critery)) { List<OClass> superClasses = entity.getSuperClasses(); // Additional wrapping to ArrayList is required , because getSuperClasses return unmodifiable list return (V)(superClasses != null ? new ArrayList<OClass>(superClasses) : new ArrayList<OClass>()); } else if((CustomAttribute.ON_CREATE_FIELDS.getName().equals(critery)) && (custom = CustomAttribute.getIfExists(critery)) != null) { String onCreateFields = custom.getValue(entity); return (V)(!Strings.isNullOrEmpty(onCreateFields) ? Lists.newArrayList(onCreateFields.split(",")) : new ArrayList<String>()); } else if((custom = CustomAttribute.getIfExists(critery))!=null) { return custom.getValue(entity); } else { return (V)PropertyResolver.getValue(critery, entity); } }
Example #16
Source File: DateColumn.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override protected IModel<String> createLabelModel(IModel<T> rowModel) { Date date = (Date) PropertyResolver.getValue(getPropertyExpression(), rowModel.getObject()); if (date == null) { return new Model<String>(""); } return new Model<String>(LOCALE_DATE_FORMAT.format(date)); }
Example #17
Source File: BooleanImageLinkPropertyColumn.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override public void populateItem(Item<ICellPopulator<T>> item, String componentId, final IModel<T> rowModel) { item.add(new AbstractImageAjaxLinkPanel(componentId) { private static final long serialVersionUID = 1L; @Override public String getImageName() { if ((Boolean) PropertyResolver.getValue(getPropertyExpression(), rowModel.getObject())) { String theme = settings.getSettings().getColorTheme(); return "images/" + ThemesManager.getTickImage(theme, (NextServerApplication)getApplication()); } else { return "images/delete.gif"; } } @Override public String getDisplayString() { return ""; } @Override public void onClick(AjaxRequestTarget target) { onImageClick(rowModel.getObject(), target); } }); }
Example #18
Source File: OIndexMetaPanel.java From Orienteer with Apache License 2.0 | 5 votes |
@Override protected void setValue(OIndex<?> entity, String critery, V value) { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); db.commit(); try { if(OIndexPrototyper.DEF_COLLATE.equals(critery)) { if(value!=null) { String collate = value.toString(); entity.getDefinition().setCollate(OSQLEngine.getCollate(collate)); } else { entity.getDefinition().setCollate(null); } } else { PropertyResolver.setValue(critery, entity, value, null); } } finally { db.begin(); } }
Example #19
Source File: OIndexMetaPanel.java From Orienteer with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override protected V getValue(OIndex<?> entity, String critery) { if(OIndexPrototyper.DEF_COLLATE.equals(critery)) { OIndexDefinition definition = entity.getDefinition(); if(definition instanceof OCompositeIndexDefinition) return (V)"composite"; OCollate collate = definition.getCollate(); return (V)(collate!=null?collate.getName():null); } else { return (V) PropertyResolver.getValue(critery, entity); } }
Example #20
Source File: MapOfListModel.java From syncope with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void setObject(final List<T> object) { final String expression = propertyExpression(); final Object target = getInnermostModelOrObject(); ((Map<String, List<T>>) PropertyResolver.getValue(expression, target)).put(key, object); }
Example #21
Source File: TestPrototypers.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testOIndexPrototyper() throws Exception { OClass newClass = wicket.getTester().getSchema().createClass("NewClass"); OProperty property = newClass.createProperty("name", OType.STRING); OIndex<?> newIndex = OIndexPrototyper.newPrototype("NewClass", Arrays.asList("name")); assertTrue(property.getAllIndexes().size()==0); PropertyResolver.setValue("type", newIndex, "notunique", null); assertNotNull(newIndex.getDefinition()); assertTrue(newIndex.getDefinition().getFields().contains("name")); assertTrue(newIndex instanceof IPrototype); OIndex<?> realizedNewIndex = ((IPrototype<OIndex<?>>)newIndex).realizePrototype(); assertEquals(1, property.getAllIndexes().size()); assertEquals(1, newClass.getIndexes().size()); property = newClass.createProperty("description", OType.STRING); newIndex = OIndexPrototyper.newPrototype("NewClass", Arrays.asList("description")); PropertyResolver.setValue("type", newIndex, "notunique", null); assertEquals(0, property.getAllIndexes().size()); PropertyResolver.setValue("algorithm", newIndex, ODefaultIndexFactory.SBTREE_ALGORITHM, null); ODocument metadata = new ODocument(); metadata.field("test", "test123", OType.STRING); PropertyResolver.setValue("metadata", newIndex, metadata, null); realizedNewIndex = ((IPrototype<OIndex<?>>)newIndex).realizePrototype(); assertEquals(1, property.getAllIndexes().size()); assertEquals(2, newClass.getIndexes().size()); assertEquals("test123", realizedNewIndex.getMetadata().field("test")); wicket.getTester().getSchema().dropClass(newClass.getName()); }
Example #22
Source File: UserManager.java From openmeetings with Apache License 2.0 | 5 votes |
@Override public User loginOAuth(OAuthUser user, long serverId) throws IOException, NoSuchAlgorithmException { if (!userDao.validLogin(user.getLogin())) { log.error("Invalid login, please check parameters"); return null; } User u = userDao.getByLogin(user.getLogin(), Type.OAUTH, serverId); if (!userDao.checkEmail(user.getEmail(), Type.OAUTH, serverId, u == null ? null : u.getId())) { log.error("Another user with the same email exists"); return null; } // generate random password // check if the user already exists and register new one if it's needed if (u == null) { final User fUser = getNewUserInstance(null); fUser.setType(Type.OAUTH); fUser.getRights().remove(Right.LOGIN); fUser.setDomainId(serverId); fUser.addGroup(groupDao.get(getDefaultGroup())); for (Map.Entry<String, String> entry : user.getUserData().entrySet()) { final String expression = entry.getKey(); PropertyResolver.setValue(expression, fUser, entry.getValue(), new LanguageConverter(expression, fUser, null, null)); } fUser.setShowContactDataToContacts(true); u = fUser; } u.setLastlogin(new Date()); ICrypt crypt = CryptProvider.get(); u = userDao.update(u, crypt.randomPassword(25), Long.valueOf(-1)); return u; }
Example #23
Source File: AbstractEntityHandler.java From Orienteer with Apache License 2.0 | 4 votes |
protected IGetAndSet getGetAndSetter(Class<?> clazz, String property) { return PropertyResolver.getLocator().get(clazz, property); }