public class EntityDataUtils extends Object
EntityData objects and their properties| Constructor and Description |
|---|
EntityDataUtils() |
| Modifier and Type | Method and Description |
|---|---|
static List<?> |
convertToEntities(List<?> entities)
Convert a list of entities / entity data to just entities,
will preserve null (i.e. null in => null out)
|
static Object |
convertToEntity(Object object)
Convert an entity/data to just an entity,
will preserve null (i.e. null in => null out)
|
static List<EntityData> |
convertToEntityData(List<?> entities,
EntityReference ref)
Convert a list of objects to entity data objects (DOES NOT populate them),
will preserve null (i.e. null in => null out)
|
static EntityData |
convertToEntityData(Object entity,
EntityReference ref)
Convert a single object to an entity data object (DOES NOT populate it),
will preserve null (i.e. null in => null out)
|
static Map<String,Object> |
extractMapProperties(Map m)
Get the values from a map and convert them to strings,
nulls pass through
|
static String |
findMapStringValue(Map<String,?> map,
String[] keys)
Finds a map value for a key (or set of keys) if it exists in the map and returns the string value of it
|
static Object |
findMapValue(Map<String,?> map,
String[] keys)
Finds a map value for a key (or set of keys) if it exists in the map and returns the value of it
|
static Restriction |
findSearchRestriction(Search search,
String key,
String[] keys,
String valuePrefix)
Finds if there are any search restrictions with the given properties, if so it returns the Restriction,
the value will have the given prefix appended to it's string value if it does not have it,
the returned restriction will have the key set to the input key,
otherwise returns null
|
static String |
getEntityId(Object entity)
Gets the id field value from an entity if possible
|
static String |
getEntityIdField(Class<?> type)
Gets the fieldname of the identifier field for an entity class type
|
static EntityContent |
getResourceDetails(ContentEntity entity)
Produces a summary of an content entity for display in entitybroker.
|
static EntityData |
makeEntityData(EntityReference ref,
Object entity)
Make an entity data object out of whatever entity is given,
use the given reference, if there is no id then this will attempt to get one otherwise it will use prefix only
|
static <T,S> void |
putAllNewInMap(Map<T,S> original,
Map<T,S> newStuff)
Puts the values of 2 maps together such that the values from the newStuff map are added to the
original map only if they are not already in the the original
|
static boolean |
translateSearchReference(Search search,
String key,
String[] keys,
String valuePrefix)
Adds in a search restriction based on existing restrictions,
this is ideally setup to convert restrictions into one that the developers expect
|
static Search |
translateStandardSearch(Search search)
Translate the search into one using the standard search params
|
public static List<EntityData> convertToEntityData(List<?> entities, EntityReference ref)
public static EntityData convertToEntityData(Object entity, EntityReference ref)
public static List<?> convertToEntities(List<?> entities)
public static Object convertToEntity(Object object)
public static EntityData makeEntityData(EntityReference ref, Object entity)
public static String getEntityId(Object entity)
entity - any entity objectpublic static String getEntityIdField(Class<?> type)
type - any entity class typepublic static Search translateStandardSearch(Search search)
search - public static boolean translateSearchReference(Search search, String key, String[] keys, String valuePrefix)
public static Restriction findSearchRestriction(Search search, String key, String[] keys, String valuePrefix)
public static String findMapStringValue(Map<String,?> map, String[] keys)
map - any map with strings as keyskeys - an array of keys to try to find in orderpublic static Object findMapValue(Map<String,?> map, String[] keys)
map - any map with strings as keyskeys - an array of keys to try to find in orderpublic static <T,S> void putAllNewInMap(Map<T,S> original, Map<T,S> newStuff)
T - S - original - newStuff - public static Map<String,Object> extractMapProperties(Map m)
m - public static EntityContent getResourceDetails(ContentEntity entity)
entity - The entity to display.Copyright © 2007–2018 CARET, University of Cambridge. All rights reserved.