Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
group 'org.launchcode'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8
sourceCompatibility = 11

repositories {
mavenCentral()
Expand All @@ -15,3 +15,4 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation('org.apache.commons:commons-csv:1.4')
}
targetCompatibility = JavaVersion.VERSION_11
56 changes: 41 additions & 15 deletions src/main/java/JobData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.*;

/**
* Created by LaunchCode
Expand Down Expand Up @@ -48,6 +45,12 @@ public static ArrayList<String> findAll(String field) {
return values;
}

// private static void loadData() {
// if (isDataLoaded) {
// return;
// }
// }

public static ArrayList<HashMap<String, String>> findAll() {

// load data, if not already loaded
Expand Down Expand Up @@ -77,9 +80,9 @@ public static ArrayList<HashMap<String, String>> findByColumnAndValue(String col

for (HashMap<String, String> row : allJobs) {

String aValue = row.get(column);
String aValue = row.get(column).toLowerCase();

if (aValue.contains(value)) {
if (aValue.contains(value.toLowerCase())) {
jobs.add(row);
}
}
Expand All @@ -91,16 +94,23 @@ public static ArrayList<HashMap<String, String>> findByColumnAndValue(String col
* Search all columns for the given term
*
* @param value The search term to look for
* @return List of all jobs with at least one field containing the value
* @return List of all jobs with at least one field containing the value
*/
public static ArrayList<HashMap<String, String>> findByValue(String value) {

// load data, if not already loaded
loadData();

//
loadData();
ArrayList<HashMap<String, String>> jobs = new ArrayList<>();
for (HashMap<String, String> row : allJobs) {
for (String key : row.keySet()) {
String aValue = row.get(key);
if (aValue.toLowerCase().contains(value.toLowerCase())){
jobs.add(row);
break;
}}
// TODO - implement this method
return null;
// return jobs;
}
return jobs;}

/**
* Read in data from a CSV file and store it in a list
Expand Down Expand Up @@ -140,7 +150,23 @@ private static void loadData() {
} catch (IOException e) {
System.out.println("Failed to load job data");
e.printStackTrace();
}
}

}}
// public static ArrayList<HashMap<String, String>> findByValue(String value) {
//
// // load data, if not already loaded
// loadData();
// ArrayList<HashMap<String, String>> jobs = new ArrayList<>();
// for (HashMap<String, String> row : allJobs) {
// for (String key : row.keySet()) {
// String aValue = row.get(key);
// if (aValue.toLowerCase().contains(value.toLowerCase())){
// jobs.add(row);
// break;
// }}
// // TODO - implement this method
//// return jobs;
// }
// return jobs;
// }
// break;
}
66 changes: 57 additions & 9 deletions src/main/java/TechJobs.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;

/**
* Created by LaunchCode
*/
public class TechJobs {

static Scanner in = new Scanner(System.in);
// private static ArrayList<HashMap<String, String>> someJobs;

public static void main (String[] args) {
public static void main(String[] args) {

// Initialize our field map with key/name pairs
HashMap<String, String> columnChoices = new HashMap<>();
Expand Down Expand Up @@ -60,9 +61,10 @@ public static void main (String[] args) {
// What is their search term?
System.out.println("\nSearch term:");
String searchTerm = in.nextLine();
// System.out.println(searchTerm);

if (searchField.equals("all")) {
printJobs(JobData.findByValue(searchTerm));
printJobs(Objects.requireNonNull(JobData.findByValue(searchTerm)));
} else {
printJobs(JobData.findByColumnAndValue(searchField, searchTerm));
}
Expand All @@ -77,7 +79,7 @@ private static String getUserSelection(String menuHeader, HashMap<String, String
Boolean validChoice = false;
String[] choiceKeys = new String[choices.size()];

// Put the choices in an ordered structure so we can
// Put the choices in an ordered structure, so we can
// associate an integer with each one
int i = 0;
for (String choiceKey : choices.keySet()) {
Expand Down Expand Up @@ -112,14 +114,60 @@ private static String getUserSelection(String menuHeader, HashMap<String, String
validChoice = true;
}

} while(!validChoice);
} while (!validChoice);

return choiceKeys[choiceIdx];
}

// Print a list of jobs
private static void printJobs(ArrayList<HashMap<String, String>> someJobs) {
// HashMap<String, String> columnChoices = new HashMap<>();
// String path = "src//main//resources//job_data.csv";
// System.out.println(path);
// BufferedReader reader = null;
// String line = "";
// System.out.print("\n");

if (someJobs.isEmpty()) {
System.out.print("No Results");
} else {
for (HashMap<String, String> sJobs : someJobs) {
System.out.print("\n*****");
System.out.print("\n");
for (Map.Entry sJob : sJobs.entrySet()) {
System.out.println(sJob.getKey() + ": " + sJob.getValue());
}
System.out.print("*****");
System.out.print("\n");
}

System.out.println("printJobs is not implemented yet");
// try {
// reader = new BufferedReader(new FileReader(path));
// while ((line = reader.readLine()) != null) {
// String[] row = line.split(",");
//// String [] column = line.split("\n");
// System.out.println("*****" + "\n" + "position type: " + row[3] + "\n" + "name: " + row[0] + "\n" + "employer: " + row[1] + "\n" + "location: " + row[2] + "\n" + "core competency: " + row[4] + "\n" + "*****" + "\n");
//// for (String index : row ){
////// System.out.printf("%-10s", "\n" + index);
////// for (String indexes : row) {
//// System.out.printf(index[0] + "\n" + ": ");
//// }
// }
// System.out.println();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// try {
// reader.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//return someJobs;
}
}
}
// public static void setSomeJobs(Object someJobs) {
// TechJobs.someJobs = (ArrayList<HashMap<String, String>>) someJobs;
// }
//}