forked from BLC/sgeUpdated
Make the Datacenter module structure following the whole code structure
This commit is contained in:
39
docker-compose.yml
Normal file
39
docker-compose.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
services:
|
||||
backend:
|
||||
build:
|
||||
context: ./sge-backend
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8080:8080"
|
||||
env_file:
|
||||
- ./config.conf
|
||||
environment:
|
||||
SPRING_PROFILES_ACTIVE: docker
|
||||
depends_on:
|
||||
- database
|
||||
restart: unless-stopped
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./sge-frontend
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "80:80"
|
||||
env_file:
|
||||
- ./config.conf
|
||||
restart: unless-stopped
|
||||
|
||||
database:
|
||||
image: postgres:15
|
||||
environment:
|
||||
POSTGRES_DB: sge
|
||||
POSTGRES_USER: sge
|
||||
POSTGRES_PASSWORD: 147
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
@@ -1,4 +1,5 @@
|
||||
package com.sgs.graphql.dataCenter.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.sgs.graphql.area.domain.Area;
|
||||
@@ -14,7 +15,6 @@ import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -26,7 +26,7 @@ public class DataCenter extends BaseDomain {
|
||||
|
||||
@Column(unique = true)
|
||||
private Integer externalId;
|
||||
|
||||
|
||||
private Integer number;
|
||||
private Area area;
|
||||
|
||||
@@ -37,16 +37,14 @@ public class DataCenter extends BaseDomain {
|
||||
private EmissionScope emissionScope;
|
||||
private Double consuptionAmount;
|
||||
private ActivitySubUnit activitySubUnit;
|
||||
|
||||
|
||||
// New attributes
|
||||
private String ayposURL;
|
||||
private String address;
|
||||
private Double latitude;
|
||||
private Double longitude;
|
||||
|
||||
|
||||
@Column(name = "data_center_name")
|
||||
@Transactional
|
||||
public String getDataCenter() {
|
||||
return dataCenter;
|
||||
}
|
||||
@@ -94,7 +92,6 @@ public class DataCenter extends BaseDomain {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "sector_id")
|
||||
public Sector getSector() {
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
package com.sgs.graphql.dataCenter.mutation;
|
||||
|
||||
import com.sgs.exception.GraphQLCustomException;
|
||||
import com.sgs.graphql.dataCenter.mutation.mapper.DataCenterMapper;
|
||||
import com.sgs.graphql.dataCenter.service.DataCenterService;
|
||||
import com.sgs.graphql.dataCenter.domain.DataCenter;
|
||||
import com.sgs.graphql.dataCenter.mutation.input.DataCenterCreateInput;
|
||||
import com.sgs.graphql.dataCenter.mutation.input.DataCenterUpdateInput;
|
||||
import com.sgs.graphql.permission.domain.PermissionName;
|
||||
import com.sgs.graphql.systemHistory.enums.LogType;
|
||||
import com.sgs.graphql.systemHistory.mutation.SystemLogger;
|
||||
import com.sgs.graphql.userHistory.mutation.UserLogger;
|
||||
import com.sgs.graphql.userNotification.mutation.UserNotificationMutation;
|
||||
import graphql.kickstart.tools.GraphQLMutationResolver;
|
||||
import graphql.schema.DataFetchingEnvironment;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import javax.validation.Valid;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Validated
|
||||
@@ -21,57 +29,128 @@ public class DataCenterMutation implements GraphQLMutationResolver {
|
||||
|
||||
private final DataCenterService dataCenterService;
|
||||
private final DataCenterMapper dataCenterMapper;
|
||||
private final SystemLogger systemLogger;
|
||||
private final UserLogger userLogger;
|
||||
private final UserNotificationMutation notificationMutation;
|
||||
|
||||
@Autowired
|
||||
public DataCenterMutation(DataCenterService dataCenterService, DataCenterMapper dataCenterMapper) {
|
||||
public DataCenterMutation(DataCenterService dataCenterService, DataCenterMapper dataCenterMapper,
|
||||
SystemLogger systemLogger, UserLogger userLogger,
|
||||
UserNotificationMutation notificationMutation) {
|
||||
this.dataCenterService = dataCenterService;
|
||||
this.dataCenterMapper = dataCenterMapper;
|
||||
this.systemLogger = systemLogger;
|
||||
this.userLogger = userLogger;
|
||||
this.notificationMutation = notificationMutation;
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('" + PermissionName.DATA_CENTER_CREATE + "')")
|
||||
public DataCenter createDataCenter(@Valid DataCenterCreateInput input) {
|
||||
// Check for duplicate externalId
|
||||
if (input.getExternalId() != null && dataCenterService.existsByExternalId(input.getExternalId())) {
|
||||
throw new RuntimeException("This external id already exists: " + input.getExternalId());
|
||||
@Transactional
|
||||
public DataCenter createDataCenter(@Valid DataCenterCreateInput input, DataFetchingEnvironment environment) {
|
||||
try {
|
||||
// Check for duplicate externalId
|
||||
if (input.getExternalId() != null && dataCenterService.existsByExternalId(input.getExternalId())) {
|
||||
throw new GraphQLCustomException("2010", input.getExternalId().toString());
|
||||
}
|
||||
|
||||
DataCenter dataCenter = dataCenterMapper.toEntity(input);
|
||||
|
||||
// Set auto-generated number if not provided
|
||||
if (dataCenter.getNumber() == null) {
|
||||
Integer maxNumber = dataCenterService.findMaxNumber();
|
||||
dataCenter.setNumber((maxNumber == null) ? 1 : maxNumber + 1);
|
||||
}
|
||||
|
||||
DataCenter savedDataCenter = dataCenterService.save(dataCenter);
|
||||
|
||||
// Log and notify
|
||||
String dataCenterName = savedDataCenter.getDataCenter() != null ? savedDataCenter.getDataCenter()
|
||||
: "DataCenter #" + savedDataCenter.getNumber();
|
||||
systemLogger.createSystemLog(LogType.INFO, dataCenterName + " adlı veri merkezi oluşturuldu");
|
||||
userLogger.createUserLog(LogType.INFO, dataCenterName + " adlı veri merkezi oluşturuldu", environment);
|
||||
notificationMutation.createNotification(environment, "Veri Merkezi",
|
||||
dataCenterName + " adlı veri merkezi oluşturuldu", "Yeni kayıt");
|
||||
|
||||
return savedDataCenter;
|
||||
} catch (GraphQLCustomException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
systemLogger.createSystemLog(LogType.ERROR,
|
||||
"Yeni veri merkezi oluşturulurken hata oluştu: " + e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
|
||||
DataCenter dataCenter = dataCenterMapper.toEntity(input);
|
||||
|
||||
// Set auto-generated number if not provided
|
||||
if (dataCenter.getNumber() == null) {
|
||||
Integer maxNumber = dataCenterService.getRepository().findMaxNumber();
|
||||
dataCenter.setNumber((maxNumber == null) ? 1 : maxNumber + 1);
|
||||
}
|
||||
|
||||
return dataCenterService.save(dataCenter);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('" + PermissionName.DATA_CENTER_UPDATE + "')")
|
||||
public DataCenter updateDataCenter(UUID id, @Valid DataCenterUpdateInput input) {
|
||||
return dataCenterService.findById(id)
|
||||
.map(dataCenter -> {
|
||||
// Check for duplicate externalId if it's being updated
|
||||
if (input.getExternalId() != null &&
|
||||
!input.getExternalId().equals(dataCenter.getExternalId()) &&
|
||||
dataCenterService.existsByExternalId(input.getExternalId())) {
|
||||
throw new RuntimeException("This external id already exists: " + input.getExternalId());
|
||||
}
|
||||
return dataCenterService.update(dataCenterMapper.updateEntity(dataCenter, input));
|
||||
})
|
||||
.orElseThrow(() -> new RuntimeException("Data center not found with ID: " + id));
|
||||
@Transactional
|
||||
public DataCenter updateDataCenter(UUID id, @Valid DataCenterUpdateInput input,
|
||||
DataFetchingEnvironment environment) {
|
||||
try {
|
||||
DataCenter dataCenter = dataCenterService.findById(id)
|
||||
.orElseThrow(() -> new NoSuchElementException("Data center not found with ID: " + id));
|
||||
|
||||
// Check for duplicate externalId if it's being updated
|
||||
if (input.getExternalId() != null &&
|
||||
!input.getExternalId().equals(dataCenter.getExternalId()) &&
|
||||
dataCenterService.existsByExternalId(input.getExternalId())) {
|
||||
throw new GraphQLCustomException("2010", input.getExternalId().toString());
|
||||
}
|
||||
|
||||
DataCenter updatedDataCenter = dataCenterService.update(dataCenterMapper.updateEntity(dataCenter, input));
|
||||
|
||||
// Log and notify
|
||||
String dataCenterName = updatedDataCenter.getDataCenter() != null ? updatedDataCenter.getDataCenter()
|
||||
: "DataCenter #" + updatedDataCenter.getNumber();
|
||||
systemLogger.createSystemLog(LogType.INFO, dataCenterName + " adlı veri merkezi güncellendi");
|
||||
userLogger.createUserLog(LogType.INFO, dataCenterName + " adlı veri merkezi güncellendi", environment);
|
||||
notificationMutation.createNotification(environment, "Veri Merkezi",
|
||||
dataCenterName + " adlı veri merkezi güncellendi", "Güncelleme");
|
||||
|
||||
return updatedDataCenter;
|
||||
} catch (GraphQLCustomException e) {
|
||||
throw e;
|
||||
} catch (NoSuchElementException e) {
|
||||
systemLogger.createSystemLog(LogType.ERROR, "Veri merkezi bulunamadı: " + id);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
systemLogger.createSystemLog(LogType.ERROR, "Veri merkezi güncellenirken hata oluştu: " + e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('" + PermissionName.DATA_CENTER_DELETE + "')")
|
||||
public Boolean deleteDataCenter(UUID id) {
|
||||
@Transactional
|
||||
public String deleteDataCenter(UUID id, DataFetchingEnvironment environment) {
|
||||
String dataCenterName = "";
|
||||
try {
|
||||
DataCenter dataCenter = dataCenterService.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Data center not found with ID: " + id));
|
||||
|
||||
.orElseThrow(() -> new NoSuchElementException("Data center not found with ID: " + id));
|
||||
|
||||
dataCenterName = dataCenter.getDataCenter() != null ? dataCenter.getDataCenter()
|
||||
: "DataCenter #" + dataCenter.getNumber();
|
||||
|
||||
// Check if data center has physical machines or other dependencies
|
||||
if (dataCenter.getPhysicalMachines() != null && !dataCenter.getPhysicalMachines().isEmpty()) {
|
||||
String message = "Silinmeye çalışılan veri merkezinin fiziksel makineleri olduğu için silinememektedir";
|
||||
systemLogger.createSystemLog(LogType.WARN, dataCenterName + ": " + message);
|
||||
return message;
|
||||
}
|
||||
|
||||
dataCenterService.delete(dataCenter);
|
||||
return true;
|
||||
|
||||
// Log and notify
|
||||
systemLogger.createSystemLog(LogType.INFO, dataCenterName + " adlı veri merkezi silindi");
|
||||
userLogger.createUserLog(LogType.INFO, dataCenterName + " adlı veri merkezi silindi", environment);
|
||||
notificationMutation.createNotification(environment, "Veri Merkezi",
|
||||
dataCenterName + " adlı veri merkezi silindi", "Silme");
|
||||
|
||||
return "true";
|
||||
} catch (NoSuchElementException e) {
|
||||
systemLogger.createSystemLog(LogType.ERROR, "Veri merkezi bulunamadı: " + id);
|
||||
return "false";
|
||||
} catch (Exception e) {
|
||||
System.out.println("DataCenter deletion error: " + e.getMessage());
|
||||
return false;
|
||||
systemLogger.createSystemLog(LogType.ERROR, "Veri merkezi silinirken hata oluştu: " + e.getMessage());
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import com.sgs.lib.dao.mutation.input.BaseUpdateInput;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class DataCenterUpdateInput extends BaseUpdateInput {
|
||||
private String dataCenter;
|
||||
private Integer externalId;
|
||||
|
||||
@@ -11,17 +11,16 @@ import javax.transaction.Transactional;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sgs.graphql.auth.service.AuthorizationService;
|
||||
import com.sgs.graphql.dataCenter.domain.DataCenter;
|
||||
import com.sgs.graphql.dataCenter.domain.PhysicalMachine;
|
||||
import com.sgs.graphql.dataCenter.query.pagination.DataCenterPageable;
|
||||
import com.sgs.graphql.dataCenter.repo.DataCenterRepo;
|
||||
import com.sgs.graphql.dataCenter.repo.PhysicalMachineRepo;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.DataCenterCriteria;
|
||||
import com.sgs.graphql.dataCenter.service.DataCenterService;
|
||||
import com.sgs.graphql.systemHistory.mutation.SystemLogger;
|
||||
import com.sgs.graphql.dataCenter.service.PhysicalMachineService;
|
||||
import com.sgs.graphql.permission.domain.PermissionName;
|
||||
import com.sgs.lib.dao.query.pagination.Pagination;
|
||||
import com.sgs.lib.dao.query.sort.SortBy;
|
||||
|
||||
@@ -30,48 +29,46 @@ import graphql.kickstart.tools.GraphQLQueryResolver;
|
||||
@Component
|
||||
public class DataCenterQueryResolver implements GraphQLQueryResolver {
|
||||
|
||||
private final DataCenterService DataCenterService;
|
||||
private final DataCenterRepo dataCenterRepo;
|
||||
private final PhysicalMachineRepo physicalMachineRepo;
|
||||
private final AuthorizationService authorizationService;
|
||||
private final SystemLogger systemLogger;
|
||||
private final DataCenterService dataCenterService;
|
||||
private final PhysicalMachineService physicalMachineService;
|
||||
|
||||
@Autowired
|
||||
public DataCenterQueryResolver(AuthorizationService authorizationService, SystemLogger systemLogger, DataCenterService DataCenterService, DataCenterRepo dataCenterRepo, PhysicalMachineRepo physicalMachineRepo) {
|
||||
this.DataCenterService = DataCenterService;
|
||||
this.dataCenterRepo = dataCenterRepo;
|
||||
this.physicalMachineRepo = physicalMachineRepo;
|
||||
this.authorizationService = authorizationService;
|
||||
this.systemLogger = systemLogger;
|
||||
public DataCenterQueryResolver(DataCenterService dataCenterService, PhysicalMachineService physicalMachineService) {
|
||||
this.dataCenterService = dataCenterService;
|
||||
this.physicalMachineService = physicalMachineService;
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('" + PermissionName.DATA_CENTER_READ + "')")
|
||||
public DataCenter dataCenter(UUID id) {
|
||||
return DataCenterService.findById(id).orElse(null);
|
||||
return dataCenterService.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@PreAuthorize("hasAuthority('" + PermissionName.DATA_CENTER_READ + "')")
|
||||
public List<DataCenter> dataCenters(DataCenterCriteria criteria, List<SortBy> sortBy) {
|
||||
List<DataCenter> dataCenters = DataCenterService.filterWithSort(ObjectUtils.defaultIfNull(criteria, new DataCenterCriteria()),
|
||||
return dataCenterService.filterWithSort(ObjectUtils.defaultIfNull(criteria, new DataCenterCriteria()),
|
||||
Sort.by(ObjectUtils.defaultIfNull(sortBy, new ArrayList<SortBy>())
|
||||
.stream()
|
||||
.map(SortBy::toOrder)
|
||||
.collect(Collectors.toList())));
|
||||
|
||||
return dataCenters;
|
||||
}
|
||||
|
||||
public DataCenterPageable paginateDataCenters(Pagination pagination, DataCenterCriteria criteria, List<SortBy> sortBy) {
|
||||
return new DataCenterPageable(DataCenterService.filterWithPaginate(ObjectUtils.defaultIfNull(criteria, new DataCenterCriteria()),
|
||||
Pagination.toPageRequest(pagination, sortBy)));
|
||||
@PreAuthorize("hasAuthority('" + PermissionName.PAGINATE_DATACENTERS_GET + "')")
|
||||
public DataCenterPageable paginateDataCenters(Pagination pagination, DataCenterCriteria criteria,
|
||||
List<SortBy> sortBy) {
|
||||
return new DataCenterPageable(
|
||||
dataCenterService.filterWithPaginate(ObjectUtils.defaultIfNull(criteria, new DataCenterCriteria()),
|
||||
Pagination.toPageRequest(pagination, sortBy)));
|
||||
}
|
||||
|
||||
|
||||
public Optional<DataCenter> getByNumber(Integer id) {
|
||||
return dataCenterRepo.findByNumber(id).stream().findFirst();
|
||||
@PreAuthorize("hasAuthority('" + PermissionName.DATA_CENTER_READ + "')")
|
||||
public Optional<DataCenter> getByNumber(Integer number) {
|
||||
return dataCenterService.findByNumber(number);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('" + PermissionName.DATA_CENTER_READ + "')")
|
||||
public List<PhysicalMachine> physicalMachines(UUID datacenterId) {
|
||||
return physicalMachineRepo.findByDatacenterId(datacenterId);
|
||||
return physicalMachineService.findByDatacenterId(datacenterId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ package com.sgs.graphql.dataCenter.repo;
|
||||
|
||||
import com.sgs.graphql.dataCenter.domain.DataCenter;
|
||||
import com.sgs.graphql.dataCenter.domain.DataCenterEmissionSource;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import com.sgs.lib.dao.repo.BaseRepo;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -11,14 +12,14 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface DataCenterEmissionSourceRepo extends JpaRepository<DataCenterEmissionSource, String> {
|
||||
|
||||
public interface DataCenterEmissionSourceRepo extends BaseRepo<DataCenterEmissionSource> {
|
||||
|
||||
List<DataCenterEmissionSource> findByDataCenter(DataCenter dataCenter);
|
||||
|
||||
|
||||
Optional<DataCenterEmissionSource> findByDataCenterAndIsDefaultTrue(DataCenter dataCenter);
|
||||
|
||||
|
||||
@Query("SELECT dces FROM DataCenterEmissionSource dces WHERE dces.dataCenter.id = :dataCenterId")
|
||||
List<DataCenterEmissionSource> findByDataCenterId(@Param("dataCenterId") String dataCenterId);
|
||||
|
||||
|
||||
void deleteByDataCenter(DataCenter dataCenter);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.sgs.graphql.dataCenter.repo.criteria;
|
||||
|
||||
import com.sgs.lib.dao.repo.criteria.BaseCriteria;
|
||||
|
||||
public class DataCenterEmissionSourceCriteria extends BaseCriteria {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.sgs.graphql.dataCenter.repo.criteria;
|
||||
|
||||
import com.sgs.lib.dao.repo.criteria.BaseCriteria;
|
||||
|
||||
public class PhysicalMachineCriteria extends BaseCriteria {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.sgs.graphql.dataCenter.repo.criteria;
|
||||
|
||||
import com.sgs.lib.dao.repo.criteria.BaseCriteria;
|
||||
|
||||
public class VMCriteria extends BaseCriteria {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.sgs.graphql.dataCenter.repo.criteria.spec;
|
||||
|
||||
import com.sgs.graphql.dataCenter.domain.DataCenterEmissionSource;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.DataCenterEmissionSourceCriteria;
|
||||
import com.sgs.lib.dao.repo.criteria.spec.BaseCriteriaSpec;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DataCenterEmissionSourceCriteriaSpec
|
||||
extends BaseCriteriaSpec<DataCenterEmissionSource, DataCenterEmissionSourceCriteria> {
|
||||
|
||||
@Override
|
||||
public Specification<DataCenterEmissionSource> createForAll(DataCenterEmissionSourceCriteria criteria) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sgs.graphql.dataCenter.repo.criteria.spec;
|
||||
|
||||
import com.sgs.graphql.dataCenter.domain.PhysicalMachine;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.PhysicalMachineCriteria;
|
||||
import com.sgs.lib.dao.repo.criteria.spec.BaseCriteriaSpec;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class PhysicalMachineCriteriaSpec extends BaseCriteriaSpec<PhysicalMachine, PhysicalMachineCriteria> {
|
||||
|
||||
@Override
|
||||
public Specification<PhysicalMachine> createForAll(PhysicalMachineCriteria criteria) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sgs.graphql.dataCenter.repo.criteria.spec;
|
||||
|
||||
import com.sgs.graphql.dataCenter.domain.VM;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.VMCriteria;
|
||||
import com.sgs.lib.dao.repo.criteria.spec.BaseCriteriaSpec;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class VMCriteriaSpec extends BaseCriteriaSpec<VM, VMCriteria> {
|
||||
|
||||
@Override
|
||||
public Specification<VM> createForAll(VMCriteria criteria) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.sgs.graphql.dataCenter.service;
|
||||
|
||||
import com.sgs.graphql.dataCenter.domain.DataCenter;
|
||||
import com.sgs.graphql.dataCenter.domain.DataCenterEmissionSource;
|
||||
import com.sgs.graphql.dataCenter.repo.DataCenterEmissionSourceRepo;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.DataCenterEmissionSourceCriteria;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.spec.DataCenterEmissionSourceCriteriaSpec;
|
||||
import com.sgs.lib.dao.service.BaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class DataCenterEmissionSourceService extends
|
||||
BaseService<DataCenterEmissionSource, DataCenterEmissionSourceRepo, DataCenterEmissionSourceCriteria, DataCenterEmissionSourceCriteriaSpec> {
|
||||
|
||||
@Autowired
|
||||
public DataCenterEmissionSourceService(DataCenterEmissionSourceRepo repository,
|
||||
DataCenterEmissionSourceCriteriaSpec criteriaSpec) {
|
||||
super(repository, criteriaSpec);
|
||||
}
|
||||
|
||||
public List<DataCenterEmissionSource> findByDataCenter(DataCenter dataCenter) {
|
||||
return getRepository().findByDataCenter(dataCenter);
|
||||
}
|
||||
|
||||
public Optional<DataCenterEmissionSource> findByDataCenterAndIsDefaultTrue(DataCenter dataCenter) {
|
||||
return getRepository().findByDataCenterAndIsDefaultTrue(dataCenter);
|
||||
}
|
||||
|
||||
public List<DataCenterEmissionSource> findByDataCenterId(String dataCenterId) {
|
||||
return getRepository().findByDataCenterId(dataCenterId);
|
||||
}
|
||||
|
||||
public void deleteByDataCenter(DataCenter dataCenter) {
|
||||
getRepository().deleteByDataCenter(dataCenter);
|
||||
}
|
||||
}
|
||||
@@ -8,15 +8,26 @@ import com.sgs.lib.dao.service.BaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class DataCenterService extends BaseService<DataCenter, DataCenterRepo, DataCenterCriteria, DataCenterCriteriaSpec> {
|
||||
public class DataCenterService
|
||||
extends BaseService<DataCenter, DataCenterRepo, DataCenterCriteria, DataCenterCriteriaSpec> {
|
||||
|
||||
@Autowired
|
||||
public DataCenterService(DataCenterRepo repository, DataCenterCriteriaSpec criteriaSpec) {
|
||||
super(repository, criteriaSpec);
|
||||
}
|
||||
|
||||
|
||||
public boolean existsByExternalId(Integer externalId) {
|
||||
return getRepository().existsByExternalId(externalId);
|
||||
}
|
||||
|
||||
public Optional<DataCenter> findByNumber(Integer number) {
|
||||
return getRepository().findByNumber(number);
|
||||
}
|
||||
|
||||
public Integer findMaxNumber() {
|
||||
return getRepository().findMaxNumber();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.sgs.graphql.dataCenter.service;
|
||||
|
||||
import com.sgs.graphql.dataCenter.domain.PhysicalMachine;
|
||||
import com.sgs.graphql.dataCenter.repo.PhysicalMachineRepo;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.PhysicalMachineCriteria;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.spec.PhysicalMachineCriteriaSpec;
|
||||
import com.sgs.lib.dao.service.BaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class PhysicalMachineService extends
|
||||
BaseService<PhysicalMachine, PhysicalMachineRepo, PhysicalMachineCriteria, PhysicalMachineCriteriaSpec> {
|
||||
|
||||
@Autowired
|
||||
public PhysicalMachineService(PhysicalMachineRepo repository, PhysicalMachineCriteriaSpec criteriaSpec) {
|
||||
super(repository, criteriaSpec);
|
||||
}
|
||||
|
||||
public List<PhysicalMachine> findByDatacenterId(UUID datacenterId) {
|
||||
return getRepository().findByDatacenterId(datacenterId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sgs.graphql.dataCenter.service;
|
||||
|
||||
import com.sgs.graphql.dataCenter.domain.VM;
|
||||
import com.sgs.graphql.dataCenter.repo.VMRepo;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.VMCriteria;
|
||||
import com.sgs.graphql.dataCenter.repo.criteria.spec.VMCriteriaSpec;
|
||||
import com.sgs.lib.dao.service.BaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class VMService extends BaseService<VM, VMRepo, VMCriteria, VMCriteriaSpec> {
|
||||
|
||||
@Autowired
|
||||
public VMService(VMRepo repository, VMCriteriaSpec criteriaSpec) {
|
||||
super(repository, criteriaSpec);
|
||||
}
|
||||
|
||||
public List<VM> findAllByVmName(String vmName) {
|
||||
return getRepository().findAllByVmName(vmName);
|
||||
}
|
||||
|
||||
public Optional<VM> findFirstByVmNameOrderByIdDesc(String vmName) {
|
||||
return getRepository().findFirstByVmNameOrderByIdDesc(vmName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user