Subversion Repositories SmartDukaan

Rev

Rev 33124 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33124 Rev 33128
Line 84... Line 84...
84
        map.put(ProfitMandiConstants.CITIES, cities);
84
        map.put(ProfitMandiConstants.CITIES, cities);
85
        return map;
85
        return map;
86
    }
86
    }
87
 
87
 
88
    @Override
88
    @Override
-
 
89
    //Get descriptions
89
    public Map<String, Object> getAreasAndTerritoriesByStateName(String stateName) {
90
    public List<AST> getAreasAndTerritoriesByStateName(String stateName) {
90
        int stateId = stateRepository.selectByName(stateName).getId();
91
        int stateId = stateRepository.selectByName(stateName).getId();
91
        List<AST> astList = astRepository.selectByStateId(stateId);
92
        List<AST> astList = astRepository.selectByStateId(stateId);
92
        Map<String, Object> result = new HashMap<>();
-
 
93
        List<Map<String, Object>> astInfoList = new ArrayList<>();
-
 
94
 
93
 
95
        for (AST ast : astList) {
94
        for (AST ast : astList) {
96
            Map<String, Object> astInfoMap = new HashMap<>();
-
 
97
            astInfoMap.put("ast_id", ast.getId());
-
 
98
 
-
 
99
            // Fetch territory descriptions from repository
95
            // Fetch territory descriptions from repository
100
            List<Territory> territoryList = territoryRepository.selectByName(ast.getTerritory());
96
            Territory territory = territoryRepository.selectByName(ast.getTerritory());
101
            if (!territoryList.isEmpty()) {
-
 
102
                Territory territory = territoryList.get(0); // Assuming territory names are unique
-
 
103
                Map<String, String> territoryMap = new HashMap<>();
-
 
104
                territoryMap.put("name", ast.getTerritory());
-
 
105
                territoryMap.put("description", territory.getDescription());
97
            ast.setTerritoryDescription(territory.getDescription());
106
                astInfoMap.put("territory", territoryMap);
-
 
107
            }
-
 
108
 
98
 
109
            // Fetch area descriptions from repository
-
 
110
            List<Area> areaList = areaRepository.selectByName(ast.getArea());
99
            Area area = areaRepository.selectByName(ast.getArea());
111
            if (!areaList.isEmpty()) {
-
 
112
                Area area = areaList.get(0); // Assuming area names are unique
-
 
113
                Map<String, String> areaMap = new HashMap<>();
-
 
114
                areaMap.put("name", ast.getArea());
-
 
115
                areaMap.put("description", area.getDescription());
100
            ast.setAreaDescription(area.getDescription());
116
                astInfoMap.put("area", areaMap);
-
 
117
            }
-
 
118
 
101
 
119
            astInfoList.add(astInfoMap);
-
 
120
        }
102
        }
121
 
-
 
122
        result.put("ast_info", astInfoList);
-
 
123
        return result;
-
 
124
    }
-
 
125
 
-
 
126
    @Override
-
 
127
    public Map<String, Object> getAreasAndTerritoriesByAstId(int astid) {
-
 
128
        List<AST> astList = astRepository.selectById(astid);
-
 
129
        Map<String, Object> result = new HashMap<>();
-
 
130
        List<Map<String, Object>> astInfoList = new ArrayList<>();
-
 
131
 
-
 
132
        for (AST ast : astList) {
-
 
133
            Map<String, Object> astInfoMap = new HashMap<>();
-
 
134
            astInfoMap.put("ast_id", ast.getId());
-
 
135
 
-
 
136
            // Fetch territory descriptions from repository
-
 
137
            List<Territory> territoryList = territoryRepository.selectByName(ast.getTerritory());
-
 
138
            if (!territoryList.isEmpty()) {
-
 
139
                Territory territory = territoryList.get(0); // Assuming territory names are unique
-
 
140
                Map<String, String> territoryMap = new HashMap<>();
-
 
141
                territoryMap.put("name", ast.getTerritory());
-
 
142
                territoryMap.put("description", territory.getDescription());
-
 
143
                astInfoMap.put("territory", territoryMap);
-
 
144
            }
-
 
145
 
-
 
146
            // Fetch area descriptions from repository
-
 
147
            List<Area> areaList = areaRepository.selectByName(ast.getArea());
-
 
148
            if (!areaList.isEmpty()) {
-
 
149
                Area area = areaList.get(0); // Assuming area names are unique
-
 
150
                Map<String, String> areaMap = new HashMap<>();
-
 
151
                areaMap.put("name", ast.getArea());
-
 
152
                areaMap.put("description", area.getDescription());
-
 
153
                astInfoMap.put("area", areaMap);
-
 
154
            }
-
 
155
 
-
 
156
            astInfoList.add(astInfoMap);
-
 
157
        }
-
 
158
 
-
 
159
        result.put("ast_info", astInfoList);
-
 
160
        return result;
103
        return astList;
161
    }
104
    }
162
}
105
}