@Override public Long getId() { return m_entity.getId(); }
@Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof BusinessServiceEntity)) return false; final BusinessServiceEntity other = (BusinessServiceEntity) obj; if (getId() != null) { return getId().equals(other.getId()); } return super.equals(obj); }
@Override public String toString() { return com.google.common.base.Objects.toStringHelper(this) .add("id", m_id) .add("businessService", m_businessService == null ? null : m_businessService.getId()) .add("enabled", m_enabled) .add("weight", m_weight) .add("mapFunction", m_mapFunction) .toString(); }
@Override public String toString() { return com.google.common.base.Objects.toStringHelper(this) .add("super", super.toString()) .add("child", child == null ? null : child.getId()) .toString(); }
@Override public Set<BusinessServiceEntity> findParents(BusinessServiceEntity child) { final long childId = Objects.requireNonNull(child).getId(); Set<BusinessServiceEntity> parents = getHibernateTemplate().execute(new HibernateCallback<Set<BusinessServiceEntity>>() { @Override public Set<BusinessServiceEntity> doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.createQuery("select edge from BusinessServiceEdgeEntity edge where type(edge) = BusinessServiceChildEdgeEntity and edge.child.id = :childId"); query.setParameter("childId", childId); @SuppressWarnings("unchecked") List<BusinessServiceEdgeEntity> list = query.list(); return list.stream().map(BusinessServiceEdgeEntity::getBusinessService).collect(Collectors.toSet()); } }); return parents; }
@Override public Set<BusinessServiceEntity> findParents(BusinessServiceEntity child) { final long childId = Objects.requireNonNull(child).getId(); Set<BusinessServiceEntity> parents = getHibernateTemplate().execute(new HibernateCallback<Set<BusinessServiceEntity>>() { @Override public Set<BusinessServiceEntity> doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.createQuery("select edge from BusinessServiceEdgeEntity edge where type(edge) = BusinessServiceChildEdgeEntity and edge.child.id = :childId"); query.setParameter("childId", childId); @SuppressWarnings("unchecked") List<BusinessServiceEdgeEntity> list = query.list(); return list.stream().map(BusinessServiceEdgeEntity::getBusinessService).collect(Collectors.toSet()); } }); return parents; }
/** * Defines if the definition of the edge is equal to the given one. * This is quite different than the equals method of the object itself. * * @return true if equal, otherwise false */ public boolean equalsDefinition(BusinessServiceEdgeEntity other) { if (other == null) return false; if (!getClass().equals(other.getClass())) return false; boolean equals = Objects.equals(getWeight(), other.getWeight()) && Objects.equals(getBusinessService().getId(), other.getBusinessService().getId()) && getMapFunction().equalsDefinition(other.getMapFunction()); return equals; }
public static BusinessServiceResponseDTO toResponseDto(BusinessServiceEntity input) { Objects.requireNonNull(input); BusinessServiceResponseDTO response = new BusinessServiceResponseDTO(); response.setId(input.getId()); response.setName(input.getName()); response.setReduceFunction(transform(input.getReductionFunction())); response.setOperationalStatus(Status.INDETERMINATE); // we assume INDETERMINATE response.setAttributes(input.getAttributes()); response.setLocation(ResourceLocationFactory.createBusinessServiceLocation(input.getId().toString())); response.setReductionKeys(input.getReductionKeyEdges().stream().map(BsmTestUtils::toResponseDTO).collect(Collectors.toList())); response.setIpServices(input.getIpServiceEdges().stream().map(BsmTestUtils::toResponseDTO).collect(Collectors.toList())); response.setChildren(input.getChildEdges().stream().map(BsmTestUtils::toResponseDTO).collect(Collectors.toList())); response.setParentServices(Sets.newHashSet()); // do not know that here return response; }
public static ChildEdgeResponseDTO toResponseDTO(BusinessServiceChildEdgeEntity input) { ChildEdgeResponseDTO edge = new ChildEdgeResponseDTO(); edge.setLocation(ResourceLocationFactory.createBusinessServiceEdgeLocation(input.getBusinessService().getId(), input.getId())); edge.setReductionKeys(edge.getReductionKeys()); edge.setMapFunction(transform(input.getMapFunction())); edge.setId(input.getId()); edge.setChildId(input.getChild().getId()); edge.setWeight(input.getWeight()); edge.setOperationalStatus(Status.INDETERMINATE); // we assume INDETERMINATE return edge; }
public static ReductionKeyEdgeResponseDTO toResponseDTO(SingleReductionKeyEdgeEntity input) { ReductionKeyEdgeResponseDTO edge = new ReductionKeyEdgeResponseDTO(); edge.setLocation(ResourceLocationFactory.createBusinessServiceEdgeLocation(input.getBusinessService().getId(), input.getId())); edge.setReductionKeys(input.getReductionKeys()); edge.setReductionKey(input.getReductionKey()); edge.setMapFunction(transform(input.getMapFunction())); edge.setId(input.getId()); edge.setWeight(input.getWeight()); edge.setFriendlyName(input.getFriendlyName()); edge.setOperationalStatus(Status.INDETERMINATE); // we assume INDETERMINATE return edge; }
public static IpServiceEdgeResponseDTO toResponseDTO(IPServiceEdgeEntity input) { IpServiceResponseDTO ipService = new IpServiceResponseDTO(); ipService.setNodeLabel("dummy"); // do not know that here ipService.setServiceName(input.getIpService().getServiceName()); ipService.setId(input.getIpService().getId()); ipService.setIpAddress(InetAddressUtils.toIpAddrString(input.getIpService().getIpAddress())); IpServiceEdgeResponseDTO edge = new IpServiceEdgeResponseDTO(); edge.setLocation(ResourceLocationFactory.createBusinessServiceEdgeLocation(input.getBusinessService().getId(), input.getId())); edge.setReductionKeys(ReductionKeyHelper.getReductionKeys(input.getIpService())); edge.setIpService(ipService); edge.setMapFunction(transform(input.getMapFunction())); edge.setId(input.getId()); edge.setWeight(input.getWeight()); edge.setFriendlyName(input.getFriendlyName()); edge.setOperationalStatus(Status.INDETERMINATE); // we assume INDETERMINATE return edge; }