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.him.editors.report.utils;
020:
021: import java.util.HashMap;
022: import java.util.Iterator;
023:
024: import org.openharmonise.him.harmonise.*;
025:
026: /**
027: * Mapping of Harmonise paths to report query element names.
028: *
029: * @author Matthew Large
030: * @version $Revision: 1.1 $
031: *
032: */
033: public class PathTagMapping {
034:
035: /**
036: * Map of path to Harmonise object element names.
037: */
038: private static HashMap m_pathObjectTagMapping = new HashMap();
039:
040: /**
041: * Map of path to Harmonise group element names.
042: */
043: private static HashMap m_pathGroupTagMapping = new HashMap();
044:
045: static {
046: m_pathObjectTagMapping.put(HarmonisePaths.PATH_ASSETS, "Asset");
047: m_pathObjectTagMapping.put(HarmonisePaths.PATH_DOCUMENTS,
048: "Document");
049: m_pathObjectTagMapping.put(HarmonisePaths.PATH_COMPOSITION,
050: "XMLResource");
051: m_pathObjectTagMapping.put(HarmonisePaths.PATH_INCLUDES,
052: "XMLResource");
053: m_pathObjectTagMapping.put(HarmonisePaths.PATH_NEWSLETTER,
054: "Document");
055: m_pathObjectTagMapping.put(HarmonisePaths.PATH_PAGE_DEFINITION,
056: "Page");
057: m_pathObjectTagMapping.put(HarmonisePaths.PATH_PROPERTIES,
058: "Property");
059: m_pathObjectTagMapping.put(HarmonisePaths.PATH_RBS_PROPS,
060: "Property");
061: m_pathObjectTagMapping.put(HarmonisePaths.PATH_RBS_VALS,
062: "Value");
063: m_pathObjectTagMapping.put(HarmonisePaths.PATH_REPORTS,
064: "XMLResource");
065: m_pathObjectTagMapping.put(HarmonisePaths.PATH_SITE_ASSETS,
066: "Asset");
067: m_pathObjectTagMapping.put(HarmonisePaths.PATH_USERS, "User");
068: m_pathObjectTagMapping.put(HarmonisePaths.PATH_VALUES, "Value");
069: m_pathObjectTagMapping.put(
070: HarmonisePaths.PATH_WORKFLOW_DEFINITIONS, "Value");
071: m_pathObjectTagMapping.put(HarmonisePaths.PATH_WORKFLOW_PROPS,
072: "Property");
073: m_pathObjectTagMapping.put(HarmonisePaths.PATH_WORKFLOW_STAGES,
074: "Value");
075: m_pathObjectTagMapping.put(HarmonisePaths.PATH_XSLT,
076: "XSLTResource");
077:
078: m_pathGroupTagMapping
079: .put(HarmonisePaths.PATH_ASSETS, "Section");
080: m_pathGroupTagMapping.put(HarmonisePaths.PATH_DOCUMENTS,
081: "Section");
082: m_pathGroupTagMapping.put(HarmonisePaths.PATH_COMPOSITION,
083: "XMLResourceGroup");
084: m_pathGroupTagMapping.put(HarmonisePaths.PATH_INCLUDES,
085: "XMLResourceGroup");
086: m_pathGroupTagMapping.put(HarmonisePaths.PATH_NEWSLETTER,
087: "Section");
088: m_pathGroupTagMapping.put(HarmonisePaths.PATH_PAGE_DEFINITION,
089: "PageGroup");
090: m_pathGroupTagMapping.put(HarmonisePaths.PATH_PROPERTIES,
091: "PropertyGroup");
092: m_pathGroupTagMapping.put(HarmonisePaths.PATH_RBS_PROPS,
093: "PropertyGroup");
094: m_pathGroupTagMapping.put(HarmonisePaths.PATH_RBS_VALS,
095: "ValueGroup");
096: m_pathGroupTagMapping.put(HarmonisePaths.PATH_REPORTS,
097: "XMLResourceGroup");
098: m_pathGroupTagMapping.put(HarmonisePaths.PATH_SITE_ASSETS,
099: "Section");
100: m_pathGroupTagMapping.put(HarmonisePaths.PATH_USERS,
101: "UserGroup");
102: m_pathGroupTagMapping.put(HarmonisePaths.PATH_VALUES,
103: "ValueGroup");
104: m_pathGroupTagMapping.put(
105: HarmonisePaths.PATH_WORKFLOW_DEFINITIONS, "ValueGroup");
106: m_pathGroupTagMapping.put(HarmonisePaths.PATH_WORKFLOW_PROPS,
107: "PropertyGroup");
108: m_pathGroupTagMapping.put(HarmonisePaths.PATH_WORKFLOW_STAGES,
109: "ValueGroup");
110: m_pathGroupTagMapping.put(HarmonisePaths.PATH_XSLT,
111: "XSLTResourceGroup");
112: }
113:
114: /**
115: *
116: */
117: private PathTagMapping() {
118: super ();
119: }
120:
121: /**
122: * Returns the tag name for a given object path.
123: *
124: * @param sPath Full path
125: * @return Tag name
126: */
127: public static String getObjectTagName(String sPath) {
128: String sTagName = null;
129:
130: Iterator itor = m_pathObjectTagMapping.keySet().iterator();
131: while (itor.hasNext()) {
132: String element = (String) itor.next();
133: if (sPath.startsWith(element)) {
134: sTagName = (String) m_pathObjectTagMapping.get(element);
135: break;
136: }
137: }
138:
139: return sTagName;
140: }
141:
142: /**
143: * Returns the tag name for a given group path.
144: *
145: * @param sPath Full path
146: * @return Tag name
147: */
148: public static String getGroupTagName(String sPath) {
149: String sTagName = null;
150:
151: Iterator itor = m_pathGroupTagMapping.keySet().iterator();
152: while (itor.hasNext()) {
153: String element = (String) itor.next();
154: if (sPath.startsWith(element)) {
155: sTagName = (String) m_pathGroupTagMapping.get(element);
156: break;
157: }
158: }
159:
160: return sTagName;
161: }
162: }
|