2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
6 *=================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package com.onap.sdnc.reports.service;
22 import java.util.ArrayList;
23 import java.util.Date;
24 import java.util.List;
26 import org.apache.logging.log4j.LogManager;
27 import org.apache.logging.log4j.Logger;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.stereotype.Service;
30 import com.onap.sdnc.reports.model.PreTestConfig;
31 import com.onap.sdnc.reports.repository.DeviceRepository;
32 import com.onap.sdnc.reports.repository.PreTestConfigRepository;
33 import com.onap.sdnc.reports.rest.model.PreTestModel;
36 public class ReportServiceImpl implements IReportService {
38 private static final Logger logger = LogManager.getLogger(ReportServiceImpl.class);
41 DeviceRepository deviceRepository;
44 PreTestConfigRepository preTestConfigRepository;
48 public List<PreTestModel> findReportByDeviceIP(Date startDate, Date endDate, String deviceIP) throws Exception{
52 List<PreTestConfig> resultSet= preTestConfigRepository.findReportByDeviceIP(startDate, endDate, deviceIP);
54 if(logger.isDebugEnabled())
55 logger.debug("Received Output From Repository Is: "+resultSet);
57 List<PreTestModel> preTestList=new ArrayList<PreTestModel>();
58 for(PreTestConfig config : resultSet)
61 long deviceid=config.getDevice().getId();
62 long testid=config.getTestId();
63 String testName=config.getTestName();
64 String deviceIp=config.getDevice().getDeviceIP();
65 String execuationDetails=config.getExecuationDetails();
66 String result=config.getResult();
67 Date timeStamp=config.getTimestamp();
69 PreTestModel model=new PreTestModel(testid, deviceid, testName, deviceIp, execuationDetails, result, timeStamp);
70 preTestList.add(model);
74 logger.info("Exception Occured : "+ex.getLocalizedMessage());
78 logger.info("Final PreTestConfig List Size : "+preTestList.size());
79 logger.info("findReportByDeviceIP Finished Working..");
84 logger.info("Exception Occured : "+ex.getLocalizedMessage());
86 throw new Exception("Exception occurred while processing findReportByDeviceIP ",ex);