esoe
2 years ago
12 changed files with 163 additions and 13 deletions
Binary file not shown.
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
package ru.egspt.implant; |
||||
|
||||
public class ExtendedUser { |
||||
private String fullname; |
||||
private String position; |
||||
private String psk; |
||||
private String username; |
||||
/** |
||||
* Основной конструктор полей расширенного пользователя |
||||
* @param builder |
||||
*/ |
||||
private ExtendedUser(ExtendedUserBuilder builder){ |
||||
fullname = builder.fullname; |
||||
position = builder.position; |
||||
psk = builder.psk; |
||||
username = builder.username; |
||||
} |
||||
/** |
||||
* Класс-строитель объектов ExtendedUser |
||||
*/ |
||||
public static class ExtendedUserBuilder{ |
||||
private String fullname; |
||||
private String position; |
||||
private String psk; |
||||
private String username; |
||||
|
||||
/** |
||||
* Основной конструктор класса с обязательным полем username |
||||
* @param username |
||||
*/ |
||||
public ExtendedUserBuilder(String username){ |
||||
this.username = username; |
||||
} |
||||
|
||||
/** |
||||
* @param fullname the fullname to set |
||||
*/ |
||||
public ExtendedUserBuilder setFullname(String fullname) { |
||||
this.fullname = fullname; |
||||
return this; |
||||
} |
||||
/** |
||||
* @param position the position to set |
||||
*/ |
||||
public ExtendedUserBuilder setPosition(String position) { |
||||
this.position = position; |
||||
return this; |
||||
} |
||||
/** |
||||
* @param psk the psk to set |
||||
*/ |
||||
public ExtendedUserBuilder setPsk(String psk) { |
||||
this.psk = psk; |
||||
return this; |
||||
} |
||||
public ExtendedUser build(){ |
||||
return new ExtendedUser(this); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
package ru.egspt.implant; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
|
||||
import org.apache.poi.ss.usermodel.Row; |
||||
import org.apache.poi.xssf.usermodel.XSSFSheet; |
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
||||
|
||||
import ru.egspt.implant.ExtendedUser.ExtendedUserBuilder; |
||||
|
||||
/** |
||||
* Данные из файлов excel, для консолидации с data при формировании полного отчета |
||||
*/ |
||||
public class Implant { |
||||
ArrayList<ExtendedUser> users = new ArrayList<>(); |
||||
public Implant(File file){ |
||||
// создание самого excel файла в памяти
|
||||
try(FileInputStream fis = new FileInputStream(file)){ |
||||
XSSFWorkbook book = new XSSFWorkbook(new FileInputStream(file)); |
||||
XSSFSheet sheet = book.getSheetAt(0); |
||||
for (Row row : sheet) { |
||||
if (row.getRowNum() == 0){ |
||||
continue; //строка заголовков
|
||||
} |
||||
String username = row.getCell(0).getStringCellValue(); |
||||
String fullname = row.getCell(1).getStringCellValue(); |
||||
String position = row.getCell(2).getStringCellValue(); |
||||
String psk = row.getCell(3).getStringCellValue(); |
||||
ExtendedUser eu = new ExtendedUserBuilder(username) |
||||
.setFullname(fullname) |
||||
.setPosition(position) |
||||
.setPsk(psk) |
||||
.build(); |
||||
users.add(eu); |
||||
} |
||||
book.close(); |
||||
}catch(IOException e){ |
||||
System.out.println("Путь к исходному файлу указан не верно!"); |
||||
System.out.println(e.getMessage()); |
||||
} |
||||
} |
||||
/** |
||||
* @param users the users to set |
||||
*/ |
||||
public void setUsers(ArrayList<ExtendedUser> users) { |
||||
this.users = users; |
||||
} |
||||
/** |
||||
* @return the users |
||||
*/ |
||||
public ArrayList<ExtendedUser> getUsers() { |
||||
return users; |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
package ru.egspt.implant; |
||||
|
||||
import java.util.ArrayList; |
||||
|
||||
import ru.egspt.Base; |
||||
import ru.egspt.Data; |
||||
import ru.egspt.Quiz; |
||||
import ru.egspt.Result; |
||||
import ru.egspt.User; |
||||
|
||||
public class Runner { |
||||
private Base base; |
||||
private Data data; |
||||
|
||||
/** |
||||
* @param base the base to set |
||||
*/ |
||||
public void setBase(Base base) { |
||||
this.base = base; |
||||
} |
||||
/** |
||||
* @return the base |
||||
*/ |
||||
public Base getBase() { |
||||
return base; |
||||
} |
||||
public static void main(String[] args) { |
||||
Runner r = new Runner(); |
||||
r.base = new Base("www.egspt.ru", "esoe", "psalm6912"); |
||||
r.base.connect(); |
||||
|
||||
r.data = new Data(); |
||||
ArrayList<Quiz> quizes = r.data.getQuizesFromBase(r.base); |
||||
ArrayList<Result> results = r.data.getResultsFromBase(r.base); |
||||
ArrayList<User> users = r.data.getUsersFromBase(r.base); |
||||
|
||||
} |
||||
|
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue