SmartAPI
Open Source .NET RQL library for RedDot CMS / OpenText WSM Management Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
IModule.cs
Go to the documentation of this file.
1 ï»¿// SmartAPI - .Net programmatic access to RedDot servers
2 //
3 // Copyright (C) 2013 erminas GbR
4 //
5 // This program is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free Software Foundation,
7 // either version 3 of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 // See the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program.
14 // If not, see <http://www.gnu.org/licenses/>.
15 
16 using System.Xml;
17 using erminas.SmartAPI.Exceptions;
18 using erminas.SmartAPI.Utils;
19 
20 namespace erminas.SmartAPI.CMS.ServerManagement
21 {
22  public enum ModuleType
23  {
24  NoModule = 0,
25  Cms,
26 
28  Search,
29  TemplateEditor,
30  Tasks,
31  Translation,
32  SmartEdit,
33  SmartTree,
34  ServerManager,
35  Assets,
36 
38  CollaborationManager,
40  DocumentManager,
41 
43  BusinessProcessManager,
44 
46  Ccs
47  }
48 
49  public static class ModuleTypeUtils
50  {
51  public static ModuleType ToModuleType(this string value)
52  {
53  switch (value)
54  {
55  case "cms":
56  return ModuleType.Cms;
57  case "search":
58  return ModuleType.Search;
59  case "templateeditor":
60  return ModuleType.TemplateEditor;
61  case "translation":
62  return ModuleType.Translation;
63  case "tasks":
64  return ModuleType.Tasks;
65  case "servermanager":
66  return ModuleType.ServerManager;
67  case "assets":
68  return ModuleType.Assets;
69  case "smartedit":
70  return ModuleType.SmartEdit;
71  case "smarttree":
72  return ModuleType.SmartTree;
73  case "collaboration":
74  return ModuleType.CollaborationManager;
75  case "dms":
76  return ModuleType.DocumentManager;
77  case "workflow":
78  return ModuleType.BusinessProcessManager;
79  case "ccs":
80  return ModuleType.Ccs;
81  default:
82  throw new SmartAPIInternalException(string.Format("Invalid string value for {0} conversion: {1}",
83  typeof (ModuleType).Name, value));
84  }
85  }
86 
87  public static string ToRQLString(this ModuleType type)
88  {
89  switch (type)
90  {
91  case ModuleType.Cms:
92  return "cms";
93  case ModuleType.Search:
94  return "search";
95  case ModuleType.TemplateEditor:
96  return "templateeditor";
97  case ModuleType.Translation:
98  return "translation";
99  case ModuleType.Tasks:
100  return "tasks";
101  case ModuleType.ServerManager:
102  return "servermanager";
103  case ModuleType.Assets:
104  return "assets";
105  case ModuleType.SmartEdit:
106  return "smartedit";
107  case ModuleType.SmartTree:
108  return "smarttree";
109  case ModuleType.BusinessProcessManager:
110  return "workflow";
111  case ModuleType.CollaborationManager:
112  return "collaboration";
113  case ModuleType.DocumentManager:
114  return "dms";
115  case ModuleType.Ccs:
116  return "ccs";
117  default:
118  throw new SmartAPIInternalException(string.Format("Invalid {0} for RQL string conversion: {1}",
119  typeof (ModuleType).Name, type));
120  }
121  }
122  }
123 
124  public interface IModule : IRedDotObject
125  {
126  ModuleType Type { get; }
127  }
128 
129  internal class Module : RedDotObject, IModule
130  {
131  internal Module(ISession session, XmlElement xmlElement) : base(session, xmlElement)
132  {
133  LoadXml(xmlElement);
134  }
135 
136  public ModuleType Type { get; private set; }
137 
138  private void LoadXml(XmlElement xmlElement)
139  {
140  Type = xmlElement.GetAttributeValue("id").ToModuleType();
141  }
142  }
143 }