This commit is contained in:
insanity 2018-04-24 22:11:29 +09:00
parent b5f0027c30
commit 548ed630b9
4 changed files with 8 additions and 7 deletions

View File

@ -2,7 +2,7 @@ package com.loafle.overflow.central.module.infra.dao;
import com.loafle.overflow.model.infra.InfraOSPort; import com.loafle.overflow.model.infra.InfraOSPort;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; // import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -11,6 +11,6 @@ import org.springframework.stereotype.Repository;
*/ */
@Repository @Repository
public interface InfraOSPortDAO extends JpaRepository<InfraOSPort, Long> { public interface InfraOSPortDAO extends JpaRepository<InfraOSPort, Long> {
@Query("SELECT p from InfraOSPort p WHERE p.os.id = (:osId) AND p.port = (:portNumber) AND p.portType = (:portType)") // @Query("SELECT p from InfraOSPort p WHERE p.os.id = (:osId) AND p.port = (:portNumber) AND p.portType = (:portType)")
InfraOSPort findByPort(@Param("osId") long osId,@Param("portNumber") int portNumber,@Param("portType") String portType); InfraOSPort findByPort(@Param("osId") long osId,@Param("portNumber") int portNumber,@Param("portType") String portType);
} }

View File

@ -11,6 +11,6 @@ import org.springframework.stereotype.Repository;
*/ */
@Repository @Repository
public interface InfraServiceDAO extends JpaRepository<InfraService, Long> { public interface InfraServiceDAO extends JpaRepository<InfraService, Long> {
@Query("SELECT ins from com.loafle.overflow.central.module.infra.model.InfraService ins WHERE ins.host.id = (:hostId) AND ins.port = (:portNumber) AND ins.portType = (:portType)") @Query("SELECT ins from com.loafle.overflow.model.infra.InfraService ins WHERE ins.host.id = (:hostId) AND ins.port = (:portNumber) AND ins.portType = (:portType)")
InfraService findByService(@Param("hostId") long hostId,@Param("portNumber") int portNumber,@Param("portType") String portType); InfraService findByService(@Param("hostId") long hostId,@Param("portNumber") int portNumber,@Param("portType") String portType);
} }

View File

@ -30,7 +30,7 @@ public class CentralSensorItemService implements SensorItemService {
@Transactional @Transactional
public SensorItem regist(SensorItem sensorItem) throws OverflowException { public SensorItem regist(SensorItem sensorItem) throws OverflowException {
Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId()); Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId());
// s.setItemCount((short)(s.getItemCount() + 1)); s.setItemCount((short)(s.getItemCount() + 1));
this.sensorDAO.save(s); this.sensorDAO.save(s);
return this.sensorItemDAO.save(sensorItem); return this.sensorItemDAO.save(sensorItem);
} }
@ -38,7 +38,7 @@ public class CentralSensorItemService implements SensorItemService {
@Transactional @Transactional
public boolean registAll(List<SensorItem> sensorItemList) throws OverflowException { public boolean registAll(List<SensorItem> sensorItemList) throws OverflowException {
Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId()); Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId());
// s.setItemCount((short)sensorItemList.size()); s.setItemCount((short)sensorItemList.size());
this.sensorDAO.save(s); this.sensorDAO.save(s);
this.sensorItemDAO.save(sensorItemList); this.sensorItemDAO.save(sensorItemList);
return true; return true;
@ -55,7 +55,7 @@ public class CentralSensorItemService implements SensorItemService {
@Transactional @Transactional
public void remove(SensorItem sensorItem) throws OverflowException { public void remove(SensorItem sensorItem) throws OverflowException {
Sensor s = sensorItem.getSensor(); Sensor s = sensorItem.getSensor();
// s.setItemCount((short)(s.getItemCount() - 1)); s.setItemCount((short)(s.getItemCount() - 1));
this.sensorDAO.save(s); this.sensorDAO.save(s);
this.sensorItemDAO.delete(sensorItem); this.sensorItemDAO.delete(sensorItem);
} }

View File

@ -14,6 +14,7 @@ import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.model.target.Target; import com.loafle.overflow.model.target.Target;
import com.loafle.overflow.service.central.infra.InfraService; import com.loafle.overflow.service.central.infra.InfraService;
import com.loafle.overflow.service.central.probe.ProbeService; import com.loafle.overflow.service.central.probe.ProbeService;
import com.loafle.overflow.service.central.sensor.SensorItemService;
import com.loafle.overflow.service.central.sensor.SensorService; import com.loafle.overflow.service.central.sensor.SensorService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -39,7 +40,7 @@ public class CentralSensorService implements SensorService {
private InfraService infraService; private InfraService infraService;
@Autowired @Autowired
private CentralSensorItemService sensorItemService; private SensorItemService sensorItemService;
@Autowired @Autowired
private SensorConfigGenerator sensorConfigGenerator; private SensorConfigGenerator sensorConfigGenerator;