Skip to content

Commit 8e0d700

Browse files
committed
Fix issue with default zone implementation
Fix an issue whereby the default zone for an environment was not able to be configured and used. Update project version numbers to reflect recent changes.
1 parent 92805fd commit 8e0d700

36 files changed

Lines changed: 1319 additions & 76 deletions

Code/Sif3Framework/Sif.Framework.EnvironmentProvider/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
//
3232
// You can specify all the values or you can default the Revision and Build Numbers
3333
// by using the '*' as shown below:
34-
[assembly: AssemblyVersion("1.1.1.0")]
35-
[assembly: AssemblyFileVersion("1.1.1.0")]
34+
[assembly: AssemblyVersion("2.0.0.0")]
35+
[assembly: AssemblyFileVersion("2.0.0.0")]

Code/Sif3Framework/Sif.Framework.EnvironmentProvider/SifFramework.cfg.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
<!-- SQL Server LocalDB specific properties -->
1212
<!--
13-
<property name="connection.connection_string">Server=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\Users\capta_000\Documents\GitHub\Sif3Framework-dotNet\Data\Databases\LocalDB\SifFrameworkDatabase.mdf;</property>
13+
<property name="connection.connection_string">Server=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\Users\user\Documents\GitHub\Sif3Framework-dotNet\Data\Databases\LocalDB\SifFrameworkDatabase.mdf;</property>
1414
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
1515
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
1616
<property name="hbm2ddl.keywords">auto-quote</property>
1717
-->
1818

1919
<!-- SQL Server specific properties -->
2020
<!--
21-
<property name="connection.connection_string">Server=(local);initial catalog=nhibernate;Integrated Security=SSPI</property>
21+
<property name="connection.connection_string">Server=machine_name\SQLEXPRESS;Database=SifFrameworkDatabase;Trusted_Connection=True;</property>
2222
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
2323
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
2424
<property name="hbm2ddl.keywords">auto-quote</property>

Code/Sif3Framework/Sif.Framework.Tests/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.1.0")]
36-
[assembly: AssemblyFileVersion("1.1.1.0")]
35+
[assembly: AssemblyVersion("2.0.0.0")]
36+
[assembly: AssemblyFileVersion("2.0.0.0")]

Code/Sif3Framework/Sif.Framework/Model/Infrastructure/EnvironmentRegister.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 Systemic Pty Ltd
2+
* Copyright 2016 Systemic Pty Ltd
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@ public class EnvironmentRegister : IPersistable<long>
2727

2828
public virtual string ApplicationKey { get; set; }
2929

30+
public virtual Zone DefaultZone { get; set; }
31+
3032
public virtual IDictionary<InfrastructureServiceNames, InfrastructureService> InfrastructureServices { get; set; }
3133

3234
public virtual string InstanceId { get; set; }

Code/Sif3Framework/Sif.Framework/Model/Infrastructure/Zone.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 Systemic Pty Ltd
2+
* Copyright 2016 Systemic Pty Ltd
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,21 +15,22 @@
1515
*/
1616

1717
using Sif.Framework.Model.Persistence;
18-
using System;
1918
using System.Collections.Generic;
2019

2120
namespace Sif.Framework.Model.Infrastructure
2221
{
2322

24-
public class Zone : IPersistable<Guid>
23+
public class Zone : IPersistable<long>
2524
{
2625

27-
public virtual Guid Id { get; set; }
26+
public virtual long Id { get; set; }
2827

2928
public virtual string Description { get; set; }
3029

3130
public virtual IDictionary<string, Property> Properties { get; set; }
3231

32+
public virtual string SifId { get; set; }
33+
3334
}
3435

3536
}

Code/Sif3Framework/Sif.Framework/Persistence/NHibernate/Mapping/EnvironmentRegister.hbm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<property name="InstanceId" column="INSTANCE_ID" length="256"/>
99
<property name="SolutionId" column="SOLUTION_ID" length="256"/>
1010
<property name="UserToken" column="USER_TOKEN" length="256"/>
11+
<many-to-one name="DefaultZone" column="ZONE_ID" class="Sif.Framework.Model.Infrastructure.Zone" cascade="all" fetch="join"/>
1112
<map name="InfrastructureServices" table="ENVIRONMENT_REGISTER_INFRASTRUCTURE_SERVICES" cascade="all" lazy="false">
1213
<key column="ENVIRONMENT_REGISTER_ID"/>
1314
<index column="NAME" type="InfrastructureServiceNames"/>

Code/Sif3Framework/Sif.Framework/Persistence/NHibernate/Mapping/Zone.hbm.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Sif.Framework" namespace="Sif.Framework.Model.Infrastructure">
33
<class name="Zone" table="ZONE">
4-
<id name="Id" type="Guid" column="ZONE_ID">
5-
<generator class="guid"/>
4+
<id name="Id" column="ZONE_ID">
5+
<generator class="native"/>
66
</id>
7+
<property name="SifId" column="SIF_ID" length="64"/>
78
<property name="Description" column="DESCRIPTION" length="256"/>
89
<map name="Properties" table="ZONE_PROPERTIES" cascade="all" lazy="false">
910
<key column="ZONE_ID"/>

Code/Sif3Framework/Sif.Framework/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.1.0")]
36-
[assembly: AssemblyFileVersion("1.1.1.0")]
35+
[assembly: AssemblyVersion("2.0.0.0")]
36+
[assembly: AssemblyFileVersion("2.0.0.0")]
3737

3838
// Configure log4net using the .config file
3939
[assembly: log4net.Config.XmlConfigurator(Watch = true)]

Code/Sif3Framework/Sif.Framework/Service/Infrastructure/EnvironmentService.cs

Lines changed: 83 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 Systemic Pty Ltd
2+
* Copyright 2016 Systemic Pty Ltd
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,91 +30,137 @@ namespace Sif.Framework.Service.Infrastructure
3030
public class EnvironmentService : SifService<environmentType, Environment>, IEnvironmentService
3131
{
3232

33+
private Zone CopyDefaultZone(Zone sourceZone)
34+
{
35+
Zone destinationZone = null;
36+
37+
if (sourceZone != null)
38+
{
39+
destinationZone = new Zone { Description = sourceZone.Description, SifId = sourceZone.SifId };
40+
41+
if (sourceZone.Properties != null)
42+
{
43+
destinationZone.Properties = CopyProperties(sourceZone.Properties);
44+
}
45+
46+
}
47+
48+
return destinationZone;
49+
}
50+
3351
private IDictionary<InfrastructureServiceNames, InfrastructureService> CopyInfrastructureServices(IDictionary<InfrastructureServiceNames, InfrastructureService> sourceInfrastructureServices)
3452
{
35-
IDictionary<InfrastructureServiceNames, InfrastructureService> destinationInfrastructureServices = new Dictionary<InfrastructureServiceNames, InfrastructureService>();
53+
IDictionary<InfrastructureServiceNames, InfrastructureService> destinationInfrastructureServices = null;
3654

37-
if (sourceInfrastructureServices != null && sourceInfrastructureServices.Count > 0)
55+
if (sourceInfrastructureServices != null)
3856
{
57+
destinationInfrastructureServices = new Dictionary<InfrastructureServiceNames, InfrastructureService>();
3958

40-
foreach (InfrastructureService sourceInfrastructureService in sourceInfrastructureServices.Values)
59+
foreach (InfrastructureServiceNames key in sourceInfrastructureServices.Keys)
4160
{
61+
InfrastructureService sourceInfrastructureService;
62+
sourceInfrastructureServices.TryGetValue(key, out sourceInfrastructureService);
4263
InfrastructureService destinationInfrastructureService = new InfrastructureService { Name = sourceInfrastructureService.Name, Value = sourceInfrastructureService.Value };
43-
destinationInfrastructureServices.Add(destinationInfrastructureService.Name, destinationInfrastructureService);
64+
destinationInfrastructureServices.Add(key, destinationInfrastructureService);
4465
}
4566

4667
}
4768

4869
return destinationInfrastructureServices;
4970
}
5071

51-
private IDictionary<string, Right> CopyRights(IDictionary<string, Right> sourceRights)
72+
private IDictionary<string, Property> CopyProperties(IDictionary<string, Property> sourceProperties)
5273
{
53-
IDictionary<string, Right> destinationRights = new Dictionary<string, Right>();
74+
IDictionary<string, Property> destinationProperties = null;
5475

55-
if (sourceRights != null && sourceRights.Count > 0)
76+
if (sourceProperties != null)
5677
{
78+
destinationProperties = new Dictionary<string, Property>();
5779

58-
foreach (Right sourceRight in sourceRights.Values)
80+
foreach (string key in sourceProperties.Keys)
5981
{
60-
Right destinationRight = new Right { Type = sourceRight.Type, Value = sourceRight.Value };
61-
destinationRights.Add(destinationRight.Type, destinationRight);
82+
Property sourceProperty;
83+
sourceProperties.TryGetValue(key, out sourceProperty);
84+
Property destinationProperty = new Property { Name = sourceProperty.Name, Value = sourceProperty.Value };
85+
destinationProperties.Add(key, destinationProperty);
6286
}
6387

6488
}
6589

66-
return destinationRights;
90+
return destinationProperties;
6791
}
6892

69-
private ICollection<Model.Infrastructure.Service> CopyServices(ICollection<Model.Infrastructure.Service> sourceServices)
93+
private IDictionary<string, ProvisionedZone> CopyProvisionedZones(IDictionary<string, ProvisionedZone> sourceProvisionedZones)
7094
{
71-
ICollection<Model.Infrastructure.Service> destinationServices = new List<Model.Infrastructure.Service>();
95+
IDictionary<string, ProvisionedZone> destinationProvisionedZones = null;
7296

73-
if (sourceServices != null && sourceServices.Count > 0)
97+
if (sourceProvisionedZones != null)
7498
{
99+
destinationProvisionedZones = new Dictionary<string, ProvisionedZone>();
75100

76-
foreach (Model.Infrastructure.Service sourceService in sourceServices)
101+
foreach (string key in sourceProvisionedZones.Keys)
77102
{
78-
Model.Infrastructure.Service destinationService = new Model.Infrastructure.Service { ContextId = sourceService.ContextId, Name = sourceService.Name, Type = sourceService.Type };
79-
IDictionary<string, Right> rights = CopyRights(sourceService.Rights);
103+
ProvisionedZone sourceProvisionedZone;
104+
sourceProvisionedZones.TryGetValue(key, out sourceProvisionedZone);
105+
ProvisionedZone destinationProvisionedZone = new ProvisionedZone { SifId = sourceProvisionedZone.SifId };
80106

81-
if (rights.Count > 0)
107+
if (sourceProvisionedZone.Services != null)
82108
{
83-
destinationService.Rights = rights;
109+
destinationProvisionedZone.Services = CopyServices(sourceProvisionedZone.Services);
84110
}
85111

86-
destinationServices.Add(destinationService);
112+
destinationProvisionedZones.Add(key, destinationProvisionedZone);
87113
}
88114

89115
}
90116

91-
return destinationServices;
117+
return destinationProvisionedZones;
92118
}
93119

94-
private IDictionary<string, ProvisionedZone> CopyProvisionedZones(IDictionary<string, ProvisionedZone> sourceProvisionedZones)
120+
private IDictionary<string, Right> CopyRights(IDictionary<string, Right> sourceRights)
95121
{
96-
IDictionary<string, ProvisionedZone> destinationProvisionedZones = new Dictionary<string, ProvisionedZone>();
122+
IDictionary<string, Right> destinationRights = null;
97123

98-
if (sourceProvisionedZones != null && sourceProvisionedZones.Count > 0)
124+
if (sourceRights != null)
99125
{
126+
destinationRights = new Dictionary<string, Right>();
100127

101-
foreach (ProvisionedZone sourceProvisionedZone in sourceProvisionedZones.Values)
128+
foreach (string key in sourceRights.Keys)
102129
{
130+
Right sourceRight;
131+
sourceRights.TryGetValue(key, out sourceRight);
132+
Right destinationRight = new Right { Type = sourceRight.Type, Value = sourceRight.Value };
133+
destinationRights.Add(key, destinationRight);
134+
}
103135

104-
ProvisionedZone destinationProvisionedZone = new ProvisionedZone { SifId = sourceProvisionedZone.SifId };
105-
ICollection<Model.Infrastructure.Service> services = CopyServices(sourceProvisionedZone.Services);
136+
}
137+
138+
return destinationRights;
139+
}
140+
141+
private ICollection<Model.Infrastructure.Service> CopyServices(ICollection<Model.Infrastructure.Service> sourceServices)
142+
{
143+
ICollection<Model.Infrastructure.Service> destinationServices = null;
106144

107-
if (services.Count > 0)
145+
if (sourceServices != null)
146+
{
147+
destinationServices = new List<Model.Infrastructure.Service>();
148+
149+
foreach (Model.Infrastructure.Service sourceService in sourceServices)
150+
{
151+
Model.Infrastructure.Service destinationService = new Model.Infrastructure.Service { ContextId = sourceService.ContextId, Name = sourceService.Name, Type = sourceService.Type };
152+
153+
if (sourceService.Rights != null)
108154
{
109-
destinationProvisionedZone.Services = services;
155+
destinationService.Rights = CopyRights(sourceService.Rights);
110156
}
111157

112-
destinationProvisionedZones.Add(destinationProvisionedZone.SifId, destinationProvisionedZone);
158+
destinationServices.Add(destinationService);
113159
}
114160

115161
}
116162

117-
return destinationProvisionedZones;
163+
return destinationServices;
118164
}
119165

120166
public EnvironmentService()
@@ -151,6 +197,11 @@ public override Guid Create(environmentType item)
151197
IDictionary<string, ProvisionedZone> provisionedZones = CopyProvisionedZones(environmentRegister.ProvisionedZones);
152198
Environment repoItem = MapperFactory.CreateInstance<environmentType, Environment>(item);
153199

200+
if (environmentRegister.DefaultZone != null)
201+
{
202+
repoItem.DefaultZone = CopyDefaultZone(environmentRegister.DefaultZone);
203+
}
204+
154205
if (infrastructureServices.Count > 0)
155206
{
156207
repoItem.InfrastructureServices = CopyInfrastructureServices(environmentRegister.InfrastructureServices);

Code/Sif3Framework/Sif.Framework/Service/Mapper/MapperFactory.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,11 @@ static MapperFactory()
167167
.ForMember(dest => dest.Id, opt => opt.Ignore());
168168

169169
AutoMapper.Mapper.CreateMap<Zone, zoneType>()
170+
.ForMember(dest => dest.id, opt => opt.MapFrom(src => src.SifId))
170171
.ForMember(dest => dest.properties, opt => opt.MapFrom(src => src.Properties.Values));
171172
AutoMapper.Mapper.CreateMap<zoneType, Zone>()
172-
.ForMember(dest => dest.Id, opt => opt.Ignore());
173+
.ForMember(dest => dest.Id, opt => opt.Ignore())
174+
.ForMember(dest => dest.SifId, opt => opt.MapFrom(src => src.id));
173175

174176
AutoMapper.Mapper.CreateMap<ResponseError, errorType>();
175177
AutoMapper.Mapper.CreateMap<errorType, ResponseError>();

0 commit comments

Comments
 (0)