Skip to content

Commit

Permalink
Merge pull request #507 from phuonghuynh/master
Browse files Browse the repository at this point in the history
Update changes
  • Loading branch information
phuonghuynh committed Feb 2, 2016
2 parents 3f69e75 + 0e992e0 commit a8fcebc
Show file tree
Hide file tree
Showing 32 changed files with 559 additions and 333 deletions.
156 changes: 74 additions & 82 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,20 @@
<hibernate-entitymanager.version>4.3.8.Final</hibernate-entitymanager.version>
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
<joda-time.version>2.8.1</joda-time.version>
<org.mapstruct.version>1.0.0.Final</org.mapstruct.version>
</properties>
<build>
<finalName>techlooper</finalName>
<resources>
<!--<resource>-->
<!--<directory>src/main/resources</directory>-->
<!--<filtering>true</filtering>-->
<!--<includes>-->
<!--<include>**/*.properties</include>-->
<!--</includes>-->
<!--<excludes>-->
<!--<exclude>**/*.ftl</exclude>-->
<!--</excludes>-->
<!--<directory>src/main/resources</directory>-->
<!--<filtering>true</filtering>-->
<!--<includes>-->
<!--<include>**/*.properties</include>-->
<!--</includes>-->
<!--<excludes>-->
<!--<exclude>**/*.ftl</exclude>-->
<!--</excludes>-->
<!--</resource>-->
<resource>
<directory>src/main/resources/common</directory>
Expand Down Expand Up @@ -240,6 +241,52 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<configuration>
<defaultOutputDirectory>
${project.build.directory}/generated-sources
</defaultOutputDirectory>
<processors>
<processor>org.mapstruct.ap.MappingProcessor</processor>
</processors>
<options>
<mapstruct.suppressGeneratorTimestamp>true</mapstruct.suppressGeneratorTimestamp>
<mapstruct.defaultComponentModel>spring</mapstruct.defaultComponentModel>
</options>
</configuration>
<executions>
<execution>
<id>process</id>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
</dependencies>
</plugin>
<!--<plugin>-->
<!--<groupId>org.projectlombok</groupId>-->
<!--<artifactId>lombok-maven-plugin</artifactId>-->
<!--<version>1.16.6.1</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>generate-sources</phase>-->
<!--<goals>-->
<!--<goal>delombok</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
</plugins>
</build>
<profiles>
Expand Down Expand Up @@ -493,62 +540,19 @@
<scope>provided</scope>
</dependency>

<!--<dependency>-->
<!--<groupId>com.itextpdf</groupId>-->
<!--<artifactId>itextpdf</artifactId>-->
<!--<version>5.5.8</version>-->
<!--</dependency>-->

<!--<dependency>-->
<!--<groupId>com.itextpdf.tool</groupId>-->
<!--<artifactId>xmlworker</artifactId>-->
<!--<version>5.5.8</version>-->
<!--</dependency>-->

<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.0.8</version>
</dependency>

<!--<dependency>-->
<!--<groupId>org.mozilla</groupId>-->
<!--<artifactId>rhino</artifactId>-->
<!--<version>1.7.7</version>-->
<!--</dependency>-->

<!--<dependency>-->
<!--<groupId>org.seleniumhq.selenium</groupId>-->
<!--<artifactId>selenium-java</artifactId>-->
<!--<version>2.48.2</version>-->
<!--</dependency>-->

<!--<dependency>-->
<!--<groupId>xerces</groupId>-->
<!--<artifactId>xercesImpl</artifactId>-->
<!--<version>2.11.0</version>-->
<!--</dependency>-->










<!-- Log Framework -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.9</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.slf4j</groupId>-->
<!--<artifactId>jul-to-slf4j</artifactId>-->
<!--<version>1.7.9</version>-->
<!--</dependency>-->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand Down Expand Up @@ -637,26 +641,6 @@
<artifactId>spring-security-messaging</artifactId>
<version>${spring.security.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.session</groupId>-->
<!--<artifactId>spring-session</artifactId>-->
<!--<version>${spring-session.version}</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.springframework.data</groupId>-->
<!--<artifactId>spring-data-redis</artifactId>-->
<!--<version>${spring-data-redis.version}</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>redis.clients</groupId>-->
<!--<artifactId>jedis</artifactId>-->
<!--<version>${jedis.version}</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>redis.embedded</groupId>-->
<!--<artifactId>embedded-redis</artifactId>-->
<!--<version>${embedded-redis.version}</version>-->
<!--</dependency>-->

<dependency>
<groupId>org.elasticsearch</groupId>
Expand All @@ -670,12 +654,6 @@
<version>${spring-social.version}</version>
</dependency>

<!--<dependency>-->
<!--<groupId>org.springframework.social</groupId>-->
<!--<artifactId>spring-social-security</artifactId>-->
<!--<version>${spring-social.version}</version>-->
<!--</dependency>-->

<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>
Expand Down Expand Up @@ -916,11 +894,6 @@
<artifactId>google-api-services-calendar</artifactId>
<version>v3-rev135-1.20.0</version>
</dependency>
<!--<dependency>-->
<!--<groupId>com.google.oauth-client</groupId>-->
<!--<artifactId>google-oauth-client-jetty</artifactId>-->
<!--<version>1.20.0</version>-->
<!--</dependency>-->

<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand All @@ -939,6 +912,25 @@
<artifactId>commons-csv</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.6</version>
<scope>provided</scope>
</dependency>

<!--<dependency>-->
<!--<groupId>org.mapstruct</groupId>-->
<!--<artifactId>mapstruct</artifactId>-->
<!--<version>${org.mapstruct.version}</version>-->
<!--</dependency>-->
<!-- Use this with Java 8 and beyond -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
</dependencies>

<repositories>
Expand Down
27 changes: 19 additions & 8 deletions src/main/java/com/techlooper/controller/ChallengeController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.techlooper.controller;

import com.techlooper.dto.ChallengeWinnerDto;
import com.techlooper.dto.JoiningRegistrantDto;
import com.techlooper.entity.ChallengeEntity;
import com.techlooper.entity.ChallengeRegistrantDto;
import com.techlooper.entity.ChallengeRegistrantEntity;
Expand Down Expand Up @@ -103,16 +104,21 @@ public ChallengeDetailDto getChallengeDetail(@PathVariable Long challengeId, Htt
}

@RequestMapping(value = "/challenge/join", method = RequestMethod.POST)
public long joinChallenge(@RequestBody ChallengeRegistrantDto challengeRegistrantDto, HttpServletResponse response) throws Exception {
if (!EmailValidator.validate(challengeRegistrantDto.getRegistrantEmail())) {
public JoiningRegistrantDto joinChallenge(@RequestBody ChallengeRegistrantDto challengeRegistrantDto, HttpServletResponse response) throws Exception {
// if (!EmailValidator.validate(challengeRegistrantDto.getRegistrantEmail())) {
// response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
// return 0L;
// }
// Long countRegistrants = challengeService.joinChallenge(challengeRegistrantDto);
// if (countRegistrants == 0L) {
// response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
// }
// return countRegistrants;
JoiningRegistrantDto joiningDto = challengeService.joinChallenge(challengeRegistrantDto);
if (!joiningDto.isSucceedJoin()) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return 0L;
}
Long countRegistrants = challengeService.joinChallenge(challengeRegistrantDto);
if (countRegistrants == 0L) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
return countRegistrants;
return joiningDto;
}

@RequestMapping(value = "/challenge/list", method = RequestMethod.GET)
Expand Down Expand Up @@ -222,4 +228,9 @@ public DraftRegistrantEntity saveDraftRegistrant(@RequestBody DraftRegistrantEnt
public DraftRegistrantEntity getDraftRegistrant(@PathVariable Long id) {
return draftRegistrantRepository.findOne(id);
}

@RequestMapping(value = "challenge/joined/{challengeId}/{email}", method = RequestMethod.GET)
public boolean joinedChallenge(@PathVariable Long challengeId, @PathVariable String email) {
return challengeRegistrantService.findRegistrantByChallengeIdAndEmail(challengeId, email, null) != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ChallengeSubmissionEntity submitMyResult(@RequestBody ChallengeSubmission
@RequestMapping(value = "user/challengeSubmissionPhase/{registrantEmail}/{challengeId}", method = RequestMethod.GET)
public ChallengePhaseEnum challengeSubmissionPhase(@PathVariable String registrantEmail, @PathVariable Long challengeId) {
ChallengeRegistrantEntity registrantEntity =
challengeRegistrantService.findRegistrantByChallengeIdAndEmail(challengeId, registrantEmail);
challengeRegistrantService.findRegistrantByChallengeIdAndEmail(challengeId, registrantEmail, null);
return (registrantEntity != null && registrantEntity.getActivePhase() != null) ?
registrantEntity.getActivePhase() : ChallengePhaseEnum.REGISTRATION;
}
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/techlooper/dto/JoiningRegistrantDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.techlooper.dto;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

/**
* Created by phuonghqh on 1/29/16.
*/
@Getter
@Setter
@Builder
public class JoiningRegistrantDto {
public enum Reason {UNMATCH_PASSCODE, INVALID_FBEMAIL, INVALID_INTERNAL_EMAIL, SINGLE_ACCOUNT}

private Long countRegistrants;
private boolean succeedJoin = false;
private Reason reason;
}
11 changes: 11 additions & 0 deletions src/main/java/com/techlooper/entity/ChallengeRegistrantEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class ChallengeRegistrantEntity {
@Field(type = String, index = FieldIndex.not_analyzed)
private String registrantEmail;

@Field(type = String, index = FieldIndex.not_analyzed)
private String registrantInternalEmail;

@Field(type = Long)
private Long challengeId;

Expand Down Expand Up @@ -65,6 +68,14 @@ public class ChallengeRegistrantEntity {
@Field(type = FieldType.Integer)
private Integer passCode;

public java.lang.String getRegistrantInternalEmail() {
return registrantInternalEmail;
}

public void setRegistrantInternalEmail(java.lang.String registrantInternalEmail) {
this.registrantInternalEmail = registrantInternalEmail;
}

public Set<ChallengeRegistrantCriteria> getCriteria() {
if (criteria == null) criteria = new HashSet<>();
return criteria;
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/techlooper/mapper/ChallengeRegistrantMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.techlooper.mapper;

import com.techlooper.entity.ChallengeEntity;
import com.techlooper.entity.ChallengeRegistrantDto;
import com.techlooper.entity.ChallengeRegistrantEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Repository;

/**
* Created by phuonghqh on 2/1/16.
*/
@Mapper
@Repository
public interface ChallengeRegistrantMapper {
ChallengeRegistrantEntity fromDto(ChallengeRegistrantDto dto);
}
18 changes: 18 additions & 0 deletions src/main/java/com/techlooper/mapper/CriteriaMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.techlooper.mapper;

import com.techlooper.entity.ChallengeCriteria;
import com.techlooper.entity.ChallengeRegistrantCriteria;
import org.mapstruct.Mapper;
import org.springframework.stereotype.Repository;

import java.util.Set;

/**
* Created by phuonghqh on 2/1/16.
*/
@Mapper
@Repository
public interface CriteriaMapper {
ChallengeRegistrantCriteria fromChallenge(ChallengeCriteria criteria);
Set<ChallengeRegistrantCriteria> fromChallenge(Set<ChallengeCriteria> criteria);
}
32 changes: 32 additions & 0 deletions src/main/java/com/techlooper/model/JobSeekerChallengeStats.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.techlooper.model;

/**
* Created by NguyenDangKhoa on 1/29/16.
*/
public class JobSeekerChallengeStats {

private JobSeekerPhaseEnum phase;

private Integer count;

public JobSeekerChallengeStats(JobSeekerPhaseEnum phase, Integer count) {
this.phase = phase;
this.count = count;
}

public JobSeekerPhaseEnum getPhase() {
return phase;
}

public void setPhase(JobSeekerPhaseEnum phase) {
this.phase = phase;
}

public Integer getCount() {
return count;
}

public void setCount(Integer count) {
this.count = count;
}
}
Loading

0 comments on commit a8fcebc

Please sign in to comment.