@@ -181,8 +181,12 @@ private Map<String, UpstreamAPIContext> collectUpstreamContexts() {
181181 context .setUpstreamContext (relationship .getUpstream ());
182182 upstreamContextMap .put (upstreamAPIName , context );
183183 }
184- context .getExposedAggregates ().addAll (relationship .getUpstreamExposedAggregates ());
185- context .getDownstreamContexts ().add (relationship .getDownstream ());
184+ for (Aggregate exposedAggregate : relationship .getUpstreamExposedAggregates ()) {
185+ if (!context .getExposedAggregates ().stream ().map (agg -> agg .getName ()).collect (Collectors .toList ()).contains (exposedAggregate .getName ()))
186+ context .getExposedAggregates ().add (exposedAggregate );
187+ }
188+ if (!context .getDownstreamContexts ().stream ().map (bc -> bc .getName ()).collect (Collectors .toList ()).contains (relationship .getDownstream ().getName ()))
189+ context .getDownstreamContexts ().add (relationship .getDownstream ());
186190 context .addDownstreamConsumations (relationship .getDownstream ().getName (), relationship .getUpstreamExposedAggregates ());
187191 if (relationship .getImplementationTechnology () != null && !"" .equals (relationship .getImplementationTechnology ()))
188192 context .getImplementationTechnologies ().add (relationship .getImplementationTechnology ());
@@ -267,7 +271,10 @@ public void addDownstreamConsumations(String downstreamName, List<Aggregate> con
267271 if (!this .consumedAggregatesByDownstreamContext .containsKey (downstreamName )) {
268272 this .consumedAggregatesByDownstreamContext .put (downstreamName , Lists .newArrayList ());
269273 }
270- this .consumedAggregatesByDownstreamContext .get (downstreamName ).addAll (consumedAggregates );
274+ for (Aggregate aggregate : consumedAggregates ) {
275+ if (!this .consumedAggregatesByDownstreamContext .get (downstreamName ).stream ().map (agg -> agg .getName ()).collect (Collectors .toList ()).contains (aggregate .getName ()))
276+ this .consumedAggregatesByDownstreamContext .get (downstreamName ).add (aggregate );
277+ }
271278 }
272279
273280 public Map <String , List <Aggregate >> getConsumedAggregatesByDownstreamContext () {
0 commit comments