diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..31d6a44 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..a0dc2ef --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + development-empmanager + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.wst.jsdt.core.jsNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..cca691f --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..49c8cd4 --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.JRE_CONTAINER \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..11006e2 --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Global \ No newline at end of file diff --git a/src/com/rhizome/example/access/EmployeeAccess.java b/src/com/rhizome/example/access/EmployeeAccess.java index 4eb9e4b..f5cfef3 100644 --- a/src/com/rhizome/example/access/EmployeeAccess.java +++ b/src/com/rhizome/example/access/EmployeeAccess.java @@ -15,6 +15,34 @@ public class EmployeeAccess extends BaseAccess { public EmployeeAccess() { super(EMPDATA_FILEPATH); } + + + public List allSelect() throws FileNotFoundException { + + //全件データ + List allList = new ArrayList<>(); + + //取得用リスト(CSV形式) + List csvList = readData(); + //CSVデータを1行で出力 + + for (String line : csvList) { + //インスタンス生成 + EmployeeData employee = new EmployeeData(); + //,=空白、[5]まで行ったら終了 + String[] columns = line.split(","); + employee.setIdEmployee(columns[0]); + employee.setNmEmployee(columns[1]); + employee.setKnEmployee(columns[2]); + employee.setMailAddress(columns[3]); + employee.setPassword(columns[4]); + employee.setIdDepartment(columns[5]); + allList.add(employee); + } + return allList; + + + } @Override public List selectById(String key) throws FileNotFoundException { diff --git a/src/com/rhizome/example/main/Main.java b/src/com/rhizome/example/main/Main.java index a08fa53..5cd3b92 100644 --- a/src/com/rhizome/example/main/Main.java +++ b/src/com/rhizome/example/main/Main.java @@ -41,7 +41,7 @@ public class Main { switch (ope) { case "1": //検索 - empSelect(); + empSel(); break; case "2": //登録 empInsert(); @@ -60,13 +60,64 @@ public class Main { break; } } - + /** - * 社員ファイルから情報を検索する - * - * @throws FileNotFoundException - */ - public void empSelect() throws FileNotFoundException { + * 検索方法を選択する + * @Override + * @throws FileNotFoundException + */ + public void empSel() throws FileNotFoundException { + //検索方法の選択 + System.out.println("1:全検索 2:条件検索 それ以外:戻る"); + String sel = sc.nextLine(); + + switch (sel) { + case "1": //全検索 + empList(); + break; + case "2": //条件検索 + empSelect(); + break; + default: //それ以外:戻る + break; + } + } + + /** + * 全検索で一覧を表示する + * + * @throws FileNotFoundException + */ + public void empList() throws FileNotFoundException { + List allList; + + //一覧データ取得 + EmployeeAccess all = new EmployeeAccess(); + + allList = all.allSelect(); + if (allList.size() == 0) { //取得結果が0件の場合 + System.out.println("入力された値で情報がみつかりませんでした"); + } + //for文を10回繰り返す + for(int) { + System.out.println(employee.toString()); + } + + //取得結果件数分、データをタブ区切りで出力する + /*for (BaseData employee : allList) { + System.out.println(employee.toString()); + }*/ + + System.out.println(allList); + + } + + /** + * 社員ファイルから情報を検索する + * + * @throws FileNotFoundException + */ + public void empSelect() throws FileNotFoundException { EmployeeAccess ea = new EmployeeAccess(); List list;