diff --git a/pom.xml b/pom.xml
index e2814d6..dd346e6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,13 +108,38 @@
commons-io2.5
+
+
+ com.itextpdf
+ itext7-core
+ 7.0.2
+ pom
+
+
+
+ javax.interceptor
+ javax.interceptor-api
+ 1.2
+
+
+
+
+ itext
+ iText Repository - releases
+ https://repo.itextsupport.com/releases
+
+
+
org.springframework.bootspring-boot-maven-plugin
+
+ true
+
diff --git a/src/main/java/com/chlorocode/tendertracker/AWSConfiguration.java b/src/main/java/com/chlorocode/tendertracker/AWSConfiguration.java
index 4d32137..d72d8ab 100644
--- a/src/main/java/com/chlorocode/tendertracker/AWSConfiguration.java
+++ b/src/main/java/com/chlorocode/tendertracker/AWSConfiguration.java
@@ -9,6 +9,9 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+/**
+ * This class is used for AWS configuration.
+ */
@Configuration
public class AWSConfiguration {
@Value("${cloud.aws.credentials.accessKey}")
@@ -20,11 +23,24 @@ public class AWSConfiguration {
@Value("${cloud.aws.region}")
private String region;
+ /**
+ * This method is used for basic AWS credentials.
+ *
+ * @return BasicAWSCredentials
+ * @see BasicAWSCredentials
+ */
@Bean
public BasicAWSCredentials basicAWSCredentials() {
return new BasicAWSCredentials(accessKey, secretKey);
}
+ /**
+ * This method is used for amazon S3 client.
+ *
+ * @param awsCredentials AWSCredentials
+ * @return AmazonS3Client
+ * @see AmazonS3Client
+ */
@Bean
public AmazonS3Client amazonS3Client(AWSCredentials awsCredentials) {
AmazonS3Client amazonS3Client = new AmazonS3Client(awsCredentials);
diff --git a/src/main/java/com/chlorocode/tendertracker/LongProcessConfiguration.java b/src/main/java/com/chlorocode/tendertracker/LongProcessConfiguration.java
new file mode 100644
index 0000000..cb6f082
--- /dev/null
+++ b/src/main/java/com/chlorocode/tendertracker/LongProcessConfiguration.java
@@ -0,0 +1,57 @@
+package com.chlorocode.tendertracker;
+
+import com.chlorocode.tendertracker.api.LongProcess;
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+
+/**
+ * Created by Kyaw Min Thu on 5/1/2017.
+ * This class is used to control the long background process of the application.
+ */
+@Configuration
+@EnableAsync
+public class LongProcessConfiguration implements AsyncConfigurer {
+
+ /**
+ * This method is used to generate the LongProcess bean.
+ *
+ * @return LongProcess
+ * @see LongProcess
+ */
+ @Bean
+ public LongProcess longProcessBean() {
+ return new LongProcess();
+ }
+
+ /**
+ * This method is used to get the executor of async tasks.
+ *
+ * @return Executor
+ */
+ @Override
+ public Executor getAsyncExecutor() {
+ ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
+ taskExecutor.setMaxPoolSize(10);
+ taskExecutor.setThreadNamePrefix("LULExecutor-");
+ taskExecutor.initialize();
+ return taskExecutor;
+ }
+
+ /**
+ * This method is used to create the AsyncUncaughtExceptionHandler.
+ *
+ * @return AsyncUncaughtExceptionHandler
+ */
+ @Override
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+ return new SimpleAsyncUncaughtExceptionHandler();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/chlorocode/tendertracker/TendertrackerApplication.java b/src/main/java/com/chlorocode/tendertracker/TendertrackerApplication.java
index c272aac..4a292ac 100644
--- a/src/main/java/com/chlorocode/tendertracker/TendertrackerApplication.java
+++ b/src/main/java/com/chlorocode/tendertracker/TendertrackerApplication.java
@@ -9,15 +9,20 @@
import org.springframework.data.jpa.datatables.repository.DataTablesRepositoryFactoryBean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import javax.annotation.PostConstruct;
import java.util.TimeZone;
import java.util.concurrent.Executor;
+/**
+ * The base class of the application. Application will be started from this class.
+ */
@SpringBootApplication
@EnableAsync
@EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class)
+@EnableScheduling
public class TendertrackerApplication {
@Value("${application.timezone}")
@@ -32,6 +37,11 @@ public static void main(String[] args) {
SpringApplication.run(TendertrackerApplication.class, args);
}
+ /**
+ * This method used to create the admin filter.
+ *
+ * @return FilterRegistrationBean
+ */
@Bean
public FilterRegistrationBean adminFilter() {
FilterRegistrationBean registration = new FilterRegistrationBean();
@@ -40,6 +50,11 @@ public FilterRegistrationBean adminFilter() {
return registration;
}
+ /**
+ * This method used to create the executor for async threads.
+ *
+ * @return Executor
+ */
@Bean
public Executor asyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
diff --git a/src/main/java/com/chlorocode/tendertracker/WebSecurityConfig.java b/src/main/java/com/chlorocode/tendertracker/WebSecurityConfig.java
index c789585..ed6cd58 100644
--- a/src/main/java/com/chlorocode/tendertracker/WebSecurityConfig.java
+++ b/src/main/java/com/chlorocode/tendertracker/WebSecurityConfig.java
@@ -12,16 +12,14 @@
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
-import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
+/**
+ * This class is used to control the security of the application by using spring security.
+ */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
-
-// @Autowired
-// private AuthenticationSuccessHandler myAuthenticationSuccessHandler;
-
@Autowired
private AuthenticationFailureHandler authenticationFailureHandler;
@@ -32,11 +30,22 @@ public PasswordEncoder passwordEncoder() {
private AuthService authService;
+ /**
+ * Constructor.
+ *
+ * @param authService AuthService
+ */
@Autowired
public WebSecurityConfig(AuthService authService) {
this.authService = authService;
}
+ /**
+ * This method is used to configure the HttpSecurity control of the application.
+ *
+ * @param http HttpSecurity
+ * @throws Exception Exception
+ */
@Override
protected void configure(HttpSecurity http) throws Exception {
http
@@ -44,8 +53,8 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers("/registerCompany").authenticated()
.antMatchers("/tenderNotification").authenticated()
.antMatchers("/user/profile").authenticated()
- .antMatchers("/admin").access("hasAnyRole('ADMIN','SYS_ADMIN','PREPARER')")
- .antMatchers("/admin/**").access("hasAnyRole('ADMIN','PREPARER')")
+ .antMatchers("/admin").access("hasAnyRole('ADMIN','SYS_ADMIN','PREPARER','SUBMITTER')")
+ .antMatchers("/admin/**").access("hasAnyRole('ADMIN','PREPARER','SUBMITTER')")
.antMatchers("/sysadm/**").access("hasRole('SYS_ADMIN')")
.antMatchers("/**").permitAll()
.and()
@@ -55,7 +64,6 @@ protected void configure(HttpSecurity http) throws Exception {
.failureUrl("/login?error")
.usernameParameter("email")
.defaultSuccessUrl("/")
-// .successHandler(myAuthenticationSuccessHandler)
.failureHandler(authenticationFailureHandler)
.permitAll()
.and()
@@ -64,9 +72,15 @@ protected void configure(HttpSecurity http) throws Exception {
.logoutSuccessUrl("/")
.permitAll()
.and()
- .csrf();
+ .csrf().ignoringAntMatchers("/restapi/**");
}
+ /**
+ * This method is used to configure the WebSecurity control of the application.
+ *
+ * @param web WebSecurity
+ * @throws Exception exception
+ */
@Override
public void configure(WebSecurity web) throws Exception {
web
@@ -74,6 +88,12 @@ public void configure(WebSecurity web) throws Exception {
.antMatchers("/resources/**", "/static/**", "/css/**", "/js/**", "/images/**", "/data/**");
}
+ /**
+ * This method is used to configure the AuthenticationManagerBuilder for login of the application.
+ *
+ * @param auth AuthenticationManagerBuilder
+ * @throws Exception exception
+ */
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
diff --git a/src/main/java/com/chlorocode/tendertracker/api/LongProcess.java b/src/main/java/com/chlorocode/tendertracker/api/LongProcess.java
new file mode 100644
index 0000000..b0232af
--- /dev/null
+++ b/src/main/java/com/chlorocode/tendertracker/api/LongProcess.java
@@ -0,0 +1,32 @@
+package com.chlorocode.tendertracker.api;
+
+import com.chlorocode.tendertracker.dao.entity.ExternalTender;
+import com.chlorocode.tendertracker.service.ExternalTenderService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.AsyncResult;
+
+import java.util.List;
+import java.util.concurrent.Future;
+
+/**
+ * This class is used to handle long process threading during external tender saving process.
+ */
+public class LongProcess {
+
+ @Autowired
+ private ExternalTenderService tenderWCService;
+
+ /**
+ * This method is used to save external tender asynchronously.
+ *
+ * @param tenders list of external tender to be saved
+ * @return String
+ */
+ @Async
+ public Future createExternalTenderList(List tenders) {
+ tenderWCService.createTenderWCList(tenders);
+ return new AsyncResult<>("success");
+ }
+
+}
diff --git a/src/main/java/com/chlorocode/tendertracker/api/WebCrawlerController.java b/src/main/java/com/chlorocode/tendertracker/api/WebCrawlerController.java
new file mode 100644
index 0000000..7164a14
--- /dev/null
+++ b/src/main/java/com/chlorocode/tendertracker/api/WebCrawlerController.java
@@ -0,0 +1,117 @@
+package com.chlorocode.tendertracker.api;
+
+import com.chlorocode.tendertracker.dao.entity.ExternalTender;
+import com.chlorocode.tendertracker.logging.TTLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Base64;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Public REST API controller to be consumed by tender crawler.
+ * This REST API is secured by basic HTTP authentication
+ */
+@RestController
+@RequestMapping("/restapi")
+public class WebCrawlerController {
+
+ @Autowired
+ private LongProcess longProcess;
+
+ @Value("${crawler.username}")
+ private String crawlerUsername;
+
+ @Value("${crawler.password}")
+ private String crawlerPassword;
+
+ private static final String template = "Hello, %s!";
+ private final AtomicLong counter = new AtomicLong();
+
+ /**
+ * This method is used to display test message for testing purpose.
+ *
+ * @param name text to be displayed
+ * @return String
+ */
+ @RequestMapping(path = "/greeting", method = RequestMethod.GET)
+ public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
+ return new Greeting(String.valueOf(counter.incrementAndGet()),
+ String.format(template, name));
+ }
+
+ /**
+ * This method is used to save external tender.
+ *
+ * @param tenders list of external tenders to be saved
+ * @param request HttpServletRequest
+ * @return ResponseEntity
+ */
+ @RequestMapping(path = "/tenders", method = RequestMethod.POST)
+ public ResponseEntity tenders(@RequestBody List tenders, HttpServletRequest request) {
+ TTLogger.debug(this.getClass().getName(),"*******************WebCrawlerController" + this.toString() + "*********************");
+
+ // Validate authentication
+ final String authorization = request.getHeader("Authorization");
+ if (authorization != null && authorization.startsWith("Basic")) {
+ String base64Credentials = authorization.substring("Basic".length()).trim();
+ String credentials = new String(Base64.getDecoder().decode(base64Credentials),
+ Charset.forName("UTF-8"));
+ // credentials = username:password
+ final String[] values = credentials.split(":", 2);
+
+ if (values.length != 2 || !values[0].equals(crawlerUsername) || !values[1].equals(crawlerPassword)) {
+ return new ResponseEntity(HttpStatus.UNAUTHORIZED);
+ }
+ } else {
+ return new ResponseEntity(HttpStatus.UNAUTHORIZED);
+ }
+
+ // Proccess the request
+ try {
+ longProcess.createExternalTenderList(tenders);
+ } catch (Exception ex) {
+ TTLogger.error(this.getClass().getName(), "Error when saving External Tender", ex);
+ ResponseEntity responseEntity = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
+ return responseEntity;
+ }
+
+ ResponseEntity responseEntity = new ResponseEntity(HttpStatus.OK);
+ return responseEntity;
+ }
+
+ public class Greeting implements Serializable {
+
+ private final String id;
+ private final String content;
+
+ public Greeting(String id, String content) {
+ this.id = id;
+ this.content = content;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ @Override
+ public String toString() {
+ return "Greeting{" +
+ "id=" + id +
+ ", content='" + content + '\'' +
+ '}';
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/chlorocode/tendertracker/constants/TTConstants.java b/src/main/java/com/chlorocode/tendertracker/constants/TTConstants.java
index 185ef55..2c5c72c 100644
--- a/src/main/java/com/chlorocode/tendertracker/constants/TTConstants.java
+++ b/src/main/java/com/chlorocode/tendertracker/constants/TTConstants.java
@@ -1,11 +1,10 @@
package com.chlorocode.tendertracker.constants;
-import org.springframework.data.domain.Sort;
-
/**
- * Created by Kyaw Min Thu on 3/7/2017.
+ * This class is to capture all system constants.
*/
public class TTConstants {
+
public static final int OTP_VALID_HOURS = 1;
public static final int OTP_LENGTH = 6;
public static String OTP_CHARS = "ABCDEFGHJKLMNPQRSTUVWXYZ";
@@ -14,6 +13,9 @@ public class TTConstants {
public static final String APPROVED = "approved";
public static final String REJECTED = "rejected";
+ public static final int APPEAL_ACCEPT = 1;
+ public static final int APPEAL_REJECT = 2;
+
public static final int ACCOUNT_STATIC_ACTIVE = 1;
public static final int ACCOUNT_STATIC_EXPIRE = 2;
public static final int ACCOUNT_STATIC_LOCK = 3;
@@ -36,23 +38,44 @@ public class TTConstants {
public static final String PARAM_COMPANY_NAME = "company_name";
public static final String PARAM_TENDER = "tender";
public static final String PARAM_APPROVAL_ACTION = "approval_action";
+ public static final String PARAM_APPEAL_ACTION = "appeal_action";
+ public static final String PARAM_MILESTONE_DESCRIPTION = "milestone_description";
+ public static final String PARAM_MILESTONE_DUE_DATE = "milestone_due_date";
+ public static final String PARAM_MILESTONE_STATUS = "milestone_status";
+ public static final String PARAM_APPEAL_COMPANY = "appeal_company";
public static final String OPEN_DATE = "openDate";
public static final String CLOSED_DATE = "closedDate";
public static final String TITLE = "title";
+ public static final String CREATE_DATE = "createdDate";
+ public static final String PRICE = "price";
public static final String ASC = "asc";
public static final String DESC = "desc";
+ public static final String PUBLISHED_DATE = "publishedDate";
+ public static final String CLOSING_DATE = "closingDate";
+
public static final String DEFAULT_SORT = OPEN_DATE;
public static final String DEFAULT_SORT_DIRECTION = ASC;
public static final String LBL_OPEN_DATE = "Open Date";
public static final String LBL_CLOSED_DATE = "Closed Date";
public static final String LBL_TITLE = "Title";
+ public static final String LBL_CREATE_DATE = "Create Date";
+ public static final String LBL_PRICE = "Price";
public static final String LBL_ASC = "Ascending";
public static final String LBL_DESC = "Descending";
public static int UPDATE_TENDER = 1;
public static int ADD_CORRIGENDUM = 2;
+
+ // External tender status.
+ public static final String ET_STATUS_OPEN = "OPEN";
+ public static final String ET_STATUS_CLOSED = "CLOSED";
+ public static final String ET_STATUS_AWARDED = "AWARDED";
+ public static final String ET_STATUS_NO_AWARD = "NO_AWARD";
+ public static final String ET_STATUS_OTHERS = "OTHERS";
+
+ public static final int MILESTONE_APPROACH_DAY=3;
}
diff --git a/src/main/java/com/chlorocode/tendertracker/dao/BidDAO.java b/src/main/java/com/chlorocode/tendertracker/dao/BidDAO.java
index a2ecabb..4b52863 100644
--- a/src/main/java/com/chlorocode/tendertracker/dao/BidDAO.java
+++ b/src/main/java/com/chlorocode/tendertracker/dao/BidDAO.java
@@ -5,10 +5,43 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
+import java.util.List;
+
+/**
+ * This DAO is used for Bid.
+ */
@Repository
public interface BidDAO extends DataTablesRepository {
+ /**
+ * This method is used to find Bid by company and tender.
+ *
+ * @param companyId unique identifier of company
+ * @param tenderId unique identifier of tender
+ * @return Bid
+ * @see Bid
+ */
@Query("select b from Bid b where b.company.id = ?1 and b.tender.id = ?2")
Bid findBidByCompanyAndTender(int companyId, int tenderId);
+ /**
+ * This method is used to find Bid by company.
+ *
+ * @param companyId unique identifier of company
+ * @return List
+ * @see Bid
+ */
+ @Query("select b from Bid b where b.company.id = ?1")
+ List findBidByCompany(int companyId);
+
+ /**
+ * This method is used to find Bid by tender.
+ *
+ * @param tenderId unique identifier of tender
+ * @return List
+ * @see Bid
+ */
+ @Query("select b from Bid b where b.tender.id = ?1")
+ List findBidByTender(int tenderId);
+
}
diff --git a/src/main/java/com/chlorocode/tendertracker/dao/BidDocumentDAO.java b/src/main/java/com/chlorocode/tendertracker/dao/BidDocumentDAO.java
new file mode 100644
index 0000000..e24673a
--- /dev/null
+++ b/src/main/java/com/chlorocode/tendertracker/dao/BidDocumentDAO.java
@@ -0,0 +1,13 @@
+package com.chlorocode.tendertracker.dao;
+
+import com.chlorocode.tendertracker.dao.entity.BidDocument;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * This DAO is used for Bid document.
+ */
+@Repository
+public interface BidDocumentDAO extends JpaRepository {
+
+}
diff --git a/src/main/java/com/chlorocode/tendertracker/dao/BidItemDAO.java b/src/main/java/com/chlorocode/tendertracker/dao/BidItemDAO.java
new file mode 100644
index 0000000..4f595fd
--- /dev/null
+++ b/src/main/java/com/chlorocode/tendertracker/dao/BidItemDAO.java
@@ -0,0 +1,12 @@
+package com.chlorocode.tendertracker.dao;
+
+import com.chlorocode.tendertracker.dao.entity.BidItem;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+/**
+ * Created by andy on 27/1/2018.
+ * This DAO is used for BidItem.
+ */
+public interface BidItemDAO extends JpaRepository {
+
+}
diff --git a/src/main/java/com/chlorocode/tendertracker/dao/ClarificationDAO.java b/src/main/java/com/chlorocode/tendertracker/dao/ClarificationDAO.java
index 5c1b2c7..940eaae 100644
--- a/src/main/java/com/chlorocode/tendertracker/dao/ClarificationDAO.java
+++ b/src/main/java/com/chlorocode/tendertracker/dao/ClarificationDAO.java
@@ -1,7 +1,6 @@
package com.chlorocode.tendertracker.dao;
import com.chlorocode.tendertracker.dao.entity.Clarification;
-import com.chlorocode.tendertracker.dao.entity.EvaluationCriteria;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@@ -10,10 +9,17 @@
/**
* Created by andy on 8/8/2017.
+ * This DAO is used for Clarification.
*/
@Repository
public interface ClarificationDAO extends JpaRepository {
-
+ /**
+ * This method is used for finding tender clarification by tender id.
+ *
+ * @param tenderId unique identifier of tender.
+ * @return List
+ * @see Clarification
+ */
@Query("select r from Clarification r where r.tender.id = ?1 order by r.createdDate desc")
List findClarificationByTenderId(int tenderId);
diff --git a/src/main/java/com/chlorocode/tendertracker/dao/CodeValueDAO.java b/src/main/java/com/chlorocode/tendertracker/dao/CodeValueDAO.java
index d84eda3..8dd917f 100644
--- a/src/main/java/com/chlorocode/tendertracker/dao/CodeValueDAO.java
+++ b/src/main/java/com/chlorocode/tendertracker/dao/CodeValueDAO.java
@@ -1,28 +1,36 @@
package com.chlorocode.tendertracker.dao;
import com.chlorocode.tendertracker.dao.entity.CodeValue;
-import com.chlorocode.tendertracker.dao.entity.Country;
-import com.chlorocode.tendertracker.dao.entity.TenderCategory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
+/**
+ * This DAO is used for finding predefined status, constant and combo box values(CodeValue).
+ */
@Repository
public interface CodeValueDAO extends JpaRepository {
+ /**
+ * This method is used to find the list of code value by type.
+ *
+ * @param type type of the constant/status
+ * @return List
+ * @see CodeValue
+ */
List findByTypeOrderByOrderAsc(String type);
+ /**
+ * This method is used to get the description of CodeValue object.
+ *
+ * @param type type of the constant/status
+ * @param code code of the constant/status
+ * @return String
+ * @see CodeValue
+ */
@Query("select c.description from CodeValue c where c.type = ?1 and c.code = ?2")
String getDescription(String type, int code);
- @Query("select c from TenderCategory c order by c.name")
- List getAllTenderCategories();
-
- @Query("select c from TenderCategory c where c.id = ?1")
- TenderCategory getTenderCategoryById(int id);
-
- @Query("select c from Country c order by c.name")
- List getAllCountries();
}
diff --git a/src/main/java/com/chlorocode/tendertracker/dao/CompanyDAO.java b/src/main/java/com/chlorocode/tendertracker/dao/CompanyDAO.java
index 09a6b26..c2aaf3f 100644
--- a/src/main/java/com/chlorocode/tendertracker/dao/CompanyDAO.java
+++ b/src/main/java/com/chlorocode/tendertracker/dao/CompanyDAO.java
@@ -5,18 +5,64 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
+import java.util.Date;
import java.util.List;
+/**
+ * This DAO is used for CRUD operation of Company.
+ */
@Repository
public interface CompanyDAO extends DataTablesRepository {
+ /**
+ * This method is used to find all companies that are waiting for approval.
+ *
+ * @return List
+ * @see Company
+ */
@Query("select c from Company c where c.status = 0")
List findCompanyPendingApproval();
+ /**
+ * This method is used to find companies by uen.
+ *
+ * @param uen uen of the company
+ * @return List
+ * @see Company
+ */
@Query("select c from Company c where c.uen = ?1")
List findCompanyByUen(String uen);
+ /**
+ * This method is used to find companies by created userId.
+ *
+ * @param userId unique identifier of the company
+ * @return List
+ * @see Company
+ */
@Query("select c from Company c where c.createdBy = ?1")
List findCompanyByCreatedBy(int userId);
+ /**
+ * This method is used to find companies that contain given string.
+ *
+ * @param name name of the company
+ * @return List
+ * @see Company
+ */
+ @Query("select c from Company c where c.name LIKE CONCAT('%',?1,'%') and status = 1")
+ List findCompanyByName(String name);
+
+ /**
+ * This method is used to get the company summary.
+ *
+ * @param startDate Date
+ * @param endDate Date
+ * @return List
+ */
+ @Query(value = "select case when status=0 then 'Pending Approval' when status=1 then 'Approved' when status=2 " +
+ "then 'Rejected' end as Status, count(*) as Count from company where created_date >= ?1 " +
+ "and created_date <= ?2 group by status",
+ nativeQuery = true)
+ List