Skip to content

Commit

Permalink
Merge pull request #11 from nsip/develop-events
Browse files Browse the repository at this point in the history
Develop events
  • Loading branch information
joerghuber authored Sep 6, 2017
2 parents 3f86be8 + adc785d commit ec7eab4
Show file tree
Hide file tree
Showing 104 changed files with 86,500 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.2.1.3")]
[assembly: AssemblyFileVersion("3.2.1.3")]
[assembly: AssemblyVersion("3.2.1.4")]
[assembly: AssemblyFileVersion("3.2.1.4")]
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.1.3")]
[assembly: AssemblyFileVersion("3.2.1.3")]
[assembly: AssemblyVersion("3.2.1.4")]
[assembly: AssemblyFileVersion("3.2.1.4")]
5 changes: 3 additions & 2 deletions Code/Sif3Framework/Sif.Framework/Consumers/Consumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using System.Collections.Generic;
using System.Net;
using System.Text;
using Sif.Framework.Model.Infrastructure;
using Environment = Sif.Framework.Model.Infrastructure.Environment;

namespace Sif.Framework.Consumers
Expand Down Expand Up @@ -339,11 +340,11 @@ public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditio

if (navigationPage.HasValue && navigationPageSize.HasValue)
{
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, navigationPage: (int)navigationPage, navigationPageSize: (int)navigationPageSize);
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, ServiceType.SERVICEPATH, navigationPage: (int)navigationPage, navigationPageSize: (int)navigationPageSize);
}
else
{
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken);
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, ServiceType.SERVICEPATH);
}

return DeserialiseMultiple(xml);
Expand Down
34 changes: 34 additions & 0 deletions Code/Sif3Framework/Sif.Framework/Model/Events/EventAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2017 Systemic Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*/

using System.ComponentModel;

namespace Sif.Framework.Model.Events
{

/// <summary>
/// The action (type of event) associated with SIF Events.
/// </summary>
public enum EventAction {
CREATE,
DELETE,
[Description("UPDATE")]
UPDATE_FULL,
[Description("UPDATE")]
UPDATE_PARTIAL
}

}
43 changes: 43 additions & 0 deletions Code/Sif3Framework/Sif.Framework/Model/Events/IEventIterator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2017 Systemic Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*/

namespace Sif.Framework.Model.Events
{

/// <summary>
/// Interface to allow Providers to iterate through SIF Events.
/// </summary>
public interface IEventIterator<TMultiple>
{

/// <summary>
/// This method returns the next available SIF Event.
/// </summary>
/// <returns>The next available SIF Event. This must return null if there are no further SIF Events available.</returns>
/// <exception cref="Exceptions.EventException">All errors should be wrapped by this exception.</exception>
SifEvent<TMultiple> GetNext();

/// <summary>
/// This method will check whether there are more SIF Events available, i.e. a call to GetNext() will not
/// return null.
/// </summary>
/// <returns>True if there are more SIF Events available; False otherwise.</returns>
/// <exception cref="Exceptions.EventException">All errors should be wrapped by this exception.</exception>
bool HasNext();

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2017 Systemic Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*/

namespace Sif.Framework.Model.Events
{

/// <summary>
/// This interface defines serialisation operations for SIF Event payloads.
/// </summary>
/// <typeparam name="TMultiple">Type that defines a SIF Events entity.</typeparam>
public interface IEventPayloadSerialisable<TMultiple>
{

/// <summary>
/// Serialise a SIF Events entity.
/// </summary>
/// <param name="obj">Payload of SIF Events.</param>
/// <returns>XML string representation of the SIF Events.</returns>
string SerialiseEvents(TMultiple obj);

}

}
45 changes: 45 additions & 0 deletions Code/Sif3Framework/Sif.Framework/Model/Events/SifEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2017 Systemic Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*/

using System;

namespace Sif.Framework.Model.Events
{

/// <summary>
/// A wrapper class for associating a SIF Event with SIF data model objects.
/// </summary>
public class SifEvent<TMultiple>
{

/// <summary>
/// The action (type of event) associated with the SIF Event.
/// </summary>
public EventAction EventAction { get; set; }

/// <summary>
/// Unique identifier for the SIF Event.
/// </summary>
public Guid Id { get; set; }

/// <summary>
/// The SIF data model objects associated with the SIF Event.
/// </summary>
public TMultiple SifObjects { get; set; }

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2017 Systemic Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*/

using System;
using System.Runtime.Serialization;

namespace Sif.Framework.Model.Exceptions
{

/// <summary>
/// This exception represents an error from the processing of SIF Events.
/// </summary>
[Serializable]
public class EventException : BaseException
{

/// <summary>
/// <see cref="BaseException(string)"/>
/// </summary>
public EventException()
: base("Error occurred processing SIF Events.")
{
}

/// <summary>
/// <see cref="BaseException(string)"/>
/// </summary>
public EventException(string message)
: base(message)
{
}

/// <summary>
/// <see cref="BaseException(string, Exception)"/>
/// </summary>
public EventException(string message, Exception innerException)
: base(message, innerException)
{
}

/// <summary>
/// <see cref="BaseException(SerializationInfo, StreamingContext)"/>
/// </summary>
protected EventException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class CreateStatus : ResponseStatus
/// <summary>
/// The advisory SIF identifier provided with the create request.
/// </summary>
public string AdvisoryId { get; internal set; }
public string AdvisoryId { get; set; }

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class MultipleObjectResponse<TStatus>
/// <summary>
/// Status response records.
/// </summary>
public ICollection<TStatus> StatusRecords { get; internal set; }
public ICollection<TStatus> StatusRecords { get; set; }

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ public abstract class ResponseStatus
/// <summary>
/// Response error (if unsuccessful).
/// </summary>
public ResponseError Error { get; internal set; }
public ResponseError Error { get; set; }

/// <summary>
/// Allocated SIF identifier.
/// </summary>
public string Id { get; internal set; }
public string Id { get; set; }

/// <summary>
/// HTTP status code.
/// </summary>
public string StatusCode { get; internal set; }
public string StatusCode { get; set; }

}

Expand Down
4 changes: 2 additions & 2 deletions Code/Sif3Framework/Sif.Framework/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.1.3")]
[assembly: AssemblyFileVersion("3.2.1.3")]
[assembly: AssemblyVersion("3.2.1.4")]
[assembly: AssemblyFileVersion("3.2.1.4")]

// Make types and members with internal scope visible to the assembly containing unit tests.
[assembly: InternalsVisibleTo("Sif.Framework.Tests")]
18 changes: 18 additions & 0 deletions Code/Sif3Framework/Sif.Framework/Providers/BasicProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Sif.Framework.Model.DataModels;
using Sif.Framework.Model.Exceptions;
using Sif.Framework.Service.Providers;
using Sif.Framework.Service.Serialisation;
using Sif.Framework.Utils;
using Sif.Framework.WebApi.ModelBinders;
using Sif.Specification.Infrastructure;
Expand All @@ -25,6 +26,7 @@
using System.Linq;
using System.Net;
using System.Web.Http;
using System.Xml.Serialization;

namespace Sif.Framework.Providers
{
Expand Down Expand Up @@ -214,6 +216,22 @@ public override IHttpActionResult Put(List<T> objs, [MatrixParameter] string[] z
return result;
}

/// <summary>
/// <see cref="Provider{TSingle, TMultiple}.SerialiseEvents(TMultiple)">SerialiseEvents</see>
/// </summary>
[NonAction]
public override string SerialiseEvents(List<T> obj)
{

XmlRootAttribute xmlRootAttribute = new XmlRootAttribute(TypeName + "s")
{
Namespace = SettingsManager.ConsumerSettings.DataModelNamespace,
IsNullable = false
};

return SerialiserFactory.GetXmlSerialiser<List<T>>(xmlRootAttribute).Serialise(obj);
}

}

}
13 changes: 13 additions & 0 deletions Code/Sif3Framework/Sif.Framework/Providers/IProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ interface IProvider<TSingle, TMultiple, TPrimaryKey>
/// <returns>No objects, just message header information (void).</returns>
IHttpActionResult Head(string[] zoneId = null, string[] contextId = null);

/// <summary>
/// Broadcast SIF Events.
/// <para/>
/// <para>200 - Success, ok</para>
/// <para>400 - Failue, bad request</para>
/// <para>401 - Failure, unauthorised</para>
/// <para>500 - Failure, internal service error</para>
/// </summary>
/// <param name="zoneId">Zone associated with the SIF Events.</param>
/// <param name="contextId">Zone context.</param>
/// <returns>Ok</returns>
IHttpActionResult BroadcastEvents(string zoneId = null, string contextId = null);

}

}
Loading

0 comments on commit ec7eab4

Please sign in to comment.