Toolkit (Wrapper) API

The functions toolkit (wrapper) API is comprised of the miscellaneous utility functions. They are primarily used in the implementation of individual functions. The documentation of toolkit API is provided below where the major categories are

  • Access (CRUD) data using their model schema
  • Interact with external service endpoints
  • JSON conversions
  • Audit and debug logging
  • Notifications

For example, consider the following the snippet and its implementation.

  • Generate a dynamic access key
  • Build the account activation link (with access key) to be sent via email
  • Use a specific email template named "policy_activation" and provided above data for the email content.
  • Send the activation email
userApp = func.getCreateUserAppObject("" + user.id, "SelfService", null);  //application info of the user with access key

rtUrl = func.getRtUrl(orgName);  //application server url
m = new HashMap();               //create data for email content
m.PolicyTitle = obj.title;
m.ClientName = v.?fullName;
m.BaseRTURL = rtUrl + "/" + orgName;
m.AccountURL = rtUrl  + "/" + "_accessApp/" + orgName + "/" + userApp.accessKey; //activation url

func.sendEmail(appName, user.email, "Your Policy is Ready", null, "policy_activation", null, m); //email user

Wrapper API Documentation

public static String asJSONPrettyString(Object obj)

As json pretty string string.

  • Parameters: obj — the obj
  • Returns: the string
public static Object getObject(String className, String id)

Gets object.

  • Parameters:
    • className — the class name
    • id — the id
  • Returns: the object
public static Object getOneByQuery(String className, String query)

Gets one by query.

  • Parameters:
    • className — the class name
    • query — the query
  • Returns: the one by query
public static Object getObjectsByQuery(String className, String query)

Gets objects by query.

  • Parameters:
    • className — the class name
    • query — the query
  • Returns: the objects by query
public static Object getPage(String className, int start, int size)

Gets page.

  • Parameters:
    • className — the class name
    • start — the start
    • size — the size
  • Returns: the page
public static Object getPage(String className, String whereClause, int start, int size)

Gets page.

  • Parameters:
    • className — the class name
    • whereClause — the where clause
    • start — the start
    • size — the size
  • Returns: the page
public static Object getPageWhereOrderBy( String className, String whereClause, String orderBy, int start, int size)

Gets page where order by.

  • Parameters:
    • className — the class name
    • whereClause — the where clause
    • orderBy — the order by
    • start — the start
    • size — the size
  • Returns: the page where order by
public static Object getPageWhereHavingGroupByOrderBy( String className, String whereClause, String having, String groupBy, String orderBy, int start, int size)

Gets page where having group by order by.

  • Parameters:
    • className — the class name
    • whereClause — the where clause
    • having — the having
    • groupBy — the group by
    • orderBy — the order by
    • start — the start
    • size — the size
  • Returns: the page where having group by order by
public static Object getPage( String className, String sqlTemplate, Map<String, Object> params, int start, int size)

Gets page.

  • Parameters:
    • className — the class name
    • sqlTemplate — the sql template
    • params — the params
    • start — the start
    • size — the size
  • Returns: the page
public static Object getPage(DataRequest dsr)

Gets page.

  • Parameters: dsr — the dsr
  • Returns: the page
public static Object save(String className, Object entity)

Save object.

  • Parameters:
    • className — the class name
    • entity — the entity
  • Returns: the object
public static Object saveAll(String className, Iterable<Object> entities)

Save all object.

  • Parameters:
    • className — the class name
    • entities — the entities
  • Returns: the object
public static Object updateAttr(String className, String id, String attrName, Object value)

Update attr object.

  • Parameters:
    • className — the class name
    • id — the id
    • attrName — the attr name
    • value — the value
  • Returns: the object
public static Object updateAttr( String className, List<String> ids, String attrName, Object value)

Update attr object.

  • Parameters:
    • className — the class name
    • ids — the ids
    • attrName — the attr name
    • value — the value
  • Returns: the object
public static Object delete(String className, String id, boolean permanent)

Delete object.

  • Parameters:
    • className — the class name
    • id — the id
    • permanent — the permanent
  • Returns: the object
public static Object deleteAll(String className, Iterable<String> ids, boolean permanent)

Delete all object.

  • Parameters:
    • className — the class name
    • ids — the ids
    • permanent — the permanent
  • Returns: the object
public static Object deleteByQuery(String className, String query, boolean permanent)

Delete by query object.

  • Parameters:
    • className — the class name
    • query — the query
    • permanent — the permanent
  • Returns: the object
public static Object getObject(String appName, String dsName, String className, String id)

Gets object.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • id — the id
  • Returns: the object
public static Object getOneByQuery( String appName, String dsName, String className, String query)

Gets one by query.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • query — the query
  • Returns: the one by query
public static Object getObjectsByQuery( String appName, String dsName, String className, String query)

Gets objects by query.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • query — the query
  • Returns: the objects by query
public static Object getPage( String appName, String dsName, String className, int start, int size)

Gets page.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • start — the start
    • size — the size
  • Returns: the page
public static Object getPage( String appName, String dsName, String className, String whereClause, int start, int size)

Gets page.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • whereClause — the where clause
    • start — the start
    • size — the size
  • Returns: the page
public static Object getPage( String appName, String dsName, String className, String whereClause, String orderBy, int start, int size)

Gets page.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • whereClause — the where clause
    • orderBy — the order by
    • start — the start
    • size — the size
  • Returns: the page
public static Object getPage( String appName, String dsName, String className, String whereClause, String having, String groupBy, String orderBy, int start, int size)

Gets page.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • whereClause — the where clause
    • having — the having
    • groupBy — the group by
    • orderBy — the order by
    • start — the start
    • size — the size
  • Returns: the page
public static Object getPage( String appName, String dsName, String className, String sqlTemplate, Map<String, Object> params, int start, int size)

Gets page.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • sqlTemplate — the sql template
    • params — the params
    • start — the start
    • size — the size
  • Returns: the page
public static Object getPage(String appName, String dsName, DataRequest dsr)

Gets page.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • dsr — the dsr
  • Returns: the page
public static Object save(String appName, String dsName, String className, Object entity)

Save object.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • entity — the entity
  • Returns: the object
public static Object saveAll( String appName, String dsName, String className, Iterable<Object> entities)

Save all object.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • entities — the entities
  • Returns: the object
public static Object updateAttr( String appName, String dsName, String className, String id, String attrName, Object value)

Update attr object.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • id — the id
    • attrName — the attr name
    • value — the value
  • Returns: the object
public static Object updateAttr( String appName, String dsName, String className, List<String> ids, String attrName, Object value)

Update attr object.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • ids — the ids
    • attrName — the attr name
    • value — the value
  • Returns: the object
public static Object delete( String appName, String dsName, String className, String id, boolean permanent)

Delete object.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • id — the id
    • permanent — the permanent
  • Returns: the object
public static Object deleteAll( String appName, String dsName, String className, Iterable<String> ids, boolean permanent)

Delete all object.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • ids — the ids
    • permanent — the permanent
  • Returns: the object
public static Object deleteByQuery( String appName, String dsName, String className, String query, boolean permanent)

Delete by query object.

  • Parameters:
    • appName — the app name
    • dsName — the ds name
    • className — the class name
    • query — the query
    • permanent — the permanent
  • Returns: the object
public static Object makeAuditLogObject( String sourceClass, long sourceId, String action, String summary)

Make audit log object object.

  • Parameters:
    • sourceClass — the source class
    • sourceId — the source id
    • action — the action
    • summary — the summary
  • Returns: the object
public static Object makeAuditLogObject( String sourceClass, long sourceId, String action, String summary, Map<String, Object> oldObject, Map<String, Object> newObject)

Make audit log object object.

  • Parameters:
    • sourceClass — the source class
    • sourceId — the source id
    • action — the action
    • summary — the summary
    • oldObject — the old object
    • newObject — the new object
  • Returns: the object
public static Object getUser(String id)

Gets user.

  • Parameters: id — the id
  • Returns: the user
public static Object getUserByQuery(String query)

Gets user by query.

  • Parameters: query — the query
  • Returns: the user by query
public static Object getUserByUserId(String userId)

Gets user by user id.

  • Parameters: userId — the user id
  • Returns: the user by user id
public static Object getUserByEmail(String email)

Gets user by email.

  • Parameters: email — the email
  • Returns: the user by email
public static Object getOrgByQuery(String orgName)

Gets org by query.

  • Parameters: orgName — the org name
  • Returns: the org by query
public static Object getOrgByOrgName(String orgName)

Gets org by org name.

  • Parameters: orgName — the org name
  • Returns: the org by org name
public static Object signup(Object entity, String authChoice)

Signup object.

  • Parameters:
    • entity — the entity
    • authChoice — the auth choice
  • Returns: the object
public static Object getCreateUser(Map<String, Object> map)

Gets create user.

  • Parameters: map — the map
  • Returns: the create user
@SuppressWarnings("unchecked") public static Object getCreateUserAppObject(String idOfUser, String appName, String role)

Gets create user app object.

  • Parameters:
    • idOfUser — the id of user
    • appName — the app name
    • role — the role
  • Returns: the create user app object
public static Object auditLog( String sourceClass, long sourceId, String action, String summary, Map<String, Object> oldObject, Map<String, Object> newObject)

Audit log object.

  • Parameters:
    • sourceClass — the source class
    • sourceId — the source id
    • action — the action
    • summary — the summary
    • oldObject — the old object
    • newObject — the new object
  • Returns: the object
public static Object auditLog(String sourceClass, long sourceId, String action, String summary)

Audit log object.

  • Parameters:
    • sourceClass — the source class
    • sourceId — the source id
    • action — the action
    • summary — the summary
  • Returns: the object
public static Object auditLog(Object logObject)

Audit log object.

  • Parameters: logObject — the log object
  • Returns: the object
public static Result httpGet(String requestUrl)

Http get result.

  • Parameters: requestUrl — the request url
  • Returns: the result
public static boolean isResult(Object obj)

Is result boolean.

  • Parameters: obj — the obj
  • Returns: the boolean
public static boolean isSuccessResult(Object obj)

Is success result boolean.

  • Parameters: obj — the obj
  • Returns: the boolean
public static boolean isFailedResult(Object obj)

Is failed result boolean.

  • Parameters: obj — the obj
  • Returns: the boolean
public static MVELLogger mvelLogger()

Mvel logger mvel logger.

  • Returns: the mvel logger
public static long uidToId(String uid)

Uid to id long.

  • Parameters: uid — the uid
  • Returns: the long
public static String uidToIdStr(String uid)

Uid to id str string.

  • Parameters: uid — the uid
  • Returns: the string
public static String uidToClassName(String uid)

Uid to class name string.

  • Parameters: uid — the uid
  • Returns: the string
public static String getRtUrl(String orgName)

Gets rt url.

  • Parameters: orgName — the org name
  • Returns: the rt url
public static Object sendEmail( String appName, String email, String subject, String content, String template, String fromAlias, Map<String, Object> templateParams)

Send email object.

  • Parameters:
    • appName — the app name
    • email — the email
    • subject — the subject
    • content — the content
    • template — the template
    • fromAlias — the from alias
    • templateParams — the template params
  • Returns: the object