All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.schoolwow.workflow.module.common.flow.AddContextDataQueryFlow Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package cn.schoolwow.workflow.module.common.flow;

import cn.schoolwow.quickdao.domain.database.dql.condition.Condition;
import cn.schoolwow.quickdao.domain.database.dql.subCondition.SubCondition;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.workflow.domain.task.ContextDataQuery;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class AddContextDataQueryFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        List contextDataQueryList = flowContext.getData("contextDataQueryList", List.class);
        if(null==contextDataQueryList||contextDataQueryList.isEmpty()){
            return;
        }
        Condition condition = flowContext.getInstanceData(Condition.class);
        SubCondition subCondition = flowContext.getInstanceData(SubCondition.class);

        for(ContextDataQuery contextDataQuery: contextDataQueryList){
            StringBuilder builder = new StringBuilder("context_data->>'"+contextDataQuery.fieldName+"' "+contextDataQuery.operator+" ");
            List parameterList = new ArrayList();
            switch (contextDataQuery.operator.toLowerCase().trim()){
                case "in":
                case "not in":{
                    int length = -1;
                    if(contextDataQuery.value.getClass().isArray()){
                        length = Array.getLength(contextDataQuery.value);
                        for(int i=0;i