/** * Using this as a data wrapper only * @param data any data to wrap this in * @param entityProperties a set of properties to return along with the entity information, * this may be presented and used for filtering, */ public EntityData(Object data, Map<String, Object> entityProperties) { setData(data); setEntityProperties(entityProperties); this.dataOnly = true; }
/** * Full constructor<br/> * Use this if you want to return the entity itself along with the key meta data and properties * * @param ref an object which represents a globally unique reference to an entity, * consists of the entity prefix and id * @param entityDisplayTitle a string which is suitable for display and provides a short summary of the entity, * typically 100 chars or less, this may be the name or title of the entity represented by an entity * @param data an entity data object, see {@link Resolvable} * @param entityProperties a set of properties to return along with the entity information, * this may be presented and used for filtering, */ public EntityData(EntityReference ref, String displayTitle, Object entity, Map<String, Object> entityProperties) { if (ref == null || ref.isEmpty()) { throw new IllegalArgumentException("reference object cannot be null and must have values set"); } this.entityRef = ref; this.entityReference = this.entityRef.getReference(); this.entityId = this.entityRef.getId(); this.entityDisplayTitle = displayTitle; this.entityURL = EntityView.DIRECT_PREFIX + this.entityReference; this.entityDisplayTitle = displayTitle; setData(entity); setEntityProperties(entityProperties); }
/** * Full constructor<br/> * Use this if you want to return the entity itself along with the key meta data and properties * * @param reference a globally unique reference to an entity, * consists of the entity prefix and id (e.g. /prefix/id) * @param entityDisplayTitle a string which is suitable for display and provides a short summary of the entity, * typically 100 chars or less, this may be the name or title of the entity represented by an entity * @param data an entity data object, see {@link Resolvable} * @param entityProperties a set of properties to return along with the entity information, * this may be presented and used for filtering, */ public EntityData(String reference, String displayTitle, Object entity, Map<String, Object> entityProperties) { this.entityRef = new EntityReference(reference); this.entityReference = this.entityRef.getReference(); this.entityId = this.entityRef.getId(); this.entityDisplayTitle = displayTitle; this.entityURL = EntityView.DIRECT_PREFIX + this.entityReference; setData(entity); setEntityProperties(entityProperties); }
try { entity = serializable.makeSerializableObject(ref, entity); entityData.setData(entity); } catch (Exception e) { throw new RuntimeException("Failure while attempting to serialize the object from ("+entity+") for ref("+ref+"): " + e.getMessage(), e);
try { entity = serializable.makeSerializableObject(ref, entity); entityData.setData(entity); } catch (Exception e) { throw new RuntimeException("Failure while attempting to serialize the object from ("+entity+") for ref("+ref+"): " + e.getMessage(), e);