Commit eb0cf72e authored by Anubhuti MISHRA's avatar Anubhuti MISHRA

Git changes made-Private,@Override

parent b701f0ba
Pipeline #10614 passed with stage
in 42 seconds
......@@ -4,15 +4,6 @@ import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.List;
//import javax.xml.ws.Response;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import org.jboss.logging.Logger;
import org.lcsb.dapi.model.Drug;
import org.lcsb.dapi.service.DrugService;
import org.lcsb.dapi.service.Parser;
......@@ -22,7 +13,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
......@@ -37,13 +27,12 @@ public class DrugController {
@GetMapping("/api/database/drugbank/releases/{releaseName}/drugs/{id}")
public ResponseEntity<?> findById(@PathVariable("id") String id, @PathVariable("releaseName") String releaseName)
throws DrugNotFoundException {
public ResponseEntity<?> findById(@PathVariable("id") String id, @PathVariable("releaseName") String releaseName){
boolean drugIdApproved = validDrugId(id);
if (!drugIdApproved) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Please enter a valid Drug-Id (eg:DB00001) ");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Please enter a valid Drug-Id (eg:DB00001) ");
}
Drug drug = drugService.findById(id, releaseName);
......
......@@ -2,8 +2,6 @@ package org.lcsb.dapi.service;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lcsb.dapi.dao.DrugDao;
import org.lcsb.dapi.dao.ReleaseDao;
import org.lcsb.dapi.model.Drug;
......@@ -14,11 +12,11 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class DrugServiceImp implements DrugService {
@Autowired
private DrugDao drugDao;
@Autowired
@Autowired
private ReleaseDao releaseDao;
@Transactional
......@@ -26,8 +24,8 @@ public class DrugServiceImp implements DrugService {
drugDao.addDrug(drug);
return drug;
}
@Override
@Transactional(readOnly = true)
public List<Drug> list() {
return drugDao.list();
......@@ -36,16 +34,16 @@ public class DrugServiceImp implements DrugService {
@Override
@Transactional
public Drug findById(String id, String releaseName) {
Release release=releaseDao.get(releaseName);
Release release = releaseDao.get(releaseName);
return drugDao.getDrugById(id, release);
}
@Override
@Transactional
public List<Drug> findByRelease(String releaseName) {
Release release=releaseDao.get(releaseName);
Release release = releaseDao.get(releaseName);
return drugDao.getAllDrugsByRelease(release);
}
}
\ No newline at end of file
......@@ -29,17 +29,17 @@ import org.xml.sax.SAXException;
public class Parser {
Logger logger = LogManager.getLogger(Parser.class);
private List<Release> releaseList = new ArrayList<>();
private Drug sampleDrug;
private String releaseTimestamp;
private String releaseName;
private String externalDatabaseName;
ExternalDatabase extDatabase;
private ExternalDatabase extDatabase;
public List<Drug> extractDrugs(InputStream filename)
throws ParserConfigurationException, ParseException, SAXException, IOException, ParserException {
Drug sampleDrug;
List<Drug> druglist = new ArrayList<>();
SAXDrugParser saxDrugParser = new SAXDrugParser();
List<String> drugData = saxDrugParser.parsedDrugs(filename);
......
......@@ -2,9 +2,6 @@ package org.lcsb.dapi.service;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
......@@ -66,8 +63,6 @@ public class DrugServiceTest {
String relName=release.getName();
List<Drug> list=drugService.findByRelease(relName);
assertEquals(1,drugService.list().size());
assertEquals(1,list.size());
assertEquals("Aspirin",list.get(0).getName());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment