Skip to content

Commit

Permalink
+ Added Group History feature
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDPeterson committed May 7, 2018
1 parent d354a6b commit 010d04f
Show file tree
Hide file tree
Showing 165 changed files with 11,110 additions and 956 deletions.
89 changes: 89 additions & 0 deletions Dev Tools/Sql/Populate_GroupHistory.sql
@@ -0,0 +1,89 @@
declare
@personId int = (select top 1 Id from Person where NickName = 'Ted' and LastName = 'Decker') /*Get PersonId for Ted Decker*/

delete from GroupMemberHistorical where GroupMemberId in (select Id from GroupMember where PersonId = @personId)

DECLARE @FakeDatesTable TABLE (
[EffectiveDateTime] DATETIME
,[ExpireDateTime] DATETIME
,[IsArchived] BIT
,[CurrentRowIndicator] BIT
)
DECLARE @StartDateTime DATETIME = DateAdd(year, - 10, SysDateTime())
,@StopDateTime DATETIME = SysDateTime()
DECLARE @EffectiveDateTime DATETIME = @StartDateTime
,@ExpireDateTime DATETIME
,@IsArchived BIT = 0
,@CurrentRowIndicator BIT = 0

set nocount on
WHILE (@EffectiveDateTime < @StopDateTime)
BEGIN
SET @ExpireDateTime = dateadd(MI, floor(RAND() * 180*24*60), @EffectiveDateTime)
if @ExpireDateTime >= @StopDateTime begin
set @ExpireDateTime = '9999-01-01 00:00:00.000'
set @CurrentRowIndicator = 1
end

INSERT INTO @FakeDatesTable (
EffectiveDateTime
,ExpireDateTime
,IsArchived
,CurrentRowIndicator
)
VALUES (
@EffectiveDateTime
,@ExpireDateTime
,@IsArchived
,@CurrentRowIndicator
);

SET @EffectiveDateTime = @ExpireDateTime;
SET @IsArchived = case when @IsArchived = 1 then 0 else 1 end
END

set nocount off

INSERT INTO [dbo].[GroupMemberHistorical] (
[GroupMemberId]
,[GroupId]
,[GroupRoleId]
,[GroupRoleName]
,[IsLeader]
,[GroupMemberStatus]
,[IsArchived]
,[ArchivedDateTime]
,[ArchivedByPersonAliasId]
,[InactiveDateTime]
,[EffectiveDateTime]
,[ExpireDateTime]
,[CurrentRowIndicator]
,[CreatedDateTime]
,[Guid]
)
SELECT gm.[Id] [GroupMemberId]
,gm.[GroupId]
,gm.[GroupRoleId]
,r.[Name] [GroupRoleName]
,r.[IsLeader]
,gm.[GroupMemberStatus]
,fd.[IsArchived]
,gm.[ArchivedDateTime]
,gm.[ArchivedByPersonAliasId]
,gm.[InactiveDateTime]
,fd.[EffectiveDateTime]
,fd.[ExpireDateTime]
,fd.[CurrentRowIndicator]
,fd.[EffectiveDateTime] [CreatedDateTime]
,NEWID() [Guid]
FROM GroupMember gm
join GroupTypeRole r on gm.GroupRoleId = r.Id
join @FakeDatesTable fd on 1=1
where gm.PersonId = @personId
and gm.GroupId in (select GroupId from GroupHistorical)
and gm.Id not in (select GroupMemberId from GroupMemberHistorical)
order by gm.Id




8 changes: 8 additions & 0 deletions Rock.Client/CodeGenerated/Attribute.cs
Expand Up @@ -43,6 +43,9 @@ public partial class AttributeEntity
/// <summary />
public string Description { get; set; }

/// <summary />
public bool EnableHistory { get; set; }

/// <summary />
public int? EntityTypeId { get; set; }

Expand All @@ -64,6 +67,9 @@ public partial class AttributeEntity
/// <summary />
public string IconCssClass { get; set; }

/// <summary />
public bool IsActive { get; set; }

/// <summary />
public bool IsAnalytic { get; set; }

Expand Down Expand Up @@ -135,13 +141,15 @@ public void CopyPropertiesFrom( Attribute source )
this.AllowSearch = source.AllowSearch;
this.DefaultValue = source.DefaultValue;
this.Description = source.Description;
this.EnableHistory = source.EnableHistory;
this.EntityTypeId = source.EntityTypeId;
this.EntityTypeQualifierColumn = source.EntityTypeQualifierColumn;
this.EntityTypeQualifierValue = source.EntityTypeQualifierValue;
this.FieldTypeId = source.FieldTypeId;
this.ForeignGuid = source.ForeignGuid;
this.ForeignKey = source.ForeignKey;
this.IconCssClass = source.IconCssClass;
this.IsActive = source.IsActive;
this.IsAnalytic = source.IsAnalytic;
this.IsAnalyticHistory = source.IsAnalyticHistory;
this.IsGridColumn = source.IsGridColumn;
Expand Down
3 changes: 3 additions & 0 deletions Rock.Client/CodeGenerated/AttributeValue.cs
Expand Up @@ -115,6 +115,9 @@ public partial class AttributeValue : AttributeValueEntity
/// <summary />
public Attribute Attribute { get; set; }

/// <summary />
public ICollection<AttributeValueHistorical> AttributeValuesHistorical { get; set; }

/// <summary />
public bool? ValueAsBoolean { get; set; }

Expand Down
152 changes: 152 additions & 0 deletions Rock.Client/CodeGenerated/AttributeValueHistorical.cs
@@ -0,0 +1,152 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Rock.CodeGeneration project
// Changes to this file will be lost when the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
// <copyright>
// Copyright by the Spark Development Network
//
// Licensed under the Rock Community License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.rockrms.com/license
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
//
using System;
using System.Collections.Generic;


namespace Rock.Client
{
/// <summary>
/// Base client model for AttributeValueHistorical that only includes the non-virtual fields. Use this for PUT/POSTs
/// </summary>
public partial class AttributeValueHistoricalEntity
{
/// <summary />
public int Id { get; set; }

/// <summary />
public int AttributeValueId { get; set; }

/// <summary />
public bool CurrentRowIndicator { get; set; }

/// <summary />
public DateTime EffectiveDateTime { get; set; }

/// <summary />
public DateTime ExpireDateTime { get; set; }

/// <summary />
public Guid? ForeignGuid { get; set; }

/// <summary />
public string ForeignKey { get; set; }

/// <summary>
/// If the ModifiedByPersonAliasId is being set manually and should not be overwritten with current user when saved, set this value to true
/// </summary>
public bool ModifiedAuditValuesAlreadyUpdated { get; set; }

/// <summary />
public string Value { get; set; }

/// <summary />
public bool? ValueAsBoolean { get; set; }

/// <summary />
public DateTime? ValueAsDateTime { get; set; }

/// <summary />
public decimal? ValueAsNumeric { get; set; }

/// <summary />
public int? ValueAsPersonId { get; set; }

/// <summary />
public string ValueFormatted { get; set; }

/// <summary>
/// Leave this as NULL to let Rock set this
/// </summary>
public DateTime? CreatedDateTime { get; set; }

/// <summary>
/// This does not need to be set or changed. Rock will always set this to the current date/time when saved to the database.
/// </summary>
public DateTime? ModifiedDateTime { get; set; }

/// <summary>
/// Leave this as NULL to let Rock set this
/// </summary>
public int? CreatedByPersonAliasId { get; set; }

/// <summary>
/// If you need to set this manually, set ModifiedAuditValuesAlreadyUpdated=True to prevent Rock from setting it
/// </summary>
public int? ModifiedByPersonAliasId { get; set; }

/// <summary />
public Guid Guid { get; set; }

/// <summary />
public int? ForeignId { get; set; }

/// <summary>
/// Copies the base properties from a source AttributeValueHistorical object
/// </summary>
/// <param name="source">The source.</param>
public void CopyPropertiesFrom( AttributeValueHistorical source )
{
this.Id = source.Id;
this.AttributeValueId = source.AttributeValueId;
this.CurrentRowIndicator = source.CurrentRowIndicator;
this.EffectiveDateTime = source.EffectiveDateTime;
this.ExpireDateTime = source.ExpireDateTime;
this.ForeignGuid = source.ForeignGuid;
this.ForeignKey = source.ForeignKey;
this.ModifiedAuditValuesAlreadyUpdated = source.ModifiedAuditValuesAlreadyUpdated;
this.Value = source.Value;
this.ValueAsBoolean = source.ValueAsBoolean;
this.ValueAsDateTime = source.ValueAsDateTime;
this.ValueAsNumeric = source.ValueAsNumeric;
this.ValueAsPersonId = source.ValueAsPersonId;
this.ValueFormatted = source.ValueFormatted;
this.CreatedDateTime = source.CreatedDateTime;
this.ModifiedDateTime = source.ModifiedDateTime;
this.CreatedByPersonAliasId = source.CreatedByPersonAliasId;
this.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
this.Guid = source.Guid;
this.ForeignId = source.ForeignId;

}
}

/// <summary>
/// Client model for AttributeValueHistorical that includes all the fields that are available for GETs. Use this for GETs (use AttributeValueHistoricalEntity for POST/PUTs)
/// </summary>
public partial class AttributeValueHistorical : AttributeValueHistoricalEntity
{
/// <summary />
public AttributeValue AttributeValue { get; set; }

/// <summary>
/// NOTE: Attributes are only populated when ?loadAttributes is specified. Options for loadAttributes are true, false, 'simple', 'expanded'
/// </summary>
public Dictionary<string, Rock.Client.Attribute> Attributes { get; set; }

/// <summary>
/// NOTE: AttributeValues are only populated when ?loadAttributes is specified. Options for loadAttributes are true, false, 'simple', 'expanded'
/// </summary>
public Dictionary<string, Rock.Client.AttributeValue> AttributeValues { get; set; }
}
}
27 changes: 27 additions & 0 deletions Rock.Client/CodeGenerated/Enums/RockEnums.cs
Expand Up @@ -307,6 +307,33 @@ public enum GroupMemberWorkflowTriggerType
MemberPlacedElsewhere = 0x5,
}

/// <summary>
/// </summary>
public enum HistoryChangeType
{
Record = 0x0,
Property = 0x1,
Attribute = 0x2,
}

/// <summary>
/// </summary>
public enum HistoryVerb
{
Add = 0x0,
Modify = 0x1,
Delete = 0x2,
Registered = 0x3,
Process = 0x4,
Matched = 0x5,
Unmatched = 0x6,
Sent = 0x7,
Login = 0x8,
Merge = 0x9,
AddedToGroup = 0xa,
RemovedFromGroup = 0xb,
}

/// <summary>
/// </summary>
public enum IconCssWeight
Expand Down
19 changes: 19 additions & 0 deletions Rock.Client/CodeGenerated/Group.cs
Expand Up @@ -37,6 +37,12 @@ public partial class GroupEntity
/// <summary />
public bool? AllowGuests { get; set; }

/// <summary />
public int? ArchivedByPersonAliasId { get; set; }

/// <summary />
public DateTime? ArchivedDateTime { get; set; }

/// <summary />
public int? CampusId { get; set; }

Expand All @@ -55,9 +61,15 @@ public partial class GroupEntity
/// <summary />
public int GroupTypeId { get; set; }

/// <summary />
public DateTime? InactiveDateTime { get; set; }

/// <summary />
public bool IsActive { get; set; }

/// <summary />
public bool IsArchived { get; set; }

/// <summary />
public bool IsPublic { get; set; }

Expand Down Expand Up @@ -121,13 +133,17 @@ public void CopyPropertiesFrom( Group source )
{
this.Id = source.Id;
this.AllowGuests = source.AllowGuests;
this.ArchivedByPersonAliasId = source.ArchivedByPersonAliasId;
this.ArchivedDateTime = source.ArchivedDateTime;
this.CampusId = source.CampusId;
this.Description = source.Description;
this.ForeignGuid = source.ForeignGuid;
this.ForeignKey = source.ForeignKey;
this.GroupCapacity = source.GroupCapacity;
this.GroupTypeId = source.GroupTypeId;
this.InactiveDateTime = source.InactiveDateTime;
this.IsActive = source.IsActive;
this.IsArchived = source.IsArchived;
this.IsPublic = source.IsPublic;
this.IsSecurityRole = source.IsSecurityRole;
this.IsSystem = source.IsSystem;
Expand All @@ -152,6 +168,9 @@ public void CopyPropertiesFrom( Group source )
/// </summary>
public partial class Group : GroupEntity
{
/// <summary />
public PersonAlias ArchivedByPersonAlias { get; set; }

/// <summary />
public Campus Campus { get; set; }

Expand Down

0 comments on commit 010d04f

Please sign in to comment.