This commit is contained in:
insanity 2018-06-22 11:26:48 +09:00
parent 1788a53710
commit 1cf8608405

View File

@ -3,27 +3,20 @@ package com.loafle.overflow.central.module.target.service;
import java.util.ArrayList;
import java.util.List;
import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.probe.service.CentralProbeService;
import com.loafle.overflow.central.module.target.dao.TargetDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.infra.InfraHost;
import com.loafle.overflow.model.meta.MetaInfraType;
import com.loafle.overflow.model.meta.MetaTargetHostType;
import com.loafle.overflow.model.meta.MetaTargetServiceType;
import com.loafle.overflow.model.meta.MetaTargetType;
import com.loafle.overflow.model.meta.MetaTargetTypeCategory;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.model.target.Target;
import com.loafle.overflow.service.central.infra.InfraService;
import com.loafle.overflow.service.central.meta.MetaTargetHostTypeMappingService;
import com.loafle.overflow.service.central.meta.MetaTargetServiceTypeService;
import com.loafle.overflow.service.central.target.TargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
/**
@ -38,8 +31,6 @@ public class CentralTargetService implements TargetService {
private InfraService infraService;
@Autowired
private CentralProbeService probeService;
@Autowired
private MetaTargetServiceTypeService metaTargetServiceTypeService;
@Transactional
public Target regist(Target target, Long probeID) throws OverflowException {
@ -92,11 +83,11 @@ public class CentralTargetService implements TargetService {
Target target = new Target();
target.setInfra(infra);
target.setSensorCount(0);
if (metaInfraTypeKey.equals(MetaInfraType.Enum.HOST.to().getKey())) {
if (metaInfraTypeKey.equals("HOST")) {
InfraHost infraHost = (InfraHost) infra;
target.setMetaTargetType(MetaTargetHostType.Enum.UNKNOWN.to());
target.setName(infraHost.getInfraHostIPs().get(0).getAddress());
} else if (metaInfraTypeKey.equals(MetaInfraType.Enum.SERVICE.to().getKey())) {
} else if (metaInfraTypeKey.equals("SERVICE")) {
com.loafle.overflow.model.infra.InfraService infraService = (com.loafle.overflow.model.infra.InfraService) infra;
target.setMetaTargetType(infraService.getMetaTargetServiceType());
String name = infraService.getMetaTargetServiceType().getName() + " on "