SmartAPI
Open Source .NET RQL library for RedDot CMS / OpenText WSM Management Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
IGlobalWorkflows.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;
17 using System.Collections.Generic;
18 using erminas.SmartAPI.CMS.Project.ContentClasses.Elements;
19 using erminas.SmartAPI.CMS.Project.Workflows;
20 
21 namespace erminas.SmartAPI.CMS.Project
22 {
24  {
25  }
26 
27  internal class GlobalWorkflows : IGlobalWorkflows
28  {
29  private readonly IProject _project;
30  private readonly WorkflowAssignments _workflowAssignments;
31 
32  internal GlobalWorkflows(IProject project)
33  {
34  _project = project;
35  _workflowAssignments = new WorkflowAssignments(new ProjectWrapper(project));
36  }
37 
38  public void CreateAndConnectContentWorkflow(string workflowName, params string[] languageVariants)
39  {
40  _workflowAssignments.CreateAndConnectContentWorkflow(workflowName, languageVariants);
41  }
42 
43  public void CreateAndConnectContentWorkflow(string workflowName, IEnumerable<ILanguageVariant> languageVariants)
44  {
45  _workflowAssignments.CreateAndConnectContentWorkflow(workflowName, languageVariants);
46  }
47 
48  public void CreateAndConnectStructuralworkflow(string workflowName)
49  {
50  _workflowAssignments.CreateAndConnectStructuralworkflow(workflowName);
51  }
52 
53  public void DisconnectAllWorkflows()
54  {
55  _workflowAssignments.DisconnectAllWorkflows();
56  }
57 
58  public IPreassignedWorkflow GetContentWorkflowFor(string languageVariantId)
59  {
60  return _workflowAssignments.GetContentWorkflowFor(languageVariantId);
61  }
62 
63  public IPreassignedWorkflow GetContentWorkflowFor(ILanguageVariant languageVariant)
64  {
65  return _workflowAssignments.GetContentWorkflowFor(languageVariant);
66  }
67 
68  public IPreassignedWorkflow GetContentWorkflowForCurrentLanguageVariant()
69  {
70  return _workflowAssignments.GetContentWorkflowForCurrentLanguageVariant();
71  }
72 
73  public void InvalidateCache()
74  {
75  _workflowAssignments.InvalidateCache();
76  }
77 
78  public IProject Project
79  {
80  get { return _project; }
81  }
82 
83  public ISession Session
84  {
85  get { return _project.Session; }
86  }
87 
88  public void SetContentWorkflow(IWorkflow workflow, IEnumerable<ILanguageVariant> languageVariants)
89  {
90  _workflowAssignments.SetContentWorkflow(workflow, languageVariants);
91  }
92 
93  public void SetContentWorkflow(IWorkflow workflow, params string[] languageVariantIds)
94  {
95  _workflowAssignments.SetContentWorkflow(workflow, languageVariantIds);
96  }
97 
98  public IPreassignedWorkflow StructuralWorkflow
99  {
100  get { return _workflowAssignments.StructuralWorkflow; }
101  set { _workflowAssignments.StructuralWorkflow = value; }
102  }
103 
104  private class ProjectWrapper : IWorkflowAssignable
105  {
106  private readonly IProject _project;
107 
108  internal ProjectWrapper(IProject project)
109  {
110  _project = project;
111  }
112 
113  public Guid Guid
114  {
115  get { return Project.Guid; }
116  }
117 
118  public string Name
119  {
120  get { return Project.Name; }
121  }
122 
123  public IProject Project
124  {
125  get { return _project; }
126  }
127 
128  public ISession Session
129  {
130  get { return Project.Session; }
131  }
132  }
133  }
134 }