@Override public String getFriendlyName() { return getEntity().getApplication().getName(); }
@Override public Set<String> getReductionKeys() { return getEntity().getReductionKeys(); }
@Override public void setApplication(Application application) { getEntity().setApplication(((ApplicationImpl)application).getEntity()); }
@Override public boolean addApplicationEdge(BusinessService businessService, Application application, MapFunction mapFunction, int weight) { final BusinessServiceEntity parentEntity = getBusinessServiceEntity(businessService); // Create the edge final ApplicationEdge edge = createEdge(ApplicationEdge.class, businessService, mapFunction, weight); edge.setApplication(application); // if already exists, no update final ApplicationEdgeEntity edgeEntity = getBusinessServiceEdgeEntity(edge); long count = parentEntity.getApplicationEdges().stream().filter(e -> e.equalsDefinition(edgeEntity)).count(); if (count > 0) { return false; } parentEntity.addEdge(((ApplicationEdgeImpl)edge).getEntity()); return true; }
@SuppressWarnings("unchecked") private <T extends Edge> T createEdge(Class<T> type, BusinessService source, MapFunction mapFunction, int weight) { T edge = null; if (type == IpServiceEdge.class) { edge = (T) new IpServiceEdgeImpl(this, new IPServiceEdgeEntity()); } if (type == ChildEdge.class) { edge = (T) new ChildEdgeImpl(this, new BusinessServiceChildEdgeEntity()); } if (type == ReductionKeyEdge.class) { edge = (T) new ReductionKeyEdgeImpl(this, new SingleReductionKeyEdgeEntity()); } if (type == ApplicationEdge.class) { edge = (T) new ApplicationEdgeImpl(this, new ApplicationEdgeEntity()); } if (edge != null) { edge.setSource(source); edge.setMapFunction(mapFunction); edge.setWeight(weight); return edge; } throw new IllegalArgumentException("Could not create edge for type " + type); }
@Override public Application getApplication() { return new ApplicationImpl(getManager(), getEntity().getApplication()); }