use of jp.co.nexus.crm.db.Area in project CRMWebApp by jshioya0506.
the class DBDataSetExecutor method createAreaMap.
private static Map<Integer, Area> createAreaMap(ObjectContext context) throws IOException {
File csvFile = new File(CSV_DIR, DBConstants.AREA + ".csv");
if (!csvFile.exists()) {
throw new FileNotFoundException("CSVファイルが存在しません。[" + csvFile.getName() + "]");
}
// CSVからサンプルデータを読み込み
LOGGER.info("エリアテーブルのcsvファイルからサンプルデータをロード開始。");
CSVFileReader reader = new CSVFileReader();
List<Map<String, Object>> dataMaps = reader.readData(csvFile);
LOGGER.debug("dataMaps=" + dataMaps);
// テーブルオブジェクトにデータを設定し、テーブルにデータを登録
LOGGER.info("サンプルデータをエリアテーブルのモデルに設定。");
Map<Integer, Area> areaMap = new HashMap<Integer, Area>();
for (Map<String, Object> dataMap : dataMaps) {
// データ登録対象のテーブルオブジェクトを取得
Area dataObj = context.newObject(Area.class);
// テーブルオブジェクトにデータを設定
for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
dataObj.writeProperty(entry.getKey(), entry.getValue());
}
int areaCode = dataObj.getAreaCd();
areaMap.put(areaCode, dataObj);
}
return areaMap;
}
use of jp.co.nexus.crm.db.Area in project CRMWebApp by jshioya0506.
the class DBDataSetExecutor method createCustomerMap.
private static Map<Integer, NCCustomer> createCustomerMap(ObjectContext context, Map<Integer, Area> areaMap, Map<Integer, Employee> employeeMap) throws IOException {
File csvFile = new File(CSV_DIR, DBConstants.NC_CUSTOMER + ".csv");
if (!csvFile.exists()) {
throw new FileNotFoundException("CSVファイルが存在しません。[" + csvFile.getName() + "]");
}
// CSVからサンプルデータを読み込み
LOGGER.info("顧客管理テーブルのcsvファイルからサンプルデータをロード開始。");
CSVFileReader reader = new CSVFileReader();
List<Map<String, Object>> dataMaps = reader.readData(csvFile);
LOGGER.info("dataMaps=" + dataMaps);
// テーブルオブジェクトにデータを設定し、テーブルにデータを登録
LOGGER.info("サンプルデータを顧客管理テーブルのモデルに設定。");
int id = 1;
Map<Integer, NCCustomer> customerMap = new HashMap<Integer, NCCustomer>();
for (Map<String, Object> dataMap : dataMaps) {
// データ登録対象のテーブルオブジェクトを取得
NCCustomer dataObj = context.newObject(NCCustomer.class);
// テーブルオブジェクトにデータを設定
for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
if ("area".equals(entry.getKey())) {
Integer areaCd = (Integer) entry.getValue();
Area area = areaMap.get(areaCd);
dataObj.setArea(area);
area.getCustomers().add(dataObj);
} else if ("employee".equals(entry.getKey())) {
Integer empNo = (Integer) entry.getValue();
Employee employee = employeeMap.get(empNo);
dataObj.setEmployee(employee);
employee.getCustomers().add(dataObj);
} else {
dataObj.writeProperty(entry.getKey(), entry.getValue());
}
}
customerMap.put(Integer.valueOf(id), dataObj);
}
return customerMap;
}
use of jp.co.nexus.crm.db.Area in project CRMWebApp by jshioya0506.
the class DBDataSetExecutor method createEmployeeMap.
private static Map<Integer, Employee> createEmployeeMap(ObjectContext context, Map<Integer, Area> areaMap) throws IOException {
File csvFile = new File(CSV_DIR, DBConstants.EMPLOYEE + ".csv");
if (!csvFile.exists()) {
throw new FileNotFoundException("CSVファイルが存在しません。[" + csvFile.getName() + "]");
}
// CSVからサンプルデータを読み込み
LOGGER.info("職員テーブルのcsvファイルからサンプルデータをロード開始。");
CSVFileReader reader = new CSVFileReader();
List<Map<String, Object>> dataMaps = reader.readData(csvFile);
LOGGER.info("dataMaps=" + dataMaps);
// テーブルオブジェクトにデータを設定し、テーブルにデータを登録
LOGGER.info("サンプルデータを職員テーブルのモデルに設定。");
Map<Integer, Employee> employeeMap = new HashMap<Integer, Employee>();
for (Map<String, Object> dataMap : dataMaps) {
// データ登録対象のテーブルオブジェクトを取得
Employee dataObj = context.newObject(Employee.class);
;
// テーブルオブジェクトにデータを設定
for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
if ("area".equals(entry.getKey())) {
Integer areaCd = (Integer) entry.getValue();
Area area = areaMap.get(areaCd);
dataObj.setArea(area);
area.getEmployees().add(dataObj);
} else {
dataObj.writeProperty(entry.getKey(), entry.getValue());
}
}
int empNo = dataObj.getEmpNo();
employeeMap.put(empNo, dataObj);
}
return employeeMap;
}
Aggregations