-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/dev_FixTest_Hao_CrawlNew…
…sService'
- Loading branch information
Showing
4 changed files
with
162 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...in/java/capstone/lip/landinformationportal/business/validation/CrawledNewsValidation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package capstone.lip.landinformationportal.business.validation; | ||
|
||
import java.sql.Timestamp; | ||
import java.util.List; | ||
import java.util.regex.Pattern; | ||
|
||
import capstone.lip.landinformationportal.common.constant.StatusCrawledNewsConstant; | ||
import capstone.lip.landinformationportal.common.entity.CrawledNews; | ||
|
||
public class CrawledNewsValidation { | ||
|
||
public String isValidCrawledNews(List<CrawledNews> listNews) { | ||
Timestamp time = new Timestamp(System.currentTimeMillis()); | ||
if(listNews == null || (listNews != null && listNews.isEmpty()) ) { | ||
return "List news can not be null or empty"; | ||
} | ||
for (CrawledNews news : listNews) { | ||
if (time.getTime() < news.getCrawledNewsTime().getTime()) { | ||
return "Can't insert future time"; | ||
} | ||
if (news.getCrawledNewsLink() == null | ||
|| (news.getCrawledNewsLink() != null && news.getCrawledNewsLink().trim().isEmpty())) { | ||
return "Link of news can not be null or empty"; | ||
} | ||
if (news.getCrawledNewsWebsite() == null | ||
|| (news.getCrawledNewsWebsite() != null && news.getCrawledNewsWebsite().trim().isEmpty())) { | ||
return "Website of crawled news can not be null or empty"; | ||
} | ||
if (news.getCrawledNewsStatus().equals(StatusCrawledNewsConstant.DISPLAY) | ||
|| news.getCrawledNewsStatus().equals(StatusCrawledNewsConstant.NON_DISPLAY)) { | ||
|
||
} else { | ||
return "News status muse be display or non display"; | ||
} | ||
} | ||
return ""; | ||
} | ||
|
||
public String isValidCrawledNewsOne(CrawledNews news) { | ||
Timestamp time = new Timestamp(System.currentTimeMillis()); | ||
if(news.getCrawledNewsID() <= 0) { | ||
return "News ID can not be negative or equal zero"; | ||
} | ||
if (time.getTime() < news.getCrawledNewsTime().getTime()) { | ||
return "Can't insert future time"; | ||
} | ||
if (news.getCrawledNewsLink() == null | ||
|| (news.getCrawledNewsLink() != null && news.getCrawledNewsLink().trim().isEmpty())) { | ||
return "Link of news can not be null or empty"; | ||
} | ||
if (news.getCrawledNewsWebsite() == null | ||
|| (news.getCrawledNewsWebsite() != null && news.getCrawledNewsWebsite().trim().isEmpty())) { | ||
return "Website of crawled news can not be null or empty"; | ||
} | ||
if (news.getCrawledNewsStatus().equals(StatusCrawledNewsConstant.DISPLAY) | ||
|| news.getCrawledNewsStatus().equals(StatusCrawledNewsConstant.NON_DISPLAY)) { | ||
|
||
} else { | ||
return "News status muse be display or non display"; | ||
} | ||
return ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters