com.fluidbpm.program.api.util.elasticsearch.ESFormUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluid-api Show documentation
Show all versions of fluid-api Show documentation
Used for the
* Custom Program Step,
* Custom Actions,
* Scheduled Actions and
* Fluid API
in the Fluid BPM and Content Management system.
/*
* Koekiebox CONFIDENTIAL
*
* [2012] - [2017] Koekiebox (Pty) Ltd
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property
* of Koekiebox and its suppliers, if any. The intellectual and
* technical concepts contained herein are proprietary to Koekiebox
* and its suppliers and may be covered by South African and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material is strictly
* forbidden unless prior written permission is obtained from Koekiebox.
*/
package com.fluidbpm.program.api.util.elasticsearch;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.QueryBuilders;
import com.fluidbpm.program.api.util.ABaseUtil;
import com.fluidbpm.program.api.util.IFormAction;
import com.fluidbpm.program.api.util.cache.CacheUtil;
import com.fluidbpm.program.api.vo.ABaseFluidJSONObject;
import com.fluidbpm.program.api.vo.form.Form;
/**
* ElasticSearch Utility class used for {@code Form} related actions.
* A {@code Form} in Fluid is the equivalent to a Document in ElasticSearch.
*
* @author jasonbruwer on 2016/08/19.
* @since 1.3
* @see ABaseUtil
* @see ABaseESUtil
* @see IFormAction
*/
public class ESFormUtil extends ABaseESUtil implements IFormAction {
/**
* Initialise with the ElasticSearch client.
*
* @param connectionParam SQL Connection to use.
* @param esClientParam The ES Client.
* @param cacheUtilParam The Cache Util for better performance.
*/
public ESFormUtil(
Connection connectionParam,
RestHighLevelClient esClientParam,
CacheUtil cacheUtilParam
) {
super(connectionParam,
esClientParam,
cacheUtilParam);
}
/**
* Initialise with the ElasticSearch client.
*
* @param esClientParam The ES Client.
*/
public ESFormUtil(RestHighLevelClient esClientParam) {
super(esClientParam);
}
/**
* Gets the ancestor for the {@code electronicFormIdParam} Form.
*
* @param electronicFormIdParam Identifier for the Form.
* @param includeFieldDataParam Whether to populate the return {@code Form} fields.
* @param includeTableFieldsParam Whether to populate the return {@code Form} table fields.
*
* @return {@code Form} descendants.
*
* @see Form
*/
public Form getFormAncestor(
Long electronicFormIdParam,
boolean includeFieldDataParam,
boolean includeTableFieldsParam
) {
if (electronicFormIdParam == null) {
return null;
}
//Query using the descendantId directly...
StringBuffer ancestorQuery = new StringBuffer(
Form.JSONMapping.DESCENDANT_IDS);
ancestorQuery.append(":\"");
ancestorQuery.append(electronicFormIdParam);
ancestorQuery.append("\"");
//Search for the Ancestor...
List