From 45c864bbd4a1d947c424d389ffd69d0b9f1a8b5e Mon Sep 17 00:00:00 2001 From: khoa-nd Date: Fri, 22 Jan 2016 10:12:50 +0700 Subject: [PATCH 01/11] Temporarily refactor challenge phase --- .../entity/ChallengeRegistrantDto.java | 197 +++++++++--------- .../entity/ChallengeRegistrantEntity.java | 10 + .../model/ChallengeDashBoardInfo.java | 9 +- .../techlooper/model/challenge/PhaseType.java | 42 ++++ .../model/challenge/RegistrationPhase.java | 7 + .../service/ChallengeRegistrantService.java | 2 +- .../impl/ChallengeRegistrantServiceImpl.java | 38 +--- 7 files changed, 175 insertions(+), 130 deletions(-) create mode 100644 src/main/java/com/techlooper/model/challenge/PhaseType.java create mode 100644 src/main/java/com/techlooper/model/challenge/RegistrationPhase.java diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java index cccb18cb4..39b748c5d 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java @@ -4,6 +4,7 @@ import com.techlooper.model.ChallengeSubmissionDto; import com.techlooper.model.Language; import com.techlooper.model.RewardEnum; +import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -13,143 +14,143 @@ */ public class ChallengeRegistrantDto { - private Long challengeId; + private Long challengeId; - private String registrantEmail; + private String registrantEmail; - private String registrantFirstName; + private String registrantFirstName; - private String registrantLastName; + private String registrantLastName; - private Language lang; + private Language lang; - private Double score; + private Double score; - private Long registrantId; + private Long registrantId; - private Boolean disqualified; + private Boolean disqualified; - private String disqualifiedReason; + private String disqualifiedReason; - private String lastEmailSentDateTime; + private String lastEmailSentDateTime; - private List submissions; + private List submissions; - private ChallengePhaseEnum activePhase; + private PhaseType activePhase; - private Set criteria; + private Set criteria; - private RewardEnum reward; + private RewardEnum reward; - public RewardEnum getReward() { - return reward; - } + public RewardEnum getReward() { + return reward; + } - public void setReward(RewardEnum reward) { - this.reward = reward; - } + public void setReward(RewardEnum reward) { + this.reward = reward; + } - public Set getCriteria() { - return criteria; - } + public Set getCriteria() { + return criteria; + } - public void setCriteria(Set criteria) { - this.criteria = criteria; - } + public void setCriteria(Set criteria) { + this.criteria = criteria; + } - public ChallengePhaseEnum getActivePhase() { - return activePhase; - } + public PhaseType getActivePhase() { + return activePhase; + } - public void setActivePhase(ChallengePhaseEnum activePhase) { - this.activePhase = activePhase; - } + public void setActivePhase(PhaseType phaseType) { + this.activePhase = phaseType; + } - public String getDisqualifiedReason() { - return disqualifiedReason; - } + public String getDisqualifiedReason() { + return disqualifiedReason; + } - public void setDisqualifiedReason(String disqualifiedReason) { - this.disqualifiedReason = disqualifiedReason; - } + public void setDisqualifiedReason(String disqualifiedReason) { + this.disqualifiedReason = disqualifiedReason; + } - public Boolean getDisqualified() { - return disqualified; - } + public Boolean getDisqualified() { + return disqualified; + } - public void setDisqualified(Boolean disqualified) { - this.disqualified = disqualified; - } + public void setDisqualified(Boolean disqualified) { + this.disqualified = disqualified; + } - public Long getRegistrantId() { - return registrantId; - } + public Long getRegistrantId() { + return registrantId; + } - public void setRegistrantId(Long registrantId) { - this.registrantId = registrantId; - } + public void setRegistrantId(Long registrantId) { + this.registrantId = registrantId; + } - public Double getScore() { - return score; - } + public Double getScore() { + return score; + } - public void setScore(Double score) { - this.score = score; - } + public void setScore(Double score) { + this.score = score; + } - public Long getChallengeId() { - return challengeId; - } + public Long getChallengeId() { + return challengeId; + } - public void setChallengeId(Long challengeId) { - this.challengeId = challengeId; - } + public void setChallengeId(Long challengeId) { + this.challengeId = challengeId; + } - public String getRegistrantEmail() { - return registrantEmail; - } + public String getRegistrantEmail() { + return registrantEmail; + } - public void setRegistrantEmail(String registrantEmail) { - this.registrantEmail = registrantEmail; - } + public void setRegistrantEmail(String registrantEmail) { + this.registrantEmail = registrantEmail; + } - public String getRegistrantFirstName() { - return registrantFirstName; - } + public String getRegistrantFirstName() { + return registrantFirstName; + } - public void setRegistrantFirstName(String registrantFirstName) { - this.registrantFirstName = registrantFirstName; - } + public void setRegistrantFirstName(String registrantFirstName) { + this.registrantFirstName = registrantFirstName; + } - public String getRegistrantLastName() { - return registrantLastName; - } + public String getRegistrantLastName() { + return registrantLastName; + } - public void setRegistrantLastName(String registrantLastName) { - this.registrantLastName = registrantLastName; - } + public void setRegistrantLastName(String registrantLastName) { + this.registrantLastName = registrantLastName; + } - public Language getLang() { - return lang; - } + public Language getLang() { + return lang; + } - public void setLang(Language lang) { - this.lang = lang; - } + public void setLang(Language lang) { + this.lang = lang; + } - public List getSubmissions() { - return submissions; - } + public List getSubmissions() { + return submissions; + } - public void setSubmissions(List submissions) { - this.submissions = submissions; - } + public void setSubmissions(List submissions) { + this.submissions = submissions; + } - public String getLastEmailSentDateTime() { - return lastEmailSentDateTime; - } + public String getLastEmailSentDateTime() { + return lastEmailSentDateTime; + } - public void setLastEmailSentDateTime(String lastEmailSentDateTime) { - this.lastEmailSentDateTime = lastEmailSentDateTime; - } + public void setLastEmailSentDateTime(String lastEmailSentDateTime) { + this.lastEmailSentDateTime = lastEmailSentDateTime; + } } diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java index 81e7f4c81..779338114 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java @@ -2,6 +2,8 @@ import com.techlooper.model.ChallengePhaseEnum; import com.techlooper.model.Language; +import com.techlooper.model.challenge.PhaseType; +import org.dozer.DozerBeanMapper; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -185,4 +187,12 @@ public Integer getPassCode() { public void setPassCode(Integer passCode) { this.passCode = passCode; } + + public ChallengeRegistrantDto toDTO() { + DozerBeanMapper dozerBeanMapper = new DozerBeanMapper(); + ChallengeRegistrantDto registrantDto = dozerBeanMapper.map(this, ChallengeRegistrantDto.class); + PhaseType phaseType = PhaseType.newChallengePhase(getActivePhase()); + registrantDto.setActivePhase(phaseType); + return registrantDto; + } } diff --git a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java index 97f499830..a7b1ff681 100644 --- a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java +++ b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java @@ -2,6 +2,7 @@ import com.techlooper.entity.ChallengeRegistrantCriteria; import com.techlooper.entity.ChallengeSubmissionEntity; +import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -17,7 +18,7 @@ public class ChallengeDashBoardInfo { private String submissionDate; - private ChallengePhaseEnum currentPhase; + private PhaseType currentPhase; private String currentPhaseSubmissionDate; @@ -61,11 +62,11 @@ public void setSubmissionDate(String submissionDate) { this.submissionDate = submissionDate; } - public ChallengePhaseEnum getCurrentPhase() { + public PhaseType getCurrentPhase() { return currentPhase; } - public void setCurrentPhase(ChallengePhaseEnum currentPhase) { + public void setCurrentPhase(PhaseType currentPhase) { this.currentPhase = currentPhase; } @@ -160,7 +161,7 @@ public Builder withSubmissionDate(String submissionDate) { return this; } - public Builder withCurrentPhase(ChallengePhaseEnum currentPhase) { + public Builder withCurrentPhase(PhaseType currentPhase) { challengeDashBoardInfo.setCurrentPhase(currentPhase); return this; } diff --git a/src/main/java/com/techlooper/model/challenge/PhaseType.java b/src/main/java/com/techlooper/model/challenge/PhaseType.java new file mode 100644 index 000000000..2529cbe52 --- /dev/null +++ b/src/main/java/com/techlooper/model/challenge/PhaseType.java @@ -0,0 +1,42 @@ +package com.techlooper.model.challenge; + +import com.techlooper.model.ChallengePhaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * Created by NguyenDangKhoa on 1/21/16. + */ +public abstract class PhaseType { + + private ChallengePhaseEnum phaseName; + + private String submissionDate; + + public static PhaseType newChallengePhase(ChallengePhaseEnum phaseName) { + if (phaseName == null) { + return new RegistrationPhase(); + } + switch (phaseName) { + case REGISTRATION: + return new RegistrationPhase(); + default: + throw new IllegalArgumentException("Incorrect Challenge Phase Name"); + } + } + + boolean exist() { + return StringUtils.isNotEmpty(getSubmissionDate()); + } + + public ChallengePhaseEnum getPhaseName() { + return phaseName; + } + + public String getSubmissionDate() { + return submissionDate; + } + + public void setSubmissionDate(String submissionDate) { + this.submissionDate = submissionDate; + } +} diff --git a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java new file mode 100644 index 000000000..81463aaa1 --- /dev/null +++ b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java @@ -0,0 +1,7 @@ +package com.techlooper.model.challenge; + +/** + * Created by NguyenDangKhoa on 1/21/16. + */ +public class RegistrationPhase extends PhaseType { +} diff --git a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java index 7ac2c292b..aad1cc2b8 100644 --- a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java +++ b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java @@ -27,7 +27,7 @@ public interface ChallengeRegistrantService { List findRegistrantsByChallengeId(Long challengeId); - List findRegistrantsByOwner(String ownerEmail); + List findRegistrantsByOwner(String ownerEmail); ChallengeRegistrantEntity findRegistrantById(Long registrantId); diff --git a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java index 5688e33cd..dd923ccae 100644 --- a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java @@ -8,6 +8,7 @@ import com.techlooper.entity.ChallengeRegistrantDto; import com.techlooper.entity.ChallengeRegistrantEntity; import com.techlooper.model.*; +import com.techlooper.model.challenge.PhaseType; import com.techlooper.repository.elasticsearch.ChallengeRegistrantRepository; import com.techlooper.repository.elasticsearch.ChallengeRepository; import com.techlooper.repository.elasticsearch.ChallengeSubmissionRepository; @@ -219,10 +220,11 @@ public List findRegistrantsByChallengeId(Long challen return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } - public List findRegistrantsByOwner(String ownerEmail) { + public List findRegistrantsByOwner(String ownerEmail) { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("challengeRegistrant"); searchQueryBuilder.withQuery(filteredQuery(matchAllQuery(), termFilter("registrantEmail", ownerEmail))); - return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); + return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder).stream().map( + registrantEntity -> registrantEntity.toDTO()).collect(toList()); } @Override @@ -270,7 +272,7 @@ public List qualifyAllRegistrants(String ownerEmail, Cha for (Long registrantId : challengeQualificationDto.getRegistrantIds()) { ChallengeRegistrantDto registrantDto = acceptRegistrant(registrantId, qualifyingPhase); - if (registrantDto.getActivePhase() == qualifyingPhase) { + if (registrantDto.getActivePhase().getPhaseName() == qualifyingPhase) { qualifiedRegistrants.add(registrantDto); } } @@ -388,9 +390,9 @@ public Long getTotalNumberOfRegistrants() { public List getChallengeDashBoardInfo(String registrantEmail) { List challengeDashBoardInfoList = new ArrayList<>(); - List registrantEntities = findRegistrantsByOwner(registrantEmail); + List registrantEntities = findRegistrantsByOwner(registrantEmail); - for (ChallengeRegistrantEntity registrantEntity : registrantEntities) { + for (ChallengeRegistrantDto registrantEntity : registrantEntities) { Long challengeId = registrantEntity.getChallengeId(); Long registrantId = registrantEntity.getRegistrantId(); ChallengeEntity challengeEntity = challengeService.findChallengeById(challengeId); @@ -400,10 +402,9 @@ public List getChallengeDashBoardInfo(String registrantE challengeDashBoardInfoBuilder.withChallengeId(challengeId); challengeDashBoardInfoBuilder.withChallengeName(challengeEntity.getChallengeName()); challengeDashBoardInfoBuilder.withSubmissionDate(challengeEntity.getSubmissionDateTime()); - ChallengePhaseEnum currentPhase = registrantEntity.getActivePhase() != null ? - registrantEntity.getActivePhase() : REGISTRATION; + PhaseType currentPhase = registrantEntity.getActivePhase(); challengeDashBoardInfoBuilder.withCurrentPhase(currentPhase); - challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(getCurrentPhaseSubmissionDate(challengeEntity, currentPhase)); + challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(currentPhase.getSubmissionDate()); challengeDashBoardInfoBuilder.withDisqualified(registrantEntity.getDisqualified()); Integer numberOfSubmissions = challengeSubmissionService.findChallengeSubmissionByRegistrant(registrantId).size(); @@ -433,8 +434,8 @@ public Set getChallengeWinners(Long challengeId) { return null; } - private Double getRegistrantSubmissionScore(ChallengeRegistrantEntity registrantEntity) { - Set criteria = registrantEntity.getCriteria(); + private Double getRegistrantSubmissionScore(ChallengeRegistrantDto registrantDto) { + Set criteria = registrantDto.getCriteria(); Double totalScore = 0D; if (criteria != null) { @@ -469,21 +470,4 @@ private ChallengeWinner getChallengeWinner(ChallengeEntity challengeEntity, Long } return null; } - - private String getCurrentPhaseSubmissionDate(ChallengeEntity challengeEntity, ChallengePhaseEnum currentPhase) { - switch (currentPhase) { - case REGISTRATION: - return challengeEntity.getRegistrationDateTime(); - case IDEA: - return challengeEntity.getIdeaSubmissionDateTime(); - case UIUX: - return challengeEntity.getUxSubmissionDateTime(); - case PROTOTYPE: - return challengeEntity.getPrototypeSubmissionDateTime(); - case FINAL: - return challengeEntity.getSubmissionDateTime(); - default: - return ""; - } - } } From 224b38b1ea82483c0a3eee68e2983ec0074ccb25 Mon Sep 17 00:00:00 2001 From: phuong Date: Fri, 22 Jan 2016 15:03:56 +0700 Subject: [PATCH 02/11] Revert "Update changes" --- .../entity/ChallengeRegistrantDto.java | 197 +++++++++--------- .../entity/ChallengeRegistrantEntity.java | 10 - .../model/ChallengeDashBoardInfo.java | 9 +- .../techlooper/model/challenge/PhaseType.java | 42 ---- .../model/challenge/RegistrationPhase.java | 7 - .../service/ChallengeRegistrantService.java | 2 +- .../impl/ChallengeRegistrantServiceImpl.java | 38 +++- .../modules/navigation/navigation.con.js | 31 +-- 8 files changed, 139 insertions(+), 197 deletions(-) delete mode 100644 src/main/java/com/techlooper/model/challenge/PhaseType.java delete mode 100644 src/main/java/com/techlooper/model/challenge/RegistrationPhase.java diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java index 39b748c5d..cccb18cb4 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java @@ -4,7 +4,6 @@ import com.techlooper.model.ChallengeSubmissionDto; import com.techlooper.model.Language; import com.techlooper.model.RewardEnum; -import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -14,143 +13,143 @@ */ public class ChallengeRegistrantDto { - private Long challengeId; + private Long challengeId; - private String registrantEmail; + private String registrantEmail; - private String registrantFirstName; + private String registrantFirstName; - private String registrantLastName; + private String registrantLastName; - private Language lang; + private Language lang; - private Double score; + private Double score; - private Long registrantId; + private Long registrantId; - private Boolean disqualified; + private Boolean disqualified; - private String disqualifiedReason; + private String disqualifiedReason; - private String lastEmailSentDateTime; + private String lastEmailSentDateTime; - private List submissions; + private List submissions; - private PhaseType activePhase; + private ChallengePhaseEnum activePhase; - private Set criteria; + private Set criteria; - private RewardEnum reward; + private RewardEnum reward; - public RewardEnum getReward() { - return reward; - } + public RewardEnum getReward() { + return reward; + } - public void setReward(RewardEnum reward) { - this.reward = reward; - } + public void setReward(RewardEnum reward) { + this.reward = reward; + } - public Set getCriteria() { - return criteria; - } + public Set getCriteria() { + return criteria; + } - public void setCriteria(Set criteria) { - this.criteria = criteria; - } + public void setCriteria(Set criteria) { + this.criteria = criteria; + } - public PhaseType getActivePhase() { - return activePhase; - } + public ChallengePhaseEnum getActivePhase() { + return activePhase; + } - public void setActivePhase(PhaseType phaseType) { - this.activePhase = phaseType; - } + public void setActivePhase(ChallengePhaseEnum activePhase) { + this.activePhase = activePhase; + } - public String getDisqualifiedReason() { - return disqualifiedReason; - } + public String getDisqualifiedReason() { + return disqualifiedReason; + } - public void setDisqualifiedReason(String disqualifiedReason) { - this.disqualifiedReason = disqualifiedReason; - } + public void setDisqualifiedReason(String disqualifiedReason) { + this.disqualifiedReason = disqualifiedReason; + } - public Boolean getDisqualified() { - return disqualified; - } + public Boolean getDisqualified() { + return disqualified; + } - public void setDisqualified(Boolean disqualified) { - this.disqualified = disqualified; - } + public void setDisqualified(Boolean disqualified) { + this.disqualified = disqualified; + } - public Long getRegistrantId() { - return registrantId; - } + public Long getRegistrantId() { + return registrantId; + } - public void setRegistrantId(Long registrantId) { - this.registrantId = registrantId; - } + public void setRegistrantId(Long registrantId) { + this.registrantId = registrantId; + } - public Double getScore() { - return score; - } + public Double getScore() { + return score; + } - public void setScore(Double score) { - this.score = score; - } + public void setScore(Double score) { + this.score = score; + } - public Long getChallengeId() { - return challengeId; - } + public Long getChallengeId() { + return challengeId; + } - public void setChallengeId(Long challengeId) { - this.challengeId = challengeId; - } + public void setChallengeId(Long challengeId) { + this.challengeId = challengeId; + } - public String getRegistrantEmail() { - return registrantEmail; - } + public String getRegistrantEmail() { + return registrantEmail; + } - public void setRegistrantEmail(String registrantEmail) { - this.registrantEmail = registrantEmail; - } + public void setRegistrantEmail(String registrantEmail) { + this.registrantEmail = registrantEmail; + } - public String getRegistrantFirstName() { - return registrantFirstName; - } + public String getRegistrantFirstName() { + return registrantFirstName; + } - public void setRegistrantFirstName(String registrantFirstName) { - this.registrantFirstName = registrantFirstName; - } + public void setRegistrantFirstName(String registrantFirstName) { + this.registrantFirstName = registrantFirstName; + } - public String getRegistrantLastName() { - return registrantLastName; - } + public String getRegistrantLastName() { + return registrantLastName; + } - public void setRegistrantLastName(String registrantLastName) { - this.registrantLastName = registrantLastName; - } + public void setRegistrantLastName(String registrantLastName) { + this.registrantLastName = registrantLastName; + } - public Language getLang() { - return lang; - } + public Language getLang() { + return lang; + } - public void setLang(Language lang) { - this.lang = lang; - } + public void setLang(Language lang) { + this.lang = lang; + } - public List getSubmissions() { - return submissions; - } + public List getSubmissions() { + return submissions; + } - public void setSubmissions(List submissions) { - this.submissions = submissions; - } + public void setSubmissions(List submissions) { + this.submissions = submissions; + } - public String getLastEmailSentDateTime() { - return lastEmailSentDateTime; - } + public String getLastEmailSentDateTime() { + return lastEmailSentDateTime; + } - public void setLastEmailSentDateTime(String lastEmailSentDateTime) { - this.lastEmailSentDateTime = lastEmailSentDateTime; - } + public void setLastEmailSentDateTime(String lastEmailSentDateTime) { + this.lastEmailSentDateTime = lastEmailSentDateTime; + } } diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java index 779338114..81e7f4c81 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java @@ -2,8 +2,6 @@ import com.techlooper.model.ChallengePhaseEnum; import com.techlooper.model.Language; -import com.techlooper.model.challenge.PhaseType; -import org.dozer.DozerBeanMapper; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -187,12 +185,4 @@ public Integer getPassCode() { public void setPassCode(Integer passCode) { this.passCode = passCode; } - - public ChallengeRegistrantDto toDTO() { - DozerBeanMapper dozerBeanMapper = new DozerBeanMapper(); - ChallengeRegistrantDto registrantDto = dozerBeanMapper.map(this, ChallengeRegistrantDto.class); - PhaseType phaseType = PhaseType.newChallengePhase(getActivePhase()); - registrantDto.setActivePhase(phaseType); - return registrantDto; - } } diff --git a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java index a7b1ff681..97f499830 100644 --- a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java +++ b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java @@ -2,7 +2,6 @@ import com.techlooper.entity.ChallengeRegistrantCriteria; import com.techlooper.entity.ChallengeSubmissionEntity; -import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -18,7 +17,7 @@ public class ChallengeDashBoardInfo { private String submissionDate; - private PhaseType currentPhase; + private ChallengePhaseEnum currentPhase; private String currentPhaseSubmissionDate; @@ -62,11 +61,11 @@ public void setSubmissionDate(String submissionDate) { this.submissionDate = submissionDate; } - public PhaseType getCurrentPhase() { + public ChallengePhaseEnum getCurrentPhase() { return currentPhase; } - public void setCurrentPhase(PhaseType currentPhase) { + public void setCurrentPhase(ChallengePhaseEnum currentPhase) { this.currentPhase = currentPhase; } @@ -161,7 +160,7 @@ public Builder withSubmissionDate(String submissionDate) { return this; } - public Builder withCurrentPhase(PhaseType currentPhase) { + public Builder withCurrentPhase(ChallengePhaseEnum currentPhase) { challengeDashBoardInfo.setCurrentPhase(currentPhase); return this; } diff --git a/src/main/java/com/techlooper/model/challenge/PhaseType.java b/src/main/java/com/techlooper/model/challenge/PhaseType.java deleted file mode 100644 index 2529cbe52..000000000 --- a/src/main/java/com/techlooper/model/challenge/PhaseType.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.techlooper.model.challenge; - -import com.techlooper.model.ChallengePhaseEnum; -import org.apache.commons.lang3.StringUtils; - -/** - * Created by NguyenDangKhoa on 1/21/16. - */ -public abstract class PhaseType { - - private ChallengePhaseEnum phaseName; - - private String submissionDate; - - public static PhaseType newChallengePhase(ChallengePhaseEnum phaseName) { - if (phaseName == null) { - return new RegistrationPhase(); - } - switch (phaseName) { - case REGISTRATION: - return new RegistrationPhase(); - default: - throw new IllegalArgumentException("Incorrect Challenge Phase Name"); - } - } - - boolean exist() { - return StringUtils.isNotEmpty(getSubmissionDate()); - } - - public ChallengePhaseEnum getPhaseName() { - return phaseName; - } - - public String getSubmissionDate() { - return submissionDate; - } - - public void setSubmissionDate(String submissionDate) { - this.submissionDate = submissionDate; - } -} diff --git a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java deleted file mode 100644 index 81463aaa1..000000000 --- a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.techlooper.model.challenge; - -/** - * Created by NguyenDangKhoa on 1/21/16. - */ -public class RegistrationPhase extends PhaseType { -} diff --git a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java index aad1cc2b8..7ac2c292b 100644 --- a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java +++ b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java @@ -27,7 +27,7 @@ public interface ChallengeRegistrantService { List findRegistrantsByChallengeId(Long challengeId); - List findRegistrantsByOwner(String ownerEmail); + List findRegistrantsByOwner(String ownerEmail); ChallengeRegistrantEntity findRegistrantById(Long registrantId); diff --git a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java index dd923ccae..5688e33cd 100644 --- a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java @@ -8,7 +8,6 @@ import com.techlooper.entity.ChallengeRegistrantDto; import com.techlooper.entity.ChallengeRegistrantEntity; import com.techlooper.model.*; -import com.techlooper.model.challenge.PhaseType; import com.techlooper.repository.elasticsearch.ChallengeRegistrantRepository; import com.techlooper.repository.elasticsearch.ChallengeRepository; import com.techlooper.repository.elasticsearch.ChallengeSubmissionRepository; @@ -220,11 +219,10 @@ public List findRegistrantsByChallengeId(Long challen return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } - public List findRegistrantsByOwner(String ownerEmail) { + public List findRegistrantsByOwner(String ownerEmail) { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("challengeRegistrant"); searchQueryBuilder.withQuery(filteredQuery(matchAllQuery(), termFilter("registrantEmail", ownerEmail))); - return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder).stream().map( - registrantEntity -> registrantEntity.toDTO()).collect(toList()); + return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } @Override @@ -272,7 +270,7 @@ public List qualifyAllRegistrants(String ownerEmail, Cha for (Long registrantId : challengeQualificationDto.getRegistrantIds()) { ChallengeRegistrantDto registrantDto = acceptRegistrant(registrantId, qualifyingPhase); - if (registrantDto.getActivePhase().getPhaseName() == qualifyingPhase) { + if (registrantDto.getActivePhase() == qualifyingPhase) { qualifiedRegistrants.add(registrantDto); } } @@ -390,9 +388,9 @@ public Long getTotalNumberOfRegistrants() { public List getChallengeDashBoardInfo(String registrantEmail) { List challengeDashBoardInfoList = new ArrayList<>(); - List registrantEntities = findRegistrantsByOwner(registrantEmail); + List registrantEntities = findRegistrantsByOwner(registrantEmail); - for (ChallengeRegistrantDto registrantEntity : registrantEntities) { + for (ChallengeRegistrantEntity registrantEntity : registrantEntities) { Long challengeId = registrantEntity.getChallengeId(); Long registrantId = registrantEntity.getRegistrantId(); ChallengeEntity challengeEntity = challengeService.findChallengeById(challengeId); @@ -402,9 +400,10 @@ public List getChallengeDashBoardInfo(String registrantE challengeDashBoardInfoBuilder.withChallengeId(challengeId); challengeDashBoardInfoBuilder.withChallengeName(challengeEntity.getChallengeName()); challengeDashBoardInfoBuilder.withSubmissionDate(challengeEntity.getSubmissionDateTime()); - PhaseType currentPhase = registrantEntity.getActivePhase(); + ChallengePhaseEnum currentPhase = registrantEntity.getActivePhase() != null ? + registrantEntity.getActivePhase() : REGISTRATION; challengeDashBoardInfoBuilder.withCurrentPhase(currentPhase); - challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(currentPhase.getSubmissionDate()); + challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(getCurrentPhaseSubmissionDate(challengeEntity, currentPhase)); challengeDashBoardInfoBuilder.withDisqualified(registrantEntity.getDisqualified()); Integer numberOfSubmissions = challengeSubmissionService.findChallengeSubmissionByRegistrant(registrantId).size(); @@ -434,8 +433,8 @@ public Set getChallengeWinners(Long challengeId) { return null; } - private Double getRegistrantSubmissionScore(ChallengeRegistrantDto registrantDto) { - Set criteria = registrantDto.getCriteria(); + private Double getRegistrantSubmissionScore(ChallengeRegistrantEntity registrantEntity) { + Set criteria = registrantEntity.getCriteria(); Double totalScore = 0D; if (criteria != null) { @@ -470,4 +469,21 @@ private ChallengeWinner getChallengeWinner(ChallengeEntity challengeEntity, Long } return null; } + + private String getCurrentPhaseSubmissionDate(ChallengeEntity challengeEntity, ChallengePhaseEnum currentPhase) { + switch (currentPhase) { + case REGISTRATION: + return challengeEntity.getRegistrationDateTime(); + case IDEA: + return challengeEntity.getIdeaSubmissionDateTime(); + case UIUX: + return challengeEntity.getUxSubmissionDateTime(); + case PROTOTYPE: + return challengeEntity.getPrototypeSubmissionDateTime(); + case FINAL: + return challengeEntity.getSubmissionDateTime(); + default: + return ""; + } + } } diff --git a/src/main/webapp/assets/modules/navigation/navigation.con.js b/src/main/webapp/assets/modules/navigation/navigation.con.js index 125a61390..04fe7dd68 100644 --- a/src/main/webapp/assets/modules/navigation/navigation.con.js +++ b/src/main/webapp/assets/modules/navigation/navigation.con.js @@ -1,31 +1,18 @@ techlooper.controller("navigationController", function ($scope, securityService, apiService, localStorageService, $location, jsonValue, utils, $timeout, $rootScope, $window) { $scope.state = function (type) { - var isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - var isJobSeeker = $rootScope.userInfo && $rootScope.userInfo.roleName === "JOB_SEEKER"; - //var userNotLogin = !$rootScope.userInfo; - var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; - var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header == "EMPLOYER"; - //var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.header != "EMPLOYER" && $rootScope.currentUiView.type != "LOGIN"; - //console.log(isJobSeekerView); + var isEmployer = undefined; + var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; switch (type) { case "show-employer-header": - if (currentViewIsLogin || isJobSeeker) return false; - if (isEmployer) return true; - //isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - //console.log("emm", isEmployerView); - return isEmployerView; - //return (!currentViewIsLogin && isEmployer) || isEmployerView; + var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; + isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + return (!currentViewIsLogin && isEmployer) || isEmployerView; case "show-job-seeker-header": - if (currentViewIsLogin || isEmployer) return false; - if (isJobSeeker) return true; - if (isEmployerView) return false; - //var employerHeaderNotShown = !$scope.state("show-employer-header"); - //var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; - //console.log("seek", isJobSeekerView); - return !currentViewIsLogin; - //return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; + var employerHeaderNotShown = !$scope.state("show-employer-header"); + var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.type != "LOGIN"; + return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; case "home-url": isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; @@ -50,7 +37,7 @@ techlooper.controller("navigationController", function ($scope, securityService, } } $scope.langKey = localStorage.NG_TRANSLATE_LANG_KEY; - $scope.changeLanguages = function (key) { + $scope.changeLanguages = function(key){ $scope.langKey = key; localStorage.NG_TRANSLATE_LANG_KEY = key; $window.location.reload(); From 00f38ac6b2540bdea957f37b3b15f0efbc81d434 Mon Sep 17 00:00:00 2001 From: phuong Date: Fri, 22 Jan 2016 16:31:41 +0700 Subject: [PATCH 03/11] Revert "Update changes" --- .../entity/ChallengeRegistrantDto.java | 197 +++++++++--------- .../entity/ChallengeRegistrantEntity.java | 10 + .../model/ChallengeDashBoardInfo.java | 9 +- .../techlooper/model/challenge/PhaseType.java | 42 ++++ .../model/challenge/RegistrationPhase.java | 7 + .../service/ChallengeRegistrantService.java | 2 +- .../impl/ChallengeRegistrantServiceImpl.java | 38 +--- .../modules/navigation/navigation.con.js | 31 ++- 8 files changed, 197 insertions(+), 139 deletions(-) create mode 100644 src/main/java/com/techlooper/model/challenge/PhaseType.java create mode 100644 src/main/java/com/techlooper/model/challenge/RegistrationPhase.java diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java index cccb18cb4..39b748c5d 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java @@ -4,6 +4,7 @@ import com.techlooper.model.ChallengeSubmissionDto; import com.techlooper.model.Language; import com.techlooper.model.RewardEnum; +import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -13,143 +14,143 @@ */ public class ChallengeRegistrantDto { - private Long challengeId; + private Long challengeId; - private String registrantEmail; + private String registrantEmail; - private String registrantFirstName; + private String registrantFirstName; - private String registrantLastName; + private String registrantLastName; - private Language lang; + private Language lang; - private Double score; + private Double score; - private Long registrantId; + private Long registrantId; - private Boolean disqualified; + private Boolean disqualified; - private String disqualifiedReason; + private String disqualifiedReason; - private String lastEmailSentDateTime; + private String lastEmailSentDateTime; - private List submissions; + private List submissions; - private ChallengePhaseEnum activePhase; + private PhaseType activePhase; - private Set criteria; + private Set criteria; - private RewardEnum reward; + private RewardEnum reward; - public RewardEnum getReward() { - return reward; - } + public RewardEnum getReward() { + return reward; + } - public void setReward(RewardEnum reward) { - this.reward = reward; - } + public void setReward(RewardEnum reward) { + this.reward = reward; + } - public Set getCriteria() { - return criteria; - } + public Set getCriteria() { + return criteria; + } - public void setCriteria(Set criteria) { - this.criteria = criteria; - } + public void setCriteria(Set criteria) { + this.criteria = criteria; + } - public ChallengePhaseEnum getActivePhase() { - return activePhase; - } + public PhaseType getActivePhase() { + return activePhase; + } - public void setActivePhase(ChallengePhaseEnum activePhase) { - this.activePhase = activePhase; - } + public void setActivePhase(PhaseType phaseType) { + this.activePhase = phaseType; + } - public String getDisqualifiedReason() { - return disqualifiedReason; - } + public String getDisqualifiedReason() { + return disqualifiedReason; + } - public void setDisqualifiedReason(String disqualifiedReason) { - this.disqualifiedReason = disqualifiedReason; - } + public void setDisqualifiedReason(String disqualifiedReason) { + this.disqualifiedReason = disqualifiedReason; + } - public Boolean getDisqualified() { - return disqualified; - } + public Boolean getDisqualified() { + return disqualified; + } - public void setDisqualified(Boolean disqualified) { - this.disqualified = disqualified; - } + public void setDisqualified(Boolean disqualified) { + this.disqualified = disqualified; + } - public Long getRegistrantId() { - return registrantId; - } + public Long getRegistrantId() { + return registrantId; + } - public void setRegistrantId(Long registrantId) { - this.registrantId = registrantId; - } + public void setRegistrantId(Long registrantId) { + this.registrantId = registrantId; + } - public Double getScore() { - return score; - } + public Double getScore() { + return score; + } - public void setScore(Double score) { - this.score = score; - } + public void setScore(Double score) { + this.score = score; + } - public Long getChallengeId() { - return challengeId; - } + public Long getChallengeId() { + return challengeId; + } - public void setChallengeId(Long challengeId) { - this.challengeId = challengeId; - } + public void setChallengeId(Long challengeId) { + this.challengeId = challengeId; + } - public String getRegistrantEmail() { - return registrantEmail; - } + public String getRegistrantEmail() { + return registrantEmail; + } - public void setRegistrantEmail(String registrantEmail) { - this.registrantEmail = registrantEmail; - } + public void setRegistrantEmail(String registrantEmail) { + this.registrantEmail = registrantEmail; + } - public String getRegistrantFirstName() { - return registrantFirstName; - } + public String getRegistrantFirstName() { + return registrantFirstName; + } - public void setRegistrantFirstName(String registrantFirstName) { - this.registrantFirstName = registrantFirstName; - } + public void setRegistrantFirstName(String registrantFirstName) { + this.registrantFirstName = registrantFirstName; + } - public String getRegistrantLastName() { - return registrantLastName; - } + public String getRegistrantLastName() { + return registrantLastName; + } - public void setRegistrantLastName(String registrantLastName) { - this.registrantLastName = registrantLastName; - } + public void setRegistrantLastName(String registrantLastName) { + this.registrantLastName = registrantLastName; + } - public Language getLang() { - return lang; - } + public Language getLang() { + return lang; + } - public void setLang(Language lang) { - this.lang = lang; - } + public void setLang(Language lang) { + this.lang = lang; + } - public List getSubmissions() { - return submissions; - } + public List getSubmissions() { + return submissions; + } - public void setSubmissions(List submissions) { - this.submissions = submissions; - } + public void setSubmissions(List submissions) { + this.submissions = submissions; + } - public String getLastEmailSentDateTime() { - return lastEmailSentDateTime; - } + public String getLastEmailSentDateTime() { + return lastEmailSentDateTime; + } - public void setLastEmailSentDateTime(String lastEmailSentDateTime) { - this.lastEmailSentDateTime = lastEmailSentDateTime; - } + public void setLastEmailSentDateTime(String lastEmailSentDateTime) { + this.lastEmailSentDateTime = lastEmailSentDateTime; + } } diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java index 81e7f4c81..779338114 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java @@ -2,6 +2,8 @@ import com.techlooper.model.ChallengePhaseEnum; import com.techlooper.model.Language; +import com.techlooper.model.challenge.PhaseType; +import org.dozer.DozerBeanMapper; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -185,4 +187,12 @@ public Integer getPassCode() { public void setPassCode(Integer passCode) { this.passCode = passCode; } + + public ChallengeRegistrantDto toDTO() { + DozerBeanMapper dozerBeanMapper = new DozerBeanMapper(); + ChallengeRegistrantDto registrantDto = dozerBeanMapper.map(this, ChallengeRegistrantDto.class); + PhaseType phaseType = PhaseType.newChallengePhase(getActivePhase()); + registrantDto.setActivePhase(phaseType); + return registrantDto; + } } diff --git a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java index 97f499830..a7b1ff681 100644 --- a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java +++ b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java @@ -2,6 +2,7 @@ import com.techlooper.entity.ChallengeRegistrantCriteria; import com.techlooper.entity.ChallengeSubmissionEntity; +import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -17,7 +18,7 @@ public class ChallengeDashBoardInfo { private String submissionDate; - private ChallengePhaseEnum currentPhase; + private PhaseType currentPhase; private String currentPhaseSubmissionDate; @@ -61,11 +62,11 @@ public void setSubmissionDate(String submissionDate) { this.submissionDate = submissionDate; } - public ChallengePhaseEnum getCurrentPhase() { + public PhaseType getCurrentPhase() { return currentPhase; } - public void setCurrentPhase(ChallengePhaseEnum currentPhase) { + public void setCurrentPhase(PhaseType currentPhase) { this.currentPhase = currentPhase; } @@ -160,7 +161,7 @@ public Builder withSubmissionDate(String submissionDate) { return this; } - public Builder withCurrentPhase(ChallengePhaseEnum currentPhase) { + public Builder withCurrentPhase(PhaseType currentPhase) { challengeDashBoardInfo.setCurrentPhase(currentPhase); return this; } diff --git a/src/main/java/com/techlooper/model/challenge/PhaseType.java b/src/main/java/com/techlooper/model/challenge/PhaseType.java new file mode 100644 index 000000000..2529cbe52 --- /dev/null +++ b/src/main/java/com/techlooper/model/challenge/PhaseType.java @@ -0,0 +1,42 @@ +package com.techlooper.model.challenge; + +import com.techlooper.model.ChallengePhaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * Created by NguyenDangKhoa on 1/21/16. + */ +public abstract class PhaseType { + + private ChallengePhaseEnum phaseName; + + private String submissionDate; + + public static PhaseType newChallengePhase(ChallengePhaseEnum phaseName) { + if (phaseName == null) { + return new RegistrationPhase(); + } + switch (phaseName) { + case REGISTRATION: + return new RegistrationPhase(); + default: + throw new IllegalArgumentException("Incorrect Challenge Phase Name"); + } + } + + boolean exist() { + return StringUtils.isNotEmpty(getSubmissionDate()); + } + + public ChallengePhaseEnum getPhaseName() { + return phaseName; + } + + public String getSubmissionDate() { + return submissionDate; + } + + public void setSubmissionDate(String submissionDate) { + this.submissionDate = submissionDate; + } +} diff --git a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java new file mode 100644 index 000000000..81463aaa1 --- /dev/null +++ b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java @@ -0,0 +1,7 @@ +package com.techlooper.model.challenge; + +/** + * Created by NguyenDangKhoa on 1/21/16. + */ +public class RegistrationPhase extends PhaseType { +} diff --git a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java index 7ac2c292b..aad1cc2b8 100644 --- a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java +++ b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java @@ -27,7 +27,7 @@ public interface ChallengeRegistrantService { List findRegistrantsByChallengeId(Long challengeId); - List findRegistrantsByOwner(String ownerEmail); + List findRegistrantsByOwner(String ownerEmail); ChallengeRegistrantEntity findRegistrantById(Long registrantId); diff --git a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java index 5688e33cd..dd923ccae 100644 --- a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java @@ -8,6 +8,7 @@ import com.techlooper.entity.ChallengeRegistrantDto; import com.techlooper.entity.ChallengeRegistrantEntity; import com.techlooper.model.*; +import com.techlooper.model.challenge.PhaseType; import com.techlooper.repository.elasticsearch.ChallengeRegistrantRepository; import com.techlooper.repository.elasticsearch.ChallengeRepository; import com.techlooper.repository.elasticsearch.ChallengeSubmissionRepository; @@ -219,10 +220,11 @@ public List findRegistrantsByChallengeId(Long challen return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } - public List findRegistrantsByOwner(String ownerEmail) { + public List findRegistrantsByOwner(String ownerEmail) { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("challengeRegistrant"); searchQueryBuilder.withQuery(filteredQuery(matchAllQuery(), termFilter("registrantEmail", ownerEmail))); - return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); + return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder).stream().map( + registrantEntity -> registrantEntity.toDTO()).collect(toList()); } @Override @@ -270,7 +272,7 @@ public List qualifyAllRegistrants(String ownerEmail, Cha for (Long registrantId : challengeQualificationDto.getRegistrantIds()) { ChallengeRegistrantDto registrantDto = acceptRegistrant(registrantId, qualifyingPhase); - if (registrantDto.getActivePhase() == qualifyingPhase) { + if (registrantDto.getActivePhase().getPhaseName() == qualifyingPhase) { qualifiedRegistrants.add(registrantDto); } } @@ -388,9 +390,9 @@ public Long getTotalNumberOfRegistrants() { public List getChallengeDashBoardInfo(String registrantEmail) { List challengeDashBoardInfoList = new ArrayList<>(); - List registrantEntities = findRegistrantsByOwner(registrantEmail); + List registrantEntities = findRegistrantsByOwner(registrantEmail); - for (ChallengeRegistrantEntity registrantEntity : registrantEntities) { + for (ChallengeRegistrantDto registrantEntity : registrantEntities) { Long challengeId = registrantEntity.getChallengeId(); Long registrantId = registrantEntity.getRegistrantId(); ChallengeEntity challengeEntity = challengeService.findChallengeById(challengeId); @@ -400,10 +402,9 @@ public List getChallengeDashBoardInfo(String registrantE challengeDashBoardInfoBuilder.withChallengeId(challengeId); challengeDashBoardInfoBuilder.withChallengeName(challengeEntity.getChallengeName()); challengeDashBoardInfoBuilder.withSubmissionDate(challengeEntity.getSubmissionDateTime()); - ChallengePhaseEnum currentPhase = registrantEntity.getActivePhase() != null ? - registrantEntity.getActivePhase() : REGISTRATION; + PhaseType currentPhase = registrantEntity.getActivePhase(); challengeDashBoardInfoBuilder.withCurrentPhase(currentPhase); - challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(getCurrentPhaseSubmissionDate(challengeEntity, currentPhase)); + challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(currentPhase.getSubmissionDate()); challengeDashBoardInfoBuilder.withDisqualified(registrantEntity.getDisqualified()); Integer numberOfSubmissions = challengeSubmissionService.findChallengeSubmissionByRegistrant(registrantId).size(); @@ -433,8 +434,8 @@ public Set getChallengeWinners(Long challengeId) { return null; } - private Double getRegistrantSubmissionScore(ChallengeRegistrantEntity registrantEntity) { - Set criteria = registrantEntity.getCriteria(); + private Double getRegistrantSubmissionScore(ChallengeRegistrantDto registrantDto) { + Set criteria = registrantDto.getCriteria(); Double totalScore = 0D; if (criteria != null) { @@ -469,21 +470,4 @@ private ChallengeWinner getChallengeWinner(ChallengeEntity challengeEntity, Long } return null; } - - private String getCurrentPhaseSubmissionDate(ChallengeEntity challengeEntity, ChallengePhaseEnum currentPhase) { - switch (currentPhase) { - case REGISTRATION: - return challengeEntity.getRegistrationDateTime(); - case IDEA: - return challengeEntity.getIdeaSubmissionDateTime(); - case UIUX: - return challengeEntity.getUxSubmissionDateTime(); - case PROTOTYPE: - return challengeEntity.getPrototypeSubmissionDateTime(); - case FINAL: - return challengeEntity.getSubmissionDateTime(); - default: - return ""; - } - } } diff --git a/src/main/webapp/assets/modules/navigation/navigation.con.js b/src/main/webapp/assets/modules/navigation/navigation.con.js index 04fe7dd68..125a61390 100644 --- a/src/main/webapp/assets/modules/navigation/navigation.con.js +++ b/src/main/webapp/assets/modules/navigation/navigation.con.js @@ -1,18 +1,31 @@ techlooper.controller("navigationController", function ($scope, securityService, apiService, localStorageService, $location, jsonValue, utils, $timeout, $rootScope, $window) { $scope.state = function (type) { - var isEmployer = undefined; - var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; + var isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + var isJobSeeker = $rootScope.userInfo && $rootScope.userInfo.roleName === "JOB_SEEKER"; + //var userNotLogin = !$rootScope.userInfo; + var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; + var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header == "EMPLOYER"; + //var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.header != "EMPLOYER" && $rootScope.currentUiView.type != "LOGIN"; + //console.log(isJobSeekerView); switch (type) { case "show-employer-header": - var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; - isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - return (!currentViewIsLogin && isEmployer) || isEmployerView; + if (currentViewIsLogin || isJobSeeker) return false; + if (isEmployer) return true; + //isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + //console.log("emm", isEmployerView); + return isEmployerView; + //return (!currentViewIsLogin && isEmployer) || isEmployerView; case "show-job-seeker-header": - var employerHeaderNotShown = !$scope.state("show-employer-header"); - var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.type != "LOGIN"; - return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; + if (currentViewIsLogin || isEmployer) return false; + if (isJobSeeker) return true; + if (isEmployerView) return false; + //var employerHeaderNotShown = !$scope.state("show-employer-header"); + //var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; + //console.log("seek", isJobSeekerView); + return !currentViewIsLogin; + //return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; case "home-url": isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; @@ -37,7 +50,7 @@ techlooper.controller("navigationController", function ($scope, securityService, } } $scope.langKey = localStorage.NG_TRANSLATE_LANG_KEY; - $scope.changeLanguages = function(key){ + $scope.changeLanguages = function (key) { $scope.langKey = key; localStorage.NG_TRANSLATE_LANG_KEY = key; $window.location.reload(); From c1194fcb50d3fa2ee0e884e113ed747b4b896606 Mon Sep 17 00:00:00 2001 From: phuong Date: Fri, 22 Jan 2016 16:32:44 +0700 Subject: [PATCH 04/11] Revert "Update changes" --- .../entity/ChallengeRegistrantDto.java | 197 +++++++++--------- .../entity/ChallengeRegistrantEntity.java | 10 - .../model/ChallengeDashBoardInfo.java | 9 +- .../techlooper/model/challenge/PhaseType.java | 42 ---- .../model/challenge/RegistrationPhase.java | 7 - .../service/ChallengeRegistrantService.java | 2 +- .../impl/ChallengeRegistrantServiceImpl.java | 38 +++- .../modules/navigation/navigation.con.js | 31 +-- 8 files changed, 139 insertions(+), 197 deletions(-) delete mode 100644 src/main/java/com/techlooper/model/challenge/PhaseType.java delete mode 100644 src/main/java/com/techlooper/model/challenge/RegistrationPhase.java diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java index 39b748c5d..cccb18cb4 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java @@ -4,7 +4,6 @@ import com.techlooper.model.ChallengeSubmissionDto; import com.techlooper.model.Language; import com.techlooper.model.RewardEnum; -import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -14,143 +13,143 @@ */ public class ChallengeRegistrantDto { - private Long challengeId; + private Long challengeId; - private String registrantEmail; + private String registrantEmail; - private String registrantFirstName; + private String registrantFirstName; - private String registrantLastName; + private String registrantLastName; - private Language lang; + private Language lang; - private Double score; + private Double score; - private Long registrantId; + private Long registrantId; - private Boolean disqualified; + private Boolean disqualified; - private String disqualifiedReason; + private String disqualifiedReason; - private String lastEmailSentDateTime; + private String lastEmailSentDateTime; - private List submissions; + private List submissions; - private PhaseType activePhase; + private ChallengePhaseEnum activePhase; - private Set criteria; + private Set criteria; - private RewardEnum reward; + private RewardEnum reward; - public RewardEnum getReward() { - return reward; - } + public RewardEnum getReward() { + return reward; + } - public void setReward(RewardEnum reward) { - this.reward = reward; - } + public void setReward(RewardEnum reward) { + this.reward = reward; + } - public Set getCriteria() { - return criteria; - } + public Set getCriteria() { + return criteria; + } - public void setCriteria(Set criteria) { - this.criteria = criteria; - } + public void setCriteria(Set criteria) { + this.criteria = criteria; + } - public PhaseType getActivePhase() { - return activePhase; - } + public ChallengePhaseEnum getActivePhase() { + return activePhase; + } - public void setActivePhase(PhaseType phaseType) { - this.activePhase = phaseType; - } + public void setActivePhase(ChallengePhaseEnum activePhase) { + this.activePhase = activePhase; + } - public String getDisqualifiedReason() { - return disqualifiedReason; - } + public String getDisqualifiedReason() { + return disqualifiedReason; + } - public void setDisqualifiedReason(String disqualifiedReason) { - this.disqualifiedReason = disqualifiedReason; - } + public void setDisqualifiedReason(String disqualifiedReason) { + this.disqualifiedReason = disqualifiedReason; + } - public Boolean getDisqualified() { - return disqualified; - } + public Boolean getDisqualified() { + return disqualified; + } - public void setDisqualified(Boolean disqualified) { - this.disqualified = disqualified; - } + public void setDisqualified(Boolean disqualified) { + this.disqualified = disqualified; + } - public Long getRegistrantId() { - return registrantId; - } + public Long getRegistrantId() { + return registrantId; + } - public void setRegistrantId(Long registrantId) { - this.registrantId = registrantId; - } + public void setRegistrantId(Long registrantId) { + this.registrantId = registrantId; + } - public Double getScore() { - return score; - } + public Double getScore() { + return score; + } - public void setScore(Double score) { - this.score = score; - } + public void setScore(Double score) { + this.score = score; + } - public Long getChallengeId() { - return challengeId; - } + public Long getChallengeId() { + return challengeId; + } - public void setChallengeId(Long challengeId) { - this.challengeId = challengeId; - } + public void setChallengeId(Long challengeId) { + this.challengeId = challengeId; + } - public String getRegistrantEmail() { - return registrantEmail; - } + public String getRegistrantEmail() { + return registrantEmail; + } - public void setRegistrantEmail(String registrantEmail) { - this.registrantEmail = registrantEmail; - } + public void setRegistrantEmail(String registrantEmail) { + this.registrantEmail = registrantEmail; + } - public String getRegistrantFirstName() { - return registrantFirstName; - } + public String getRegistrantFirstName() { + return registrantFirstName; + } - public void setRegistrantFirstName(String registrantFirstName) { - this.registrantFirstName = registrantFirstName; - } + public void setRegistrantFirstName(String registrantFirstName) { + this.registrantFirstName = registrantFirstName; + } - public String getRegistrantLastName() { - return registrantLastName; - } + public String getRegistrantLastName() { + return registrantLastName; + } - public void setRegistrantLastName(String registrantLastName) { - this.registrantLastName = registrantLastName; - } + public void setRegistrantLastName(String registrantLastName) { + this.registrantLastName = registrantLastName; + } - public Language getLang() { - return lang; - } + public Language getLang() { + return lang; + } - public void setLang(Language lang) { - this.lang = lang; - } + public void setLang(Language lang) { + this.lang = lang; + } - public List getSubmissions() { - return submissions; - } + public List getSubmissions() { + return submissions; + } - public void setSubmissions(List submissions) { - this.submissions = submissions; - } + public void setSubmissions(List submissions) { + this.submissions = submissions; + } - public String getLastEmailSentDateTime() { - return lastEmailSentDateTime; - } + public String getLastEmailSentDateTime() { + return lastEmailSentDateTime; + } - public void setLastEmailSentDateTime(String lastEmailSentDateTime) { - this.lastEmailSentDateTime = lastEmailSentDateTime; - } + public void setLastEmailSentDateTime(String lastEmailSentDateTime) { + this.lastEmailSentDateTime = lastEmailSentDateTime; + } } diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java index 779338114..81e7f4c81 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java @@ -2,8 +2,6 @@ import com.techlooper.model.ChallengePhaseEnum; import com.techlooper.model.Language; -import com.techlooper.model.challenge.PhaseType; -import org.dozer.DozerBeanMapper; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -187,12 +185,4 @@ public Integer getPassCode() { public void setPassCode(Integer passCode) { this.passCode = passCode; } - - public ChallengeRegistrantDto toDTO() { - DozerBeanMapper dozerBeanMapper = new DozerBeanMapper(); - ChallengeRegistrantDto registrantDto = dozerBeanMapper.map(this, ChallengeRegistrantDto.class); - PhaseType phaseType = PhaseType.newChallengePhase(getActivePhase()); - registrantDto.setActivePhase(phaseType); - return registrantDto; - } } diff --git a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java index a7b1ff681..97f499830 100644 --- a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java +++ b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java @@ -2,7 +2,6 @@ import com.techlooper.entity.ChallengeRegistrantCriteria; import com.techlooper.entity.ChallengeSubmissionEntity; -import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -18,7 +17,7 @@ public class ChallengeDashBoardInfo { private String submissionDate; - private PhaseType currentPhase; + private ChallengePhaseEnum currentPhase; private String currentPhaseSubmissionDate; @@ -62,11 +61,11 @@ public void setSubmissionDate(String submissionDate) { this.submissionDate = submissionDate; } - public PhaseType getCurrentPhase() { + public ChallengePhaseEnum getCurrentPhase() { return currentPhase; } - public void setCurrentPhase(PhaseType currentPhase) { + public void setCurrentPhase(ChallengePhaseEnum currentPhase) { this.currentPhase = currentPhase; } @@ -161,7 +160,7 @@ public Builder withSubmissionDate(String submissionDate) { return this; } - public Builder withCurrentPhase(PhaseType currentPhase) { + public Builder withCurrentPhase(ChallengePhaseEnum currentPhase) { challengeDashBoardInfo.setCurrentPhase(currentPhase); return this; } diff --git a/src/main/java/com/techlooper/model/challenge/PhaseType.java b/src/main/java/com/techlooper/model/challenge/PhaseType.java deleted file mode 100644 index 2529cbe52..000000000 --- a/src/main/java/com/techlooper/model/challenge/PhaseType.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.techlooper.model.challenge; - -import com.techlooper.model.ChallengePhaseEnum; -import org.apache.commons.lang3.StringUtils; - -/** - * Created by NguyenDangKhoa on 1/21/16. - */ -public abstract class PhaseType { - - private ChallengePhaseEnum phaseName; - - private String submissionDate; - - public static PhaseType newChallengePhase(ChallengePhaseEnum phaseName) { - if (phaseName == null) { - return new RegistrationPhase(); - } - switch (phaseName) { - case REGISTRATION: - return new RegistrationPhase(); - default: - throw new IllegalArgumentException("Incorrect Challenge Phase Name"); - } - } - - boolean exist() { - return StringUtils.isNotEmpty(getSubmissionDate()); - } - - public ChallengePhaseEnum getPhaseName() { - return phaseName; - } - - public String getSubmissionDate() { - return submissionDate; - } - - public void setSubmissionDate(String submissionDate) { - this.submissionDate = submissionDate; - } -} diff --git a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java deleted file mode 100644 index 81463aaa1..000000000 --- a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.techlooper.model.challenge; - -/** - * Created by NguyenDangKhoa on 1/21/16. - */ -public class RegistrationPhase extends PhaseType { -} diff --git a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java index aad1cc2b8..7ac2c292b 100644 --- a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java +++ b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java @@ -27,7 +27,7 @@ public interface ChallengeRegistrantService { List findRegistrantsByChallengeId(Long challengeId); - List findRegistrantsByOwner(String ownerEmail); + List findRegistrantsByOwner(String ownerEmail); ChallengeRegistrantEntity findRegistrantById(Long registrantId); diff --git a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java index dd923ccae..5688e33cd 100644 --- a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java @@ -8,7 +8,6 @@ import com.techlooper.entity.ChallengeRegistrantDto; import com.techlooper.entity.ChallengeRegistrantEntity; import com.techlooper.model.*; -import com.techlooper.model.challenge.PhaseType; import com.techlooper.repository.elasticsearch.ChallengeRegistrantRepository; import com.techlooper.repository.elasticsearch.ChallengeRepository; import com.techlooper.repository.elasticsearch.ChallengeSubmissionRepository; @@ -220,11 +219,10 @@ public List findRegistrantsByChallengeId(Long challen return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } - public List findRegistrantsByOwner(String ownerEmail) { + public List findRegistrantsByOwner(String ownerEmail) { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("challengeRegistrant"); searchQueryBuilder.withQuery(filteredQuery(matchAllQuery(), termFilter("registrantEmail", ownerEmail))); - return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder).stream().map( - registrantEntity -> registrantEntity.toDTO()).collect(toList()); + return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } @Override @@ -272,7 +270,7 @@ public List qualifyAllRegistrants(String ownerEmail, Cha for (Long registrantId : challengeQualificationDto.getRegistrantIds()) { ChallengeRegistrantDto registrantDto = acceptRegistrant(registrantId, qualifyingPhase); - if (registrantDto.getActivePhase().getPhaseName() == qualifyingPhase) { + if (registrantDto.getActivePhase() == qualifyingPhase) { qualifiedRegistrants.add(registrantDto); } } @@ -390,9 +388,9 @@ public Long getTotalNumberOfRegistrants() { public List getChallengeDashBoardInfo(String registrantEmail) { List challengeDashBoardInfoList = new ArrayList<>(); - List registrantEntities = findRegistrantsByOwner(registrantEmail); + List registrantEntities = findRegistrantsByOwner(registrantEmail); - for (ChallengeRegistrantDto registrantEntity : registrantEntities) { + for (ChallengeRegistrantEntity registrantEntity : registrantEntities) { Long challengeId = registrantEntity.getChallengeId(); Long registrantId = registrantEntity.getRegistrantId(); ChallengeEntity challengeEntity = challengeService.findChallengeById(challengeId); @@ -402,9 +400,10 @@ public List getChallengeDashBoardInfo(String registrantE challengeDashBoardInfoBuilder.withChallengeId(challengeId); challengeDashBoardInfoBuilder.withChallengeName(challengeEntity.getChallengeName()); challengeDashBoardInfoBuilder.withSubmissionDate(challengeEntity.getSubmissionDateTime()); - PhaseType currentPhase = registrantEntity.getActivePhase(); + ChallengePhaseEnum currentPhase = registrantEntity.getActivePhase() != null ? + registrantEntity.getActivePhase() : REGISTRATION; challengeDashBoardInfoBuilder.withCurrentPhase(currentPhase); - challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(currentPhase.getSubmissionDate()); + challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(getCurrentPhaseSubmissionDate(challengeEntity, currentPhase)); challengeDashBoardInfoBuilder.withDisqualified(registrantEntity.getDisqualified()); Integer numberOfSubmissions = challengeSubmissionService.findChallengeSubmissionByRegistrant(registrantId).size(); @@ -434,8 +433,8 @@ public Set getChallengeWinners(Long challengeId) { return null; } - private Double getRegistrantSubmissionScore(ChallengeRegistrantDto registrantDto) { - Set criteria = registrantDto.getCriteria(); + private Double getRegistrantSubmissionScore(ChallengeRegistrantEntity registrantEntity) { + Set criteria = registrantEntity.getCriteria(); Double totalScore = 0D; if (criteria != null) { @@ -470,4 +469,21 @@ private ChallengeWinner getChallengeWinner(ChallengeEntity challengeEntity, Long } return null; } + + private String getCurrentPhaseSubmissionDate(ChallengeEntity challengeEntity, ChallengePhaseEnum currentPhase) { + switch (currentPhase) { + case REGISTRATION: + return challengeEntity.getRegistrationDateTime(); + case IDEA: + return challengeEntity.getIdeaSubmissionDateTime(); + case UIUX: + return challengeEntity.getUxSubmissionDateTime(); + case PROTOTYPE: + return challengeEntity.getPrototypeSubmissionDateTime(); + case FINAL: + return challengeEntity.getSubmissionDateTime(); + default: + return ""; + } + } } diff --git a/src/main/webapp/assets/modules/navigation/navigation.con.js b/src/main/webapp/assets/modules/navigation/navigation.con.js index 125a61390..04fe7dd68 100644 --- a/src/main/webapp/assets/modules/navigation/navigation.con.js +++ b/src/main/webapp/assets/modules/navigation/navigation.con.js @@ -1,31 +1,18 @@ techlooper.controller("navigationController", function ($scope, securityService, apiService, localStorageService, $location, jsonValue, utils, $timeout, $rootScope, $window) { $scope.state = function (type) { - var isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - var isJobSeeker = $rootScope.userInfo && $rootScope.userInfo.roleName === "JOB_SEEKER"; - //var userNotLogin = !$rootScope.userInfo; - var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; - var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header == "EMPLOYER"; - //var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.header != "EMPLOYER" && $rootScope.currentUiView.type != "LOGIN"; - //console.log(isJobSeekerView); + var isEmployer = undefined; + var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; switch (type) { case "show-employer-header": - if (currentViewIsLogin || isJobSeeker) return false; - if (isEmployer) return true; - //isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - //console.log("emm", isEmployerView); - return isEmployerView; - //return (!currentViewIsLogin && isEmployer) || isEmployerView; + var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; + isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + return (!currentViewIsLogin && isEmployer) || isEmployerView; case "show-job-seeker-header": - if (currentViewIsLogin || isEmployer) return false; - if (isJobSeeker) return true; - if (isEmployerView) return false; - //var employerHeaderNotShown = !$scope.state("show-employer-header"); - //var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; - //console.log("seek", isJobSeekerView); - return !currentViewIsLogin; - //return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; + var employerHeaderNotShown = !$scope.state("show-employer-header"); + var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.type != "LOGIN"; + return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; case "home-url": isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; @@ -50,7 +37,7 @@ techlooper.controller("navigationController", function ($scope, securityService, } } $scope.langKey = localStorage.NG_TRANSLATE_LANG_KEY; - $scope.changeLanguages = function (key) { + $scope.changeLanguages = function(key){ $scope.langKey = key; localStorage.NG_TRANSLATE_LANG_KEY = key; $window.location.reload(); From 8e89717855456fbac527cb22024030a91ca37746 Mon Sep 17 00:00:00 2001 From: khoa-nd Date: Fri, 22 Jan 2016 10:12:50 +0700 Subject: [PATCH 05/11] Temporarily refactor challenge phase --- .../entity/ChallengeRegistrantDto.java | 197 +++++++++--------- .../entity/ChallengeRegistrantEntity.java | 10 + .../model/ChallengeDashBoardInfo.java | 9 +- .../techlooper/model/challenge/PhaseType.java | 42 ++++ .../model/challenge/RegistrationPhase.java | 7 + .../service/ChallengeRegistrantService.java | 2 +- .../impl/ChallengeRegistrantServiceImpl.java | 38 +--- 7 files changed, 175 insertions(+), 130 deletions(-) create mode 100644 src/main/java/com/techlooper/model/challenge/PhaseType.java create mode 100644 src/main/java/com/techlooper/model/challenge/RegistrationPhase.java diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java index cccb18cb4..39b748c5d 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java @@ -4,6 +4,7 @@ import com.techlooper.model.ChallengeSubmissionDto; import com.techlooper.model.Language; import com.techlooper.model.RewardEnum; +import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -13,143 +14,143 @@ */ public class ChallengeRegistrantDto { - private Long challengeId; + private Long challengeId; - private String registrantEmail; + private String registrantEmail; - private String registrantFirstName; + private String registrantFirstName; - private String registrantLastName; + private String registrantLastName; - private Language lang; + private Language lang; - private Double score; + private Double score; - private Long registrantId; + private Long registrantId; - private Boolean disqualified; + private Boolean disqualified; - private String disqualifiedReason; + private String disqualifiedReason; - private String lastEmailSentDateTime; + private String lastEmailSentDateTime; - private List submissions; + private List submissions; - private ChallengePhaseEnum activePhase; + private PhaseType activePhase; - private Set criteria; + private Set criteria; - private RewardEnum reward; + private RewardEnum reward; - public RewardEnum getReward() { - return reward; - } + public RewardEnum getReward() { + return reward; + } - public void setReward(RewardEnum reward) { - this.reward = reward; - } + public void setReward(RewardEnum reward) { + this.reward = reward; + } - public Set getCriteria() { - return criteria; - } + public Set getCriteria() { + return criteria; + } - public void setCriteria(Set criteria) { - this.criteria = criteria; - } + public void setCriteria(Set criteria) { + this.criteria = criteria; + } - public ChallengePhaseEnum getActivePhase() { - return activePhase; - } + public PhaseType getActivePhase() { + return activePhase; + } - public void setActivePhase(ChallengePhaseEnum activePhase) { - this.activePhase = activePhase; - } + public void setActivePhase(PhaseType phaseType) { + this.activePhase = phaseType; + } - public String getDisqualifiedReason() { - return disqualifiedReason; - } + public String getDisqualifiedReason() { + return disqualifiedReason; + } - public void setDisqualifiedReason(String disqualifiedReason) { - this.disqualifiedReason = disqualifiedReason; - } + public void setDisqualifiedReason(String disqualifiedReason) { + this.disqualifiedReason = disqualifiedReason; + } - public Boolean getDisqualified() { - return disqualified; - } + public Boolean getDisqualified() { + return disqualified; + } - public void setDisqualified(Boolean disqualified) { - this.disqualified = disqualified; - } + public void setDisqualified(Boolean disqualified) { + this.disqualified = disqualified; + } - public Long getRegistrantId() { - return registrantId; - } + public Long getRegistrantId() { + return registrantId; + } - public void setRegistrantId(Long registrantId) { - this.registrantId = registrantId; - } + public void setRegistrantId(Long registrantId) { + this.registrantId = registrantId; + } - public Double getScore() { - return score; - } + public Double getScore() { + return score; + } - public void setScore(Double score) { - this.score = score; - } + public void setScore(Double score) { + this.score = score; + } - public Long getChallengeId() { - return challengeId; - } + public Long getChallengeId() { + return challengeId; + } - public void setChallengeId(Long challengeId) { - this.challengeId = challengeId; - } + public void setChallengeId(Long challengeId) { + this.challengeId = challengeId; + } - public String getRegistrantEmail() { - return registrantEmail; - } + public String getRegistrantEmail() { + return registrantEmail; + } - public void setRegistrantEmail(String registrantEmail) { - this.registrantEmail = registrantEmail; - } + public void setRegistrantEmail(String registrantEmail) { + this.registrantEmail = registrantEmail; + } - public String getRegistrantFirstName() { - return registrantFirstName; - } + public String getRegistrantFirstName() { + return registrantFirstName; + } - public void setRegistrantFirstName(String registrantFirstName) { - this.registrantFirstName = registrantFirstName; - } + public void setRegistrantFirstName(String registrantFirstName) { + this.registrantFirstName = registrantFirstName; + } - public String getRegistrantLastName() { - return registrantLastName; - } + public String getRegistrantLastName() { + return registrantLastName; + } - public void setRegistrantLastName(String registrantLastName) { - this.registrantLastName = registrantLastName; - } + public void setRegistrantLastName(String registrantLastName) { + this.registrantLastName = registrantLastName; + } - public Language getLang() { - return lang; - } + public Language getLang() { + return lang; + } - public void setLang(Language lang) { - this.lang = lang; - } + public void setLang(Language lang) { + this.lang = lang; + } - public List getSubmissions() { - return submissions; - } + public List getSubmissions() { + return submissions; + } - public void setSubmissions(List submissions) { - this.submissions = submissions; - } + public void setSubmissions(List submissions) { + this.submissions = submissions; + } - public String getLastEmailSentDateTime() { - return lastEmailSentDateTime; - } + public String getLastEmailSentDateTime() { + return lastEmailSentDateTime; + } - public void setLastEmailSentDateTime(String lastEmailSentDateTime) { - this.lastEmailSentDateTime = lastEmailSentDateTime; - } + public void setLastEmailSentDateTime(String lastEmailSentDateTime) { + this.lastEmailSentDateTime = lastEmailSentDateTime; + } } diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java index 81e7f4c81..779338114 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java @@ -2,6 +2,8 @@ import com.techlooper.model.ChallengePhaseEnum; import com.techlooper.model.Language; +import com.techlooper.model.challenge.PhaseType; +import org.dozer.DozerBeanMapper; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -185,4 +187,12 @@ public Integer getPassCode() { public void setPassCode(Integer passCode) { this.passCode = passCode; } + + public ChallengeRegistrantDto toDTO() { + DozerBeanMapper dozerBeanMapper = new DozerBeanMapper(); + ChallengeRegistrantDto registrantDto = dozerBeanMapper.map(this, ChallengeRegistrantDto.class); + PhaseType phaseType = PhaseType.newChallengePhase(getActivePhase()); + registrantDto.setActivePhase(phaseType); + return registrantDto; + } } diff --git a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java index 97f499830..a7b1ff681 100644 --- a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java +++ b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java @@ -2,6 +2,7 @@ import com.techlooper.entity.ChallengeRegistrantCriteria; import com.techlooper.entity.ChallengeSubmissionEntity; +import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -17,7 +18,7 @@ public class ChallengeDashBoardInfo { private String submissionDate; - private ChallengePhaseEnum currentPhase; + private PhaseType currentPhase; private String currentPhaseSubmissionDate; @@ -61,11 +62,11 @@ public void setSubmissionDate(String submissionDate) { this.submissionDate = submissionDate; } - public ChallengePhaseEnum getCurrentPhase() { + public PhaseType getCurrentPhase() { return currentPhase; } - public void setCurrentPhase(ChallengePhaseEnum currentPhase) { + public void setCurrentPhase(PhaseType currentPhase) { this.currentPhase = currentPhase; } @@ -160,7 +161,7 @@ public Builder withSubmissionDate(String submissionDate) { return this; } - public Builder withCurrentPhase(ChallengePhaseEnum currentPhase) { + public Builder withCurrentPhase(PhaseType currentPhase) { challengeDashBoardInfo.setCurrentPhase(currentPhase); return this; } diff --git a/src/main/java/com/techlooper/model/challenge/PhaseType.java b/src/main/java/com/techlooper/model/challenge/PhaseType.java new file mode 100644 index 000000000..2529cbe52 --- /dev/null +++ b/src/main/java/com/techlooper/model/challenge/PhaseType.java @@ -0,0 +1,42 @@ +package com.techlooper.model.challenge; + +import com.techlooper.model.ChallengePhaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * Created by NguyenDangKhoa on 1/21/16. + */ +public abstract class PhaseType { + + private ChallengePhaseEnum phaseName; + + private String submissionDate; + + public static PhaseType newChallengePhase(ChallengePhaseEnum phaseName) { + if (phaseName == null) { + return new RegistrationPhase(); + } + switch (phaseName) { + case REGISTRATION: + return new RegistrationPhase(); + default: + throw new IllegalArgumentException("Incorrect Challenge Phase Name"); + } + } + + boolean exist() { + return StringUtils.isNotEmpty(getSubmissionDate()); + } + + public ChallengePhaseEnum getPhaseName() { + return phaseName; + } + + public String getSubmissionDate() { + return submissionDate; + } + + public void setSubmissionDate(String submissionDate) { + this.submissionDate = submissionDate; + } +} diff --git a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java new file mode 100644 index 000000000..81463aaa1 --- /dev/null +++ b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java @@ -0,0 +1,7 @@ +package com.techlooper.model.challenge; + +/** + * Created by NguyenDangKhoa on 1/21/16. + */ +public class RegistrationPhase extends PhaseType { +} diff --git a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java index 7ac2c292b..aad1cc2b8 100644 --- a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java +++ b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java @@ -27,7 +27,7 @@ public interface ChallengeRegistrantService { List findRegistrantsByChallengeId(Long challengeId); - List findRegistrantsByOwner(String ownerEmail); + List findRegistrantsByOwner(String ownerEmail); ChallengeRegistrantEntity findRegistrantById(Long registrantId); diff --git a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java index 5688e33cd..dd923ccae 100644 --- a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java @@ -8,6 +8,7 @@ import com.techlooper.entity.ChallengeRegistrantDto; import com.techlooper.entity.ChallengeRegistrantEntity; import com.techlooper.model.*; +import com.techlooper.model.challenge.PhaseType; import com.techlooper.repository.elasticsearch.ChallengeRegistrantRepository; import com.techlooper.repository.elasticsearch.ChallengeRepository; import com.techlooper.repository.elasticsearch.ChallengeSubmissionRepository; @@ -219,10 +220,11 @@ public List findRegistrantsByChallengeId(Long challen return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } - public List findRegistrantsByOwner(String ownerEmail) { + public List findRegistrantsByOwner(String ownerEmail) { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("challengeRegistrant"); searchQueryBuilder.withQuery(filteredQuery(matchAllQuery(), termFilter("registrantEmail", ownerEmail))); - return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); + return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder).stream().map( + registrantEntity -> registrantEntity.toDTO()).collect(toList()); } @Override @@ -270,7 +272,7 @@ public List qualifyAllRegistrants(String ownerEmail, Cha for (Long registrantId : challengeQualificationDto.getRegistrantIds()) { ChallengeRegistrantDto registrantDto = acceptRegistrant(registrantId, qualifyingPhase); - if (registrantDto.getActivePhase() == qualifyingPhase) { + if (registrantDto.getActivePhase().getPhaseName() == qualifyingPhase) { qualifiedRegistrants.add(registrantDto); } } @@ -388,9 +390,9 @@ public Long getTotalNumberOfRegistrants() { public List getChallengeDashBoardInfo(String registrantEmail) { List challengeDashBoardInfoList = new ArrayList<>(); - List registrantEntities = findRegistrantsByOwner(registrantEmail); + List registrantEntities = findRegistrantsByOwner(registrantEmail); - for (ChallengeRegistrantEntity registrantEntity : registrantEntities) { + for (ChallengeRegistrantDto registrantEntity : registrantEntities) { Long challengeId = registrantEntity.getChallengeId(); Long registrantId = registrantEntity.getRegistrantId(); ChallengeEntity challengeEntity = challengeService.findChallengeById(challengeId); @@ -400,10 +402,9 @@ public List getChallengeDashBoardInfo(String registrantE challengeDashBoardInfoBuilder.withChallengeId(challengeId); challengeDashBoardInfoBuilder.withChallengeName(challengeEntity.getChallengeName()); challengeDashBoardInfoBuilder.withSubmissionDate(challengeEntity.getSubmissionDateTime()); - ChallengePhaseEnum currentPhase = registrantEntity.getActivePhase() != null ? - registrantEntity.getActivePhase() : REGISTRATION; + PhaseType currentPhase = registrantEntity.getActivePhase(); challengeDashBoardInfoBuilder.withCurrentPhase(currentPhase); - challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(getCurrentPhaseSubmissionDate(challengeEntity, currentPhase)); + challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(currentPhase.getSubmissionDate()); challengeDashBoardInfoBuilder.withDisqualified(registrantEntity.getDisqualified()); Integer numberOfSubmissions = challengeSubmissionService.findChallengeSubmissionByRegistrant(registrantId).size(); @@ -433,8 +434,8 @@ public Set getChallengeWinners(Long challengeId) { return null; } - private Double getRegistrantSubmissionScore(ChallengeRegistrantEntity registrantEntity) { - Set criteria = registrantEntity.getCriteria(); + private Double getRegistrantSubmissionScore(ChallengeRegistrantDto registrantDto) { + Set criteria = registrantDto.getCriteria(); Double totalScore = 0D; if (criteria != null) { @@ -469,21 +470,4 @@ private ChallengeWinner getChallengeWinner(ChallengeEntity challengeEntity, Long } return null; } - - private String getCurrentPhaseSubmissionDate(ChallengeEntity challengeEntity, ChallengePhaseEnum currentPhase) { - switch (currentPhase) { - case REGISTRATION: - return challengeEntity.getRegistrationDateTime(); - case IDEA: - return challengeEntity.getIdeaSubmissionDateTime(); - case UIUX: - return challengeEntity.getUxSubmissionDateTime(); - case PROTOTYPE: - return challengeEntity.getPrototypeSubmissionDateTime(); - case FINAL: - return challengeEntity.getSubmissionDateTime(); - default: - return ""; - } - } } From 7cfeb80984149b92bec0afea5eb9089af74c6c20 Mon Sep 17 00:00:00 2001 From: phuong Date: Fri, 22 Jan 2016 15:03:56 +0700 Subject: [PATCH 06/11] Revert "Update changes" --- .../entity/ChallengeRegistrantDto.java | 197 +++++++++--------- .../entity/ChallengeRegistrantEntity.java | 10 - .../model/ChallengeDashBoardInfo.java | 9 +- .../techlooper/model/challenge/PhaseType.java | 42 ---- .../model/challenge/RegistrationPhase.java | 7 - .../service/ChallengeRegistrantService.java | 2 +- .../impl/ChallengeRegistrantServiceImpl.java | 38 +++- .../modules/navigation/navigation.con.js | 31 +-- 8 files changed, 139 insertions(+), 197 deletions(-) delete mode 100644 src/main/java/com/techlooper/model/challenge/PhaseType.java delete mode 100644 src/main/java/com/techlooper/model/challenge/RegistrationPhase.java diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java index 39b748c5d..cccb18cb4 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java @@ -4,7 +4,6 @@ import com.techlooper.model.ChallengeSubmissionDto; import com.techlooper.model.Language; import com.techlooper.model.RewardEnum; -import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -14,143 +13,143 @@ */ public class ChallengeRegistrantDto { - private Long challengeId; + private Long challengeId; - private String registrantEmail; + private String registrantEmail; - private String registrantFirstName; + private String registrantFirstName; - private String registrantLastName; + private String registrantLastName; - private Language lang; + private Language lang; - private Double score; + private Double score; - private Long registrantId; + private Long registrantId; - private Boolean disqualified; + private Boolean disqualified; - private String disqualifiedReason; + private String disqualifiedReason; - private String lastEmailSentDateTime; + private String lastEmailSentDateTime; - private List submissions; + private List submissions; - private PhaseType activePhase; + private ChallengePhaseEnum activePhase; - private Set criteria; + private Set criteria; - private RewardEnum reward; + private RewardEnum reward; - public RewardEnum getReward() { - return reward; - } + public RewardEnum getReward() { + return reward; + } - public void setReward(RewardEnum reward) { - this.reward = reward; - } + public void setReward(RewardEnum reward) { + this.reward = reward; + } - public Set getCriteria() { - return criteria; - } + public Set getCriteria() { + return criteria; + } - public void setCriteria(Set criteria) { - this.criteria = criteria; - } + public void setCriteria(Set criteria) { + this.criteria = criteria; + } - public PhaseType getActivePhase() { - return activePhase; - } + public ChallengePhaseEnum getActivePhase() { + return activePhase; + } - public void setActivePhase(PhaseType phaseType) { - this.activePhase = phaseType; - } + public void setActivePhase(ChallengePhaseEnum activePhase) { + this.activePhase = activePhase; + } - public String getDisqualifiedReason() { - return disqualifiedReason; - } + public String getDisqualifiedReason() { + return disqualifiedReason; + } - public void setDisqualifiedReason(String disqualifiedReason) { - this.disqualifiedReason = disqualifiedReason; - } + public void setDisqualifiedReason(String disqualifiedReason) { + this.disqualifiedReason = disqualifiedReason; + } - public Boolean getDisqualified() { - return disqualified; - } + public Boolean getDisqualified() { + return disqualified; + } - public void setDisqualified(Boolean disqualified) { - this.disqualified = disqualified; - } + public void setDisqualified(Boolean disqualified) { + this.disqualified = disqualified; + } - public Long getRegistrantId() { - return registrantId; - } + public Long getRegistrantId() { + return registrantId; + } - public void setRegistrantId(Long registrantId) { - this.registrantId = registrantId; - } + public void setRegistrantId(Long registrantId) { + this.registrantId = registrantId; + } - public Double getScore() { - return score; - } + public Double getScore() { + return score; + } - public void setScore(Double score) { - this.score = score; - } + public void setScore(Double score) { + this.score = score; + } - public Long getChallengeId() { - return challengeId; - } + public Long getChallengeId() { + return challengeId; + } - public void setChallengeId(Long challengeId) { - this.challengeId = challengeId; - } + public void setChallengeId(Long challengeId) { + this.challengeId = challengeId; + } - public String getRegistrantEmail() { - return registrantEmail; - } + public String getRegistrantEmail() { + return registrantEmail; + } - public void setRegistrantEmail(String registrantEmail) { - this.registrantEmail = registrantEmail; - } + public void setRegistrantEmail(String registrantEmail) { + this.registrantEmail = registrantEmail; + } - public String getRegistrantFirstName() { - return registrantFirstName; - } + public String getRegistrantFirstName() { + return registrantFirstName; + } - public void setRegistrantFirstName(String registrantFirstName) { - this.registrantFirstName = registrantFirstName; - } + public void setRegistrantFirstName(String registrantFirstName) { + this.registrantFirstName = registrantFirstName; + } - public String getRegistrantLastName() { - return registrantLastName; - } + public String getRegistrantLastName() { + return registrantLastName; + } - public void setRegistrantLastName(String registrantLastName) { - this.registrantLastName = registrantLastName; - } + public void setRegistrantLastName(String registrantLastName) { + this.registrantLastName = registrantLastName; + } - public Language getLang() { - return lang; - } + public Language getLang() { + return lang; + } - public void setLang(Language lang) { - this.lang = lang; - } + public void setLang(Language lang) { + this.lang = lang; + } - public List getSubmissions() { - return submissions; - } + public List getSubmissions() { + return submissions; + } - public void setSubmissions(List submissions) { - this.submissions = submissions; - } + public void setSubmissions(List submissions) { + this.submissions = submissions; + } - public String getLastEmailSentDateTime() { - return lastEmailSentDateTime; - } + public String getLastEmailSentDateTime() { + return lastEmailSentDateTime; + } - public void setLastEmailSentDateTime(String lastEmailSentDateTime) { - this.lastEmailSentDateTime = lastEmailSentDateTime; - } + public void setLastEmailSentDateTime(String lastEmailSentDateTime) { + this.lastEmailSentDateTime = lastEmailSentDateTime; + } } diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java index 779338114..81e7f4c81 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java @@ -2,8 +2,6 @@ import com.techlooper.model.ChallengePhaseEnum; import com.techlooper.model.Language; -import com.techlooper.model.challenge.PhaseType; -import org.dozer.DozerBeanMapper; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -187,12 +185,4 @@ public Integer getPassCode() { public void setPassCode(Integer passCode) { this.passCode = passCode; } - - public ChallengeRegistrantDto toDTO() { - DozerBeanMapper dozerBeanMapper = new DozerBeanMapper(); - ChallengeRegistrantDto registrantDto = dozerBeanMapper.map(this, ChallengeRegistrantDto.class); - PhaseType phaseType = PhaseType.newChallengePhase(getActivePhase()); - registrantDto.setActivePhase(phaseType); - return registrantDto; - } } diff --git a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java index a7b1ff681..97f499830 100644 --- a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java +++ b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java @@ -2,7 +2,6 @@ import com.techlooper.entity.ChallengeRegistrantCriteria; import com.techlooper.entity.ChallengeSubmissionEntity; -import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -18,7 +17,7 @@ public class ChallengeDashBoardInfo { private String submissionDate; - private PhaseType currentPhase; + private ChallengePhaseEnum currentPhase; private String currentPhaseSubmissionDate; @@ -62,11 +61,11 @@ public void setSubmissionDate(String submissionDate) { this.submissionDate = submissionDate; } - public PhaseType getCurrentPhase() { + public ChallengePhaseEnum getCurrentPhase() { return currentPhase; } - public void setCurrentPhase(PhaseType currentPhase) { + public void setCurrentPhase(ChallengePhaseEnum currentPhase) { this.currentPhase = currentPhase; } @@ -161,7 +160,7 @@ public Builder withSubmissionDate(String submissionDate) { return this; } - public Builder withCurrentPhase(PhaseType currentPhase) { + public Builder withCurrentPhase(ChallengePhaseEnum currentPhase) { challengeDashBoardInfo.setCurrentPhase(currentPhase); return this; } diff --git a/src/main/java/com/techlooper/model/challenge/PhaseType.java b/src/main/java/com/techlooper/model/challenge/PhaseType.java deleted file mode 100644 index 2529cbe52..000000000 --- a/src/main/java/com/techlooper/model/challenge/PhaseType.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.techlooper.model.challenge; - -import com.techlooper.model.ChallengePhaseEnum; -import org.apache.commons.lang3.StringUtils; - -/** - * Created by NguyenDangKhoa on 1/21/16. - */ -public abstract class PhaseType { - - private ChallengePhaseEnum phaseName; - - private String submissionDate; - - public static PhaseType newChallengePhase(ChallengePhaseEnum phaseName) { - if (phaseName == null) { - return new RegistrationPhase(); - } - switch (phaseName) { - case REGISTRATION: - return new RegistrationPhase(); - default: - throw new IllegalArgumentException("Incorrect Challenge Phase Name"); - } - } - - boolean exist() { - return StringUtils.isNotEmpty(getSubmissionDate()); - } - - public ChallengePhaseEnum getPhaseName() { - return phaseName; - } - - public String getSubmissionDate() { - return submissionDate; - } - - public void setSubmissionDate(String submissionDate) { - this.submissionDate = submissionDate; - } -} diff --git a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java deleted file mode 100644 index 81463aaa1..000000000 --- a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.techlooper.model.challenge; - -/** - * Created by NguyenDangKhoa on 1/21/16. - */ -public class RegistrationPhase extends PhaseType { -} diff --git a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java index aad1cc2b8..7ac2c292b 100644 --- a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java +++ b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java @@ -27,7 +27,7 @@ public interface ChallengeRegistrantService { List findRegistrantsByChallengeId(Long challengeId); - List findRegistrantsByOwner(String ownerEmail); + List findRegistrantsByOwner(String ownerEmail); ChallengeRegistrantEntity findRegistrantById(Long registrantId); diff --git a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java index dd923ccae..5688e33cd 100644 --- a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java @@ -8,7 +8,6 @@ import com.techlooper.entity.ChallengeRegistrantDto; import com.techlooper.entity.ChallengeRegistrantEntity; import com.techlooper.model.*; -import com.techlooper.model.challenge.PhaseType; import com.techlooper.repository.elasticsearch.ChallengeRegistrantRepository; import com.techlooper.repository.elasticsearch.ChallengeRepository; import com.techlooper.repository.elasticsearch.ChallengeSubmissionRepository; @@ -220,11 +219,10 @@ public List findRegistrantsByChallengeId(Long challen return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } - public List findRegistrantsByOwner(String ownerEmail) { + public List findRegistrantsByOwner(String ownerEmail) { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("challengeRegistrant"); searchQueryBuilder.withQuery(filteredQuery(matchAllQuery(), termFilter("registrantEmail", ownerEmail))); - return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder).stream().map( - registrantEntity -> registrantEntity.toDTO()).collect(toList()); + return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } @Override @@ -272,7 +270,7 @@ public List qualifyAllRegistrants(String ownerEmail, Cha for (Long registrantId : challengeQualificationDto.getRegistrantIds()) { ChallengeRegistrantDto registrantDto = acceptRegistrant(registrantId, qualifyingPhase); - if (registrantDto.getActivePhase().getPhaseName() == qualifyingPhase) { + if (registrantDto.getActivePhase() == qualifyingPhase) { qualifiedRegistrants.add(registrantDto); } } @@ -390,9 +388,9 @@ public Long getTotalNumberOfRegistrants() { public List getChallengeDashBoardInfo(String registrantEmail) { List challengeDashBoardInfoList = new ArrayList<>(); - List registrantEntities = findRegistrantsByOwner(registrantEmail); + List registrantEntities = findRegistrantsByOwner(registrantEmail); - for (ChallengeRegistrantDto registrantEntity : registrantEntities) { + for (ChallengeRegistrantEntity registrantEntity : registrantEntities) { Long challengeId = registrantEntity.getChallengeId(); Long registrantId = registrantEntity.getRegistrantId(); ChallengeEntity challengeEntity = challengeService.findChallengeById(challengeId); @@ -402,9 +400,10 @@ public List getChallengeDashBoardInfo(String registrantE challengeDashBoardInfoBuilder.withChallengeId(challengeId); challengeDashBoardInfoBuilder.withChallengeName(challengeEntity.getChallengeName()); challengeDashBoardInfoBuilder.withSubmissionDate(challengeEntity.getSubmissionDateTime()); - PhaseType currentPhase = registrantEntity.getActivePhase(); + ChallengePhaseEnum currentPhase = registrantEntity.getActivePhase() != null ? + registrantEntity.getActivePhase() : REGISTRATION; challengeDashBoardInfoBuilder.withCurrentPhase(currentPhase); - challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(currentPhase.getSubmissionDate()); + challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(getCurrentPhaseSubmissionDate(challengeEntity, currentPhase)); challengeDashBoardInfoBuilder.withDisqualified(registrantEntity.getDisqualified()); Integer numberOfSubmissions = challengeSubmissionService.findChallengeSubmissionByRegistrant(registrantId).size(); @@ -434,8 +433,8 @@ public Set getChallengeWinners(Long challengeId) { return null; } - private Double getRegistrantSubmissionScore(ChallengeRegistrantDto registrantDto) { - Set criteria = registrantDto.getCriteria(); + private Double getRegistrantSubmissionScore(ChallengeRegistrantEntity registrantEntity) { + Set criteria = registrantEntity.getCriteria(); Double totalScore = 0D; if (criteria != null) { @@ -470,4 +469,21 @@ private ChallengeWinner getChallengeWinner(ChallengeEntity challengeEntity, Long } return null; } + + private String getCurrentPhaseSubmissionDate(ChallengeEntity challengeEntity, ChallengePhaseEnum currentPhase) { + switch (currentPhase) { + case REGISTRATION: + return challengeEntity.getRegistrationDateTime(); + case IDEA: + return challengeEntity.getIdeaSubmissionDateTime(); + case UIUX: + return challengeEntity.getUxSubmissionDateTime(); + case PROTOTYPE: + return challengeEntity.getPrototypeSubmissionDateTime(); + case FINAL: + return challengeEntity.getSubmissionDateTime(); + default: + return ""; + } + } } diff --git a/src/main/webapp/assets/modules/navigation/navigation.con.js b/src/main/webapp/assets/modules/navigation/navigation.con.js index 125a61390..04fe7dd68 100644 --- a/src/main/webapp/assets/modules/navigation/navigation.con.js +++ b/src/main/webapp/assets/modules/navigation/navigation.con.js @@ -1,31 +1,18 @@ techlooper.controller("navigationController", function ($scope, securityService, apiService, localStorageService, $location, jsonValue, utils, $timeout, $rootScope, $window) { $scope.state = function (type) { - var isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - var isJobSeeker = $rootScope.userInfo && $rootScope.userInfo.roleName === "JOB_SEEKER"; - //var userNotLogin = !$rootScope.userInfo; - var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; - var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header == "EMPLOYER"; - //var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.header != "EMPLOYER" && $rootScope.currentUiView.type != "LOGIN"; - //console.log(isJobSeekerView); + var isEmployer = undefined; + var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; switch (type) { case "show-employer-header": - if (currentViewIsLogin || isJobSeeker) return false; - if (isEmployer) return true; - //isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - //console.log("emm", isEmployerView); - return isEmployerView; - //return (!currentViewIsLogin && isEmployer) || isEmployerView; + var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; + isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + return (!currentViewIsLogin && isEmployer) || isEmployerView; case "show-job-seeker-header": - if (currentViewIsLogin || isEmployer) return false; - if (isJobSeeker) return true; - if (isEmployerView) return false; - //var employerHeaderNotShown = !$scope.state("show-employer-header"); - //var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; - //console.log("seek", isJobSeekerView); - return !currentViewIsLogin; - //return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; + var employerHeaderNotShown = !$scope.state("show-employer-header"); + var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.type != "LOGIN"; + return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; case "home-url": isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; @@ -50,7 +37,7 @@ techlooper.controller("navigationController", function ($scope, securityService, } } $scope.langKey = localStorage.NG_TRANSLATE_LANG_KEY; - $scope.changeLanguages = function (key) { + $scope.changeLanguages = function(key){ $scope.langKey = key; localStorage.NG_TRANSLATE_LANG_KEY = key; $window.location.reload(); From a45d284a6f4c87f7147da6a4295778243c81219c Mon Sep 17 00:00:00 2001 From: phuong Date: Fri, 22 Jan 2016 16:31:41 +0700 Subject: [PATCH 07/11] Revert "Update changes" --- .../entity/ChallengeRegistrantDto.java | 197 +++++++++--------- .../entity/ChallengeRegistrantEntity.java | 10 + .../model/ChallengeDashBoardInfo.java | 9 +- .../techlooper/model/challenge/PhaseType.java | 42 ++++ .../model/challenge/RegistrationPhase.java | 7 + .../service/ChallengeRegistrantService.java | 2 +- .../impl/ChallengeRegistrantServiceImpl.java | 38 +--- .../modules/navigation/navigation.con.js | 31 ++- 8 files changed, 197 insertions(+), 139 deletions(-) create mode 100644 src/main/java/com/techlooper/model/challenge/PhaseType.java create mode 100644 src/main/java/com/techlooper/model/challenge/RegistrationPhase.java diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java index cccb18cb4..39b748c5d 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java @@ -4,6 +4,7 @@ import com.techlooper.model.ChallengeSubmissionDto; import com.techlooper.model.Language; import com.techlooper.model.RewardEnum; +import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -13,143 +14,143 @@ */ public class ChallengeRegistrantDto { - private Long challengeId; + private Long challengeId; - private String registrantEmail; + private String registrantEmail; - private String registrantFirstName; + private String registrantFirstName; - private String registrantLastName; + private String registrantLastName; - private Language lang; + private Language lang; - private Double score; + private Double score; - private Long registrantId; + private Long registrantId; - private Boolean disqualified; + private Boolean disqualified; - private String disqualifiedReason; + private String disqualifiedReason; - private String lastEmailSentDateTime; + private String lastEmailSentDateTime; - private List submissions; + private List submissions; - private ChallengePhaseEnum activePhase; + private PhaseType activePhase; - private Set criteria; + private Set criteria; - private RewardEnum reward; + private RewardEnum reward; - public RewardEnum getReward() { - return reward; - } + public RewardEnum getReward() { + return reward; + } - public void setReward(RewardEnum reward) { - this.reward = reward; - } + public void setReward(RewardEnum reward) { + this.reward = reward; + } - public Set getCriteria() { - return criteria; - } + public Set getCriteria() { + return criteria; + } - public void setCriteria(Set criteria) { - this.criteria = criteria; - } + public void setCriteria(Set criteria) { + this.criteria = criteria; + } - public ChallengePhaseEnum getActivePhase() { - return activePhase; - } + public PhaseType getActivePhase() { + return activePhase; + } - public void setActivePhase(ChallengePhaseEnum activePhase) { - this.activePhase = activePhase; - } + public void setActivePhase(PhaseType phaseType) { + this.activePhase = phaseType; + } - public String getDisqualifiedReason() { - return disqualifiedReason; - } + public String getDisqualifiedReason() { + return disqualifiedReason; + } - public void setDisqualifiedReason(String disqualifiedReason) { - this.disqualifiedReason = disqualifiedReason; - } + public void setDisqualifiedReason(String disqualifiedReason) { + this.disqualifiedReason = disqualifiedReason; + } - public Boolean getDisqualified() { - return disqualified; - } + public Boolean getDisqualified() { + return disqualified; + } - public void setDisqualified(Boolean disqualified) { - this.disqualified = disqualified; - } + public void setDisqualified(Boolean disqualified) { + this.disqualified = disqualified; + } - public Long getRegistrantId() { - return registrantId; - } + public Long getRegistrantId() { + return registrantId; + } - public void setRegistrantId(Long registrantId) { - this.registrantId = registrantId; - } + public void setRegistrantId(Long registrantId) { + this.registrantId = registrantId; + } - public Double getScore() { - return score; - } + public Double getScore() { + return score; + } - public void setScore(Double score) { - this.score = score; - } + public void setScore(Double score) { + this.score = score; + } - public Long getChallengeId() { - return challengeId; - } + public Long getChallengeId() { + return challengeId; + } - public void setChallengeId(Long challengeId) { - this.challengeId = challengeId; - } + public void setChallengeId(Long challengeId) { + this.challengeId = challengeId; + } - public String getRegistrantEmail() { - return registrantEmail; - } + public String getRegistrantEmail() { + return registrantEmail; + } - public void setRegistrantEmail(String registrantEmail) { - this.registrantEmail = registrantEmail; - } + public void setRegistrantEmail(String registrantEmail) { + this.registrantEmail = registrantEmail; + } - public String getRegistrantFirstName() { - return registrantFirstName; - } + public String getRegistrantFirstName() { + return registrantFirstName; + } - public void setRegistrantFirstName(String registrantFirstName) { - this.registrantFirstName = registrantFirstName; - } + public void setRegistrantFirstName(String registrantFirstName) { + this.registrantFirstName = registrantFirstName; + } - public String getRegistrantLastName() { - return registrantLastName; - } + public String getRegistrantLastName() { + return registrantLastName; + } - public void setRegistrantLastName(String registrantLastName) { - this.registrantLastName = registrantLastName; - } + public void setRegistrantLastName(String registrantLastName) { + this.registrantLastName = registrantLastName; + } - public Language getLang() { - return lang; - } + public Language getLang() { + return lang; + } - public void setLang(Language lang) { - this.lang = lang; - } + public void setLang(Language lang) { + this.lang = lang; + } - public List getSubmissions() { - return submissions; - } + public List getSubmissions() { + return submissions; + } - public void setSubmissions(List submissions) { - this.submissions = submissions; - } + public void setSubmissions(List submissions) { + this.submissions = submissions; + } - public String getLastEmailSentDateTime() { - return lastEmailSentDateTime; - } + public String getLastEmailSentDateTime() { + return lastEmailSentDateTime; + } - public void setLastEmailSentDateTime(String lastEmailSentDateTime) { - this.lastEmailSentDateTime = lastEmailSentDateTime; - } + public void setLastEmailSentDateTime(String lastEmailSentDateTime) { + this.lastEmailSentDateTime = lastEmailSentDateTime; + } } diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java index 81e7f4c81..779338114 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java @@ -2,6 +2,8 @@ import com.techlooper.model.ChallengePhaseEnum; import com.techlooper.model.Language; +import com.techlooper.model.challenge.PhaseType; +import org.dozer.DozerBeanMapper; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -185,4 +187,12 @@ public Integer getPassCode() { public void setPassCode(Integer passCode) { this.passCode = passCode; } + + public ChallengeRegistrantDto toDTO() { + DozerBeanMapper dozerBeanMapper = new DozerBeanMapper(); + ChallengeRegistrantDto registrantDto = dozerBeanMapper.map(this, ChallengeRegistrantDto.class); + PhaseType phaseType = PhaseType.newChallengePhase(getActivePhase()); + registrantDto.setActivePhase(phaseType); + return registrantDto; + } } diff --git a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java index 97f499830..a7b1ff681 100644 --- a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java +++ b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java @@ -2,6 +2,7 @@ import com.techlooper.entity.ChallengeRegistrantCriteria; import com.techlooper.entity.ChallengeSubmissionEntity; +import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -17,7 +18,7 @@ public class ChallengeDashBoardInfo { private String submissionDate; - private ChallengePhaseEnum currentPhase; + private PhaseType currentPhase; private String currentPhaseSubmissionDate; @@ -61,11 +62,11 @@ public void setSubmissionDate(String submissionDate) { this.submissionDate = submissionDate; } - public ChallengePhaseEnum getCurrentPhase() { + public PhaseType getCurrentPhase() { return currentPhase; } - public void setCurrentPhase(ChallengePhaseEnum currentPhase) { + public void setCurrentPhase(PhaseType currentPhase) { this.currentPhase = currentPhase; } @@ -160,7 +161,7 @@ public Builder withSubmissionDate(String submissionDate) { return this; } - public Builder withCurrentPhase(ChallengePhaseEnum currentPhase) { + public Builder withCurrentPhase(PhaseType currentPhase) { challengeDashBoardInfo.setCurrentPhase(currentPhase); return this; } diff --git a/src/main/java/com/techlooper/model/challenge/PhaseType.java b/src/main/java/com/techlooper/model/challenge/PhaseType.java new file mode 100644 index 000000000..2529cbe52 --- /dev/null +++ b/src/main/java/com/techlooper/model/challenge/PhaseType.java @@ -0,0 +1,42 @@ +package com.techlooper.model.challenge; + +import com.techlooper.model.ChallengePhaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * Created by NguyenDangKhoa on 1/21/16. + */ +public abstract class PhaseType { + + private ChallengePhaseEnum phaseName; + + private String submissionDate; + + public static PhaseType newChallengePhase(ChallengePhaseEnum phaseName) { + if (phaseName == null) { + return new RegistrationPhase(); + } + switch (phaseName) { + case REGISTRATION: + return new RegistrationPhase(); + default: + throw new IllegalArgumentException("Incorrect Challenge Phase Name"); + } + } + + boolean exist() { + return StringUtils.isNotEmpty(getSubmissionDate()); + } + + public ChallengePhaseEnum getPhaseName() { + return phaseName; + } + + public String getSubmissionDate() { + return submissionDate; + } + + public void setSubmissionDate(String submissionDate) { + this.submissionDate = submissionDate; + } +} diff --git a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java new file mode 100644 index 000000000..81463aaa1 --- /dev/null +++ b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java @@ -0,0 +1,7 @@ +package com.techlooper.model.challenge; + +/** + * Created by NguyenDangKhoa on 1/21/16. + */ +public class RegistrationPhase extends PhaseType { +} diff --git a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java index 7ac2c292b..aad1cc2b8 100644 --- a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java +++ b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java @@ -27,7 +27,7 @@ public interface ChallengeRegistrantService { List findRegistrantsByChallengeId(Long challengeId); - List findRegistrantsByOwner(String ownerEmail); + List findRegistrantsByOwner(String ownerEmail); ChallengeRegistrantEntity findRegistrantById(Long registrantId); diff --git a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java index 5688e33cd..dd923ccae 100644 --- a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java @@ -8,6 +8,7 @@ import com.techlooper.entity.ChallengeRegistrantDto; import com.techlooper.entity.ChallengeRegistrantEntity; import com.techlooper.model.*; +import com.techlooper.model.challenge.PhaseType; import com.techlooper.repository.elasticsearch.ChallengeRegistrantRepository; import com.techlooper.repository.elasticsearch.ChallengeRepository; import com.techlooper.repository.elasticsearch.ChallengeSubmissionRepository; @@ -219,10 +220,11 @@ public List findRegistrantsByChallengeId(Long challen return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } - public List findRegistrantsByOwner(String ownerEmail) { + public List findRegistrantsByOwner(String ownerEmail) { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("challengeRegistrant"); searchQueryBuilder.withQuery(filteredQuery(matchAllQuery(), termFilter("registrantEmail", ownerEmail))); - return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); + return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder).stream().map( + registrantEntity -> registrantEntity.toDTO()).collect(toList()); } @Override @@ -270,7 +272,7 @@ public List qualifyAllRegistrants(String ownerEmail, Cha for (Long registrantId : challengeQualificationDto.getRegistrantIds()) { ChallengeRegistrantDto registrantDto = acceptRegistrant(registrantId, qualifyingPhase); - if (registrantDto.getActivePhase() == qualifyingPhase) { + if (registrantDto.getActivePhase().getPhaseName() == qualifyingPhase) { qualifiedRegistrants.add(registrantDto); } } @@ -388,9 +390,9 @@ public Long getTotalNumberOfRegistrants() { public List getChallengeDashBoardInfo(String registrantEmail) { List challengeDashBoardInfoList = new ArrayList<>(); - List registrantEntities = findRegistrantsByOwner(registrantEmail); + List registrantEntities = findRegistrantsByOwner(registrantEmail); - for (ChallengeRegistrantEntity registrantEntity : registrantEntities) { + for (ChallengeRegistrantDto registrantEntity : registrantEntities) { Long challengeId = registrantEntity.getChallengeId(); Long registrantId = registrantEntity.getRegistrantId(); ChallengeEntity challengeEntity = challengeService.findChallengeById(challengeId); @@ -400,10 +402,9 @@ public List getChallengeDashBoardInfo(String registrantE challengeDashBoardInfoBuilder.withChallengeId(challengeId); challengeDashBoardInfoBuilder.withChallengeName(challengeEntity.getChallengeName()); challengeDashBoardInfoBuilder.withSubmissionDate(challengeEntity.getSubmissionDateTime()); - ChallengePhaseEnum currentPhase = registrantEntity.getActivePhase() != null ? - registrantEntity.getActivePhase() : REGISTRATION; + PhaseType currentPhase = registrantEntity.getActivePhase(); challengeDashBoardInfoBuilder.withCurrentPhase(currentPhase); - challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(getCurrentPhaseSubmissionDate(challengeEntity, currentPhase)); + challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(currentPhase.getSubmissionDate()); challengeDashBoardInfoBuilder.withDisqualified(registrantEntity.getDisqualified()); Integer numberOfSubmissions = challengeSubmissionService.findChallengeSubmissionByRegistrant(registrantId).size(); @@ -433,8 +434,8 @@ public Set getChallengeWinners(Long challengeId) { return null; } - private Double getRegistrantSubmissionScore(ChallengeRegistrantEntity registrantEntity) { - Set criteria = registrantEntity.getCriteria(); + private Double getRegistrantSubmissionScore(ChallengeRegistrantDto registrantDto) { + Set criteria = registrantDto.getCriteria(); Double totalScore = 0D; if (criteria != null) { @@ -469,21 +470,4 @@ private ChallengeWinner getChallengeWinner(ChallengeEntity challengeEntity, Long } return null; } - - private String getCurrentPhaseSubmissionDate(ChallengeEntity challengeEntity, ChallengePhaseEnum currentPhase) { - switch (currentPhase) { - case REGISTRATION: - return challengeEntity.getRegistrationDateTime(); - case IDEA: - return challengeEntity.getIdeaSubmissionDateTime(); - case UIUX: - return challengeEntity.getUxSubmissionDateTime(); - case PROTOTYPE: - return challengeEntity.getPrototypeSubmissionDateTime(); - case FINAL: - return challengeEntity.getSubmissionDateTime(); - default: - return ""; - } - } } diff --git a/src/main/webapp/assets/modules/navigation/navigation.con.js b/src/main/webapp/assets/modules/navigation/navigation.con.js index 04fe7dd68..125a61390 100644 --- a/src/main/webapp/assets/modules/navigation/navigation.con.js +++ b/src/main/webapp/assets/modules/navigation/navigation.con.js @@ -1,18 +1,31 @@ techlooper.controller("navigationController", function ($scope, securityService, apiService, localStorageService, $location, jsonValue, utils, $timeout, $rootScope, $window) { $scope.state = function (type) { - var isEmployer = undefined; - var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; + var isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + var isJobSeeker = $rootScope.userInfo && $rootScope.userInfo.roleName === "JOB_SEEKER"; + //var userNotLogin = !$rootScope.userInfo; + var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; + var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header == "EMPLOYER"; + //var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.header != "EMPLOYER" && $rootScope.currentUiView.type != "LOGIN"; + //console.log(isJobSeekerView); switch (type) { case "show-employer-header": - var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; - isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - return (!currentViewIsLogin && isEmployer) || isEmployerView; + if (currentViewIsLogin || isJobSeeker) return false; + if (isEmployer) return true; + //isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + //console.log("emm", isEmployerView); + return isEmployerView; + //return (!currentViewIsLogin && isEmployer) || isEmployerView; case "show-job-seeker-header": - var employerHeaderNotShown = !$scope.state("show-employer-header"); - var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.type != "LOGIN"; - return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; + if (currentViewIsLogin || isEmployer) return false; + if (isJobSeeker) return true; + if (isEmployerView) return false; + //var employerHeaderNotShown = !$scope.state("show-employer-header"); + //var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; + //console.log("seek", isJobSeekerView); + return !currentViewIsLogin; + //return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; case "home-url": isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; @@ -37,7 +50,7 @@ techlooper.controller("navigationController", function ($scope, securityService, } } $scope.langKey = localStorage.NG_TRANSLATE_LANG_KEY; - $scope.changeLanguages = function(key){ + $scope.changeLanguages = function (key) { $scope.langKey = key; localStorage.NG_TRANSLATE_LANG_KEY = key; $window.location.reload(); From c85f8df9f8e61ce772615f5eb895c08d20169db6 Mon Sep 17 00:00:00 2001 From: phuong Date: Fri, 22 Jan 2016 16:32:44 +0700 Subject: [PATCH 08/11] Revert "Update changes" --- .../entity/ChallengeRegistrantDto.java | 197 +++++++++--------- .../entity/ChallengeRegistrantEntity.java | 10 - .../model/ChallengeDashBoardInfo.java | 9 +- .../techlooper/model/challenge/PhaseType.java | 42 ---- .../model/challenge/RegistrationPhase.java | 7 - .../service/ChallengeRegistrantService.java | 2 +- .../impl/ChallengeRegistrantServiceImpl.java | 38 +++- .../modules/navigation/navigation.con.js | 31 +-- 8 files changed, 139 insertions(+), 197 deletions(-) delete mode 100644 src/main/java/com/techlooper/model/challenge/PhaseType.java delete mode 100644 src/main/java/com/techlooper/model/challenge/RegistrationPhase.java diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java index 39b748c5d..cccb18cb4 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantDto.java @@ -4,7 +4,6 @@ import com.techlooper.model.ChallengeSubmissionDto; import com.techlooper.model.Language; import com.techlooper.model.RewardEnum; -import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -14,143 +13,143 @@ */ public class ChallengeRegistrantDto { - private Long challengeId; + private Long challengeId; - private String registrantEmail; + private String registrantEmail; - private String registrantFirstName; + private String registrantFirstName; - private String registrantLastName; + private String registrantLastName; - private Language lang; + private Language lang; - private Double score; + private Double score; - private Long registrantId; + private Long registrantId; - private Boolean disqualified; + private Boolean disqualified; - private String disqualifiedReason; + private String disqualifiedReason; - private String lastEmailSentDateTime; + private String lastEmailSentDateTime; - private List submissions; + private List submissions; - private PhaseType activePhase; + private ChallengePhaseEnum activePhase; - private Set criteria; + private Set criteria; - private RewardEnum reward; + private RewardEnum reward; - public RewardEnum getReward() { - return reward; - } + public RewardEnum getReward() { + return reward; + } - public void setReward(RewardEnum reward) { - this.reward = reward; - } + public void setReward(RewardEnum reward) { + this.reward = reward; + } - public Set getCriteria() { - return criteria; - } + public Set getCriteria() { + return criteria; + } - public void setCriteria(Set criteria) { - this.criteria = criteria; - } + public void setCriteria(Set criteria) { + this.criteria = criteria; + } - public PhaseType getActivePhase() { - return activePhase; - } + public ChallengePhaseEnum getActivePhase() { + return activePhase; + } - public void setActivePhase(PhaseType phaseType) { - this.activePhase = phaseType; - } + public void setActivePhase(ChallengePhaseEnum activePhase) { + this.activePhase = activePhase; + } - public String getDisqualifiedReason() { - return disqualifiedReason; - } + public String getDisqualifiedReason() { + return disqualifiedReason; + } - public void setDisqualifiedReason(String disqualifiedReason) { - this.disqualifiedReason = disqualifiedReason; - } + public void setDisqualifiedReason(String disqualifiedReason) { + this.disqualifiedReason = disqualifiedReason; + } - public Boolean getDisqualified() { - return disqualified; - } + public Boolean getDisqualified() { + return disqualified; + } - public void setDisqualified(Boolean disqualified) { - this.disqualified = disqualified; - } + public void setDisqualified(Boolean disqualified) { + this.disqualified = disqualified; + } - public Long getRegistrantId() { - return registrantId; - } + public Long getRegistrantId() { + return registrantId; + } - public void setRegistrantId(Long registrantId) { - this.registrantId = registrantId; - } + public void setRegistrantId(Long registrantId) { + this.registrantId = registrantId; + } - public Double getScore() { - return score; - } + public Double getScore() { + return score; + } - public void setScore(Double score) { - this.score = score; - } + public void setScore(Double score) { + this.score = score; + } - public Long getChallengeId() { - return challengeId; - } + public Long getChallengeId() { + return challengeId; + } - public void setChallengeId(Long challengeId) { - this.challengeId = challengeId; - } + public void setChallengeId(Long challengeId) { + this.challengeId = challengeId; + } - public String getRegistrantEmail() { - return registrantEmail; - } + public String getRegistrantEmail() { + return registrantEmail; + } - public void setRegistrantEmail(String registrantEmail) { - this.registrantEmail = registrantEmail; - } + public void setRegistrantEmail(String registrantEmail) { + this.registrantEmail = registrantEmail; + } - public String getRegistrantFirstName() { - return registrantFirstName; - } + public String getRegistrantFirstName() { + return registrantFirstName; + } - public void setRegistrantFirstName(String registrantFirstName) { - this.registrantFirstName = registrantFirstName; - } + public void setRegistrantFirstName(String registrantFirstName) { + this.registrantFirstName = registrantFirstName; + } - public String getRegistrantLastName() { - return registrantLastName; - } + public String getRegistrantLastName() { + return registrantLastName; + } - public void setRegistrantLastName(String registrantLastName) { - this.registrantLastName = registrantLastName; - } + public void setRegistrantLastName(String registrantLastName) { + this.registrantLastName = registrantLastName; + } - public Language getLang() { - return lang; - } + public Language getLang() { + return lang; + } - public void setLang(Language lang) { - this.lang = lang; - } + public void setLang(Language lang) { + this.lang = lang; + } - public List getSubmissions() { - return submissions; - } + public List getSubmissions() { + return submissions; + } - public void setSubmissions(List submissions) { - this.submissions = submissions; - } + public void setSubmissions(List submissions) { + this.submissions = submissions; + } - public String getLastEmailSentDateTime() { - return lastEmailSentDateTime; - } + public String getLastEmailSentDateTime() { + return lastEmailSentDateTime; + } - public void setLastEmailSentDateTime(String lastEmailSentDateTime) { - this.lastEmailSentDateTime = lastEmailSentDateTime; - } + public void setLastEmailSentDateTime(String lastEmailSentDateTime) { + this.lastEmailSentDateTime = lastEmailSentDateTime; + } } diff --git a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java index 779338114..81e7f4c81 100644 --- a/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java +++ b/src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java @@ -2,8 +2,6 @@ import com.techlooper.model.ChallengePhaseEnum; import com.techlooper.model.Language; -import com.techlooper.model.challenge.PhaseType; -import org.dozer.DozerBeanMapper; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -187,12 +185,4 @@ public Integer getPassCode() { public void setPassCode(Integer passCode) { this.passCode = passCode; } - - public ChallengeRegistrantDto toDTO() { - DozerBeanMapper dozerBeanMapper = new DozerBeanMapper(); - ChallengeRegistrantDto registrantDto = dozerBeanMapper.map(this, ChallengeRegistrantDto.class); - PhaseType phaseType = PhaseType.newChallengePhase(getActivePhase()); - registrantDto.setActivePhase(phaseType); - return registrantDto; - } } diff --git a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java index a7b1ff681..97f499830 100644 --- a/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java +++ b/src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java @@ -2,7 +2,6 @@ import com.techlooper.entity.ChallengeRegistrantCriteria; import com.techlooper.entity.ChallengeSubmissionEntity; -import com.techlooper.model.challenge.PhaseType; import java.util.List; import java.util.Set; @@ -18,7 +17,7 @@ public class ChallengeDashBoardInfo { private String submissionDate; - private PhaseType currentPhase; + private ChallengePhaseEnum currentPhase; private String currentPhaseSubmissionDate; @@ -62,11 +61,11 @@ public void setSubmissionDate(String submissionDate) { this.submissionDate = submissionDate; } - public PhaseType getCurrentPhase() { + public ChallengePhaseEnum getCurrentPhase() { return currentPhase; } - public void setCurrentPhase(PhaseType currentPhase) { + public void setCurrentPhase(ChallengePhaseEnum currentPhase) { this.currentPhase = currentPhase; } @@ -161,7 +160,7 @@ public Builder withSubmissionDate(String submissionDate) { return this; } - public Builder withCurrentPhase(PhaseType currentPhase) { + public Builder withCurrentPhase(ChallengePhaseEnum currentPhase) { challengeDashBoardInfo.setCurrentPhase(currentPhase); return this; } diff --git a/src/main/java/com/techlooper/model/challenge/PhaseType.java b/src/main/java/com/techlooper/model/challenge/PhaseType.java deleted file mode 100644 index 2529cbe52..000000000 --- a/src/main/java/com/techlooper/model/challenge/PhaseType.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.techlooper.model.challenge; - -import com.techlooper.model.ChallengePhaseEnum; -import org.apache.commons.lang3.StringUtils; - -/** - * Created by NguyenDangKhoa on 1/21/16. - */ -public abstract class PhaseType { - - private ChallengePhaseEnum phaseName; - - private String submissionDate; - - public static PhaseType newChallengePhase(ChallengePhaseEnum phaseName) { - if (phaseName == null) { - return new RegistrationPhase(); - } - switch (phaseName) { - case REGISTRATION: - return new RegistrationPhase(); - default: - throw new IllegalArgumentException("Incorrect Challenge Phase Name"); - } - } - - boolean exist() { - return StringUtils.isNotEmpty(getSubmissionDate()); - } - - public ChallengePhaseEnum getPhaseName() { - return phaseName; - } - - public String getSubmissionDate() { - return submissionDate; - } - - public void setSubmissionDate(String submissionDate) { - this.submissionDate = submissionDate; - } -} diff --git a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java b/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java deleted file mode 100644 index 81463aaa1..000000000 --- a/src/main/java/com/techlooper/model/challenge/RegistrationPhase.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.techlooper.model.challenge; - -/** - * Created by NguyenDangKhoa on 1/21/16. - */ -public class RegistrationPhase extends PhaseType { -} diff --git a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java index aad1cc2b8..7ac2c292b 100644 --- a/src/main/java/com/techlooper/service/ChallengeRegistrantService.java +++ b/src/main/java/com/techlooper/service/ChallengeRegistrantService.java @@ -27,7 +27,7 @@ public interface ChallengeRegistrantService { List findRegistrantsByChallengeId(Long challengeId); - List findRegistrantsByOwner(String ownerEmail); + List findRegistrantsByOwner(String ownerEmail); ChallengeRegistrantEntity findRegistrantById(Long registrantId); diff --git a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java index dd923ccae..5688e33cd 100644 --- a/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/ChallengeRegistrantServiceImpl.java @@ -8,7 +8,6 @@ import com.techlooper.entity.ChallengeRegistrantDto; import com.techlooper.entity.ChallengeRegistrantEntity; import com.techlooper.model.*; -import com.techlooper.model.challenge.PhaseType; import com.techlooper.repository.elasticsearch.ChallengeRegistrantRepository; import com.techlooper.repository.elasticsearch.ChallengeRepository; import com.techlooper.repository.elasticsearch.ChallengeSubmissionRepository; @@ -220,11 +219,10 @@ public List findRegistrantsByChallengeId(Long challen return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } - public List findRegistrantsByOwner(String ownerEmail) { + public List findRegistrantsByOwner(String ownerEmail) { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("challengeRegistrant"); searchQueryBuilder.withQuery(filteredQuery(matchAllQuery(), termFilter("registrantEmail", ownerEmail))); - return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder).stream().map( - registrantEntity -> registrantEntity.toDTO()).collect(toList()); + return DataUtils.getAllEntities(challengeRegistrantRepository, searchQueryBuilder); } @Override @@ -272,7 +270,7 @@ public List qualifyAllRegistrants(String ownerEmail, Cha for (Long registrantId : challengeQualificationDto.getRegistrantIds()) { ChallengeRegistrantDto registrantDto = acceptRegistrant(registrantId, qualifyingPhase); - if (registrantDto.getActivePhase().getPhaseName() == qualifyingPhase) { + if (registrantDto.getActivePhase() == qualifyingPhase) { qualifiedRegistrants.add(registrantDto); } } @@ -390,9 +388,9 @@ public Long getTotalNumberOfRegistrants() { public List getChallengeDashBoardInfo(String registrantEmail) { List challengeDashBoardInfoList = new ArrayList<>(); - List registrantEntities = findRegistrantsByOwner(registrantEmail); + List registrantEntities = findRegistrantsByOwner(registrantEmail); - for (ChallengeRegistrantDto registrantEntity : registrantEntities) { + for (ChallengeRegistrantEntity registrantEntity : registrantEntities) { Long challengeId = registrantEntity.getChallengeId(); Long registrantId = registrantEntity.getRegistrantId(); ChallengeEntity challengeEntity = challengeService.findChallengeById(challengeId); @@ -402,9 +400,10 @@ public List getChallengeDashBoardInfo(String registrantE challengeDashBoardInfoBuilder.withChallengeId(challengeId); challengeDashBoardInfoBuilder.withChallengeName(challengeEntity.getChallengeName()); challengeDashBoardInfoBuilder.withSubmissionDate(challengeEntity.getSubmissionDateTime()); - PhaseType currentPhase = registrantEntity.getActivePhase(); + ChallengePhaseEnum currentPhase = registrantEntity.getActivePhase() != null ? + registrantEntity.getActivePhase() : REGISTRATION; challengeDashBoardInfoBuilder.withCurrentPhase(currentPhase); - challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(currentPhase.getSubmissionDate()); + challengeDashBoardInfoBuilder.withCurrentPhaseSubmissionDate(getCurrentPhaseSubmissionDate(challengeEntity, currentPhase)); challengeDashBoardInfoBuilder.withDisqualified(registrantEntity.getDisqualified()); Integer numberOfSubmissions = challengeSubmissionService.findChallengeSubmissionByRegistrant(registrantId).size(); @@ -434,8 +433,8 @@ public Set getChallengeWinners(Long challengeId) { return null; } - private Double getRegistrantSubmissionScore(ChallengeRegistrantDto registrantDto) { - Set criteria = registrantDto.getCriteria(); + private Double getRegistrantSubmissionScore(ChallengeRegistrantEntity registrantEntity) { + Set criteria = registrantEntity.getCriteria(); Double totalScore = 0D; if (criteria != null) { @@ -470,4 +469,21 @@ private ChallengeWinner getChallengeWinner(ChallengeEntity challengeEntity, Long } return null; } + + private String getCurrentPhaseSubmissionDate(ChallengeEntity challengeEntity, ChallengePhaseEnum currentPhase) { + switch (currentPhase) { + case REGISTRATION: + return challengeEntity.getRegistrationDateTime(); + case IDEA: + return challengeEntity.getIdeaSubmissionDateTime(); + case UIUX: + return challengeEntity.getUxSubmissionDateTime(); + case PROTOTYPE: + return challengeEntity.getPrototypeSubmissionDateTime(); + case FINAL: + return challengeEntity.getSubmissionDateTime(); + default: + return ""; + } + } } diff --git a/src/main/webapp/assets/modules/navigation/navigation.con.js b/src/main/webapp/assets/modules/navigation/navigation.con.js index 125a61390..04fe7dd68 100644 --- a/src/main/webapp/assets/modules/navigation/navigation.con.js +++ b/src/main/webapp/assets/modules/navigation/navigation.con.js @@ -1,31 +1,18 @@ techlooper.controller("navigationController", function ($scope, securityService, apiService, localStorageService, $location, jsonValue, utils, $timeout, $rootScope, $window) { $scope.state = function (type) { - var isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - var isJobSeeker = $rootScope.userInfo && $rootScope.userInfo.roleName === "JOB_SEEKER"; - //var userNotLogin = !$rootScope.userInfo; - var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; - var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header == "EMPLOYER"; - //var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.header != "EMPLOYER" && $rootScope.currentUiView.type != "LOGIN"; - //console.log(isJobSeekerView); + var isEmployer = undefined; + var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; switch (type) { case "show-employer-header": - if (currentViewIsLogin || isJobSeeker) return false; - if (isEmployer) return true; - //isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - //console.log("emm", isEmployerView); - return isEmployerView; - //return (!currentViewIsLogin && isEmployer) || isEmployerView; + var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; + isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + return (!currentViewIsLogin && isEmployer) || isEmployerView; case "show-job-seeker-header": - if (currentViewIsLogin || isEmployer) return false; - if (isJobSeeker) return true; - if (isEmployerView) return false; - //var employerHeaderNotShown = !$scope.state("show-employer-header"); - //var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; - //console.log("seek", isJobSeekerView); - return !currentViewIsLogin; - //return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; + var employerHeaderNotShown = !$scope.state("show-employer-header"); + var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.type != "LOGIN"; + return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; case "home-url": isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; @@ -50,7 +37,7 @@ techlooper.controller("navigationController", function ($scope, securityService, } } $scope.langKey = localStorage.NG_TRANSLATE_LANG_KEY; - $scope.changeLanguages = function (key) { + $scope.changeLanguages = function(key){ $scope.langKey = key; localStorage.NG_TRANSLATE_LANG_KEY = key; $window.location.reload(); From 73f9c1b49a5df5459102ba0f1af443a101dc8333 Mon Sep 17 00:00:00 2001 From: Phuong H Date: Fri, 22 Jan 2016 17:14:03 +0700 Subject: [PATCH 09/11] Fix last commit not correct --- .../modules/navigation/navigation.con.js | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/webapp/assets/modules/navigation/navigation.con.js b/src/main/webapp/assets/modules/navigation/navigation.con.js index 04fe7dd68..125a61390 100644 --- a/src/main/webapp/assets/modules/navigation/navigation.con.js +++ b/src/main/webapp/assets/modules/navigation/navigation.con.js @@ -1,18 +1,31 @@ techlooper.controller("navigationController", function ($scope, securityService, apiService, localStorageService, $location, jsonValue, utils, $timeout, $rootScope, $window) { $scope.state = function (type) { - var isEmployer = undefined; - var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; + var isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + var isJobSeeker = $rootScope.userInfo && $rootScope.userInfo.roleName === "JOB_SEEKER"; + //var userNotLogin = !$rootScope.userInfo; + var currentViewIsLogin = $rootScope.currentUiView && $rootScope.currentUiView.isLoginPage; + var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header == "EMPLOYER"; + //var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.header != "EMPLOYER" && $rootScope.currentUiView.type != "LOGIN"; + //console.log(isJobSeekerView); switch (type) { case "show-employer-header": - var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; - isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; - return (!currentViewIsLogin && isEmployer) || isEmployerView; + if (currentViewIsLogin || isJobSeeker) return false; + if (isEmployer) return true; + //isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; + //console.log("emm", isEmployerView); + return isEmployerView; + //return (!currentViewIsLogin && isEmployer) || isEmployerView; case "show-job-seeker-header": - var employerHeaderNotShown = !$scope.state("show-employer-header"); - var isJobSeekerView = $rootScope.currentUiView && $rootScope.currentUiView.type != "LOGIN"; - return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; + if (currentViewIsLogin || isEmployer) return false; + if (isJobSeeker) return true; + if (isEmployerView) return false; + //var employerHeaderNotShown = !$scope.state("show-employer-header"); + //var isEmployerView = $rootScope.currentUiView && $rootScope.currentUiView.header === "EMPLOYER"; + //console.log("seek", isJobSeekerView); + return !currentViewIsLogin; + //return !currentViewIsLogin && employerHeaderNotShown && isJobSeekerView; case "home-url": isEmployer = $rootScope.userInfo && $rootScope.userInfo.roleName === "EMPLOYER"; @@ -37,7 +50,7 @@ techlooper.controller("navigationController", function ($scope, securityService, } } $scope.langKey = localStorage.NG_TRANSLATE_LANG_KEY; - $scope.changeLanguages = function(key){ + $scope.changeLanguages = function (key) { $scope.langKey = key; localStorage.NG_TRANSLATE_LANG_KEY = key; $window.location.reload(); From ffb5c79daa0124dc7ffc625be081629aa52e101f Mon Sep 17 00:00:00 2001 From: johnsonpham Date: Fri, 22 Jan 2016 18:32:26 +0700 Subject: [PATCH 10/11] delete loading if have error from server --- .../assets/modules/common/challenge/submissionChallenge.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/webapp/assets/modules/common/challenge/submissionChallenge.js b/src/main/webapp/assets/modules/common/challenge/submissionChallenge.js index 5071707ee..99e507ad7 100644 --- a/src/main/webapp/assets/modules/common/challenge/submissionChallenge.js +++ b/src/main/webapp/assets/modules/common/challenge/submissionChallenge.js @@ -100,6 +100,7 @@ techlooper.directive("submissionChallenge", function (localStorageService, apiSe }) .error(function () { scope.submissionForm.submissionPassCode.$setValidity("credential", false); + delete scope.loadingData; }); } scope.submissionForm && scope.submissionForm.submissionURL.$setValidity("invalidUrl", !inValid); From ae178ff14a7208ee2381152492d59d3cdbe68bc5 Mon Sep 17 00:00:00 2001 From: johnsonpham Date: Fri, 22 Jan 2016 18:37:47 +0700 Subject: [PATCH 11/11] show name for employee --- .../webapp/assets/modules/navigation/employer-header.tem.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/assets/modules/navigation/employer-header.tem.html b/src/main/webapp/assets/modules/navigation/employer-header.tem.html index 9c7abf065..64a2ab068 100644 --- a/src/main/webapp/assets/modules/navigation/employer-header.tem.html +++ b/src/main/webapp/assets/modules/navigation/employer-header.tem.html @@ -14,7 +14,7 @@


       <div class= -

{{$root.userInfo.name}}

+

{{($root.userInfo.name | textTruncate: 'display-text') || ($root.userInfo.username | textTruncate: 'email')}}