1 19 package org.openharmonise.workfloweditor.vfs; 20 21 import java.util.*; 22 23 import org.openharmonise.him.*; 24 import org.openharmonise.him.context.StateHandler; 25 import org.openharmonise.him.metadata.range.swing.workflowstagepermissions.*; 26 import org.openharmonise.vfs.*; 27 import org.openharmonise.vfs.context.*; 28 import org.openharmonise.vfs.metadata.*; 29 import org.openharmonise.vfs.metadata.range.*; 30 import org.openharmonise.vfs.servers.ServerList; 31 import org.openharmonise.workfloweditor.model.*; 32 33 34 41 public class VFSWorkflowModel extends WorkflowModel { 42 43 46 private Property m_workflowProp = null; 47 48 51 private VirtualFile m_valuesCollection = null; 52 53 59 public VFSWorkflowModel(String sTitle, Property prop) { 60 super(sTitle); 61 this.m_workflowProp = prop; 62 this.setup(); 63 } 64 65 69 private void setup() { 70 AbstractVirtualFileSystem vfs = ServerList.getInstance().getHarmoniseServer().getVFS(); 71 72 VirtualFile vfRoleCollection = vfs.getVirtualFile("/webdav/RBS_VALS/roles").getResource(); 73 74 WorkflowPermissionsResourceFilter resourceFilter = new WorkflowPermissionsResourceFilter(); 75 76 Iterator itor = vfRoleCollection.getChildren().iterator(); 77 while (itor.hasNext()) { 78 String sRolePath = (String ) itor.next(); 79 VirtualFile vfRoleFile = vfs.getVirtualFile(sRolePath).getResource(); 80 if(vfRoleFile!=null && resourceFilter.showResource(vfRoleFile)) { 81 VFSRole vfsRole = new VFSRole(sRolePath); 82 this.addAvailableRole(vfsRole); 83 } 84 } 85 86 this.m_valuesCollection = this.getStagesCollection(); 87 88 itor = this.m_valuesCollection.getChildren().iterator(); 89 while (itor.hasNext()) { 90 String sChildPath = (String ) itor.next(); 91 boolean bFound = false; 92 Iterator itor2 = this.getWorkflowStages().iterator(); 93 while (itor2.hasNext()) { 94 VFSWorkflowStage tempStage = (VFSWorkflowStage) itor2.next(); 95 if(tempStage.getPath().equals(sChildPath)) { 96 bFound=true; 97 break; 98 } 99 } 100 if(!bFound) { 101 VirtualFile vfStageFile = vfs.getVirtualFile(sChildPath).getResource(); 102 VFSWorkflowStage vfsWorkflowStage = new VFSWorkflowStage(this, vfStageFile); 103 super.addWorkflowStage(vfsWorkflowStage); 104 } 105 } 106 } 107 108 111 public void addWorkflowStage(WorkflowStage stage) { 112 super.addWorkflowStage(stage); 113 } 114 115 118 public void removeWorkflowStage(WorkflowStage stage) { 119 StateHandler.getInstance().addWait("WORKFLOWSTAGEDELETE"); 120 try { 121 VFSWorkflowStage vfsStage = (VFSWorkflowStage) stage; 122 AbstractVirtualFileSystem vfs = ServerList.getInstance().getHarmoniseServer().getVFS(); 123 VirtualFile vfFile = vfs.getVirtualFile(vfsStage.getPath()).getResource(); 124 if(vfFile!=null) { 125 vfFile.delete(); 126 } 127 } catch(Exception e) { 128 e.printStackTrace(); 129 } finally { 130 StateHandler.getInstance().removeWait("WORKFLOWSTAGEDELETE"); 131 super.removeWorkflowStage(stage); 132 } 133 } 134 135 140 public Property getWorkflowProperty() { 141 return this.m_workflowProp; 142 } 143 144 149 public VirtualFile getStagesCollection() { 150 AbstractVirtualFileSystem vfs = ServerList.getInstance().getHarmoniseServer().getVFS(); 151 String sValueCollectionPath = (String ) ((ResourceRange)this.m_workflowProp.getRange()).getHREFs().get(0); 152 153 return vfs.getVirtualFile(sValueCollectionPath).getResource(); 154 } 155 156 } 157 | Popular Tags |