diff --git a/pom.xml b/pom.xml index 8cd262a..343c2c0 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,15 @@ + + central + Maven Central + default + https://repo1.maven.org/maven2 + + false + + Vaadin Directory https://maven.vaadin.com/vaadin-addons @@ -45,8 +54,7 @@ com.vaadin - - vaadin + vaadin-core com.vaadin @@ -98,11 +106,32 @@ spring-boot-starter-test test + + org.hibernate.validator + hibernate-validator + 8.0.1.Final + + + org.hibernate.search + hibernate-search-mapper-orm + 7.1.1.Final + + + org.hibernate.search + hibernate-search-backend-lucene + 7.1.1.Final + com.vaadin vaadin-testbench-junit5 test + + org.assertj + assertj-core + 3.25.3 + test + net.openhft compiler @@ -137,11 +166,62 @@ org.projectlombok lombok + + org.mapstruct + mapstruct + 1.5.5.Final + + + org.mapstruct + mapstruct-processor + 1.5.5.Final + + + org.apache.lucene + lucene-core + 9.10.0 + + + org.apache.lucene + lucene-queryparser + 9.10.0 + + + com.google.guava + guava + 33.1.0-jre + + + org.apache.commons + commons-lang3 + 3.14.0 + spring-boot:run + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.3.1 + + src/main/resources/checkstyle.xml + true + true + + ${project.build.sourceDirectory} + + + + + + check + + compile + + + org.springframework.boot spring-boot-maven-plugin @@ -162,6 +242,28 @@ + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.3.1 + + src/main/resources/checkstyle.xml + true + true + + + + + checkstyle-aggregate + + + + + + + diff --git a/src/main/java/com/primefactorsolutions/Application.java b/src/main/java/com/primefactorsolutions/Application.java index 8a4a1d5..298fd56 100644 --- a/src/main/java/com/primefactorsolutions/Application.java +++ b/src/main/java/com/primefactorsolutions/Application.java @@ -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); } diff --git a/src/main/java/com/primefactorsolutions/config/SecurityConfig.java b/src/main/java/com/primefactorsolutions/config/SecurityConfig.java index f505000..7fb147d 100644 --- a/src/main/java/com/primefactorsolutions/config/SecurityConfig.java +++ b/src/main/java/com/primefactorsolutions/config/SecurityConfig.java @@ -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"); diff --git a/src/main/java/com/primefactorsolutions/model/Assessment.java b/src/main/java/com/primefactorsolutions/model/Assessment.java index 7ff63ce..ff495b6 100644 --- a/src/main/java/com/primefactorsolutions/model/Assessment.java +++ b/src/main/java/com/primefactorsolutions/model/Assessment.java @@ -35,7 +35,8 @@ public class Assessment extends BaseEntity { } public Long getRemainingTimeSeconds() { - final Optional started = assessmentEvents.stream().filter(e -> e.getStatus() == AssessmentStatus.STARTED) + final Optional 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 started = assessmentEvents.stream().filter(e -> e.getStatus() == AssessmentStatus.STARTED) + final Optional 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; } } diff --git a/src/main/java/com/primefactorsolutions/model/Question.java b/src/main/java/com/primefactorsolutions/model/Question.java index 0b08d5c..3e9b8c3 100644 --- a/src/main/java/com/primefactorsolutions/model/Question.java +++ b/src/main/java/com/primefactorsolutions/model/Question.java @@ -13,7 +13,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode(callSuper = true) -public class Question extends BaseEntity{ +public class Question extends BaseEntity { @Column(unique = true) private String title; @Lob diff --git a/src/main/java/com/primefactorsolutions/service/AssessmentService.java b/src/main/java/com/primefactorsolutions/service/AssessmentService.java index 4b4821d..a5bfa87 100644 --- a/src/main/java/com/primefactorsolutions/service/AssessmentService.java +++ b/src/main/java/com/primefactorsolutions/service/AssessmentService.java @@ -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())) diff --git a/src/main/java/com/primefactorsolutions/service/CompilerService.java b/src/main/java/com/primefactorsolutions/service/CompilerService.java index ea657a2..af0b5bc 100644 --- a/src/main/java/com/primefactorsolutions/service/CompilerService.java +++ b/src/main/java/com/primefactorsolutions/service/CompilerService.java @@ -28,9 +28,11 @@ public class CompilerService { final String qualifiedClassName = "com.primefactorsolutions.TestClass"; final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); final DiagnosticCollector 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 sourceFiles = Collections.singletonList(new JavaSourceFromString(qualifiedClassName, javaCode)); + final List sourceFiles = Collections.singletonList(new JavaSourceFromString(qualifiedClassName, + javaCode)); final JavaCompiler.CompilationTask task = compiler.getTask(null, manager, diagnostics, List.of("-proc:full", "-Xlint:-options"), null, sourceFiles); diff --git a/src/main/java/com/primefactorsolutions/service/QuestionService.java b/src/main/java/com/primefactorsolutions/service/QuestionService.java index cdd2151..59282b3 100644 --- a/src/main/java/com/primefactorsolutions/service/QuestionService.java +++ b/src/main/java/com/primefactorsolutions/service/QuestionService.java @@ -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); } } diff --git a/src/main/java/com/primefactorsolutions/service/compiler/InMemoryClassLoader.java b/src/main/java/com/primefactorsolutions/service/compiler/InMemoryClassLoader.java index 926bb97..517411e 100644 --- a/src/main/java/com/primefactorsolutions/service/compiler/InMemoryClassLoader.java +++ b/src/main/java/com/primefactorsolutions/service/compiler/InMemoryClassLoader.java @@ -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 compiledClasses = manager .getBytesMap(); diff --git a/src/main/java/com/primefactorsolutions/service/compiler/InMemoryFileManager.java b/src/main/java/com/primefactorsolutions/service/compiler/InMemoryFileManager.java index 8602a35..df16adf 100644 --- a/src/main/java/com/primefactorsolutions/service/compiler/InMemoryFileManager.java +++ b/src/main/java/com/primefactorsolutions/service/compiler/InMemoryFileManager.java @@ -14,7 +14,7 @@ public class InMemoryFileManager extends ForwardingJavaFileManager 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 implements Ha private ComboBox candidate = null; private SubListSelector 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; diff --git a/src/main/java/com/primefactorsolutions/views/AssessmentsListView.java b/src/main/java/com/primefactorsolutions/views/AssessmentsListView.java index 823898e..cf755c3 100644 --- a/src/main/java/com/primefactorsolutions/views/AssessmentsListView.java +++ b/src/main/java/com/primefactorsolutions/views/AssessmentsListView.java @@ -64,10 +64,12 @@ public class AssessmentsListView extends Main { assessment.getCandidate().getEmail(), assessment.getId())) )); - grid.addComponentColumn((ValueProvider) assessment -> new Button("Send Email", event -> { + grid.addComponentColumn((ValueProvider) 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 query) { + public int size(final Query query) { return assessmentService.getAssessments().size(); } @Override - public Stream fetch(Query query) { + public Stream fetch(final Query 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 dataProviderListener) { + public Registration addDataProviderListener(final DataProviderListener dataProviderListener) { return null; } }); diff --git a/src/main/java/com/primefactorsolutions/views/CandidatesListView.java b/src/main/java/com/primefactorsolutions/views/CandidatesListView.java index af470b9..599bb57 100644 --- a/src/main/java/com/primefactorsolutions/views/CandidatesListView.java +++ b/src/main/java/com/primefactorsolutions/views/CandidatesListView.java @@ -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 query) { + public int size(final Query query) { return candidateService.getCandidates().size(); } @Override - public Stream fetch(Query query) { + public Stream fetch(final Query 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 dataProviderListener) { + public Registration addDataProviderListener(final DataProviderListener dataProviderListener) { return null; } }); diff --git a/src/main/java/com/primefactorsolutions/views/EvaluationView.java b/src/main/java/com/primefactorsolutions/views/EvaluationView.java index 84d6122..95298de 100644 --- a/src/main/java/com/primefactorsolutions/views/EvaluationView.java +++ b/src/main/java/com/primefactorsolutions/views/EvaluationView.java @@ -59,31 +59,27 @@ import java.util.stream.Collectors; @Slf4j public class EvaluationView extends Main implements HasUrlParameter { - 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 { 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 { }); final MenuBar navMenuBar = new MenuBar(); - prev = navMenuBar.addItem("Anterior pregunta", (ComponentEventListener>) menuItemClickEvent -> { + prev = navMenuBar.addItem("Anterior pregunta", + (ComponentEventListener>) 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>) menuItemClickEvent -> { + next = navMenuBar.addItem("Siguiente pregunta", + (ComponentEventListener>) 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>) menuItemClickEvent -> { + reset = navMenuBar.addItem("Reiniciar pregunta (deshacer todos los cambios)", + (ComponentEventListener>) 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 { 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 { 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 { 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 { 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 { } } - 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 { // 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 { } @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) { diff --git a/src/main/java/com/primefactorsolutions/views/MainLayout.java b/src/main/java/com/primefactorsolutions/views/MainLayout.java index 4276818..da56ee1 100644 --- a/src/main/java/com/primefactorsolutions/views/MainLayout.java +++ b/src/main/java/com/primefactorsolutions/views/MainLayout.java @@ -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); diff --git a/src/main/java/com/primefactorsolutions/views/QuestionsListView.java b/src/main/java/com/primefactorsolutions/views/QuestionsListView.java index 69f0991..23deca7 100644 --- a/src/main/java/com/primefactorsolutions/views/QuestionsListView.java +++ b/src/main/java/com/primefactorsolutions/views/QuestionsListView.java @@ -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 query) { + public int size(final Query query) { return questionService.getQuestions().size(); } @Override - public Stream fetch(Query query) { + public Stream fetch(final Query 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 dataProviderListener) { + public Registration addDataProviderListener(final DataProviderListener dataProviderListener) { return null; } }); diff --git a/src/main/java/com/primefactorsolutions/views/SubmissionView.java b/src/main/java/com/primefactorsolutions/views/SubmissionView.java index 9672dd5..a48fc98 100644 --- a/src/main/java/com/primefactorsolutions/views/SubmissionView.java +++ b/src/main/java/com/primefactorsolutions/views/SubmissionView.java @@ -42,19 +42,19 @@ import java.util.stream.Collectors; @Slf4j public class SubmissionView extends Main implements HasUrlParameter { - 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 { final MenuBar runMenuBar = new MenuBar(); runMenuBar.addThemeVariants(MenuBarVariant.LUMO_PRIMARY); - runMenuBar.addItem("Ejecutar/Compilar", (ComponentEventListener>) menuItemClickEvent -> { + runMenuBar.addItem("Ejecutar/Compilar", + (ComponentEventListener>) menuItemClickEvent -> { final String javaCode = questionEditor.getValue(); final Optional result = this.compilerService.doCompile(javaCode); @@ -127,12 +128,15 @@ public class SubmissionView extends Main implements HasUrlParameter { }); final MenuBar navMenuBar = new MenuBar(); - prev = navMenuBar.addItem("Anterior pregunta", (ComponentEventListener>) menuItemClickEvent -> { + prev = navMenuBar.addItem("Anterior pregunta", + (ComponentEventListener>) 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>) menuItemClickEvent -> { + next = navMenuBar.addItem("Siguiente pregunta", + (ComponentEventListener>) menuItemClickEvent -> { this.currSubmission.setResponse(this.questionEditor.getValue()); goToNext(); }); @@ -176,13 +180,14 @@ public class SubmissionView extends Main implements HasUrlParameter { 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 { 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 { } @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) { diff --git a/src/main/resources/checkstyle.xml b/src/main/resources/checkstyle.xml new file mode 100644 index 0000000..216d48d --- /dev/null +++ b/src/main/resources/checkstyle.xml @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file