xworker.app.userflow.UserFlowTaskTreeModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xworker_app Show documentation
Show all versions of xworker_app Show documentation
XWorker app model liberary.
The newest version!
package xworker.app.userflow;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.World;
import xworker.dataObject.DataObject;
import xworker.dataObject.app.model.tree.implnew.ThingRegistTreeModel;
import xworker.dataObject.data.tree.TreeModel;
import xworker.dataObject.data.tree.TreeModelItem;
import xworker.dataObject.query.Condition;
import xworker.lang.util.ThingGroup;
import xworker.lang.util.XWorkerUtils;
import java.util.ArrayList;
import java.util.List;
public class UserFlowTaskTreeModel {
public static TreeModelItem getRoot(ActionContext actionContext){
Thing self = actionContext.getObject("self");
TreeModel treeModel = actionContext.getObject("treeModel");
//查询所有正在执行的任务
DataObject dataObject = new DataObject("xworker.app.userflow.dataobjects.UserFlow");
Condition condition = new Condition();
condition.eq("status", 1);
List tasks = dataObject.query(actionContext, condition);
List things = new ArrayList<>();
World world = World.getInstance();
for(DataObject task : tasks){
Thing thing = world.getThing(task.getString("thingPath"));
if(thing != null && !things.contains(thing)){
things.add(thing);
}
}
List groups = XWorkerUtils.getThingGroups(things, self.getMetadata().getPath());
//没有子节点的分组
removeEmptyGroup(groups);
//实际没有根节点
TreeModelItem rootItem = new TreeModelItem(treeModel, null);
List items = new ArrayList<>();
for(ThingGroup childGroup : groups){
items.add(ThingRegistTreeModel.toTreeModelItem(treeModel, rootItem, childGroup));
}
rootItem.setItems(items);
return rootItem;
}
static void removeEmptyGroup(List groups){
if(groups == null){
return;
}
for(int i=0; i children = thingGroup.getChilds();
if((thing == null || thing.getThingName().equals("TaskGroup")) && (children == null || children.size() == 0)){
groups.remove(i);
i--;
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy