adding checkstyle

This commit is contained in:
alex 2024-08-11 14:12:06 -04:00
parent 3f10d6224a
commit 0f3c01b1c1
20 changed files with 463 additions and 128 deletions

106
pom.xml
View File

@ -21,6 +21,15 @@
</parent>
<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>
<id>Vaadin Directory</id>
<url>https://maven.vaadin.com/vaadin-addons</url>
@ -45,8 +54,7 @@
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<!-- Replace artifactId with vaadin-core to use only free components -->
<artifactId>vaadin</artifactId>
<artifactId>vaadin-core</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
@ -98,11 +106,32 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</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>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-testbench-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.openhft</groupId>
<artifactId>compiler</artifactId>
@ -137,11 +166,62 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</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>
<build>
<defaultGoal>spring-boot:run</defaultGoal>
<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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
@ -162,6 +242,28 @@
</plugins>
</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>
<profile>
<!-- Production mode is activated using -Pproduction -->

View File

@ -16,7 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@Theme(value = "pfs-intra")
public class Application implements AppShellConfigurator {
public static void main(String[] args) {
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}

View File

@ -17,7 +17,7 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
public class SecurityConfig extends VaadinWebSecurity {
@Override
protected void configure(HttpSecurity http) throws Exception {
protected void configure(final HttpSecurity http) throws Exception {
http.authorizeHttpRequests(auth ->
auth
.requestMatchers(AntPathRequestMatcher.antMatcher("/h2-console/**")).permitAll()
@ -38,7 +38,8 @@ public class SecurityConfig extends VaadinWebSecurity {
@Bean
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);
LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource);
factory.setUserDnPatterns("uid={0},ou=users");

View File

@ -35,7 +35,8 @@ public class Assessment extends BaseEntity {
}
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)
.findFirst();
@ -50,7 +51,8 @@ public class Assessment extends BaseEntity {
}
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)
.findFirst();
@ -71,11 +73,11 @@ public class Assessment extends BaseEntity {
.isPresent();
}
public boolean isFirst(Submission currSubmission) {
public boolean isFirst(final Submission currSubmission) {
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;
}
}

View File

@ -34,14 +34,17 @@ public class AssessmentService {
public void sendEmail(final Assessment assessment) {
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();
message.setFrom("no-reply@primefactorsolutions.com");
message.setBcc("no-reply@primefactorsolutions.com");
message.setTo(assessment.getCandidate().getEmail());
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 "
+ "una evaluacion tecnica de programacion en JAVA. La prueba tiene una duracion de 30 minutos y puede completarla cuando tenga una buena "
message.setText(String.format("Estimado candidato,\n\nGracias por su candidatura. En esta etapa del "
+ "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"
+ "Haga click aca: " + evaluationLink + "\n\n"
+ "Exito!"));
@ -77,7 +80,8 @@ public class AssessmentService {
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();
Assessment saved;
@ -92,7 +96,8 @@ public class AssessmentService {
.findFirst();
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);
}
@ -121,7 +126,8 @@ public class AssessmentService {
.findFirst();
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);
}
@ -163,13 +169,14 @@ public class AssessmentService {
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);
return saved;
}
public void saveSubmission(UUID id, Submission currSubmission) {
public void saveSubmission(final UUID id, final Submission currSubmission) {
Assessment assessment = assessmentRepository.findById(id).get();
final Submission submission = assessment.getSubmissions().stream()
.filter(s -> s.getId().equals(currSubmission.getId()))

View File

@ -28,9 +28,11 @@ public class CompilerService {
final String qualifiedClassName = "com.primefactorsolutions.TestClass";
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
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,
List.of("-proc:full", "-Xlint:-options"), null, sourceFiles);

View File

@ -13,7 +13,7 @@ import java.util.UUID;
public class QuestionService {
private final QuestionRepository questionRepository;
public Question getQuestion(UUID id) {
public Question getQuestion(final UUID id) {
return questionRepository.findById(id).get();
}
@ -21,7 +21,7 @@ public class QuestionService {
return questionRepository.findAll();
}
public Question createOrUpdate(Question question) {
public Question createOrUpdate(final Question question) {
return questionRepository.save(question);
}
}

View File

@ -8,13 +8,13 @@ public class InMemoryClassLoader extends ClassLoader {
private final InMemoryFileManager manager;
public InMemoryClassLoader(ClassLoader parent, InMemoryFileManager manager) {
public InMemoryClassLoader(final ClassLoader parent, final InMemoryFileManager manager) {
super(parent);
this.manager = requireNonNull(manager, "manager must not be null");
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
protected Class<?> findClass(final String name) throws ClassNotFoundException {
Map<String, JavaClassAsBytes> compiledClasses = manager
.getBytesMap();

View File

@ -14,7 +14,7 @@ public class InMemoryFileManager extends ForwardingJavaFileManager<JavaFileManag
private final Map<String, JavaClassAsBytes> compiledClasses;
private final ClassLoader loader;
public InMemoryFileManager(StandardJavaFileManager standardManager) {
public InMemoryFileManager(final StandardJavaFileManager standardManager) {
super(standardManager);
this.compiledClasses = new Hashtable<>();
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.
*/
@Override
public ClassLoader getClassLoader(Location location) {
public ClassLoader getClassLoader(final Location location) {
return loader;
}
@Override
public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind,
FileObject sibling) {
public JavaFileObject getJavaFileForOutput(final Location location, final String className, final Kind kind,
final FileObject sibling) {
JavaClassAsBytes classAsBytes = new JavaClassAsBytes(
className, kind);

View File

@ -7,10 +7,10 @@ import java.net.URI;
public class JavaClassAsBytes extends SimpleJavaFileObject {
protected ByteArrayOutputStream bos =
private final ByteArrayOutputStream bos =
new ByteArrayOutputStream();
public JavaClassAsBytes(String name, Kind kind) {
public JavaClassAsBytes(final String name, final Kind kind) {
super(URI.create("string:///" + name.replace('.', '/')
+ kind.extension), kind);
}

View File

@ -9,14 +9,14 @@ public class JavaSourceFromString extends SimpleJavaFileObject {
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),
Kind.SOURCE);
this.sourceCode = requireNonNull(sourceCode, "sourceCode must not be null");
}
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
public CharSequence getCharContent(final boolean ignoreEncodingErrors) {
return sourceCode;
}
}

View File

@ -36,7 +36,8 @@ public class AssessmentView extends BeanValidationForm<Assessment> implements Ha
private ComboBox<Candidate> candidate = 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);
this.assessmentService = assessmentService;

View File

@ -64,10 +64,12 @@ public class AssessmentsListView extends Main {
assessment.getCandidate().getEmail(),
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();
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.setConfirmText("Enviar");
dialog.setConfirmButtonTheme("primary");
@ -75,7 +77,8 @@ public class AssessmentsListView extends Main {
try {
assessmentService.sendEmail(assessment);
} 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();
@ -88,12 +91,12 @@ public class AssessmentsListView extends Main {
}
@Override
public int size(Query<Assessment, Object> query) {
public int size(final Query<Assessment, Object> query) {
return assessmentService.getAssessments().size();
}
@Override
public Stream<Assessment> fetch(Query<Assessment, Object> query) {
public Stream<Assessment> fetch(final Query<Assessment, Object> query) {
int limit = query.getLimit();
int pagerSize = query.getPageSize();
int page = query.getPage();
@ -102,8 +105,8 @@ public class AssessmentsListView extends Main {
}
@Override
public void refreshItem(Assessment assessment) {
public void refreshItem(final Assessment assessment) {
// no-op
}
@Override
@ -112,7 +115,7 @@ public class AssessmentsListView extends Main {
}
@Override
public Registration addDataProviderListener(DataProviderListener<Assessment> dataProviderListener) {
public Registration addDataProviderListener(final DataProviderListener<Assessment> dataProviderListener) {
return null;
}
});

View File

@ -28,7 +28,7 @@ import java.util.stream.Stream;
@Route(value = "/candidates", layout = MainLayout.class)
@PermitAll
public class CandidatesListView extends Main {
final CandidateService candidateService;
private final CandidateService candidateService;
public CandidatesListView(final CandidateService candidateService) {
this.candidateService = candidateService;
@ -57,12 +57,12 @@ public class CandidatesListView extends Main {
}
@Override
public int size(Query<Candidate, Object> query) {
public int size(final Query<Candidate, Object> query) {
return candidateService.getCandidates().size();
}
@Override
public Stream<Candidate> fetch(Query<Candidate, Object> query) {
public Stream<Candidate> fetch(final Query<Candidate, Object> query) {
int limit = query.getLimit();
int pagerSize = query.getPageSize();
int page = query.getPage();
@ -70,17 +70,17 @@ public class CandidatesListView extends Main {
}
@Override
public void refreshItem(Candidate candidate) {
public void refreshItem(final Candidate candidate) {
// no-op
}
@Override
public void refreshAll() {
// no-op
}
@Override
public Registration addDataProviderListener(DataProviderListener<Candidate> dataProviderListener) {
public Registration addDataProviderListener(final DataProviderListener<Candidate> dataProviderListener) {
return null;
}
});

View File

@ -59,31 +59,27 @@ import java.util.stream.Collectors;
@Slf4j
public class EvaluationView extends Main implements HasUrlParameter<String> {
final CompilerService compilerService;
final AssessmentService assessmentService;
private final CompilerService compilerService;
private final AssessmentService assessmentService;
AceEditor questionEditor = null;
Dialog dialog = null;
Dialog completeDialog = null;
AceEditor result = null;
private AceEditor questionEditor = null;
private Dialog dialog = null;
private Dialog completeDialog = null;
private AceEditor result = null;
private Assessment assessment = null;
private Submission currSubmission = null;
private Boolean isCompleted = false;
Assessment assessment = null;
Submission currSubmission = null;
Boolean isCompleted = false;
Button start = null;
MenuItem prev = null;
MenuItem next = null;
MenuItem reset = null;
Section sidebar = null;
SimpleTimer timer = null;
DescriptionList dl = null;
Section editorSection = null;
Section startSection = null;
Section completedSection = null;
private Button start = null;
private MenuItem prev = null;
private MenuItem next = null;
private MenuItem reset = null;
private Section sidebar = null;
private SimpleTimer timer = null;
private DescriptionList dl = null;
private Section editorSection = null;
private Section startSection = null;
private Section completedSection = null;
private H3 questionTitle = null;
private Text questionDescription = null;
@ -147,7 +143,8 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
completeDialog = new Dialog();
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.setSpacing(false);
dialogLayout.setAlignItems(FlexComponent.Alignment.STRETCH);
@ -197,19 +194,22 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
});
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");
this.currSubmission.setResponse(this.questionEditor.getValue());
this.assessmentService.saveSubmission(assessment.getId(), this.currSubmission);
this.currSubmission = this.assessmentService.getPrevSubmission(assessment.getId(), this.currSubmission);
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.assessmentService.saveSubmission(assessment.getId(), this.currSubmission);
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.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);
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 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."));
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."));
TextField tf = new TextField();
tf.setRequiredIndicatorVisible(true);
@ -261,7 +263,8 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
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"));
closeButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
@ -310,13 +313,14 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
return questionEditor;
}
private void setInlineBlock(MenuBar menuBar) {
private void setInlineBlock(final MenuBar menuBar) {
menuBar.getStyle().set("display", "inline-block");
}
private void goToNext() {
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) {
this.completeDialog.open();
@ -391,7 +395,8 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
dl.add(
createItem("Candidato:", assessment.getCandidate().getEmail()),
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"))
);
}
@ -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));
}
@ -413,13 +418,13 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
// 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.addClassNames(FontWeight.MEDIUM, TextColor.SECONDARY);
return term;
}
private Description createDescription(String value, String... themeNames) {
private Description createDescription(final String value, final String... themeNames) {
Description desc = new Description(value);
desc.addClassName(Margin.Left.NONE);
@ -431,7 +436,7 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
}
@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));
if (this.assessment == null) {

View File

@ -23,7 +23,7 @@ public class MainLayout extends AppLayout {
private H1 viewTitle;
public MainLayout(AuthenticationContext authContext) {
public MainLayout(final AuthenticationContext authContext) {
this.authContext = authContext;
setPrimarySection(Section.DRAWER);
addDrawerContent();
@ -54,19 +54,30 @@ public class MainLayout extends AppLayout {
SideNav nav = new SideNav();
authContext.getAuthenticatedUser(UserDetails.class).ifPresent(u -> {
SideNavItem recruiting = new SideNavItem("Recruiting", MainView.class, LineAwesomeIcon.BUSINESS_TIME_SOLID.create());
recruiting.addItem(new SideNavItem("Assessments", AssessmentsListView.class, 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 recruiting = new SideNavItem("Recruiting", MainView.class,
LineAwesomeIcon.BUSINESS_TIME_SOLID.create());
recruiting.addItem(new SideNavItem("Assessments", AssessmentsListView.class,
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());
admin.addItem(new SideNavItem("Time-off requests", AssessmentsListView.class, 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 admin = new SideNavItem("Admin", MainView.class,
LineAwesomeIcon.SUITCASE_SOLID.create());
admin.addItem(new SideNavItem("Time-off requests", AssessmentsListView.class,
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 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());
SideNavItem timeOff = new SideNavItem("My Time-off", MainView.class,
LineAwesomeIcon.THEMEISLE.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(admin);

View File

@ -28,7 +28,7 @@ import java.util.stream.Stream;
@Route(value = "/questions", layout = MainLayout.class)
@PermitAll
public class QuestionsListView extends Main {
final QuestionService questionService;
private final QuestionService questionService;
public QuestionsListView(final QuestionService questionService) {
this.questionService = questionService;
@ -55,12 +55,12 @@ public class QuestionsListView extends Main {
}
@Override
public int size(Query<Question, Object> query) {
public int size(final Query<Question, Object> query) {
return questionService.getQuestions().size();
}
@Override
public Stream<Question> fetch(Query<Question, Object> query) {
public Stream<Question> fetch(final Query<Question, Object> query) {
int limit = query.getLimit();
int pagerSize = query.getPageSize();
int page = query.getPage();
@ -68,17 +68,17 @@ public class QuestionsListView extends Main {
}
@Override
public void refreshItem(Question question) {
public void refreshItem(final Question question) {
// no-op
}
@Override
public void refreshAll() {
// no-op
}
@Override
public Registration addDataProviderListener(DataProviderListener<Question> dataProviderListener) {
public Registration addDataProviderListener(final DataProviderListener<Question> dataProviderListener) {
return null;
}
});

View File

@ -42,19 +42,19 @@ import java.util.stream.Collectors;
@Slf4j
public class SubmissionView extends Main implements HasUrlParameter<String> {
final CompilerService compilerService;
final AssessmentService assessmentService;
private final CompilerService compilerService;
private final AssessmentService assessmentService;
AceEditor questionEditor = null;
AceEditor result = null;
Dialog dialog = null;
Assessment assessment = null;
Submission currSubmission = null;
MenuItem prev = null;
MenuItem next = null;
Section sidebar = null;
DescriptionList dl = null;
Section editorSection = null;
private AceEditor questionEditor = null;
private AceEditor result = null;
private Dialog dialog = null;
private Assessment assessment = null;
private Submission currSubmission = null;
private MenuItem prev = null;
private MenuItem next = null;
private Section sidebar = null;
private DescriptionList dl = null;
private Section editorSection = null;
private H3 questionTitle = null;
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();
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 Optional<String> result = this.compilerService.doCompile(javaCode);
@ -127,12 +128,15 @@ public class SubmissionView extends Main implements HasUrlParameter<String> {
});
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");
this.currSubmission = this.assessmentService.getPrevSubmission(assessment.getId(), this.currSubmission);
this.currSubmission = this.assessmentService.getPrevSubmission(assessment.getId(),
this.currSubmission);
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());
goToNext();
});
@ -176,13 +180,14 @@ public class SubmissionView extends Main implements HasUrlParameter<String> {
return questionEditor;
}
private void setInlineBlock(MenuBar menuBar) {
private void setInlineBlock(final MenuBar menuBar) {
menuBar.getStyle().set("display", "inline-block");
}
private void goToNext() {
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) {
this.currSubmission = found;
@ -223,24 +228,25 @@ public class SubmissionView extends Main implements HasUrlParameter<String> {
dl.add(
createItem("Candidato:", assessment.getCandidate().getEmail()),
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"))
);
}
}
}
private Div createItem(String label, String value) {
private Div createItem(final String label, final String 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.addClassNames(FontWeight.MEDIUM, TextColor.SECONDARY);
return term;
}
private Description createDescription(String value, String... themeNames) {
private Description createDescription(final String value, final String... themeNames) {
Description desc = new Description(value);
desc.addClassName(Margin.Left.NONE);
@ -252,7 +258,7 @@ public class SubmissionView extends Main implements HasUrlParameter<String> {
}
@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));
if (this.assessment == null) {

View 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>