Search in sources :

Example 1 with Department

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;
}
Also used : Department(org.apache.ignite.console.demo.model.Department) ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with Department

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.");
}
Also used : Department(org.apache.ignite.console.demo.model.Department) Employee(org.apache.ignite.console.demo.model.Employee) Country(org.apache.ignite.console.demo.model.Country)

Aggregations

Department (org.apache.ignite.console.demo.model.Department)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 QueryEntity (org.apache.ignite.cache.QueryEntity)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 Country (org.apache.ignite.console.demo.model.Country)1 Employee (org.apache.ignite.console.demo.model.Employee)1