[MDD] Tree - TheOpenCloudEngine/metaworks GitHub Wiki
Make a Tree Object Structure as a Tree View
Mark the fields as @Id, @Name, @Children for id field, displayable name field, and the children item field. And use the face 'dwr/metaworks/genericfaces/TreeFace.ejs'
package org.uengine.social;
import org.metaworks.annotation.Children;
import org.metaworks.annotation.Face;
import org.metaworks.annotation.Id;
import org.metaworks.annotation.Name;
import java.util.List;
/**
* Created by jjy on 2016. 9. 19..
*/
@Face(ejsPath="dwr/metaworks/genericfaces/TreeFace.ejs")
public class ProcessInstanceExplorerNode{
String instanceId;
@Id
public String getInstanceId() {
return instanceId;
}
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}
String name;
@Name
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
List<ProcessInstanceExplorerNode> childInstances;
@Children
public List<ProcessInstanceExplorerNode> getChildInstances() {
return childInstances;
}
public void setChildInstances(List<ProcessInstanceExplorerNode> childInstances) {
this.childInstances = childInstances;
}
}
And add the object as a field where you wish to locate it.
package org.uengine.social;
import org.uengine.codi.mw3.model.IInstance;
import org.uengine.codi.mw3.model.Instance;
import java.util.ArrayList;
import java.util.List;
/**
* Created by jjy on 2016. 9. 19..
*/
public class ProcessInstanceExplorer {
ProcessInstanceExplorerNode root;
public ProcessInstanceExplorerNode getRoot() {
return root;
}
public void setRoot(ProcessInstanceExplorerNode root) {
this.root = root;
}
public void load(long rootInstanceId) throws Exception {
setRoot(new ProcessInstanceExplorerNode());
IInstance instances = Instance.loadForAllChildInstances(rootInstanceId);
List<ProcessInstanceExplorerNode> processInstanceExplorerNodeList = new ArrayList<ProcessInstanceExplorerNode>();
while(instances.next()){
ProcessInstanceExplorerNode processInstanceExplorerNode = new ProcessInstanceExplorerNode();
processInstanceExplorerNode.setName(instances.getName());
processInstanceExplorerNode.setInstanceId(instances.getInstId());
processInstanceExplorerNodeList.add(processInstanceExplorerNode);
}
//TODO: change the data to be structured as a tree by recursively finding the parentInstanceId
getRoot().setChildInstances(processInstanceExplorerNodeList);
}
}