This commit is contained in:
insanity 2018-06-06 14:51:25 +09:00
commit cece514174
36 changed files with 663 additions and 514 deletions

12
pom.xml
View File

@ -24,12 +24,13 @@
<caffeine.version>2.5.6</caffeine.version> <caffeine.version>2.5.6</caffeine.version>
<protoc.version>3.5.1</protoc.version> <protoc.version>3.5.1</protoc.version>
<spring.version>5.0.6.RELEASE</spring.version> <spring.version>5.0.6.RELEASE</spring.version>
<spring.data.commons.version>2.0.7.RELEASE</spring.data.commons.version>
<spring.data.jpa.version>2.0.7.RELEASE</spring.data.jpa.version> <spring.data.jpa.version>2.0.7.RELEASE</spring.data.jpa.version>
<spring.data.redis.version>2.0.7.RELEASE</spring.data.redis.version> <spring.data.redis.version>2.0.7.RELEASE</spring.data.redis.version>
<spring.crypto.version>5.0.5.RELEASE</spring.crypto.version> <spring.crypto.version>5.0.5.RELEASE</spring.crypto.version>
<!-- <gson.version>2.8.2</gson.version> --> <!-- <gson.version>2.8.2</gson.version> -->
<jackson.mapper.version>1.9.13</jackson.mapper.version> <jackson.mapper.version>1.9.13</jackson.mapper.version>
<hibernate.version>5.2.10.Final</hibernate.version> <hibernate.version>5.3.1.Final</hibernate.version>
<javax.mail.version>1.4.7</javax.mail.version> <javax.mail.version>1.4.7</javax.mail.version>
<javax.mail-api.version>1.6.0</javax.mail-api.version> <javax.mail-api.version>1.6.0</javax.mail-api.version>
<apache.velocity.version>1.7</apache.velocity.version> <apache.velocity.version>1.7</apache.velocity.version>
@ -49,7 +50,7 @@
<dependency> <dependency>
<groupId>com.loafle.overflow</groupId> <groupId>com.loafle.overflow</groupId>
<artifactId>commons-java</artifactId> <artifactId>commons-java</artifactId>
<version>1.0.9-SNAPSHOT</version> <version>1.0.13-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
@ -81,6 +82,13 @@
</dependency> </dependency>
<!-- Spring Dependency--> <!-- Spring Dependency-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>${spring.data.jpa.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId> <artifactId>spring-data-jpa</artifactId>

View File

@ -4,6 +4,8 @@ import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.domain.DomainMember; import com.loafle.overflow.model.domain.DomainMember;
import com.loafle.overflow.model.member.Member; import com.loafle.overflow.model.member.Member;
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.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -16,7 +18,9 @@ public interface DomainMemberDAO extends JpaRepository<DomainMember, Long> {
DomainMember findByMemberEmail(String memberEmail); DomainMember findByMemberEmail(String memberEmail);
Domain findDomainByMemberId(Long memberId); @Query("SELECT dm.domain from DomainMember dm where dm.member.email = :memberEmail")
Domain findDomainByMemberEmail(@Param("memberEmail") String memberEmail);
List<Member> findAllMemberByDomainId(Long domainID); @Query("SELECT dm.member from DomainMember dm where dm.domain.id = :domainId")
List<Member> findAllMemberByDomainId(@Param("domainId") Long domainId);
} }

View File

@ -24,8 +24,8 @@ public class CentralDomainMemberService implements DomainMemberService {
this.domainMemberDAO.save(domainMember); this.domainMemberDAO.save(domainMember);
} }
public Domain readDomainByMemberID(Long memberID) { public Domain readDomainByMemberEmail(String memberEmail) {
return this.domainMemberDAO.findDomainByMemberId(memberID); return this.domainMemberDAO.findDomainByMemberEmail(memberEmail);
} }
public DomainMember readByMemberEmail(String email) { public DomainMember readByMemberEmail(String email) {

View File

@ -48,7 +48,7 @@ public class EmailAuthService {
// "http://127.0.0.1:4200/auth/"; // "http://127.0.0.1:4200/auth/";
public EmailAuth read(Long id) { public EmailAuth read(Long id) {
return this.emailAuthDAO.findOne(id); return this.emailAuthDAO.findById(id).get();
} }
public EmailAuth readBySignupAuthKey(String token) throws OverflowException { public EmailAuth readBySignupAuthKey(String token) throws OverflowException {

View File

@ -19,10 +19,10 @@ public interface InfraDAO extends JpaRepository<Infra, Long> {
Page<Infra> findAllByProbeId(Long probeID, Pageable pageable); Page<Infra> findAllByProbeId(Long probeID, Pageable pageable);
Page<Infra> findAllByProbeInAndTargetNotNull(List<Probe> probes, Pageable pageable); Page<Infra> findAllByProbeIn(List<Probe> probes, Pageable pageable);
List<Target> findAllTargetByProbeIn(List<Probe> probes); List<Target> findAllTargetByProbeIn(List<Probe> probes);
Infra findByTargetId(Long targetID); // Infra findByTargetId(Long targetID);
} }

View File

@ -9,5 +9,5 @@ import org.springframework.stereotype.Repository;
*/ */
@Repository @Repository
public interface InfraOSPortDAO extends JpaRepository<InfraOSPort, Long> { public interface InfraOSPortDAO extends JpaRepository<InfraOSPort, Long> {
InfraOSPort findByInfraOSIdAndPortAndPortType(Long infraOSId, Integer port, String portType); InfraOSPort findByInfraOSAndPortAndPortType(Long infraOSId, Integer port, String portType);
} }

View File

@ -22,7 +22,7 @@ public class CentralInfraHostService implements InfraHostService {
} }
public InfraHost read(Long id) throws OverflowException { public InfraHost read(Long id) throws OverflowException {
return this.infraHostDAO.findOne(id); return this.infraHostDAO.findById(id).get();
} }
public InfraHost readByProbeIdAndIpv4(Long probeId, String ip) throws OverflowException { public InfraHost readByProbeIdAndIpv4(Long probeId, String ip) throws OverflowException {

View File

@ -20,6 +20,6 @@ public class CentralInfraMachineService implements InfraMachineService {
} }
public InfraMachine read(Long id) { public InfraMachine read(Long id) {
return this.infraMachineDAO.findOne(id); return this.infraMachineDAO.findById(id).get();
} }
} }

View File

@ -21,6 +21,6 @@ public class CentralInfraOSApplicationService implements InfraOSApplicationServi
} }
public InfraOSApplication read(Long id) throws OverflowException { public InfraOSApplication read(Long id) throws OverflowException {
return this.infraOSApplicationDAO.findOne(id); return this.infraOSApplicationDAO.findById(id).get();
} }
} }

View File

@ -21,6 +21,6 @@ public class CentralInfraOSDaemonService implements InfraOSDaemonService {
} }
public InfraOSDaemon read(Long id) throws OverflowException { public InfraOSDaemon read(Long id) throws OverflowException {
return this.infraOSDaemonDAO.findOne(id); return this.infraOSDaemonDAO.findById(id).get();
} }
} }

View File

@ -21,11 +21,11 @@ public class CentralInfraOSPortService implements InfraOSPortService {
} }
public InfraOSPort read(Long id) throws OverflowException { public InfraOSPort read(Long id) throws OverflowException {
return this.infraOSPortDAO.findOne(id); return this.infraOSPortDAO.findById(id).get();
} }
public InfraOSPort readByInfraOSIDAndPortAndPortType(Long infraOSID, Integer port, String portType) public InfraOSPort readByInfraOSIDAndPortAndPortType(Long infraOSID, Integer port, String portType)
throws OverflowException { throws OverflowException {
return this.infraOSPortDAO.findByInfraOSIdAndPortAndPortType(infraOSID, port, portType); return this.infraOSPortDAO.findByInfraOSAndPortAndPortType(infraOSID, port, portType);
} }
} }

View File

@ -21,6 +21,6 @@ public class CentralInfraOSService implements InfraOSService {
} }
public InfraOS read(Long id) throws OverflowException { public InfraOS read(Long id) throws OverflowException {
return this.infraOSDAO.findOne(id); return this.infraOSDAO.findById(id).get();
} }
} }

View File

@ -38,7 +38,7 @@ public class CentralInfraService implements InfraService {
} }
public Infra read(Long id) throws OverflowException { public Infra read(Long id) throws OverflowException {
Infra infra = this.infraDAO.findOne(id); Infra infra = this.infraDAO.findById(id).get();
return infra; return infra;
} }
@ -53,7 +53,7 @@ public class CentralInfraService implements InfraService {
throw new OverflowException("ProbeNotFoundException", new Throwable()); throw new OverflowException("ProbeNotFoundException", new Throwable());
} }
Page<Infra> infraList = this.infraDAO.findAllByProbeInAndTargetNotNull(probeList, PageUtil.getPageRequest(pageParams)); Page<Infra> infraList = this.infraDAO.findAllByProbeIn(probeList, PageUtil.getPageRequest(pageParams));
return infraList; return infraList;
} }
@ -74,7 +74,8 @@ public class CentralInfraService implements InfraService {
} }
public Infra readByTargetID(Long targetID) throws OverflowException { public Infra readByTargetID(Long targetID) throws OverflowException {
return this.infraDAO.findByTargetId(targetID); // return this.infraDAO.findByTargetId(targetID);
return null;
} }
} }

View File

@ -21,7 +21,7 @@ public class CentralInfraServiceService implements InfraServiceService {
} }
public InfraService read(Long id) throws OverflowException { public InfraService read(Long id) throws OverflowException {
return this.infraServiceDAO.findOne(id); return this.infraServiceDAO.findById(id).get();
} }
public InfraService readByInfraHostIDAndPortAndPortType(Long infraHostID, int port, String portType) public InfraService readByInfraHostIDAndPortAndPortType(Long infraHostID, int port, String portType)

View File

@ -245,7 +245,7 @@ public class CentralMemberService implements MemberService {
throw new OverflowException("SignInIdNotExistException()", new Throwable()); throw new OverflowException("SignInIdNotExistException()", new Throwable());
} }
Member resMember = this.memberDAO.findOne(memberId); Member resMember = this.memberDAO.findById(memberId).get();
return resMember; return resMember;
} }

View File

@ -51,11 +51,11 @@ public class CentralMemberTotpService implements MemberTotpService {
} }
public void remove(Long id) throws OverflowException { public void remove(Long id) throws OverflowException {
this.totpDAO.delete(id); this.totpDAO.deleteById(id);
} }
public MemberTotp read(Long id) throws OverflowException { public MemberTotp read(Long id) throws OverflowException {
return this.totpDAO.findOne(id); return this.totpDAO.findById(id).get();
} }
public boolean checkCodeForMember(String memberEmail, String code) throws OverflowException { public boolean checkCodeForMember(String memberEmail, String code) throws OverflowException {

View File

@ -3,6 +3,8 @@ package com.loafle.overflow.central.module.meta.dao;
import com.loafle.overflow.model.meta.MetaSensorDisplayMapping; import com.loafle.overflow.model.meta.MetaSensorDisplayMapping;
import com.loafle.overflow.model.meta.MetaSensorItemKey; import com.loafle.overflow.model.meta.MetaSensorItemKey;
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.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -12,5 +14,7 @@ import java.util.List;
*/ */
@Repository @Repository
public interface MetaSensorDisplayMappingDAO extends JpaRepository<MetaSensorDisplayMapping, Short> { public interface MetaSensorDisplayMappingDAO extends JpaRepository<MetaSensorDisplayMapping, Short> {
public List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(Long metaSensorDisplayItemId);
@Query("SELECT m.metaSensorItemKey from MetaSensorDisplayMapping m where m.metaSensorDisplayItem.id = :metaSensorDisplayItemId")
public List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
} }

View File

@ -28,6 +28,6 @@ public class CentralMetaHistoryTypeService implements MetaHistoryTypeService {
} }
public List<MetaHistoryType> registAll(List<MetaHistoryType> metaHistoryTypes) throws OverflowException { public List<MetaHistoryType> registAll(List<MetaHistoryType> metaHistoryTypes) throws OverflowException {
return (List<MetaHistoryType>)this.hisotyTypeDAO.save(metaHistoryTypes); return (List<MetaHistoryType>)this.hisotyTypeDAO.saveAll(metaHistoryTypes);
} }
} }

View File

@ -23,7 +23,7 @@ public class CentralMetaSensorDisplayItemService implements MetaSensorDisplayIte
} }
public MetaSensorDisplayItem read(Long id) throws OverflowException { public MetaSensorDisplayItem read(Long id) throws OverflowException {
return this.displayItemDAO.findOne(id); return this.displayItemDAO.findById(id).get();
} }
public List<MetaSensorDisplayItem> readAllByCrawlerID(Short metaCrawlerID) throws OverflowException { public List<MetaSensorDisplayItem> readAllByCrawlerID(Short metaCrawlerID) throws OverflowException {

View File

@ -28,6 +28,6 @@ public class CentralMetaSensorItemTypeService implements MetaSensorItemTypeServi
} }
public List<MetaSensorItemType> registAll(List<MetaSensorItemType> list) throws OverflowException { public List<MetaSensorItemType> registAll(List<MetaSensorItemType> list) throws OverflowException {
return (List<MetaSensorItemType>)this.sensorItemTypeDAO.save(list); return (List<MetaSensorItemType>)this.sensorItemTypeDAO.saveAll(list);
} }
} }

View File

@ -98,13 +98,13 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
} }
public NoAuthProbe read(Long id) { public NoAuthProbe read(Long id) {
return this.noAuthProbeDAO.findOne(id); return this.noAuthProbeDAO.findById(id).get();
} }
@WebappAPI @WebappAPI
@Transactional @Transactional
public List<NoAuthProbe> acceptNoAuthProbe(Long noAuthProbeID) throws OverflowException { public List<NoAuthProbe> acceptNoAuthProbe(Long noAuthProbeID) throws OverflowException {
NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findOne(noAuthProbeID); NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findById(noAuthProbeID).get();
NoAuthProbeDescription noAuthProbeDescription = null; NoAuthProbeDescription noAuthProbeDescription = null;
try { try {
@ -197,7 +197,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
private void newProbeHost(InfraHost infraHost, Probe probe) throws OverflowException { private void newProbeHost(InfraHost infraHost, Probe probe) throws OverflowException {
ProbeHost probeHost = new ProbeHost(); ProbeHost probeHost = new ProbeHost();
probeHost.setHost(infraHost); probeHost.setInfraHost(infraHost);
probeHost.setProbe(probe); probeHost.setProbe(probe);
this.probeHostService.regist(probeHost); this.probeHostService.regist(probeHost);
@ -205,7 +205,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
@WebappAPI @WebappAPI
public List<NoAuthProbe> denyNoauthProbe(Long noAuthProbeID) throws OverflowException { public List<NoAuthProbe> denyNoauthProbe(Long noAuthProbeID) throws OverflowException {
NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findOne(noAuthProbeID); NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findById(noAuthProbeID).get();
noAuthProbe.setMetaNoAuthProbeStatus(new MetaNoAuthProbeStatus((short) 2)); noAuthProbe.setMetaNoAuthProbeStatus(new MetaNoAuthProbeStatus((short) 2));
this.noAuthProbeDAO.save(noAuthProbe); this.noAuthProbeDAO.save(noAuthProbe);

View File

@ -48,7 +48,7 @@ public class CentralNotificationService implements NotificationService {
for (Notification n : list) { for (Notification n : list) {
n.setConfirmDate(new Date()); n.setConfirmDate(new Date());
} }
this.notificationDAO.save(list); this.notificationDAO.saveAll(list);
return this.readAllByMemberEmail(memberEmail, pageParams); return this.readAllByMemberEmail(memberEmail, pageParams);
} }
@ -58,12 +58,12 @@ public class CentralNotificationService implements NotificationService {
for (Notification n : list) { for (Notification n : list) {
n.setConfirmDate(null); n.setConfirmDate(null);
} }
this.notificationDAO.save(list); this.notificationDAO.saveAll(list);
return this.readAllByMemberEmail(memberEmail, pageParams); return this.readAllByMemberEmail(memberEmail, pageParams);
} }
public Notification markAsRead(Long notificationID) throws OverflowException { public Notification markAsRead(Long notificationID) throws OverflowException {
Notification notification = this.notificationDAO.findOne(notificationID); Notification notification = this.notificationDAO.findById(notificationID).get();
notification.setConfirmDate(new Date()); notification.setConfirmDate(new Date());
return this.notificationDAO.save(notification); return this.notificationDAO.save(notification);
} }

View File

@ -20,7 +20,7 @@ public class CentralProbeHostService implements ProbeHostService {
private ProbeHostDAO probeHostDAO; private ProbeHostDAO probeHostDAO;
public ProbeHost read(Long id) throws OverflowException { public ProbeHost read(Long id) throws OverflowException {
return this.probeHostDAO.findOne(id); return this.probeHostDAO.findById(id).get();
} }
public ProbeHost readByProbeID(Long probeID) throws OverflowException { public ProbeHost readByProbeID(Long probeID) throws OverflowException {

View File

@ -28,7 +28,7 @@ public class CentralProbeService implements ProbeService {
} }
public List<Probe> regist(List<Probe> probes) throws OverflowException { public List<Probe> regist(List<Probe> probes) throws OverflowException {
return (List<Probe>)this.probeDAO.save(probes); return (List<Probe>)this.probeDAO.saveAll(probes);
} }
public List<Probe> readAllByDomainID(Long domainID) throws OverflowException { public List<Probe> readAllByDomainID(Long domainID) throws OverflowException {
@ -37,7 +37,7 @@ public class CentralProbeService implements ProbeService {
} }
public Probe read(Long id) throws OverflowException { public Probe read(Long id) throws OverflowException {
return this.probeDAO.findOne(id); return this.probeDAO.findById(id).get();
} }
public Probe readByProbeKey(String probeKey) throws OverflowException { public Probe readByProbeKey(String probeKey) throws OverflowException {
@ -49,18 +49,18 @@ public class CentralProbeService implements ProbeService {
} }
public boolean remove(Long id) throws OverflowException { public boolean remove(Long id) throws OverflowException {
this.probeDAO.delete(id); this.probeDAO.deleteById(id);
return true; return true;
} }
public Probe increaseTargetCount(Probe probe) { public Probe increaseTargetCount(Probe probe) {
Probe p = this.probeDAO.findOne(probe.getId()); Probe p = this.probeDAO.findById(probe.getId()).get();
p.setTargetCount(p.getTargetCount() + 1); p.setTargetCount(p.getTargetCount() + 1);
return this.probeDAO.save(p); return this.probeDAO.save(p);
} }
public Probe decreaseTargetCount(Probe probe) { public Probe decreaseTargetCount(Probe probe) {
Probe p = this.probeDAO.findOne(probe.getId()); Probe p = this.probeDAO.findById(probe.getId()).get();
int count = p.getTargetCount(); int count = p.getTargetCount();
if (count > 0) { if (count > 0) {
p.setTargetCount(count - 1); p.setTargetCount(count - 1);
@ -69,7 +69,7 @@ public class CentralProbeService implements ProbeService {
} }
public Probe modifyDisplayName(Long probeId, String displayName) { public Probe modifyDisplayName(Long probeId, String displayName) {
Probe probe = this.probeDAO.findOne(probeId); Probe probe = this.probeDAO.findById(probeId).get();
probe.setDisplayName(displayName); probe.setDisplayName(displayName);
return this.probeDAO.save(probe); return this.probeDAO.save(probe);
} }

View File

@ -4,6 +4,8 @@ import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.SensorItemDependency; import com.loafle.overflow.model.sensor.SensorItemDependency;
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.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -14,5 +16,6 @@ import java.util.List;
@Repository @Repository
public interface SensorItemDependencyDAO extends JpaRepository<SensorItemDependency, Long> { public interface SensorItemDependencyDAO extends JpaRepository<SensorItemDependency, Long> {
List<MetaSensorItemKey> findAllByMetaSensorDisplayItemId(Long metaSensorDisplayItemId); @Query("SELECT s.metaSensorItemKey from SensorItemDependency s where s.metaSensorDisplayItem.id = :metaSensorDisplayItemId")
List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
} }

View File

@ -30,7 +30,7 @@ public class CentralSensorItemDependencyService implements SensorItemDependencyS
public List<MetaSensorItemKey> readAllMetaSensorItemKeyByMetaSensorDisplayItemID(Long metaSensorDisplayItemID) public List<MetaSensorItemKey> readAllMetaSensorItemKeyByMetaSensorDisplayItemID(Long metaSensorDisplayItemID)
throws OverflowException { throws OverflowException {
return this.sensorItemDependencyDAO.findAllByMetaSensorDisplayItemId(metaSensorDisplayItemID); return this.sensorItemDependencyDAO.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(metaSensorDisplayItemID);
} }
public Map<String, List<MetaSensorItemKey>> readAllMapByMetaSensorDisplayItems( public Map<String, List<MetaSensorItemKey>> readAllMapByMetaSensorDisplayItems(
@ -40,7 +40,7 @@ public class CentralSensorItemDependencyService implements SensorItemDependencyS
for (MetaSensorDisplayItem displayItem : metaSensorDisplayItems) { for (MetaSensorDisplayItem displayItem : metaSensorDisplayItems) {
List<MetaSensorItemKey> itemKeys = this.sensorItemDependencyDAO List<MetaSensorItemKey> itemKeys = this.sensorItemDependencyDAO
.findAllByMetaSensorDisplayItemId(displayItem.getId()); .findAllMetaSensorItemKeyByMetaSensorDisplayItemId(displayItem.getId());
map.put(displayItem.getKey(), itemKeys); map.put(displayItem.getKey(), itemKeys);
} }

View File

@ -29,7 +29,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.findById(sensorItem.getSensor().getId()).get();
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);
@ -37,15 +37,15 @@ 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.findById(sensorItemList.get(0).getSensor().getId()).get();
s.setItemCount((short) sensorItemList.size()); s.setItemCount((short) sensorItemList.size());
this.sensorDAO.save(s); this.sensorDAO.save(s);
this.sensorItemDAO.save(sensorItemList); this.sensorItemDAO.saveAll(sensorItemList);
return true; return true;
} }
public SensorItem read(String id) throws OverflowException { public SensorItem read(String id) throws OverflowException {
return this.sensorItemDAO.findOne(Long.valueOf(id)); return this.sensorItemDAO.findById(Long.valueOf(id)).get();
} }
public Page<SensorItem> readAllBySensorID(Long sensorID, PageParams pageParams) throws OverflowException { public Page<SensorItem> readAllBySensorID(Long sensorID, PageParams pageParams) throws OverflowException {

View File

@ -86,25 +86,25 @@ public class CentralSensorService implements SensorService {
} }
public Sensor read(Long id) throws OverflowException { public Sensor read(Long id) throws OverflowException {
return this.sensorDAO.findOne(Long.valueOf(id)); return this.sensorDAO.findById(Long.valueOf(id)).get();
} }
@Transactional @Transactional
public void remove(Long sensorID) throws OverflowException { public void remove(Long sensorID) throws OverflowException {
Sensor sensor = this.sensorDAO.findOne(sensorID); Sensor sensor = this.sensorDAO.findById(sensorID).get();
this.targetService.decreaseSensorCount(sensor.getTarget()); this.targetService.decreaseSensorCount(sensor.getTarget());
this.sensorDAO.delete(sensor); this.sensorDAO.delete(sensor);
} }
public Sensor start(Long sensorID) throws OverflowException { public Sensor start(Long sensorID) throws OverflowException {
Sensor sensor = this.sensorDAO.findOne(sensorID); Sensor sensor = this.sensorDAO.findById(sensorID).get();
MetaSensorStatus status = new MetaSensorStatus((short) 1); MetaSensorStatus status = new MetaSensorStatus((short) 1);
sensor.setMetaSensorStatus(status); sensor.setMetaSensorStatus(status);
return this.sensorDAO.save(sensor); return this.sensorDAO.save(sensor);
} }
public Sensor stop(Long sensorID) throws OverflowException { public Sensor stop(Long sensorID) throws OverflowException {
Sensor sensor = this.sensorDAO.findOne(sensorID); Sensor sensor = this.sensorDAO.findById(sensorID).get();
MetaSensorStatus status = new MetaSensorStatus((short) 2); MetaSensorStatus status = new MetaSensorStatus((short) 2);
sensor.setMetaSensorStatus(status); sensor.setMetaSensorStatus(status);
return this.sensorDAO.save(sensor); return this.sensorDAO.save(sensor);

View File

@ -50,7 +50,7 @@ public class CentralTargetService implements TargetService {
} }
public Target read(String id) throws OverflowException { public Target read(String id) throws OverflowException {
return this.targetDAO.findOne(Long.valueOf(id)); return this.targetDAO.findById(Long.valueOf(id)).get();
} }
public Target modify(Target target) throws OverflowException { public Target modify(Target target) throws OverflowException {
@ -68,13 +68,13 @@ public class CentralTargetService implements TargetService {
} }
public Target increaseSensorCount(Target target) throws OverflowException { public Target increaseSensorCount(Target target) throws OverflowException {
Target t = this.targetDAO.findOne(target.getId()); Target t = this.targetDAO.findById(target.getId()).get();
t.setSensorCount(t.getSensorCount() + 1); t.setSensorCount(t.getSensorCount() + 1);
return this.targetDAO.save(t); return this.targetDAO.save(t);
} }
public Target decreaseSensorCount(Target target) throws OverflowException { public Target decreaseSensorCount(Target target) throws OverflowException {
Target t = this.targetDAO.findOne(target.getId()); Target t = this.targetDAO.findById(target.getId()).get();
int count = t.getSensorCount(); int count = t.getSensorCount();
if (t.getSensorCount() > 0) { if (t.getSensorCount() > 0) {
t.setSensorCount(count - 1); t.setSensorCount(count - 1);

View File

@ -5,11 +5,15 @@ import com.loafle.overflow.central.redis.service.RedisMessagePublisher;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisClientConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.serializer.GenericToStringSerializer; import org.springframework.data.redis.serializer.GenericToStringSerializer;
import java.time.Duration;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -25,9 +29,22 @@ public class RedisConfiguration {
@Bean @Bean
JedisConnectionFactory jedisConnectionFactory() { JedisConnectionFactory jedisConnectionFactory() {
JedisConnectionFactory jedisConFactory = new JedisConnectionFactory(); RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
jedisConFactory.setHostName(host); redisStandaloneConfiguration.setHostName(host);
jedisConFactory.setPort(port); redisStandaloneConfiguration.setPort(port);
// redisStandaloneConfiguration.setDatabase(0);
// redisStandaloneConfiguration.setPassword(RedisPassword.of("password"));
JedisClientConfigurationBuilder jedisClientConfiguration = JedisClientConfiguration.builder();
jedisClientConfiguration.connectTimeout(Duration.ofSeconds(60));// 60s connection timeout
JedisConnectionFactory jedisConFactory = new JedisConnectionFactory(redisStandaloneConfiguration,
jedisClientConfiguration.build());
// JedisConnectionFactory jedisConFactory = new JedisConnectionFactory();
// jedisConFactory.setHostName(host);
// jedisConFactory.setPort(port);
return jedisConFactory; return jedisConFactory;
} }

View File

@ -8,4 +8,4 @@ jpa.database=postgresql
jpa.hibernate.ddl-auto=create jpa.hibernate.ddl-auto=create
#jpa.hibernate.ddl-auto=update #jpa.hibernate.ddl-auto=update
jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
jpa.show-sql=true jpa.show-sql=false

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
package com.loafle.overflow.central.module.domain.dao;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.member.Member;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by snoop on 17. 9. 14.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfigTest.class})
public class DomainMemberDAOTest {
@Autowired
private DomainMemberDAO domainMemberDAO;
@Test
public void findDomainByMemberEmail() throws Exception {
Domain domain = this.domainMemberDAO.findDomainByMemberEmail("overflow@loafle.com");
assertNotNull(domain);
}
@Test
public void findAllMemberByDomainId() throws Exception {
List<Member> members = this.domainMemberDAO.findAllMemberByDomainId(Long.valueOf(1));
assertNotNull(members);
}
}

View File

@ -23,7 +23,7 @@ public class InfraDAOTest {
private InfraDAO infraDAO; private InfraDAO infraDAO;
@Test @Test
public void findAllByProbeList() throws Exception { public void findAllTargetByProbeIn() throws Exception {
List<Probe> probes = new ArrayList<>(); List<Probe> probes = new ArrayList<>();
@ -37,4 +37,4 @@ public class InfraDAOTest {
} }
} }

View File

@ -0,0 +1,34 @@
package com.loafle.overflow.central.module.meta.dao;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.meta.MetaSensorItemKey;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by snoop on 17. 9. 14.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfigTest.class})
public class MetaSensorDisplayMappingDAOTest {
@Autowired
private MetaSensorDisplayMappingDAO metaSensorDisplayMappingDAO;
@Test
public void findAllMetaSensorItemKeyByMetaSensorDisplayItemId() throws Exception {
List<MetaSensorItemKey> metaSensorItemKeys = this.metaSensorDisplayMappingDAO.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(Long.valueOf(1));
assertNotNull(metaSensorItemKeys);
}
}

View File

@ -0,0 +1,35 @@
package com.loafle.overflow.central.module.sensor.dao;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.meta.MetaSensorItemKey;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by snoop on 17. 9. 14.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { AppConfigTest.class })
public class SensorItemDependencyDAOTest {
@Autowired
private SensorItemDependencyDAO sensorItemDependencyDAO;
@Test
public void findAllMetaSensorItemKeyByMetaSensorDisplayItemId() throws Exception {
List<MetaSensorItemKey> metaSensorItemKeys = this.sensorItemDependencyDAO
.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(Long.valueOf(1));
assertNotNull(metaSensorItemKeys);
}
}