use of org.apache.ignite.console.demo.model.Department in project ignite by apache.
the class DemoCachesLoadService method cacheDepartment.
/**
* Configure cacheEmployee.
*/
private static CacheConfiguration cacheDepartment() {
CacheConfiguration ccfg = cacheConfiguration(DEPARTMENT_CACHE_NAME);
// Configure cacheDepartment types.
Collection<QueryEntity> qryEntities = new ArrayList<>();
// DEPARTMENT.
QueryEntity type = new QueryEntity();
qryEntities.add(type);
type.setKeyType(Integer.class.getName());
type.setValueType(Department.class.getName());
// Query fields for DEPARTMENT.
LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
qryFlds.put("id", "java.lang.Integer");
qryFlds.put("countryId", "java.lang.Integer");
qryFlds.put("name", "java.lang.String");
type.setFields(qryFlds);
ccfg.setQueryEntities(qryEntities);
return ccfg;
}
use of org.apache.ignite.console.demo.model.Department in project ignite by apache.
the class DemoCachesLoadService method populateCacheEmployee.
/**
*/
private void populateCacheEmployee() {
if (ignite.log().isDebugEnabled())
ignite.log().debug("DEMO: Start employees population with data...");
IgniteCache<Integer, Country> cacheCountry = ignite.cache(COUNTRY_CACHE_NAME);
for (int i = 0, n = 1; i < CNTR_CNT; i++, n++) cacheCountry.put(i, new Country(i, "Country #" + n, n * 10000000));
IgniteCache<Integer, Department> cacheDepartment = ignite.cache(DEPARTMENT_CACHE_NAME);
IgniteCache<Integer, Employee> cacheEmployee = ignite.cache(EMPLOYEE_CACHE_NAME);
for (int i = 0, n = 1; i < DEP_CNT; i++, n++) {
cacheDepartment.put(i, new Department(n, rnd.nextInt(CNTR_CNT), "Department #" + n));
double r = rnd.nextDouble();
cacheEmployee.put(i, new Employee(i, rnd.nextInt(DEP_CNT), null, "First name manager #" + n, "Last name manager #" + n, "Email manager #" + n, "Phone number manager #" + n, new java.sql.Date((long) (r * range)), "Job manager #" + n, 1000 + AgentDemoUtils.round(r * 4000, 2)));
}
for (int i = 0, n = 1; i < EMPL_CNT; i++, n++) {
Integer depId = rnd.nextInt(DEP_CNT);
double r = rnd.nextDouble();
cacheEmployee.put(i, new Employee(i, depId, depId, "First name employee #" + n, "Last name employee #" + n, "Email employee #" + n, "Phone number employee #" + n, new java.sql.Date((long) (r * range)), "Job employee #" + n, 500 + AgentDemoUtils.round(r * 2000, 2)));
}
if (ignite.log().isDebugEnabled())
ignite.log().debug("DEMO: Finished employees population.");
}
Aggregations