001    package org.tynamo.util;
002    
003    import ognl.Ognl;
004    import ognl.OgnlException;
005    import org.apache.tapestry5.beaneditor.BeanModel;
006    import org.apache.tapestry5.ioc.internal.util.InternalUtils;
007    import org.tynamo.descriptor.TynamoClassDescriptor;
008    
009    import java.util.List;
010    
011    /**
012     * Utilities used to modify a {@link org.apache.tapestry5.beaneditor.BeanModel}.
013     */
014    public final class BeanModelUtils
015    {
016    
017            /**
018             * Removes properties from the bean model.
019             *
020             * @param model            to modifiy
021             * @param classDescriptor
022             */
023            public static void exclude(BeanModel model, TynamoClassDescriptor classDescriptor)
024            {
025                    try
026                    {
027                            List<String> nameList = (List<String>) Ognl
028                                            .getValue("propertyDescriptors.{? identifier or !summary or nonVisual or collection}.{name}",
029                                                            classDescriptor);
030    
031                            model.exclude((String[]) nameList.toArray(new String[nameList.size()]));
032    
033                    } catch (OgnlException e)
034                    {
035                    }
036            }
037    
038            public static final String join(String firstList, String optionalSecondList)
039            {
040                    if (InternalUtils.isBlank(optionalSecondList))
041                            return firstList;
042    
043                    return firstList + "," + optionalSecondList;
044            }
045    
046    }