Skip to content

Commit 451a4e1

Browse files
author
Joerg Huber
committed
Added zpne/context list to event object.
1 parent 36482bc commit 451a4e1

1 file changed

Lines changed: 71 additions & 7 deletions

File tree

  • SIF3InfraREST/sif3Common/src/main/java/sif3/common/model

SIF3InfraREST/sif3Common/src/main/java/sif3/common/model/SIFEvent.java

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.io.Serializable;
2222
import java.util.HashMap;
23+
import java.util.List;
2324

2425
import sif3.common.header.HeaderValues.EventAction;
2526
import sif3.common.header.HeaderValues.UpdateType;
@@ -29,7 +30,16 @@
2930
* It is expected that the object type this event class deals with is a list of objects a defined in the applicable data model specification.
3031
* To keep this class data model independent it is not possible to generically enforce how a "list of objects" is represented in the POJOs
3132
* of the data model and therefore it is necessary to pass on the size of the object list the event deals with as a parameter/property to
32-
* this class.
33+
* this class.<br/><br/>
34+
*
35+
* This class also has a property called limitToZoneCtxList. This property is managed in two ways depending if the adapter is a consumer or
36+
* a provider.<br/>
37+
* <b>PROVIDER</b><br/>
38+
* If this List is null or empty then it is assumed that the events are published to all zone and/or context the provider has appropriate
39+
* access rights to as per its environment. If this list has any entries then events are published to the zone & contexts listed only.<br/>
40+
* <b>CONSUMER<b><br/>
41+
* This property will be set by the framework and will only hold one single entry. The entry holds the zone and context from where the
42+
* event has been received.
3343
*
3444
* @author Joerg Huber
3545
*/
@@ -43,11 +53,12 @@ public class SIFEvent<L> implements Serializable
4353
private UpdateType updateType;
4454
private String fingerprint;
4555
private HashMap<String, String> metadata = new HashMap<String, String>();
56+
private List<ZoneContextInfo> limitToZoneCtxList = null;
4657

47-
public SIFEvent()
48-
{
49-
this(null, null, null, 0);
50-
}
58+
public SIFEvent()
59+
{
60+
this(null, null, null, 0, null);
61+
}
5162

5263
/**
5364
* Constructor
@@ -59,15 +70,42 @@ public SIFEvent()
5970
* @param listSize Since this class is independent from the data model it cannot automatically determine how many objects are in the
6071
* sifObjectList. The sifObjectList could be any data structure. To indicate the number of object in the sifObjectList
6172
* this field must be set.
73+
* @param limitToZoneCtxList This property is managed in two ways depending if the adapter is a consumer or provider.<br/>
74+
* PROVIDER:<br/>
75+
* If this List is null or empty then it is assumed that the events are published to all zone and/or context
76+
* the provider has appropriate access rights to as per its environment. If this list has any entries then
77+
* events are published to the zone & contexts listed only.<br/>
78+
* CONSUMER:<br/>
79+
* This property will be set by the framework and will only hold one single entry. The entry holds the zone and
80+
* context from where the event has been received.
6281
*/
63-
public SIFEvent(L sifObjectList, EventAction eventAction, UpdateType updateType, int listSize)
82+
public SIFEvent(L sifObjectList, EventAction eventAction, UpdateType updateType, int listSize, List<ZoneContextInfo> limitToZoneCtxList)
6483
{
6584
super();
6685
setSIFObjectList(sifObjectList);
6786
setEventAction(eventAction);
6887
setListSize(listSize);
6988
setUpdateType(updateType);
89+
setLimitToZoneCtxList(limitToZoneCtxList);
7090
}
91+
92+
/**
93+
* As above but the limitToZoneCtxList is defaulted to null.
94+
*
95+
* @param sifObjectList A list style object that encapsulates the list of objects to pack into an event.
96+
* @param eventAction The event action for this event. Note that all object in the sifObjectList will be published with this event action.
97+
* @param updateType If the event action is UPDATE then this update type is required to indicate if the data in the sifObjectList are
98+
* partial updates (only updated fields are provided in the event) or are full updates (all known fields to that provider
99+
* for the objects are provided).
100+
* @param listSize Since this class is independent from the data model it cannot automatically determine how many objects are in the
101+
* sifObjectList. The sifObjectList could be any data structure. To indicate the number of object in the sifObjectList
102+
* this field must be set.
103+
*/
104+
public SIFEvent(L sifObjectList, EventAction eventAction, UpdateType updateType, int listSize)
105+
{
106+
this(sifObjectList, eventAction, updateType, listSize, null);
107+
}
108+
71109

72110
public L getSIFObjectList()
73111
{
@@ -157,13 +195,39 @@ public void addMetadataValue(String name, String value)
157195
{
158196
getMetadata().put(name, value);
159197
}
198+
199+
public List<ZoneContextInfo> getLimitToZoneCtxList()
200+
{
201+
return limitToZoneCtxList;
202+
}
203+
204+
/**
205+
* If the events shall only be sent to a given zone and context list then this list can be defined here. The internal publishing method
206+
* will get this list and will attempt to send the events to the zone and context defined in this list only. If this list is null or empty
207+
* then the internal publishing method will attempt to send the events to all zones and context the provider has publish rights to. This
208+
* is based on the environment of the provider.
209+
*
210+
* @param limitToZoneCtxList This property is managed in two ways depending if the adapter is a consumer or provider.<br/>
211+
* PROVIDER:<br/>
212+
* If this List is null or empty then it is assumed that the events are published to all zone and/or context
213+
* the provider has appropriate access rights to as per its environment. If this list has any entries then
214+
* events are published to the zone & contexts listed only.<br/>
215+
* CONSUMER:<br/>
216+
* This property will be set by the framework and will only hold one single entry. The entry holds the zone and
217+
* context from where the event has been received.
218+
*/
219+
public void setLimitToZoneCtxList(List<ZoneContextInfo> limitToZoneCtxList)
220+
{
221+
this.limitToZoneCtxList = limitToZoneCtxList;
222+
}
160223

161224
@Override
162225
public String toString()
163226
{
164227
return "SIFEvent [sifObjectList=" + sifObjectList + ", eventAction=" + eventAction
165228
+ ", listSize=" + listSize + ", updateType=" + updateType + ", fingerprint="
166-
+ fingerprint + ", metadata=" + metadata + "]";
229+
+ fingerprint + ", metadata=" + metadata + ", limitToZoneCtxList="
230+
+ limitToZoneCtxList + "]";
167231
}
168232

169233

0 commit comments

Comments
 (0)