adding checkstyle
This commit is contained in:
parent
3f10d6224a
commit
0f3c01b1c1
106
pom.xml
106
pom.xml
@ -21,6 +21,15 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>central</id>
|
||||||
|
<name>Maven Central</name>
|
||||||
|
<layout>default</layout>
|
||||||
|
<url>https://repo1.maven.org/maven2</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>Vaadin Directory</id>
|
<id>Vaadin Directory</id>
|
||||||
<url>https://maven.vaadin.com/vaadin-addons</url>
|
<url>https://maven.vaadin.com/vaadin-addons</url>
|
||||||
@ -45,8 +54,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.vaadin</groupId>
|
<groupId>com.vaadin</groupId>
|
||||||
<!-- Replace artifactId with vaadin-core to use only free components -->
|
<artifactId>vaadin-core</artifactId>
|
||||||
<artifactId>vaadin</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.vaadin</groupId>
|
<groupId>com.vaadin</groupId>
|
||||||
@ -98,11 +106,32 @@
|
|||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.validator</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
<version>8.0.1.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.search</groupId>
|
||||||
|
<artifactId>hibernate-search-mapper-orm</artifactId>
|
||||||
|
<version>7.1.1.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.search</groupId>
|
||||||
|
<artifactId>hibernate-search-backend-lucene</artifactId>
|
||||||
|
<version>7.1.1.Final</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.vaadin</groupId>
|
<groupId>com.vaadin</groupId>
|
||||||
<artifactId>vaadin-testbench-junit5</artifactId>
|
<artifactId>vaadin-testbench-junit5</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>3.25.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.openhft</groupId>
|
<groupId>net.openhft</groupId>
|
||||||
<artifactId>compiler</artifactId>
|
<artifactId>compiler</artifactId>
|
||||||
@ -137,11 +166,62 @@
|
|||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct</artifactId>
|
||||||
|
<version>1.5.5.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>1.5.5.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.lucene</groupId>
|
||||||
|
<artifactId>lucene-core</artifactId>
|
||||||
|
<version>9.10.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.lucene</groupId>
|
||||||
|
<artifactId>lucene-queryparser</artifactId>
|
||||||
|
<version>9.10.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>33.1.0-jre</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.14.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>spring-boot:run</defaultGoal>
|
<defaultGoal>spring-boot:run</defaultGoal>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>src/main/resources/checkstyle.xml</configLocation>
|
||||||
|
<consoleOutput>true</consoleOutput>
|
||||||
|
<failsOnError>true</failsOnError>
|
||||||
|
<sourceDirectories>
|
||||||
|
<directory>${project.build.sourceDirectory}</directory>
|
||||||
|
</sourceDirectories>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>compile</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
@ -162,6 +242,28 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>src/main/resources/checkstyle.xml</configLocation>
|
||||||
|
<failOnViolation>true</failOnViolation>
|
||||||
|
<enableFilesSummary>true</enableFilesSummary>
|
||||||
|
</configuration>
|
||||||
|
<reportSets>
|
||||||
|
<reportSet>
|
||||||
|
<reports>
|
||||||
|
<report>checkstyle-aggregate</report>
|
||||||
|
</reports>
|
||||||
|
</reportSet>
|
||||||
|
</reportSets>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<!-- Production mode is activated using -Pproduction -->
|
<!-- Production mode is activated using -Pproduction -->
|
||||||
|
@ -16,7 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
@Theme(value = "pfs-intra")
|
@Theme(value = "pfs-intra")
|
||||||
public class Application implements AppShellConfigurator {
|
public class Application implements AppShellConfigurator {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(final String[] args) {
|
||||||
SpringApplication.run(Application.class, args);
|
SpringApplication.run(Application.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
|||||||
public class SecurityConfig extends VaadinWebSecurity {
|
public class SecurityConfig extends VaadinWebSecurity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(final HttpSecurity http) throws Exception {
|
||||||
http.authorizeHttpRequests(auth ->
|
http.authorizeHttpRequests(auth ->
|
||||||
auth
|
auth
|
||||||
.requestMatchers(AntPathRequestMatcher.antMatcher("/h2-console/**")).permitAll()
|
.requestMatchers(AntPathRequestMatcher.antMatcher("/h2-console/**")).permitAll()
|
||||||
@ -38,7 +38,8 @@ public class SecurityConfig extends VaadinWebSecurity {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public AuthenticationManager authenticationManager() {
|
public AuthenticationManager authenticationManager() {
|
||||||
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource("ldap://ldap.primefactorsolutions.com:389/dc=primefactorsolutions,dc=com");
|
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
|
||||||
|
"ldap://ldap.primefactorsolutions.com:389/dc=primefactorsolutions,dc=com");
|
||||||
contextSource.setCacheEnvironmentProperties(false);
|
contextSource.setCacheEnvironmentProperties(false);
|
||||||
LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource);
|
LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource);
|
||||||
factory.setUserDnPatterns("uid={0},ou=users");
|
factory.setUserDnPatterns("uid={0},ou=users");
|
||||||
|
@ -35,7 +35,8 @@ public class Assessment extends BaseEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long getRemainingTimeSeconds() {
|
public Long getRemainingTimeSeconds() {
|
||||||
final Optional<Instant> started = assessmentEvents.stream().filter(e -> e.getStatus() == AssessmentStatus.STARTED)
|
final Optional<Instant> started = assessmentEvents.stream()
|
||||||
|
.filter(e -> e.getStatus() == AssessmentStatus.STARTED)
|
||||||
.map(AssessmentEvent::getTimestamp)
|
.map(AssessmentEvent::getTimestamp)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
@ -50,7 +51,8 @@ public class Assessment extends BaseEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Instant getStartingTime() {
|
public Instant getStartingTime() {
|
||||||
final Optional<Instant> started = assessmentEvents.stream().filter(e -> e.getStatus() == AssessmentStatus.STARTED)
|
final Optional<Instant> started = assessmentEvents.stream()
|
||||||
|
.filter(e -> e.getStatus() == AssessmentStatus.STARTED)
|
||||||
.map(AssessmentEvent::getTimestamp)
|
.map(AssessmentEvent::getTimestamp)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
@ -71,11 +73,11 @@ public class Assessment extends BaseEntity {
|
|||||||
.isPresent();
|
.isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFirst(Submission currSubmission) {
|
public boolean isFirst(final Submission currSubmission) {
|
||||||
return getQuestions().indexOf(currSubmission.getQuestion()) == 0;
|
return getQuestions().indexOf(currSubmission.getQuestion()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLast(Submission currSubmission) {
|
public boolean isLast(final Submission currSubmission) {
|
||||||
return getQuestions().indexOf(currSubmission.getQuestion()) == getQuestions().size() - 1;
|
return getQuestions().indexOf(currSubmission.getQuestion()) == getQuestions().size() - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class Question extends BaseEntity{
|
public class Question extends BaseEntity {
|
||||||
@Column(unique = true)
|
@Column(unique = true)
|
||||||
private String title;
|
private String title;
|
||||||
@Lob
|
@Lob
|
||||||
|
@ -34,14 +34,17 @@ public class AssessmentService {
|
|||||||
|
|
||||||
public void sendEmail(final Assessment assessment) {
|
public void sendEmail(final Assessment assessment) {
|
||||||
try {
|
try {
|
||||||
final String evaluationLink = String.format("https://careers.primefactorsolutions.com/evaluation/%s", assessment.getId());
|
final String evaluationLink = String.format("https://careers.primefactorsolutions.com/evaluation/%s",
|
||||||
|
assessment.getId());
|
||||||
final SimpleMailMessage message = new SimpleMailMessage();
|
final SimpleMailMessage message = new SimpleMailMessage();
|
||||||
message.setFrom("no-reply@primefactorsolutions.com");
|
message.setFrom("no-reply@primefactorsolutions.com");
|
||||||
message.setBcc("no-reply@primefactorsolutions.com");
|
message.setBcc("no-reply@primefactorsolutions.com");
|
||||||
message.setTo(assessment.getCandidate().getEmail());
|
message.setTo(assessment.getCandidate().getEmail());
|
||||||
message.setSubject("PFS - Evaluacion Tecnica");
|
message.setSubject("PFS - Evaluacion Tecnica");
|
||||||
message.setText(String.format("Estimado candidato,\n\nGracias por su candidatura. En esta etapa del proceso de seleccion, usted debe completar "
|
message.setText(String.format("Estimado candidato,\n\nGracias por su candidatura. En esta etapa del "
|
||||||
+ "una evaluacion tecnica de programacion en JAVA. La prueba tiene una duracion de 30 minutos y puede completarla cuando tenga una buena "
|
+ "proceso de seleccion, usted debe completar "
|
||||||
|
+ "una evaluacion tecnica de programacion en JAVA. La prueba tiene una duracion de 30 minutos y "
|
||||||
|
+ "puede completarla cuando tenga una buena "
|
||||||
+ "conexion de internet.\n\n"
|
+ "conexion de internet.\n\n"
|
||||||
+ "Haga click aca: " + evaluationLink + "\n\n"
|
+ "Haga click aca: " + evaluationLink + "\n\n"
|
||||||
+ "Exito!"));
|
+ "Exito!"));
|
||||||
@ -77,7 +80,8 @@ public class AssessmentService {
|
|||||||
return getNextSubmission(assessmentId, currSubmissionId, true);
|
return getNextSubmission(assessmentId, currSubmissionId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Submission getNextSubmission(final UUID assessmentId, final UUID currSubmissionId, boolean checkCompleted) {
|
public Submission getNextSubmission(final UUID assessmentId, final UUID currSubmissionId,
|
||||||
|
final boolean checkCompleted) {
|
||||||
final Assessment assessment = assessmentRepository.findById(assessmentId).get();
|
final Assessment assessment = assessmentRepository.findById(assessmentId).get();
|
||||||
|
|
||||||
Assessment saved;
|
Assessment saved;
|
||||||
@ -92,7 +96,8 @@ public class AssessmentService {
|
|||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
if (submissionToReturn.isEmpty()) {
|
if (submissionToReturn.isEmpty()) {
|
||||||
final Submission result = new Submission(firstQuestion, firstQuestion.getContent(), Map.of(), SubmissionStatus.FAIL, assessment);
|
final Submission result = new Submission(firstQuestion, firstQuestion.getContent(), Map.of(),
|
||||||
|
SubmissionStatus.FAIL, assessment);
|
||||||
assessment.getSubmissions().add(result);
|
assessment.getSubmissions().add(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +126,8 @@ public class AssessmentService {
|
|||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
if (submissionToReturn.isEmpty()) {
|
if (submissionToReturn.isEmpty()) {
|
||||||
final Submission result = new Submission(nextQuestion, nextQuestion.getContent(), Map.of(), SubmissionStatus.FAIL, assessment);
|
final Submission result = new Submission(nextQuestion, nextQuestion.getContent(), Map.of(),
|
||||||
|
SubmissionStatus.FAIL, assessment);
|
||||||
assessment.getSubmissions().add(result);
|
assessment.getSubmissions().add(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,13 +169,14 @@ public class AssessmentService {
|
|||||||
return assessment;
|
return assessment;
|
||||||
}
|
}
|
||||||
|
|
||||||
assessment.getAssessmentEvents().add(new AssessmentEvent(Instant.now(), AssessmentStatus.COMPLETED, assessment));
|
assessment.getAssessmentEvents().add(new AssessmentEvent(Instant.now(), AssessmentStatus.COMPLETED,
|
||||||
|
assessment));
|
||||||
Assessment saved = assessmentRepository.save(assessment);
|
Assessment saved = assessmentRepository.save(assessment);
|
||||||
|
|
||||||
return saved;
|
return saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveSubmission(UUID id, Submission currSubmission) {
|
public void saveSubmission(final UUID id, final Submission currSubmission) {
|
||||||
Assessment assessment = assessmentRepository.findById(id).get();
|
Assessment assessment = assessmentRepository.findById(id).get();
|
||||||
final Submission submission = assessment.getSubmissions().stream()
|
final Submission submission = assessment.getSubmissions().stream()
|
||||||
.filter(s -> s.getId().equals(currSubmission.getId()))
|
.filter(s -> s.getId().equals(currSubmission.getId()))
|
||||||
|
@ -28,9 +28,11 @@ public class CompilerService {
|
|||||||
final String qualifiedClassName = "com.primefactorsolutions.TestClass";
|
final String qualifiedClassName = "com.primefactorsolutions.TestClass";
|
||||||
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
final DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
|
final DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
|
||||||
final InMemoryFileManager manager = new InMemoryFileManager(compiler.getStandardFileManager(null, null, null));
|
final InMemoryFileManager manager = new InMemoryFileManager(
|
||||||
|
compiler.getStandardFileManager(null, null, null));
|
||||||
|
|
||||||
final List<JavaFileObject> sourceFiles = Collections.singletonList(new JavaSourceFromString(qualifiedClassName, javaCode));
|
final List<JavaFileObject> sourceFiles = Collections.singletonList(new JavaSourceFromString(qualifiedClassName,
|
||||||
|
javaCode));
|
||||||
final JavaCompiler.CompilationTask task = compiler.getTask(null, manager, diagnostics,
|
final JavaCompiler.CompilationTask task = compiler.getTask(null, manager, diagnostics,
|
||||||
List.of("-proc:full", "-Xlint:-options"), null, sourceFiles);
|
List.of("-proc:full", "-Xlint:-options"), null, sourceFiles);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import java.util.UUID;
|
|||||||
public class QuestionService {
|
public class QuestionService {
|
||||||
private final QuestionRepository questionRepository;
|
private final QuestionRepository questionRepository;
|
||||||
|
|
||||||
public Question getQuestion(UUID id) {
|
public Question getQuestion(final UUID id) {
|
||||||
return questionRepository.findById(id).get();
|
return questionRepository.findById(id).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ public class QuestionService {
|
|||||||
return questionRepository.findAll();
|
return questionRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Question createOrUpdate(Question question) {
|
public Question createOrUpdate(final Question question) {
|
||||||
return questionRepository.save(question);
|
return questionRepository.save(question);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,13 @@ public class InMemoryClassLoader extends ClassLoader {
|
|||||||
|
|
||||||
private final InMemoryFileManager manager;
|
private final InMemoryFileManager manager;
|
||||||
|
|
||||||
public InMemoryClassLoader(ClassLoader parent, InMemoryFileManager manager) {
|
public InMemoryClassLoader(final ClassLoader parent, final InMemoryFileManager manager) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.manager = requireNonNull(manager, "manager must not be null");
|
this.manager = requireNonNull(manager, "manager must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
protected Class<?> findClass(final String name) throws ClassNotFoundException {
|
||||||
|
|
||||||
Map<String, JavaClassAsBytes> compiledClasses = manager
|
Map<String, JavaClassAsBytes> compiledClasses = manager
|
||||||
.getBytesMap();
|
.getBytesMap();
|
||||||
|
@ -14,7 +14,7 @@ public class InMemoryFileManager extends ForwardingJavaFileManager<JavaFileManag
|
|||||||
private final Map<String, JavaClassAsBytes> compiledClasses;
|
private final Map<String, JavaClassAsBytes> compiledClasses;
|
||||||
private final ClassLoader loader;
|
private final ClassLoader loader;
|
||||||
|
|
||||||
public InMemoryFileManager(StandardJavaFileManager standardManager) {
|
public InMemoryFileManager(final StandardJavaFileManager standardManager) {
|
||||||
super(standardManager);
|
super(standardManager);
|
||||||
this.compiledClasses = new Hashtable<>();
|
this.compiledClasses = new Hashtable<>();
|
||||||
this.loader = new InMemoryClassLoader(this.getClass()
|
this.loader = new InMemoryClassLoader(this.getClass()
|
||||||
@ -31,13 +31,13 @@ public class InMemoryFileManager extends ForwardingJavaFileManager<JavaFileManag
|
|||||||
* @param location where to place or search for file objects.
|
* @param location where to place or search for file objects.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ClassLoader getClassLoader(Location location) {
|
public ClassLoader getClassLoader(final Location location) {
|
||||||
return loader;
|
return loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind,
|
public JavaFileObject getJavaFileForOutput(final Location location, final String className, final Kind kind,
|
||||||
FileObject sibling) {
|
final FileObject sibling) {
|
||||||
|
|
||||||
JavaClassAsBytes classAsBytes = new JavaClassAsBytes(
|
JavaClassAsBytes classAsBytes = new JavaClassAsBytes(
|
||||||
className, kind);
|
className, kind);
|
||||||
|
@ -7,10 +7,10 @@ import java.net.URI;
|
|||||||
|
|
||||||
public class JavaClassAsBytes extends SimpleJavaFileObject {
|
public class JavaClassAsBytes extends SimpleJavaFileObject {
|
||||||
|
|
||||||
protected ByteArrayOutputStream bos =
|
private final ByteArrayOutputStream bos =
|
||||||
new ByteArrayOutputStream();
|
new ByteArrayOutputStream();
|
||||||
|
|
||||||
public JavaClassAsBytes(String name, Kind kind) {
|
public JavaClassAsBytes(final String name, final Kind kind) {
|
||||||
super(URI.create("string:///" + name.replace('.', '/')
|
super(URI.create("string:///" + name.replace('.', '/')
|
||||||
+ kind.extension), kind);
|
+ kind.extension), kind);
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,14 @@ public class JavaSourceFromString extends SimpleJavaFileObject {
|
|||||||
|
|
||||||
private String sourceCode;
|
private String sourceCode;
|
||||||
|
|
||||||
public JavaSourceFromString(String name, String sourceCode) {
|
public JavaSourceFromString(final String name, final String sourceCode) {
|
||||||
super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension),
|
super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension),
|
||||||
Kind.SOURCE);
|
Kind.SOURCE);
|
||||||
this.sourceCode = requireNonNull(sourceCode, "sourceCode must not be null");
|
this.sourceCode = requireNonNull(sourceCode, "sourceCode must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
|
public CharSequence getCharContent(final boolean ignoreEncodingErrors) {
|
||||||
return sourceCode;
|
return sourceCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@ public class AssessmentView extends BeanValidationForm<Assessment> implements Ha
|
|||||||
private ComboBox<Candidate> candidate = null;
|
private ComboBox<Candidate> candidate = null;
|
||||||
private SubListSelector<Question> questions = null;
|
private SubListSelector<Question> questions = null;
|
||||||
|
|
||||||
public AssessmentView(AssessmentService assessmentService, QuestionService questionService, CandidateService candidateService) {
|
public AssessmentView(final AssessmentService assessmentService, final QuestionService questionService,
|
||||||
|
final CandidateService candidateService) {
|
||||||
super(Assessment.class);
|
super(Assessment.class);
|
||||||
|
|
||||||
this.assessmentService = assessmentService;
|
this.assessmentService = assessmentService;
|
||||||
|
@ -64,10 +64,12 @@ public class AssessmentsListView extends Main {
|
|||||||
assessment.getCandidate().getEmail(),
|
assessment.getCandidate().getEmail(),
|
||||||
assessment.getId()))
|
assessment.getId()))
|
||||||
));
|
));
|
||||||
grid.addComponentColumn((ValueProvider<Assessment, Component>) assessment -> new Button("Send Email", event -> {
|
grid.addComponentColumn((ValueProvider<Assessment, Component>) assessment ->
|
||||||
|
new Button("Send Email", event -> {
|
||||||
ConfirmDialog dialog = new ConfirmDialog();
|
ConfirmDialog dialog = new ConfirmDialog();
|
||||||
dialog.setHeader("Send Link Email");
|
dialog.setHeader("Send Link Email");
|
||||||
dialog.setText(String.format("Enviar link por email al candidato %s?", assessment.getCandidate().getEmail()));
|
dialog.setText(String.format("Enviar link por email al candidato %s?",
|
||||||
|
assessment.getCandidate().getEmail()));
|
||||||
dialog.setCancelable(true);
|
dialog.setCancelable(true);
|
||||||
dialog.setConfirmText("Enviar");
|
dialog.setConfirmText("Enviar");
|
||||||
dialog.setConfirmButtonTheme("primary");
|
dialog.setConfirmButtonTheme("primary");
|
||||||
@ -75,7 +77,8 @@ public class AssessmentsListView extends Main {
|
|||||||
try {
|
try {
|
||||||
assessmentService.sendEmail(assessment);
|
assessmentService.sendEmail(assessment);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Notification.show("Error sending email: " + e.getMessage(), 10_000, Notification.Position.TOP_CENTER);
|
Notification.show("Error sending email: " + e.getMessage(), 10_000,
|
||||||
|
Notification.Position.TOP_CENTER);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialog.open();
|
dialog.open();
|
||||||
@ -88,12 +91,12 @@ public class AssessmentsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size(Query<Assessment, Object> query) {
|
public int size(final Query<Assessment, Object> query) {
|
||||||
return assessmentService.getAssessments().size();
|
return assessmentService.getAssessments().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<Assessment> fetch(Query<Assessment, Object> query) {
|
public Stream<Assessment> fetch(final Query<Assessment, Object> query) {
|
||||||
int limit = query.getLimit();
|
int limit = query.getLimit();
|
||||||
int pagerSize = query.getPageSize();
|
int pagerSize = query.getPageSize();
|
||||||
int page = query.getPage();
|
int page = query.getPage();
|
||||||
@ -102,8 +105,8 @@ public class AssessmentsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshItem(Assessment assessment) {
|
public void refreshItem(final Assessment assessment) {
|
||||||
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,7 +115,7 @@ public class AssessmentsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Registration addDataProviderListener(DataProviderListener<Assessment> dataProviderListener) {
|
public Registration addDataProviderListener(final DataProviderListener<Assessment> dataProviderListener) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,7 @@ import java.util.stream.Stream;
|
|||||||
@Route(value = "/candidates", layout = MainLayout.class)
|
@Route(value = "/candidates", layout = MainLayout.class)
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public class CandidatesListView extends Main {
|
public class CandidatesListView extends Main {
|
||||||
final CandidateService candidateService;
|
private final CandidateService candidateService;
|
||||||
|
|
||||||
public CandidatesListView(final CandidateService candidateService) {
|
public CandidatesListView(final CandidateService candidateService) {
|
||||||
this.candidateService = candidateService;
|
this.candidateService = candidateService;
|
||||||
@ -57,12 +57,12 @@ public class CandidatesListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size(Query<Candidate, Object> query) {
|
public int size(final Query<Candidate, Object> query) {
|
||||||
return candidateService.getCandidates().size();
|
return candidateService.getCandidates().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<Candidate> fetch(Query<Candidate, Object> query) {
|
public Stream<Candidate> fetch(final Query<Candidate, Object> query) {
|
||||||
int limit = query.getLimit();
|
int limit = query.getLimit();
|
||||||
int pagerSize = query.getPageSize();
|
int pagerSize = query.getPageSize();
|
||||||
int page = query.getPage();
|
int page = query.getPage();
|
||||||
@ -70,17 +70,17 @@ public class CandidatesListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshItem(Candidate candidate) {
|
public void refreshItem(final Candidate candidate) {
|
||||||
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshAll() {
|
public void refreshAll() {
|
||||||
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Registration addDataProviderListener(DataProviderListener<Candidate> dataProviderListener) {
|
public Registration addDataProviderListener(final DataProviderListener<Candidate> dataProviderListener) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -59,31 +59,27 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class EvaluationView extends Main implements HasUrlParameter<String> {
|
public class EvaluationView extends Main implements HasUrlParameter<String> {
|
||||||
|
|
||||||
final CompilerService compilerService;
|
private final CompilerService compilerService;
|
||||||
final AssessmentService assessmentService;
|
private final AssessmentService assessmentService;
|
||||||
|
|
||||||
AceEditor questionEditor = null;
|
private AceEditor questionEditor = null;
|
||||||
Dialog dialog = null;
|
private Dialog dialog = null;
|
||||||
Dialog completeDialog = null;
|
private Dialog completeDialog = null;
|
||||||
AceEditor result = null;
|
private AceEditor result = null;
|
||||||
|
private Assessment assessment = null;
|
||||||
|
private Submission currSubmission = null;
|
||||||
|
private Boolean isCompleted = false;
|
||||||
|
|
||||||
Assessment assessment = null;
|
private Button start = null;
|
||||||
Submission currSubmission = null;
|
private MenuItem prev = null;
|
||||||
Boolean isCompleted = false;
|
private MenuItem next = null;
|
||||||
|
private MenuItem reset = null;
|
||||||
Button start = null;
|
private Section sidebar = null;
|
||||||
MenuItem prev = null;
|
private SimpleTimer timer = null;
|
||||||
MenuItem next = null;
|
private DescriptionList dl = null;
|
||||||
MenuItem reset = null;
|
private Section editorSection = null;
|
||||||
Section sidebar = null;
|
private Section startSection = null;
|
||||||
SimpleTimer timer = null;
|
private Section completedSection = null;
|
||||||
|
|
||||||
DescriptionList dl = null;
|
|
||||||
|
|
||||||
Section editorSection = null;
|
|
||||||
Section startSection = null;
|
|
||||||
|
|
||||||
Section completedSection = null;
|
|
||||||
private H3 questionTitle = null;
|
private H3 questionTitle = null;
|
||||||
private Text questionDescription = null;
|
private Text questionDescription = null;
|
||||||
|
|
||||||
@ -147,7 +143,8 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
|||||||
completeDialog = new Dialog();
|
completeDialog = new Dialog();
|
||||||
completeDialog.setHeaderTitle("Terminar Evaluacion");
|
completeDialog.setHeaderTitle("Terminar Evaluacion");
|
||||||
|
|
||||||
final VerticalLayout dialogLayout = new VerticalLayout(new Text("Desea terminar la evaluacion? No podra editar las respuestas despues de terminar."));
|
final VerticalLayout dialogLayout = new VerticalLayout(
|
||||||
|
new Text("Desea terminar la evaluacion? No podra editar las respuestas despues de terminar."));
|
||||||
dialogLayout.setPadding(false);
|
dialogLayout.setPadding(false);
|
||||||
dialogLayout.setSpacing(false);
|
dialogLayout.setSpacing(false);
|
||||||
dialogLayout.setAlignItems(FlexComponent.Alignment.STRETCH);
|
dialogLayout.setAlignItems(FlexComponent.Alignment.STRETCH);
|
||||||
@ -197,19 +194,22 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
final MenuBar navMenuBar = new MenuBar();
|
final MenuBar navMenuBar = new MenuBar();
|
||||||
prev = navMenuBar.addItem("Anterior pregunta", (ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
prev = navMenuBar.addItem("Anterior pregunta",
|
||||||
|
(ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
||||||
log.info(">>> prev");
|
log.info(">>> prev");
|
||||||
this.currSubmission.setResponse(this.questionEditor.getValue());
|
this.currSubmission.setResponse(this.questionEditor.getValue());
|
||||||
this.assessmentService.saveSubmission(assessment.getId(), this.currSubmission);
|
this.assessmentService.saveSubmission(assessment.getId(), this.currSubmission);
|
||||||
this.currSubmission = this.assessmentService.getPrevSubmission(assessment.getId(), this.currSubmission);
|
this.currSubmission = this.assessmentService.getPrevSubmission(assessment.getId(), this.currSubmission);
|
||||||
updateUI();
|
updateUI();
|
||||||
});
|
});
|
||||||
next = navMenuBar.addItem("Siguiente pregunta", (ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
next = navMenuBar.addItem("Siguiente pregunta",
|
||||||
|
(ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
||||||
this.currSubmission.setResponse(this.questionEditor.getValue());
|
this.currSubmission.setResponse(this.questionEditor.getValue());
|
||||||
this.assessmentService.saveSubmission(assessment.getId(), this.currSubmission);
|
this.assessmentService.saveSubmission(assessment.getId(), this.currSubmission);
|
||||||
goToNext();
|
goToNext();
|
||||||
});
|
});
|
||||||
reset = navMenuBar.addItem("Reiniciar pregunta (deshacer todos los cambios)", (ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
reset = navMenuBar.addItem("Reiniciar pregunta (deshacer todos los cambios)",
|
||||||
|
(ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
||||||
this.currSubmission.setResponse(this.currSubmission.getQuestion().getContent());
|
this.currSubmission.setResponse(this.currSubmission.getQuestion().getContent());
|
||||||
this.questionEditor.setValue(this.currSubmission.getQuestion().getContent());
|
this.questionEditor.setValue(this.currSubmission.getQuestion().getContent());
|
||||||
});
|
});
|
||||||
@ -238,10 +238,12 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
|||||||
startSection.addClassNames(Display.FLEX, FlexDirection.COLUMN, Flex.GROW, Height.FULL);
|
startSection.addClassNames(Display.FLEX, FlexDirection.COLUMN, Flex.GROW, Height.FULL);
|
||||||
|
|
||||||
Div startHelp = new Div();
|
Div startHelp = new Div();
|
||||||
startHelp.add(new Text("Bienvenido(a) al examen de evaluacion de PFS. Ingrese su email y apriete el boton 'Empezar' para empezar la evaluacion. Tiene 30 minutos para completar."));
|
startHelp.add(new Text("Bienvenido(a) al examen de evaluacion de PFS. Ingrese su email y apriete el boton "
|
||||||
|
+ "'Empezar' para empezar la evaluacion. Tiene 30 minutos para completar."));
|
||||||
startHelp.add(new HtmlComponent("br"));
|
startHelp.add(new HtmlComponent("br"));
|
||||||
startHelp.add(new Text("La evaluacion consta de 2 (DOS) preguntas son de implementacion de codigo en JAVA. " +
|
startHelp.add(new Text("La evaluacion consta de 2 (DOS) preguntas son de implementacion de codigo en JAVA. "
|
||||||
"Una vez empezada la evaluacion puede usar el boton 'Ejecutar' para compilar el codigo JAVA. Tambien puede pasar un pregunta o volver a una pregunta anterior."));
|
+ "Una vez empezada la evaluacion puede usar el boton 'Ejecutar' para compilar el codigo JAVA. "
|
||||||
|
+ "Tambien puede pasar un pregunta o volver a una pregunta anterior."));
|
||||||
|
|
||||||
TextField tf = new TextField();
|
TextField tf = new TextField();
|
||||||
tf.setRequiredIndicatorVisible(true);
|
tf.setRequiredIndicatorVisible(true);
|
||||||
@ -261,7 +263,8 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
|||||||
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
|
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
|
||||||
notification.setPosition(Notification.Position.TOP_CENTER);
|
notification.setPosition(Notification.Position.TOP_CENTER);
|
||||||
|
|
||||||
Div text = new Div(new Text("Email invalido. Verifique que el email corresponde al email donde recibio el enlace a la evaluacion."));
|
Div text = new Div(new Text("Email invalido. Verifique que el email corresponde al email "
|
||||||
|
+ "donde recibio el enlace a la evaluacion."));
|
||||||
|
|
||||||
Button closeButton = new Button(new Icon("lumo", "cross"));
|
Button closeButton = new Button(new Icon("lumo", "cross"));
|
||||||
closeButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
|
closeButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
|
||||||
@ -310,13 +313,14 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
|||||||
return questionEditor;
|
return questionEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInlineBlock(MenuBar menuBar) {
|
private void setInlineBlock(final MenuBar menuBar) {
|
||||||
menuBar.getStyle().set("display", "inline-block");
|
menuBar.getStyle().set("display", "inline-block");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void goToNext() {
|
private void goToNext() {
|
||||||
log.info(">>> next");
|
log.info(">>> next");
|
||||||
Submission found = this.assessmentService.getNextSubmission(assessment.getId(), this.currSubmission.getId());
|
Submission found = this.assessmentService.getNextSubmission(assessment.getId(),
|
||||||
|
this.currSubmission.getId());
|
||||||
|
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
this.completeDialog.open();
|
this.completeDialog.open();
|
||||||
@ -391,7 +395,8 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
|||||||
dl.add(
|
dl.add(
|
||||||
createItem("Candidato:", assessment.getCandidate().getEmail()),
|
createItem("Candidato:", assessment.getCandidate().getEmail()),
|
||||||
createItem("Hora de inicio:", Optional.ofNullable(assessment.getStartingTime())
|
createItem("Hora de inicio:", Optional.ofNullable(assessment.getStartingTime())
|
||||||
.map(t -> ZonedDateTime.ofInstant(t, ZoneId.of("GMT-4")).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
.map(t -> ZonedDateTime.ofInstant(t,
|
||||||
|
ZoneId.of("GMT-4")).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
||||||
.orElse("N/A"))
|
.orElse("N/A"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -405,7 +410,7 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Div createItem(String label, String value) {
|
private Div createItem(final String label, final String value) {
|
||||||
return new Div(createTerm(label), createDescription(value));
|
return new Div(createTerm(label), createDescription(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,13 +418,13 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
|||||||
// return new Div(createTerm(label), createDescription(value, "badge"));
|
// return new Div(createTerm(label), createDescription(value, "badge"));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private Term createTerm(String label) {
|
private Term createTerm(final String label) {
|
||||||
Term term = new Term(label);
|
Term term = new Term(label);
|
||||||
term.addClassNames(FontWeight.MEDIUM, TextColor.SECONDARY);
|
term.addClassNames(FontWeight.MEDIUM, TextColor.SECONDARY);
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Description createDescription(String value, String... themeNames) {
|
private Description createDescription(final String value, final String... themeNames) {
|
||||||
Description desc = new Description(value);
|
Description desc = new Description(value);
|
||||||
desc.addClassName(Margin.Left.NONE);
|
desc.addClassName(Margin.Left.NONE);
|
||||||
|
|
||||||
@ -431,7 +436,7 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameter(BeforeEvent beforeEvent, String s) {
|
public void setParameter(final BeforeEvent beforeEvent, final String s) {
|
||||||
this.assessment = this.assessmentService.getAssessment(UUID.fromString(s));
|
this.assessment = this.assessmentService.getAssessment(UUID.fromString(s));
|
||||||
|
|
||||||
if (this.assessment == null) {
|
if (this.assessment == null) {
|
||||||
|
@ -23,7 +23,7 @@ public class MainLayout extends AppLayout {
|
|||||||
|
|
||||||
private H1 viewTitle;
|
private H1 viewTitle;
|
||||||
|
|
||||||
public MainLayout(AuthenticationContext authContext) {
|
public MainLayout(final AuthenticationContext authContext) {
|
||||||
this.authContext = authContext;
|
this.authContext = authContext;
|
||||||
setPrimarySection(Section.DRAWER);
|
setPrimarySection(Section.DRAWER);
|
||||||
addDrawerContent();
|
addDrawerContent();
|
||||||
@ -54,19 +54,30 @@ public class MainLayout extends AppLayout {
|
|||||||
SideNav nav = new SideNav();
|
SideNav nav = new SideNav();
|
||||||
|
|
||||||
authContext.getAuthenticatedUser(UserDetails.class).ifPresent(u -> {
|
authContext.getAuthenticatedUser(UserDetails.class).ifPresent(u -> {
|
||||||
SideNavItem recruiting = new SideNavItem("Recruiting", MainView.class, LineAwesomeIcon.BUSINESS_TIME_SOLID.create());
|
SideNavItem recruiting = new SideNavItem("Recruiting", MainView.class,
|
||||||
recruiting.addItem(new SideNavItem("Assessments", AssessmentsListView.class, LineAwesomeIcon.RIBBON_SOLID.create()));
|
LineAwesomeIcon.BUSINESS_TIME_SOLID.create());
|
||||||
recruiting.addItem(new SideNavItem("Candidates", CandidatesListView.class, LineAwesomeIcon.USER.create()));
|
recruiting.addItem(new SideNavItem("Assessments", AssessmentsListView.class,
|
||||||
recruiting.addItem(new SideNavItem("Questions", QuestionsListView.class, LineAwesomeIcon.QUESTION_SOLID.create()));
|
LineAwesomeIcon.RIBBON_SOLID.create()));
|
||||||
|
recruiting.addItem(new SideNavItem("Candidates", CandidatesListView.class,
|
||||||
|
LineAwesomeIcon.USER.create()));
|
||||||
|
recruiting.addItem(new SideNavItem("Questions", QuestionsListView.class,
|
||||||
|
LineAwesomeIcon.QUESTION_SOLID.create()));
|
||||||
|
|
||||||
SideNavItem admin = new SideNavItem("Admin", MainView.class, LineAwesomeIcon.SUITCASE_SOLID.create());
|
SideNavItem admin = new SideNavItem("Admin", MainView.class,
|
||||||
admin.addItem(new SideNavItem("Time-off requests", AssessmentsListView.class, LineAwesomeIcon.THEMEISLE.create()));
|
LineAwesomeIcon.SUITCASE_SOLID.create());
|
||||||
admin.addItem(new SideNavItem("Timesheets", CandidatesListView.class, LineAwesomeIcon.HOURGLASS_END_SOLID.create()));
|
admin.addItem(new SideNavItem("Time-off requests", AssessmentsListView.class,
|
||||||
admin.addItem(new SideNavItem("Employees", QuestionsListView.class, LineAwesomeIcon.USER_EDIT_SOLID.create()));
|
LineAwesomeIcon.THEMEISLE.create()));
|
||||||
|
admin.addItem(new SideNavItem("Timesheets", CandidatesListView.class,
|
||||||
|
LineAwesomeIcon.HOURGLASS_END_SOLID.create()));
|
||||||
|
admin.addItem(new SideNavItem("Employees", QuestionsListView.class,
|
||||||
|
LineAwesomeIcon.USER_EDIT_SOLID.create()));
|
||||||
|
|
||||||
SideNavItem timeOff = new SideNavItem("My Time-off", MainView.class, LineAwesomeIcon.THEMEISLE.create());
|
SideNavItem timeOff = new SideNavItem("My Time-off", MainView.class,
|
||||||
SideNavItem timesheet = new SideNavItem("My Timesheet", MainView.class, LineAwesomeIcon.HOURGLASS_START_SOLID.create());
|
LineAwesomeIcon.THEMEISLE.create());
|
||||||
SideNavItem profile = new SideNavItem("My Profile", MainView.class, LineAwesomeIcon.USER_EDIT_SOLID.create());
|
SideNavItem timesheet = new SideNavItem("My Timesheet", MainView.class,
|
||||||
|
LineAwesomeIcon.HOURGLASS_START_SOLID.create());
|
||||||
|
SideNavItem profile = new SideNavItem("My Profile", MainView.class,
|
||||||
|
LineAwesomeIcon.USER_EDIT_SOLID.create());
|
||||||
|
|
||||||
nav.addItem(new SideNavItem("Home", MainView.class, LineAwesomeIcon.HOME_SOLID.create()));
|
nav.addItem(new SideNavItem("Home", MainView.class, LineAwesomeIcon.HOME_SOLID.create()));
|
||||||
nav.addItem(admin);
|
nav.addItem(admin);
|
||||||
|
@ -28,7 +28,7 @@ import java.util.stream.Stream;
|
|||||||
@Route(value = "/questions", layout = MainLayout.class)
|
@Route(value = "/questions", layout = MainLayout.class)
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public class QuestionsListView extends Main {
|
public class QuestionsListView extends Main {
|
||||||
final QuestionService questionService;
|
private final QuestionService questionService;
|
||||||
|
|
||||||
public QuestionsListView(final QuestionService questionService) {
|
public QuestionsListView(final QuestionService questionService) {
|
||||||
this.questionService = questionService;
|
this.questionService = questionService;
|
||||||
@ -55,12 +55,12 @@ public class QuestionsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size(Query<Question, Object> query) {
|
public int size(final Query<Question, Object> query) {
|
||||||
return questionService.getQuestions().size();
|
return questionService.getQuestions().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<Question> fetch(Query<Question, Object> query) {
|
public Stream<Question> fetch(final Query<Question, Object> query) {
|
||||||
int limit = query.getLimit();
|
int limit = query.getLimit();
|
||||||
int pagerSize = query.getPageSize();
|
int pagerSize = query.getPageSize();
|
||||||
int page = query.getPage();
|
int page = query.getPage();
|
||||||
@ -68,17 +68,17 @@ public class QuestionsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshItem(Question question) {
|
public void refreshItem(final Question question) {
|
||||||
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshAll() {
|
public void refreshAll() {
|
||||||
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Registration addDataProviderListener(DataProviderListener<Question> dataProviderListener) {
|
public Registration addDataProviderListener(final DataProviderListener<Question> dataProviderListener) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -42,19 +42,19 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class SubmissionView extends Main implements HasUrlParameter<String> {
|
public class SubmissionView extends Main implements HasUrlParameter<String> {
|
||||||
|
|
||||||
final CompilerService compilerService;
|
private final CompilerService compilerService;
|
||||||
final AssessmentService assessmentService;
|
private final AssessmentService assessmentService;
|
||||||
|
|
||||||
AceEditor questionEditor = null;
|
private AceEditor questionEditor = null;
|
||||||
AceEditor result = null;
|
private AceEditor result = null;
|
||||||
Dialog dialog = null;
|
private Dialog dialog = null;
|
||||||
Assessment assessment = null;
|
private Assessment assessment = null;
|
||||||
Submission currSubmission = null;
|
private Submission currSubmission = null;
|
||||||
MenuItem prev = null;
|
private MenuItem prev = null;
|
||||||
MenuItem next = null;
|
private MenuItem next = null;
|
||||||
Section sidebar = null;
|
private Section sidebar = null;
|
||||||
DescriptionList dl = null;
|
private DescriptionList dl = null;
|
||||||
Section editorSection = null;
|
private Section editorSection = null;
|
||||||
private H3 questionTitle = null;
|
private H3 questionTitle = null;
|
||||||
|
|
||||||
public SubmissionView(final CompilerService compilerService, final AssessmentService assessmentService) {
|
public SubmissionView(final CompilerService compilerService, final AssessmentService assessmentService) {
|
||||||
@ -116,7 +116,8 @@ public class SubmissionView extends Main implements HasUrlParameter<String> {
|
|||||||
|
|
||||||
final MenuBar runMenuBar = new MenuBar();
|
final MenuBar runMenuBar = new MenuBar();
|
||||||
runMenuBar.addThemeVariants(MenuBarVariant.LUMO_PRIMARY);
|
runMenuBar.addThemeVariants(MenuBarVariant.LUMO_PRIMARY);
|
||||||
runMenuBar.addItem("Ejecutar/Compilar", (ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
runMenuBar.addItem("Ejecutar/Compilar",
|
||||||
|
(ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
||||||
final String javaCode = questionEditor.getValue();
|
final String javaCode = questionEditor.getValue();
|
||||||
final Optional<String> result = this.compilerService.doCompile(javaCode);
|
final Optional<String> result = this.compilerService.doCompile(javaCode);
|
||||||
|
|
||||||
@ -127,12 +128,15 @@ public class SubmissionView extends Main implements HasUrlParameter<String> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
final MenuBar navMenuBar = new MenuBar();
|
final MenuBar navMenuBar = new MenuBar();
|
||||||
prev = navMenuBar.addItem("Anterior pregunta", (ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
prev = navMenuBar.addItem("Anterior pregunta",
|
||||||
|
(ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
||||||
log.info(">>> prev");
|
log.info(">>> prev");
|
||||||
this.currSubmission = this.assessmentService.getPrevSubmission(assessment.getId(), this.currSubmission);
|
this.currSubmission = this.assessmentService.getPrevSubmission(assessment.getId(),
|
||||||
|
this.currSubmission);
|
||||||
updateUI();
|
updateUI();
|
||||||
});
|
});
|
||||||
next = navMenuBar.addItem("Siguiente pregunta", (ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
next = navMenuBar.addItem("Siguiente pregunta",
|
||||||
|
(ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
||||||
this.currSubmission.setResponse(this.questionEditor.getValue());
|
this.currSubmission.setResponse(this.questionEditor.getValue());
|
||||||
goToNext();
|
goToNext();
|
||||||
});
|
});
|
||||||
@ -176,13 +180,14 @@ public class SubmissionView extends Main implements HasUrlParameter<String> {
|
|||||||
return questionEditor;
|
return questionEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInlineBlock(MenuBar menuBar) {
|
private void setInlineBlock(final MenuBar menuBar) {
|
||||||
menuBar.getStyle().set("display", "inline-block");
|
menuBar.getStyle().set("display", "inline-block");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void goToNext() {
|
private void goToNext() {
|
||||||
log.info(">>> next");
|
log.info(">>> next");
|
||||||
Submission found = this.assessmentService.getNextSubmission(assessment.getId(), this.currSubmission.getId(), false);
|
Submission found = this.assessmentService.getNextSubmission(assessment.getId(),
|
||||||
|
this.currSubmission.getId(), false);
|
||||||
|
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
this.currSubmission = found;
|
this.currSubmission = found;
|
||||||
@ -223,24 +228,25 @@ public class SubmissionView extends Main implements HasUrlParameter<String> {
|
|||||||
dl.add(
|
dl.add(
|
||||||
createItem("Candidato:", assessment.getCandidate().getEmail()),
|
createItem("Candidato:", assessment.getCandidate().getEmail()),
|
||||||
createItem("Hora de inicio:", Optional.ofNullable(assessment.getStartingTime())
|
createItem("Hora de inicio:", Optional.ofNullable(assessment.getStartingTime())
|
||||||
.map(t -> ZonedDateTime.ofInstant(t, ZoneId.of("GMT-4")).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
.map(t -> ZonedDateTime.ofInstant(t,
|
||||||
|
ZoneId.of("GMT-4")).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
||||||
.orElse("N/A"))
|
.orElse("N/A"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Div createItem(String label, String value) {
|
private Div createItem(final String label, final String value) {
|
||||||
return new Div(createTerm(label), createDescription(value));
|
return new Div(createTerm(label), createDescription(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Term createTerm(String label) {
|
private Term createTerm(final String label) {
|
||||||
Term term = new Term(label);
|
Term term = new Term(label);
|
||||||
term.addClassNames(FontWeight.MEDIUM, TextColor.SECONDARY);
|
term.addClassNames(FontWeight.MEDIUM, TextColor.SECONDARY);
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Description createDescription(String value, String... themeNames) {
|
private Description createDescription(final String value, final String... themeNames) {
|
||||||
Description desc = new Description(value);
|
Description desc = new Description(value);
|
||||||
desc.addClassName(Margin.Left.NONE);
|
desc.addClassName(Margin.Left.NONE);
|
||||||
|
|
||||||
@ -252,7 +258,7 @@ public class SubmissionView extends Main implements HasUrlParameter<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameter(BeforeEvent beforeEvent, String s) {
|
public void setParameter(final BeforeEvent beforeEvent, final String s) {
|
||||||
this.assessment = this.assessmentService.getAssessment(UUID.fromString(s));
|
this.assessment = this.assessmentService.getAssessment(UUID.fromString(s));
|
||||||
|
|
||||||
if (this.assessment == null) {
|
if (this.assessment == null) {
|
||||||
|
195
src/main/resources/checkstyle.xml
Normal file
195
src/main/resources/checkstyle.xml
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||||
|
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Checkstyle configuration that checks the sun coding conventions from:
|
||||||
|
|
||||||
|
- the Java Language Specification at
|
||||||
|
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
|
||||||
|
|
||||||
|
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
|
||||||
|
|
||||||
|
- the Javadoc guidelines at
|
||||||
|
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
|
||||||
|
|
||||||
|
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
|
||||||
|
|
||||||
|
- some best practices
|
||||||
|
|
||||||
|
Checkstyle is very configurable. Be sure to read the documentation at
|
||||||
|
https://checkstyle.org (or in your downloaded distribution).
|
||||||
|
|
||||||
|
Most Checks are configurable, be sure to consult the documentation.
|
||||||
|
|
||||||
|
To completely disable a check, just comment it out or delete it from the file.
|
||||||
|
To suppress certain violations please review suppression filters.
|
||||||
|
|
||||||
|
Finally, it is worth reading the documentation.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<module name="Checker">
|
||||||
|
<!--
|
||||||
|
If you set the basedir property below, then all reported file
|
||||||
|
names will be relative to the specified directory. See
|
||||||
|
https://checkstyle.org/config.html#Checker
|
||||||
|
|
||||||
|
<property name="basedir" value="${basedir}"/>
|
||||||
|
-->
|
||||||
|
<property name="severity" value="error"/>
|
||||||
|
|
||||||
|
<property name="fileExtensions" value="java, properties, xml"/>
|
||||||
|
|
||||||
|
<!-- Excludes all 'module-info.java' files -->
|
||||||
|
<!-- See https://checkstyle.org/config_filefilters.html -->
|
||||||
|
<module name="BeforeExecutionExclusionFileFilter">
|
||||||
|
<property name="fileNamePattern" value="module\-info\.java$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
|
||||||
|
<module name="SuppressionFilter">
|
||||||
|
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}"
|
||||||
|
default="checkstyle-suppressions.xml" />
|
||||||
|
<property name="optional" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Checks that a package-info.java file exists for each package. -->
|
||||||
|
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
|
||||||
|
<!-- <module name="JavadocPackage"/> -->
|
||||||
|
|
||||||
|
<!-- Checks whether files end with a new line. -->
|
||||||
|
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
|
||||||
|
<!-- <module name="NewlineAtEndOfFile"/> -->
|
||||||
|
|
||||||
|
<!-- Checks that property files contain the same keys. -->
|
||||||
|
<!-- See https://checkstyle.org/config_misc.html#Translation -->
|
||||||
|
<module name="Translation"/>
|
||||||
|
|
||||||
|
<!-- Checks for Size Violations. -->
|
||||||
|
<!-- See https://checkstyle.org/config_sizes.html -->
|
||||||
|
<module name="FileLength"/>
|
||||||
|
<module name="LineLength">
|
||||||
|
<property name="max" value="120"/>
|
||||||
|
<property name="fileExtensions" value="java"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Checks for whitespace -->
|
||||||
|
<!-- See https://checkstyle.org/config_whitespace.html -->
|
||||||
|
<module name="FileTabCharacter"/>
|
||||||
|
|
||||||
|
<!-- Miscellaneous other checks. -->
|
||||||
|
<!-- See https://checkstyle.org/config_misc.html -->
|
||||||
|
<module name="RegexpSingleline">
|
||||||
|
<property name="format" value="\s+$"/>
|
||||||
|
<property name="minimum" value="0"/>
|
||||||
|
<property name="maximum" value="0"/>
|
||||||
|
<property name="message" value="Line has trailing spaces."/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Checks for Headers -->
|
||||||
|
<!-- See https://checkstyle.org/config_header.html -->
|
||||||
|
<!-- <module name="Header"> -->
|
||||||
|
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
|
||||||
|
<!-- <property name="fileExtensions" value="java"/> -->
|
||||||
|
<!-- </module> -->
|
||||||
|
|
||||||
|
<module name="TreeWalker">
|
||||||
|
|
||||||
|
<!-- Checks for Javadoc comments. -->
|
||||||
|
<!-- See https://checkstyle.org/config_javadoc.html -->
|
||||||
|
<module name="InvalidJavadocPosition"/>
|
||||||
|
|
||||||
|
<!-- Checks for Naming Conventions. -->
|
||||||
|
<!-- See https://checkstyle.org/config_naming.html -->
|
||||||
|
<module name="ConstantName"/>
|
||||||
|
<module name="LocalFinalVariableName"/>
|
||||||
|
<module name="LocalVariableName"/>
|
||||||
|
<module name="MemberName"/>
|
||||||
|
<module name="MethodName"/>
|
||||||
|
<module name="PackageName"/>
|
||||||
|
<module name="ParameterName"/>
|
||||||
|
<module name="StaticVariableName"/>
|
||||||
|
<module name="TypeName"/>
|
||||||
|
|
||||||
|
<!-- Checks for imports -->
|
||||||
|
<!-- See https://checkstyle.org/config_imports.html -->
|
||||||
|
<!-- <module name="AvoidStarImport"/> -->
|
||||||
|
|
||||||
|
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
|
||||||
|
<module name="RedundantImport"/>
|
||||||
|
<module name="UnusedImports">
|
||||||
|
<property name="processJavadoc" value="false"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Checks for Size Violations. -->
|
||||||
|
<!-- See https://checkstyle.org/config_sizes.html -->
|
||||||
|
<module name="MethodLength"/>
|
||||||
|
<module name="ParameterNumber"/>
|
||||||
|
|
||||||
|
<!-- Checks for whitespace -->
|
||||||
|
<!-- See https://checkstyle.org/config_whitespace.html -->
|
||||||
|
<module name="EmptyForIteratorPad"/>
|
||||||
|
<module name="GenericWhitespace"/>
|
||||||
|
<module name="MethodParamPad"/>
|
||||||
|
<module name="NoWhitespaceAfter"/>
|
||||||
|
<module name="NoWhitespaceBefore"/>
|
||||||
|
<module name="OperatorWrap"/>
|
||||||
|
<module name="ParenPad"/>
|
||||||
|
<module name="TypecastParenPad"/>
|
||||||
|
<module name="WhitespaceAfter"/>
|
||||||
|
<module name="WhitespaceAround"/>
|
||||||
|
|
||||||
|
<!-- Modifier Checks -->
|
||||||
|
<!-- See https://checkstyle.org/config_modifier.html -->
|
||||||
|
<module name="ModifierOrder"/>
|
||||||
|
<module name="RedundantModifier"/>
|
||||||
|
|
||||||
|
<!-- Checks for blocks. You know, those {}'s -->
|
||||||
|
<!-- See https://checkstyle.org/config_blocks.html -->
|
||||||
|
<module name="AvoidNestedBlocks"/>
|
||||||
|
<module name="EmptyBlock"/>
|
||||||
|
<module name="LeftCurly"/>
|
||||||
|
<module name="NeedBraces"/>
|
||||||
|
<module name="RightCurly"/>
|
||||||
|
|
||||||
|
<!-- Checks for common coding problems -->
|
||||||
|
<!-- See https://checkstyle.org/config_coding.html -->
|
||||||
|
<module name="EmptyStatement"/>
|
||||||
|
<module name="EqualsHashCode"/>
|
||||||
|
<!-- <module name="HiddenField"/> -->
|
||||||
|
<module name="IllegalInstantiation"/>
|
||||||
|
<module name="InnerAssignment"/>
|
||||||
|
<!-- <module name="MagicNumber"/> -->
|
||||||
|
<module name="MissingSwitchDefault"/>
|
||||||
|
<module name="MultipleVariableDeclarations"/>
|
||||||
|
<module name="SimplifyBooleanExpression"/>
|
||||||
|
<module name="SimplifyBooleanReturn"/>
|
||||||
|
|
||||||
|
<!-- Checks for class design -->
|
||||||
|
<!-- See https://checkstyle.org/config_design.html -->
|
||||||
|
<!--<module name="DesignForExtension"/>-->
|
||||||
|
<module name="FinalClass"/>
|
||||||
|
<!-- <module name="HideUtilityClassConstructor"/>-->
|
||||||
|
<module name="InterfaceIsType"/>
|
||||||
|
<module name="VisibilityModifier"/>
|
||||||
|
|
||||||
|
<!-- Miscellaneous other checks. -->
|
||||||
|
<!-- See https://checkstyle.org/config_misc.html -->
|
||||||
|
<module name="ArrayTypeStyle"/>
|
||||||
|
<module name="FinalParameters"/>
|
||||||
|
<module name="TodoComment"/>
|
||||||
|
<module name="UpperEll"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
|
||||||
|
<module name="SuppressionXpathFilter">
|
||||||
|
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
|
||||||
|
default="checkstyle-xpath-suppressions.xml" />
|
||||||
|
<property name="optional" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
</module>
|
||||||
|
|
||||||
|
</module>
|
Loading…
Reference in New Issue
Block a user