BoomiExtUtil
Kotlin in Boomi - Boomi Extended Util library
This library is completely written in Kotlin for Boomi Script use cases.
How to install this Library in your environment
Below are the steps you have to follow to use this in your Boomi Environment;
- Download the latest release .jar file from this link Latest Release
- Upload this jar file in your Boomi account Upload in Boomi
- Create Custom Library component in Boomi Create Custom Library Component
- Select Custom Library Type -> Scripting.
- Search and Add the .jar file which was previously uploaded in your account.
- Deploy this component to your environment.
- Create a new process and write a Groovy custom script(Groovy 2.4) in data process shape in Boomi and then test the process on the same environment you have deployed this BoomiExtUtil.
Note: Don't forget to select "Groovy 2.4" as the custom scripting language
Simple Usage Code:
import java.util.Properties;
import java.io.InputStream;
import com.arunzlair.boomiextutil.Simple;
import com.boomi.execution.ExecutionUtil;
logger = ExecutionUtil.getBaseLogger();
Simple simple = new Simple()
logger.info(simple.getSimpleMessage());
for( int i = 0; i < dataContext.getDataCount(); i++ ) {
InputStream is = dataContext.getStream(i);
Properties props = dataContext.getProperties(i);
dataContext.storeStream(is, props);
}
JSON Schema Validation:
Reference Links:
Tested with Draft4, Draft7 and should support Draft6 as well.
import java.util.Properties;
import java.io.InputStream;
import com.arunzlair.boomiextutil.JSONValidation;
import com.boomi.execution.ExecutionUtil;
import groovy.transform.Field
logger = ExecutionUtil.getBaseLogger();
@Field
JSONValidation jsonVal = new JSONValidation()
for( int i = 0; i < dataContext.getDataCount(); i++ ) {
InputStream is = dataContext.getStream(i);
Properties props = dataContext.getProperties(i);
String jsonSchema = props.getProperty("document.dynamic.userdefined.DDP_JSON_SCHEMA");
String jsonData = props.getProperty("document.dynamic.userdefined.DDP_JSON_FILE");
Boolean result = jsonVal.isValid(jsonSchema, jsonData)
logger.info("valid =" + result);
// Access Validation Message only when the "isValid" method returns false
if (!result) {
// default delimiter is "; "
String message1 = jsonVal.getValidationMsg()
logger.info(message1);
// newline "\n" char
String message2 = jsonVal.getValidationMsg("\n")
logger.info(message2);
// Validation Message in JSON format
String message3 = jsonVal.getValidationMsgJSON()
logger.info(message3);
}
dataContext.storeStream(is, props);
}
XML Schema Validation:
import java.util.Properties;
import java.io.InputStream;
import com.arunzlair.boomiextutil.XMLValidation;
import com.boomi.execution.ExecutionUtil;
import groovy.transform.Field
logger = ExecutionUtil.getBaseLogger();
@Field
XMLValidation xmlVal = new XMLValidation()
for( int i = 0; i < dataContext.getDataCount(); i++ ) {
InputStream is = dataContext.getStream(i);
Properties props = dataContext.getProperties(i);
String xmlSchema = props.getProperty("document.dynamic.userdefined.DDP_XML_SCHEMA");
String xmlData = props.getProperty("document.dynamic.userdefined.DDP_XML_FILE");
Boolean result = xmlVal.isValid(xmlSchema, xmlData)
logger.info("valid =" + result);
// Access Validation Message only when the "isValid" method returns false
if (!result) {
// default delimiter is "; "
String message1 = xmlVal.getValidationMsg()
logger.info(message1);
// newline "\n" char
String message2 = xmlVal.getValidationMsg("\n")
logger.info(message2);
// Validation Message in JSON format
String message3 = xmlVal.getValidationMsgJSON()
logger.info(message3);
}
dataContext.storeStream(is, props);
}