001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.workfloweditor.vfs;
020:
021: import java.util.*;
022:
023: import org.openharmonise.commons.xml.namespace.*;
024: import org.openharmonise.vfs.*;
025: import org.openharmonise.vfs.metadata.*;
026: import org.openharmonise.vfs.metadata.value.*;
027: import org.openharmonise.workfloweditor.model.*;
028:
029: /**
030: * Virtual file system implementation of {@link org.openharmonise.workfloweditor.model.WorkflowStageDefinition}.
031: *
032: * @author Matthew Large
033: * @version $Revision: 1.2 $
034: *
035: */
036: public class VFSWorkflowStageDefinition extends WorkflowStageDefinition {
037:
038: /**
039: * Virtual file for the value for this definition.
040: */
041: private VirtualFile m_valueResource = null;
042:
043: /**
044: * Property instance for the roles.
045: */
046: private PropertyInstance m_rolesPropInst = null;
047:
048: private VFSWorkflowStageDefinition(String sTitle,
049: VFSWorkflowModel model) {
050: super (model);
051: }
052:
053: /**
054: * Constructs a new virtual file system workflow stage definition.
055: *
056: * @param valueResource Virtual file for the value
057: * @param model Model
058: */
059: public VFSWorkflowStageDefinition(VirtualFile valueResource,
060: VFSWorkflowModel model) {
061: super (model);
062: this .m_valueResource = valueResource;
063: this .setup();
064: }
065:
066: /**
067: * Configures this stage definition.
068: *
069: */
070: private void setup() {
071: String sTitle = this .m_valueResource.getVFS()
072: .getVirtualFileSystemView().getDisplayName(
073: m_valueResource);
074: this .setTitle(sTitle);
075:
076: m_rolesPropInst = this .m_valueResource.getProperty(
077: NamespaceType.OHRM.getURI(), "WORKFLOW_ROLES");
078: Iterator itor = m_rolesPropInst.getValues().iterator();
079: while (itor.hasNext()) {
080: ValueValue value = (ValueValue) itor.next();
081: String sValuePath = value.getValue();
082: Iterator itor2 = this .getModel().getAvailableRoles()
083: .iterator();
084: while (itor2.hasNext()) {
085: VFSRole role = (VFSRole) itor2.next();
086: if (role.getValuePath().equals(sValuePath)) {
087: super .addRole(role);
088: }
089: }
090: }
091: }
092:
093: /**
094: * Returns the full path to the virtual file for the value for this
095: * workflow stage definition.
096: *
097: * @return Full path
098: */
099: public String getPath() {
100: return this.m_valueResource.getFullPath();
101: }
102: }
|