Skip to content

Commit

Permalink
remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Boaz Cahlon committed Oct 16, 2021
1 parent 1de5a67 commit 520591a
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 30 deletions.
27 changes: 20 additions & 7 deletions src/main/java/ui/LoginUI.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
package ui;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static javax.swing.LayoutStyle.ComponentPlacement.UNRELATED;

import javax.swing.*;
import java.awt.*;
import java.awt.Component;
import java.awt.Container;
import java.awt.Desktop;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.io.File;

import static javax.swing.LayoutStyle.ComponentPlacement.UNRELATED;
import javax.swing.AbstractAction;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoginUI extends JFrame {

private static Logger logger = LoggerFactory.getLogger(LoginUI.class);
private static final Logger logger = LoggerFactory.getLogger(LoginUI.class);

private static final String DEFAULT_COMPANY = "https://wix.net.hilan.co.il";
private static final String FOLDER_IMG_PATH = "/open_folder.png";
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/clients/AuthenticatedClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.fasterxml.jackson.databind.{JsonNode, ObjectMapper}
import com.gargoylesoftware.htmlunit.{HttpMethod, Page, WebClient, WebRequest}
import org.slf4j.LoggerFactory
import scrape.NoDataFoundException
import scala.jdk.CollectionConverters._

import scala.jdk.CollectionConverters._
import scala.util.{Failure, Success, Try}


Expand All @@ -17,7 +17,7 @@ class AuthenticatedClient(webClient: WebClient, username: String, orgId: String,
private val logger = LoggerFactory.getLogger(classOf[AuthenticatedClient])
private val mapper = new ObjectMapper

def getAllPayslipsDates(): Try[Seq[HilanDate]] = {
def fetchAllPayslipsDates(): Try[Seq[HilanDate]] = {
val request = new WebRequest(new URL(s"$baseUrl/Hilannetv2/Services/Public/WS/PaySlipApiapi.asmx/GetInitialData"), HttpMethod.POST)
request.setRequestBody(s"""{"employeeId":"$username"}""")
val pageWithDates = Try(webClient.getPage[Page](request).getWebResponse.getContentAsString())
Expand All @@ -31,7 +31,7 @@ class AuthenticatedClient(webClient: WebClient, username: String, orgId: String,
)
}

def getAllForm106Dates(): Try[Seq[HilanDate]] = {
def fetchAllForm106Dates(): Try[Seq[HilanDate]] = {
val request = new WebRequest(new URL(s"$baseUrl/Hilannetv2/Services/Public/WS/Form106Apiapi.asmx/GetInitialData"), HttpMethod.POST)
request.setRequestBody(s"""{"employeeId":"$username"}""")
val pageWithDates = Try(webClient.getPage[Page](request).getWebResponse.getContentAsString())
Expand Down
8 changes: 3 additions & 5 deletions src/main/scala/main/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ object Main {
.getOrElse(getUserInput(description))

private def runGUI(): Unit = {
EventQueue.invokeLater(new Runnable {
override def run(): Unit = {
val ex: LoginUI = new LoginUI()
ex.setVisible(true)
}
EventQueue.invokeLater(() => {
val ex: LoginUI = new LoginUI()
ex.setVisible(true)
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/scrape/Scraper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class Scraper(authenticatedClient: AuthenticatedClient) {

def downloadPayslips(folderPath: String): Try[Unit] = {
for {
payslipDates <- authenticatedClient.getAllPayslipsDates()
payslipDates <- authenticatedClient.fetchAllPayslipsDates()
downloaded <- downloadPayslipsToFolder(folderPath, payslipDates)
} yield downloaded
}

def downloadForm106s(folderPath: String): Try[Unit] = {
for {
form106Dates <- authenticatedClient.getAllForm106Dates()
form106Dates <- authenticatedClient.fetchAllForm106Dates()
downloaded <- downloadForm106sToFolder(Paths.get(folderPath, "Form106").toString, form106Dates)
} yield downloaded
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/util/ExcelExport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ object ExcelExport {

private def fillWorkSheet(data: Seq[(Key, Map[Date, Value])],
worksheet: HSSFSheet,
columnResolver: (Date => Int),
setCellValue: ((HSSFCell, Value) => Unit)): Unit = {
columnResolver: Date => Int,
setCellValue: (HSSFCell, Value) => Unit): Unit = {
data.zipWithIndex.foreach { case ((k, v), i) =>

val rowInWorkSheet = createRow(worksheet, k.info, k.notes.getOrElse(""), i + 1)
Expand All @@ -63,7 +63,7 @@ object ExcelExport {
createdRow
}

private def fillPayslipsWorkSheet(data: Seq[(Key, Map[Date, Value])], payslipsSheet: HSSFSheet, columnResolver: (Date => Int)): Unit = {
private def fillPayslipsWorkSheet(data: Seq[(Key, Map[Date, Value])], payslipsSheet: HSSFSheet, columnResolver: Date => Int): Unit = {

val pensionData = data.filter(isPension).zipWithIndex

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/util/MathUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object MathUtil {
}

implicit class Numbers(val str: String) extends AnyVal {
def removeCommas: String = str.replace(",", "")
def removeCommas(): String = str.replace(",", "")
}

}
2 changes: 1 addition & 1 deletion src/test/scala/clients/ClientTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ClientTest extends SpecWithJUnit {

"extract OrgId From Text" in new Ctx {
val text = "\\u003c/div\\u003e\\\\r\\\\n\\u003c/div\\u003e\\\\r\\\\n{{/if}}\\\\r\\\\n\\\\r\\\\n\\\",\\\"templateId\\\":null,\\\"initialData\\\":{\\\"OrgId\\\":\\\"2013\\\",\\\"IsShowOrganizationSelection\\\":false,\\\"IsShowId\\\":false,\\\"IsShowOrgLogo\\\":false,\\\"IsShowForgotPassword\\\":true,\\\"IsShowForgotPasswordHelp\\\":true,\\\"OrgName\\\":\\\"WIX\\\",\\\"Culture\\\":\\\"en-US\\\",\\\"SiteType\\\":1,\\\"Code\\\":0,\\\"IsMobileApp\\\":false,\\\"OCookie\\\":null,\\\"ErrorMessage\\\":null,\\\"IsUseIdAsEmployeeId\\\":false,\\\"IsBlocked\\\":false,\\\"VmName\\\":null,\\\"Title\\\":null}}'));"
val orgId = client.extractOrgIdFromPage(text)
val orgId: Option[String] = client.extractOrgIdFromPage(text)
orgId must beSome("2013")
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/data/DataExtractorTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package data

import java.util.GregorianCalendar
import java.util.{Date, GregorianCalendar}

import org.specs2.mutable.SpecificationWithJUnit
import org.specs2.specification.Scope
Expand All @@ -26,10 +26,10 @@ class DataExtractorTest extends SpecificationWithJUnit {
}

"merge info from two lines into one if possible" in new Context {
val info = DataExtractor.getLinesByKey(payslip)
val info: Map[String, List[String]] = DataExtractor.getLinesByKey(payslip)
info must havePair("064 מנורה משלימה קצבה שכיר-תג." -> List("5,001.00 6.25 312.56", "5,001.00 5.75 287.55"))

val merged = DataExtractor.mergeInfoSplitIntoTwoLines(info)
val merged: Map[String, List[String]] = DataExtractor.mergeInfoSplitIntoTwoLines(info)
merged must havePair("064 מנורה משלימה קצבה שכיר-תג." -> List("5001.0 6.25 312.56 5.75 287.55"))
}

Expand All @@ -47,7 +47,7 @@ class DataExtractorTest extends SpecificationWithJUnit {
}

class Context extends Scope {
val date = new GregorianCalendar(2016, 4, 1).getTime
val date: Date = new GregorianCalendar(2016, 4, 1).getTime

val payslip: String =
"""
Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/util/HebrewUtilTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class HebrewUtilTest extends SpecificationWithJUnit {
}

class Ctx extends Scope {
val hebrewText =
val hebrewText: String =
"""|-1,234.56 -10,000.00 04/16 םייוציפ ינמז הבצק מ.ב 002
|1,098.76 5.50 11,123.00 .גת-ריכש הבצק היסנפ ןרק לארה 047
|-1,111 35% א45 ףיעסל יוכינ
|1,000.00 ESPP לארשי 680""".stripMargin
|1,098.76 5.50 11,123.00 .גת-ריכש הבצק היסנפ ןרק לארה 047
|-1,111 35% א45 ףיעסל יוכינ
|1,000.00 ESPP לארשי 680""".stripMargin
}

}

0 comments on commit 520591a

Please sign in to comment.