public final class MetaManager extends Object
| Modifier and Type | Field and Description |
|---|---|
static Comparator<DisplayPropertyMetaModel> |
C_BY_SORT_INDEX
Comparator to sort by ascending sortIndex.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
applyPropertySort(QCriteria<?> q,
List<DisplayPropertyMetaModel> properties)
Walk the list of properties, and defines the list that should be added as sort properties
to the QCriteria.
|
static boolean |
areObjectsEqual(Object a,
Object b) |
static boolean |
areObjectsEqual(Object a,
Object b,
ClassMetaModel cmm)
This is a complex EQUAL routine which compares objects.
|
static List<DisplayPropertyMetaModel> |
calculateObjectProperties(ClassMetaModel cm)
Generate some set of columns to show from a class' metadata, if enabled.
|
static List<SearchPropertyMetaModel> |
calculateSearchProperties(ClassMetaModel cm)
Try to calculate some search properties off a data class for debug/test pps, if enabled
|
static void |
copyValuesExcept(Object to,
Object from,
Object... except)
Copy all matching properties from "from" to "to", but ignore the specified list of
properties.
|
static INodeContentRenderer<?> |
createDefaultComboRenderer(PropertyMetaModel<?> pmm,
ClassMetaModel cmm)
This creates a default combo option value renderer using whatever metadata is available.
|
static <T extends Enum<?>> |
createEnumList(Class<T> clz)
Creates a List of Pair's for each domain value in a class which represents a domain (like an enum or Boolean).
|
static <T> void |
fillCopy(T source,
T target)
Fill target instance with same values as found in source instance.
|
static <T> void |
fillCopy(T source,
T target,
boolean copyPK,
boolean copyTCN,
boolean copyTransient,
String... ignoredColumns)
Fill target instance with same values as found in source instance.
|
static <T> void |
fillCopy(T source,
T target,
String... ignoredColumns)
Fill target instance with same values as found in source instance.
|
static <X,T extends Collection<X>> |
filter(T in,
QCriteria<X> query)
Return a new list which contains only the items in the input list that are obeying
the specified criteria.
|
static ClassMetaModel |
findClassByTable(String tableName)
EXPENSIVE - Use with care - try to find a ClassMetaModel that represents the specified table name.
|
static ClassMetaModel |
findClassMeta(Class<?> clz) |
static ClassMetaModel |
findClassMeta(IMetaClass mc)
Get the metamodel for some metadata-defined object.
|
static Class<?> |
findCollectionType(Type genericType)
This tries to determine the value class for a property defined as some kind
of Collection<T> or T[].
|
static <T extends Enum<?>> |
findEnumLabel(T val)
Locate the enum's default label.
|
static PropertyMetaModel<?> |
findPropertyMeta(Class<?> clz,
String name)
Find a property using the metamodel for a class.
|
static PropertyMetaModel<?> |
findPropertyMeta(IMetaClass mc,
String name)
Find a property using some genericized meta definition.
|
static List<DisplayPropertyMetaModel> |
getComboProperties(PropertyMetaModel<?> pmm)
Return the list of defined combo properties, either on property model or class model.
|
static String |
getEnumLabel(Class<?> clz,
String property,
Object value)
Get a label for the enum value "value" presented on the property passed.
|
static String |
getEnumLabel(Enum<?> label)
Get a NLSed label for the specified enum label.
|
static String |
getEnumLabel(PropertyMetaModel<?> pmm,
Object value)
Get a label for the enum value "value" presented on the property passed.
|
static Object |
getPrimaryKey(Object instance)
Return the primary key field for a given instance.
|
static Object |
getPrimaryKey(Object instance,
ClassMetaModel cmm) |
static PropertyMetaModel<?> |
getPropertyMeta(Class<?> clz,
String name) |
static PropertyMetaModel<?> |
getPropertyMeta(IMetaClass clz,
String name) |
static <K,T extends IIdentifyable<K>> |
hasChildRecords(QDataContext dc,
String schemaName,
T instance)
If the persistent class specified has dependent child records this returns the first table name or table entity name (if found) for which
children are found.
|
static <T> boolean |
hasDuplicates(List<T> items,
T instance,
String propertyname)
Returns T if instance.propertyname is a duplicate in some other instance in the list.
|
static String |
identify(Object t) |
static PropertyMetaModel<?> |
internalCalculateDottedPath(ClassMetaModel cmm,
String name) |
static void |
internalClear()
Clears the cache.
|
static boolean |
isAccessAllowed(String[][] roleset,
IRequestContext ctx)
Handles the permission sets like "viewpermission" and "editpermission".
|
static List<PropertyMetaModel<?>> |
parsePropertyPath(ClassMetaModel m,
String compoundName)
Parse the property path and return the list of properties in the path.
|
static void |
registerModel(IClassMetaModelFactory model) |
public static final Comparator<DisplayPropertyMetaModel> C_BY_SORT_INDEX
public static void registerModel(@Nonnull IClassMetaModelFactory model)
@Nonnull public static ClassMetaModel findClassMeta(@Nonnull Class<?> clz)
@Nonnull public static ClassMetaModel findClassMeta(@Nonnull IMetaClass mc)
mc - public static void internalClear()
@Nullable public static PropertyMetaModel<?> findPropertyMeta(@Nonnull Class<?> clz, @Nonnull String name)
clz - name - @Nullable public static PropertyMetaModel<?> findPropertyMeta(IMetaClass mc, String name)
mc - name - @Nonnull public static PropertyMetaModel<?> getPropertyMeta(Class<?> clz, String name)
@Nonnull public static PropertyMetaModel<?> getPropertyMeta(IMetaClass clz, String name)
public static boolean isAccessAllowed(String[][] roleset, IRequestContext ctx)
{ {"admin"}
, {"editroles", "user"}
, {"tester"}
};
this means that the field is visible for a user with the roles:
"admin" OR "tester" OR ("editroles" AND "user")
roleset - ctx - @Nonnull public static INodeContentRenderer<?> createDefaultComboRenderer(@Nullable PropertyMetaModel<?> pmm, @Nullable ClassMetaModel cmm)
pmm - If not-null this takes precedence. This then must be the property that
is to be filled from the list-of-values in the combo. The property is used
to override the presentation only. Formally speaking, pmm.getActualType() must
be equal to the combo's list item type, and the renderer expects items of that
type.cmm - public static boolean areObjectsEqual(Object a, Object b, ClassMetaModel cmm)
a - b - cmm - public static <T extends Enum<?>> String findEnumLabel(T val)
T - val - public static <T extends Enum<?>> List<ValueLabelPair<T>> createEnumList(Class<T> clz)
clz - public static PropertyMetaModel<?> internalCalculateDottedPath(ClassMetaModel cmm, String name)
public static List<PropertyMetaModel<?>> parsePropertyPath(@Nonnull ClassMetaModel m, String compoundName)
m - compoundName - @Nullable public static Class<?> findCollectionType(Type genericType)
genericType - public static <T> boolean hasDuplicates(List<T> items, T instance, String propertyname) throws Exception
T - items - instance - propertyname - Exceptionpublic static Object getPrimaryKey(Object instance) throws Exception
instance - Exceptionpublic static Object getPrimaryKey(Object instance, ClassMetaModel cmm) throws Exception
Exception@Nonnull public static List<SearchPropertyMetaModel> calculateSearchProperties(ClassMetaModel cm)
cm - @Nonnull public static List<DisplayPropertyMetaModel> calculateObjectProperties(ClassMetaModel cm)
cmm - public static String getEnumLabel(Enum<?> label)
public static String getEnumLabel(Class<?> clz, String property, Object value)
clz - property - value - public static String getEnumLabel(PropertyMetaModel<?> pmm, Object value)
pmm - value - public static void copyValuesExcept(Object to, Object from, Object... except) throws Exception
to - from - except - Exception@Nonnull public static List<DisplayPropertyMetaModel> getComboProperties(@Nonnull PropertyMetaModel<?> pmm)
pmm - public static void applyPropertySort(@Nonnull QCriteria<?> q, @Nonnull List<DisplayPropertyMetaModel> properties)
crit - properties - public static <T> void fillCopy(@Nonnull T source, @Nonnull T target)
T - source - target - Exceptionpublic static <T> void fillCopy(@Nonnull T source, @Nonnull T target, String... ignoredColumns)
T - source - target - ignoredColumns - Specified optional columns that would not be filled with data from sourceExceptionpublic static <T> void fillCopy(@Nonnull T source, @Nonnull T target, boolean copyPK, boolean copyTCN, boolean copyTransient, String... ignoredColumns)
T - source - target - copyPK - If T, it also copies PK value(s)copyTCN - If T, it also copies TCN value(s)copyTransient - If T, it also copies transient valuesignoredColumns - Specified optional columns that would not be filled with data from sourceException@Nullable public static ClassMetaModel findClassByTable(@Nonnull String tableName)
tableName - @Nullable public static <K,T extends IIdentifyable<K>> String hasChildRecords(QDataContext dc, @Nonnull String schemaName, @Nonnull T instance) throws Exception
dc - schemaName - instance - ExceptionCopyright © 2017 etc.to. All rights reserved.