diff --git a/source/Dovetail.SDK.Bootstrap/Dovetail.SDK.Bootstrap.csproj b/source/Dovetail.SDK.Bootstrap/Dovetail.SDK.Bootstrap.csproj
index 47204d54..338fc339 100644
--- a/source/Dovetail.SDK.Bootstrap/Dovetail.SDK.Bootstrap.csproj
+++ b/source/Dovetail.SDK.Bootstrap/Dovetail.SDK.Bootstrap.csproj
@@ -101,7 +101,7 @@
-
+
diff --git a/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/MergeCaseWithSubcaseHistoryAssemblerPolicy.cs b/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/CaseHistoryAssemblerPolicy.cs
similarity index 82%
rename from source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/MergeCaseWithSubcaseHistoryAssemblerPolicy.cs
rename to source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/CaseHistoryAssemblerPolicy.cs
index fcb5bbdb..7b0125ea 100644
--- a/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/MergeCaseWithSubcaseHistoryAssemblerPolicy.cs
+++ b/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/CaseHistoryAssemblerPolicy.cs
@@ -8,15 +8,13 @@
namespace Dovetail.SDK.Bootstrap.History.AssemblerPolicies
{
- public class MergeCaseWithSubcaseHistoryAssemblerPolicy : IHistoryAssemblerPolicy
+ public class CaseHistoryAssemblerPolicy : IHistoryAssemblerPolicy
{
private readonly IClarifySessionCache _sessionCache;
private readonly HistoryBuilder _historyBuilder;
private readonly HistorySettings _historySettings;
- //TODO add settings object to allow getting subcases to be configurable - default (do not get subcase)
-
- public MergeCaseWithSubcaseHistoryAssemblerPolicy(IClarifySessionCache sessionCache, HistoryBuilder historyBuilder, HistorySettings historySettings)
+ public CaseHistoryAssemblerPolicy(IClarifySessionCache sessionCache, HistoryBuilder historyBuilder, HistorySettings historySettings)
{
_sessionCache = sessionCache;
_historyBuilder = historyBuilder;
@@ -25,11 +23,16 @@ public MergeCaseWithSubcaseHistoryAssemblerPolicy(IClarifySessionCache sessionCa
public bool Handles(WorkflowObject workflowObject)
{
- return _historySettings.MergeCaseHistoryChildSubcases && workflowObject.Type == WorkflowObject.Case;
+ return workflowObject.Type == WorkflowObject.Case;
}
public IEnumerable BuildHistory(WorkflowObject workflowObject, Filter actEntryFilter)
{
+ if(!_historySettings.MergeCaseHistoryChildSubcases)
+ {
+ return _historyBuilder.Build(workflowObject, actEntryFilter);
+ }
+
var subcaseIds = GetSubcaseIds(workflowObject);
var caseHistory = _historyBuilder.Build(workflowObject, actEntryFilter);
diff --git a/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/DefaultHistoryAssemblerProvider.cs b/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/DefaultHistoryAssemblerProvider.cs
index 97a125da..9d4faa43 100644
--- a/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/DefaultHistoryAssemblerProvider.cs
+++ b/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/DefaultHistoryAssemblerProvider.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
using FChoice.Foundation.Filters;
namespace Dovetail.SDK.Bootstrap.History.AssemblerPolicies
@@ -21,5 +22,15 @@ public IEnumerable BuildHistory(WorkflowObject workflowObject, Filt
{
return _historyBuilder.Build(workflowObject, actEntryFilter);
}
+
+ public IEnumerable BuildHistories(string type, string[] ids, Filter actEntryFilter)
+ {
+ return ids.SelectMany(id =>
+ {
+ var workflowObject = WorkflowObject.Create(type, id);
+ return BuildHistory(workflowObject, actEntryFilter);
+ });
+ }
+
}
}
\ No newline at end of file
diff --git a/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/IHistoryAssemblerPolicy.cs b/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/IHistoryAssemblerPolicy.cs
index 05cb5fc5..3fe5f6df 100644
--- a/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/IHistoryAssemblerPolicy.cs
+++ b/source/Dovetail.SDK.Bootstrap/History/AssemblerPolicies/IHistoryAssemblerPolicy.cs
@@ -7,5 +7,6 @@ public interface IHistoryAssemblerPolicy
{
bool Handles(WorkflowObject workflowObject);
IEnumerable BuildHistory(WorkflowObject workflowObject, Filter actEntryFilter);
+ IEnumerable BuildHistories(string type, string[] ids, Filter actEntryFilter);
}
}
\ No newline at end of file
diff --git a/source/Dovetail.SDK.Bootstrap/History/HistoryAssembler.cs b/source/Dovetail.SDK.Bootstrap/History/HistoryAssembler.cs
index 5535bb37..b51e85bd 100644
--- a/source/Dovetail.SDK.Bootstrap/History/HistoryAssembler.cs
+++ b/source/Dovetail.SDK.Bootstrap/History/HistoryAssembler.cs
@@ -8,6 +8,9 @@ namespace Dovetail.SDK.Bootstrap.History
{
public interface IHistoryAssembler
{
+ HistoryItem[] GetHistories(string type, string[] ids);
+ HistoryItem[] GetHistoriesSince(string type, string[] ids, DateTime sinceDate);
+
HistoryViewModel GetHistory(WorkflowObject workflowObject);
HistoryViewModel GetHistoryTop(WorkflowObject workflowObject, int numberOfMostRecentEntries);
HistoryViewModel GetHistorySince(WorkflowObject workflowObject, DateTime sinceDate);
@@ -22,7 +25,32 @@ public HistoryAssembler(IEnumerable entityHistoryBuilde
_entityHistoryBuilders = entityHistoryBuilders;
}
- public HistoryViewModel GetHistory(WorkflowObject workflowObject)
+ public HistoryItem[] GetHistoriesSince(string type, string[] ids, DateTime sinceDate)
+ {
+ return getHistories(type, ids, ()=> new FilterExpression().MoreThan("entry_time", sinceDate));
+ }
+
+ public HistoryItem[] GetHistories(string type, string[] ids)
+ {
+ return getHistories(type, ids, null);
+ }
+
+ private HistoryItem[] getHistories(string type, string[] ids, Func filterFunc)
+ {
+ var workflowObject = WorkflowObject.Create(type, ids.FirstOrDefault());
+ var historyBuilderPolicy = _entityHistoryBuilders.First(policy => policy.Handles(workflowObject));
+
+ Filter filter = null;
+ if(filterFunc != null)
+ {
+ filter = filterFunc();
+ }
+
+ return historyBuilderPolicy.BuildHistories(type, ids, filter).ToArray();
+ }
+
+
+ public HistoryViewModel GetHistory(WorkflowObject workflowObject)
{
return getHistoryWithConstraint(workflowObject, null);
}
diff --git a/source/Dovetail.SDK.Bootstrap/History/HistoryViewModel.cs b/source/Dovetail.SDK.Bootstrap/History/HistoryViewModel.cs
index 10e7d5d1..a899123b 100644
--- a/source/Dovetail.SDK.Bootstrap/History/HistoryViewModel.cs
+++ b/source/Dovetail.SDK.Bootstrap/History/HistoryViewModel.cs
@@ -56,6 +56,6 @@ public class HistoryItemEmployee
public class HistoryViewModel
{
public WorkflowObject WorkflowObject { get; set; }
- public HistoryItem[] HistoryItems { get; set; }
+ public HistoryItem[] HistoryItems { get; set; }
}
}
\ No newline at end of file
diff --git a/source/Web/Handlers/api/histories/get_Type_handler.cs b/source/Web/Handlers/api/histories/get_Type_handler.cs
new file mode 100644
index 00000000..41026239
--- /dev/null
+++ b/source/Web/Handlers/api/histories/get_Type_handler.cs
@@ -0,0 +1,55 @@
+using System;
+using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
+using Dovetail.SDK.Bootstrap;
+using Dovetail.SDK.Bootstrap.History;
+using FubuMVC.Swagger.Specification;
+
+namespace Bootstrap.Web.Handlers.api.histories
+{
+ public class get_Type_handler
+ {
+ private readonly IHistoryAssembler _historyAssembler;
+
+ public get_Type_handler(IHistoryAssembler historyAssembler)
+ {
+ _historyAssembler = historyAssembler;
+ }
+
+ public HistoriesModel Execute(HistoriesRequest request)
+ {
+ var ids = request.Ids.Split(',');
+
+ var items = request.Since.HasValue ? _historyAssembler.GetHistoriesSince(request.Type, ids, request.Since.Value) : _historyAssembler.GetHistories(request.Type, ids);
+
+ return new HistoriesModel
+ {
+ HistoryItems = items,
+ Type = request.Type,
+ Ids = ids,
+ Since = request.Since
+ };
+ }
+ }
+
+ public class HistoriesModel
+ {
+ public string Type { get; set; }
+ public string[] Ids { get; set; }
+ public DateTime? Since { get; set; }
+ public HistoryItem[] HistoryItems { get; set; }
+ }
+
+ [Description("Workflow objects history")]
+ public class HistoriesRequest : IApi
+ {
+ [Required, Description("Type of workflow object. Typically this is 'case'.")]
+ [AllowableValues("case", "subcase", "solution", "")]
+ public string Type { get; set; }
+ [Required, Description("Ids of the workflow objects.")]
+ public string Ids { get; set; }
+
+ [Description("")]
+ public DateTime? Since{ get; set; }
+ }
+}
\ No newline at end of file
diff --git a/source/Web/Handlers/api/histories/histories.spark b/source/Web/Handlers/api/histories/histories.spark
new file mode 100644
index 00000000..e57d6965
--- /dev/null
+++ b/source/Web/Handlers/api/histories/histories.spark
@@ -0,0 +1,29 @@
+
+
+
+
+
+History for ${Model.Type} By Id
+
+
+
+
+
diff --git a/source/Web/Web.csproj b/source/Web/Web.csproj
index 3449e8db..0426ce06 100644
--- a/source/Web/Web.csproj
+++ b/source/Web/Web.csproj
@@ -152,6 +152,7 @@
+
@@ -165,6 +166,9 @@
+
+ Designer
+