Пример #1
0
 public void merge(LldpElement element) {
   if (element == null) return;
   setLldpChassisId(element.getLldpChassisId());
   setLldpChassisIdSubType(element.getLldpChassisIdSubType());
   setLldpSysname(element.getLldpSysname());
   setLldpNodeLastPollTime(element.getLldpNodeCreateTime());
 }
 @Override
 public void reconcileLldp(int nodeId, Date now) {
   LldpElement element = m_lldpElementDao.findByNodeId(nodeId);
   if (element != null && element.getLldpNodeLastPollTime().getTime() < now.getTime()) {
     m_lldpElementDao.delete(element);
     m_lldpElementDao.flush();
   }
   m_lldpLinkDao.deleteByNodeIdOlderThen(nodeId, now);
   m_lldpLinkDao.flush();
 }
  @Override
  @Transactional
  public void store(int nodeId, LldpElement element) {
    if (element == null) return;
    final OnmsNode node = m_nodeDao.get(nodeId);
    if (node == null) return;

    LldpElement dbelement = node.getLldpElement();
    if (dbelement != null) {
      dbelement.merge(element);
      node.setLldpElement(dbelement);
    } else {
      element.setNode(node);
      element.setLldpNodeLastPollTime(element.getLldpNodeCreateTime());
      node.setLldpElement(element);
    }

    m_nodeDao.saveOrUpdate(node);
    m_nodeDao.flush();
  }