[POLICY-73] replace openecomp for policy-engine
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / controller / DictionaryImportController.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PAP-REST
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.pap.xacml.rest.controller;
22  /*
23   * 
24   * 
25   * */
26 import java.io.File;
27 import java.io.FileOutputStream;
28 import java.io.FileReader;
29 import java.io.OutputStream;
30 import java.util.List;
31
32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse;
34
35 import org.apache.commons.compress.utils.IOUtils;
36 import org.onap.policy.rest.dao.CommonClassDao;
37 import org.onap.policy.rest.jpa.ActionList;
38 import org.onap.policy.rest.jpa.ActionPolicyDict;
39 import org.onap.policy.rest.jpa.AddressGroup;
40 import org.onap.policy.rest.jpa.Attribute;
41 import org.onap.policy.rest.jpa.BRMSParamTemplate;
42 import org.onap.policy.rest.jpa.Category;
43 import org.onap.policy.rest.jpa.Datatype;
44 import org.onap.policy.rest.jpa.DecisionSettings;
45 import org.onap.policy.rest.jpa.DescriptiveScope;
46 import org.onap.policy.rest.jpa.OnapName;
47 import org.onap.policy.rest.jpa.GroupServiceList;
48 import org.onap.policy.rest.jpa.PEPOptions;
49 import org.onap.policy.rest.jpa.PrefixList;
50 import org.onap.policy.rest.jpa.ProtocolList;
51 import org.onap.policy.rest.jpa.SecurityZone;
52 import org.onap.policy.rest.jpa.ServiceList;
53 import org.onap.policy.rest.jpa.TermList;
54 import org.onap.policy.rest.jpa.UserInfo;
55 import org.onap.policy.rest.jpa.VNFType;
56 import org.onap.policy.rest.jpa.VSCLAction;
57 import org.onap.policy.rest.jpa.VarbindDictionary;
58 import org.onap.policy.rest.jpa.Zone;
59 import org.springframework.beans.factory.annotation.Autowired;
60 import org.springframework.stereotype.Controller;
61 import org.springframework.web.bind.annotation.RequestMapping;
62
63 import com.fasterxml.jackson.databind.DeserializationFeature;
64 import com.fasterxml.jackson.databind.ObjectMapper;
65
66 import au.com.bytecode.opencsv.CSVReader;
67
68
69 @Controller
70 public class DictionaryImportController {
71         private String newFile;
72
73         private static CommonClassDao commonClassDao;
74         
75         @Autowired
76         public DictionaryImportController(CommonClassDao commonClassDao){
77                 DictionaryImportController.commonClassDao = commonClassDao;
78         }
79         
80         public DictionaryImportController(){}   
81
82
83         @RequestMapping(value={"/dictionary/import_dictionary"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
84         public void ImportDictionaryData(HttpServletRequest request, HttpServletResponse response) throws Exception{
85                 ObjectMapper mapper = new ObjectMapper();
86                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
87                 //JsonNode root = mapper.readTree(request.getReader());
88                 String userId = request.getParameter("userId");
89                 String dictionaryName = request.getParameter("dictionaryName");
90
91                 File file = new File(dictionaryName);
92                 OutputStream outputStream = new FileOutputStream(file);
93                 IOUtils.copy(request.getInputStream(), outputStream);
94                 outputStream.close();
95                 this.newFile = file.toString();
96                 CSVReader csvReader = new CSVReader(new FileReader(this.newFile));
97                 List<String[]> dictSheet = csvReader.readAll();
98                 if(dictionaryName.startsWith("Attribute")){
99                         for(int i = 1; i< dictSheet.size(); i++){
100                                 Attribute attribute = new Attribute("");
101                                 UserInfo userinfo = new UserInfo();
102                                 userinfo.setUserLoginId(userId);
103                                 attribute.setUserCreatedBy(userinfo);
104                                 attribute.setUserModifiedBy(userinfo);
105                                 String[] rows = dictSheet.get(i);
106                                 for (int j=0 ; j<rows.length; j++ ){
107                                         if(dictSheet.get(0)[j].equalsIgnoreCase("xacml_id") || dictSheet.get(0)[j].equalsIgnoreCase("Attribute ID")){
108                                                 attribute.setXacmlId(rows[j]);
109                                         }
110                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
111                                                 attribute.setDescription(rows[j]);
112                                         }
113                                         if(dictSheet.get(0)[j].equalsIgnoreCase("priority")){
114                                                 attribute.setPriority(rows[j]);
115                                         }
116                                         if(dictSheet.get(0)[j].equalsIgnoreCase("datatype") || dictSheet.get(0)[j].equalsIgnoreCase("Data Type")){
117                                                 Datatype dataType = new Datatype();
118                                                 if(rows[j].equalsIgnoreCase("string")){
119                                                         dataType.setId(26);
120                                                 }else if(rows[j].equalsIgnoreCase("integer")){
121                                                         dataType.setId(12);
122                                                 }else if(rows[j].equalsIgnoreCase("double")){
123                                                         dataType.setId(25);
124                                                 }else if(rows[j].equalsIgnoreCase("boolean")){
125                                                         dataType.setId(18);
126                                                 }else if(rows[j].equalsIgnoreCase("user")){
127                                                         dataType.setId(29);
128                                                 }
129                                                 attribute.setDatatypeBean(dataType);
130                                                 Category category = new Category();
131                                                 category.setId(5);
132                                                 attribute.setCategoryBean(category);
133                                         }
134                                         if(dictSheet.get(0)[j].equalsIgnoreCase("attribute_value") || dictSheet.get(0)[j].equalsIgnoreCase("Attribute Value")){
135                                                 attribute.setAttributeValue(rows[j]);
136                                         }
137                                 }
138                                 commonClassDao.save(attribute);
139                         }
140                 }
141                 if(dictionaryName.startsWith("ActionPolicyDictionary")){
142                         for(int i = 1; i< dictSheet.size(); i++){
143                                 ActionPolicyDict attribute = new ActionPolicyDict("",  userId);
144                                 UserInfo userinfo = new UserInfo();
145                                 userinfo.setUserLoginId(userId);
146                                 attribute.setUserCreatedBy(userinfo);
147                                 attribute.setUserModifiedBy(userinfo);
148                                 String[] rows = dictSheet.get(i);
149                                 for (int j=0 ; j<rows.length; j++ ){
150                                         if(dictSheet.get(0)[j].equalsIgnoreCase("attribute_name") || dictSheet.get(0)[j].equalsIgnoreCase("Attribute Name")){
151                                                 attribute.setAttributeName(rows[j]);
152                                         }
153                                         if(dictSheet.get(0)[j].equalsIgnoreCase("body")){
154                                                 attribute.setBody(rows[j]);
155                                         }
156                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
157                                                 attribute.setDescription(rows[j]);
158                                         }
159                                         if(dictSheet.get(0)[j].equalsIgnoreCase("headers")){
160                                                 attribute.setHeader(rows[j]);
161                                         }
162                                         if(dictSheet.get(0)[j].equalsIgnoreCase("method")){
163                                                 attribute.setMethod(rows[j]);
164                                         }
165                                         if(dictSheet.get(0)[j].equalsIgnoreCase("type")){
166                                                 attribute.setMethod(rows[j]);
167                                         }
168                                         if(dictSheet.get(0)[j].equalsIgnoreCase("url")){
169                                                 attribute.setMethod(rows[j]);
170                                         }
171                                 }
172                                 commonClassDao.save(attribute);
173                         }
174                 }
175                 if(dictionaryName.startsWith("OnapName")){
176                         for(int i = 1; i< dictSheet.size(); i++){
177                                 OnapName attribute = new OnapName("",  userId);
178                                 UserInfo userinfo = new UserInfo();
179                                 userinfo.setUserLoginId(userId);
180                                 attribute.setUserCreatedBy(userinfo);
181                                 attribute.setUserModifiedBy(userinfo);
182                                 String[] rows = dictSheet.get(i);
183                                 for (int j=0 ; j<rows.length; j++ ){
184                                         if(dictSheet.get(0)[j].equalsIgnoreCase("onap_name") || dictSheet.get(0)[j].equalsIgnoreCase("Onap Name")){
185                                                 attribute.setOnapName(rows[j]);
186                                         }
187                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
188                                                 attribute.setDescription(rows[j]);
189                                         }
190                                 }
191                                 commonClassDao.save(attribute);
192                         }
193                 }
194                 if(dictionaryName.startsWith("VNFType")){
195                         for(int i = 1; i< dictSheet.size(); i++){
196                                 VNFType attribute = new VNFType("",  userId);
197                                 UserInfo userinfo = new UserInfo();
198                                 userinfo.setUserLoginId(userId);
199                                 attribute.setUserCreatedBy(userinfo);
200                                 attribute.setUserModifiedBy(userinfo);
201                                 String[] rows = dictSheet.get(i);
202                                 for (int j=0 ; j<rows.length; j++ ){
203                                         if(dictSheet.get(0)[j].equalsIgnoreCase("vnf_type") || dictSheet.get(0)[j].equalsIgnoreCase("VNF Type")){
204                                                 attribute.setVnftype(rows[j]);
205                                         }
206                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
207                                                 attribute.setDescription(rows[j]);
208                                         }
209                                 }
210                                 commonClassDao.save(attribute);
211                         }
212                 }
213                 if(dictionaryName.startsWith("VSCLAction")){
214                         for(int i = 1; i< dictSheet.size(); i++){
215                                 VSCLAction attribute = new VSCLAction("",  userId);
216                                 UserInfo userinfo = new UserInfo();
217                                 userinfo.setUserLoginId(userId);
218                                 attribute.setUserCreatedBy(userinfo);
219                                 attribute.setUserModifiedBy(userinfo);
220                                 String[] rows = dictSheet.get(i);
221                                 for (int j=0 ; j<rows.length; j++ ){
222                                         if(dictSheet.get(0)[j].equalsIgnoreCase("vscl_action") || dictSheet.get(0)[j].equalsIgnoreCase("VSCL Action")){
223                                                 attribute.setVsclaction(rows[j]);
224                                         }
225                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
226                                                 attribute.setDescription(rows[j]);
227                                         }
228                                 }
229                                 commonClassDao.save(attribute);
230                         }
231                 }
232                 if(dictionaryName.startsWith("PEPOptions")){
233                         for(int i = 1; i< dictSheet.size(); i++){
234                                 PEPOptions attribute = new PEPOptions("",  userId);
235                                 UserInfo userinfo = new UserInfo();
236                                 userinfo.setUserLoginId(userId);
237                                 attribute.setUserCreatedBy(userinfo);
238                                 attribute.setUserModifiedBy(userinfo);
239                                 String[] rows = dictSheet.get(i);
240                                 for (int j=0 ; j<rows.length; j++ ){
241                                         if(dictSheet.get(0)[j].equalsIgnoreCase("PEP_NAME") || dictSheet.get(0)[j].equalsIgnoreCase("PEP Name")){
242                                                 attribute.setPepName(rows[j]);
243                                         }
244                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
245                                                 attribute.setDescription(rows[j]);
246                                         }
247                                         if(dictSheet.get(0)[j].equalsIgnoreCase("Actions")){
248                                                 attribute.setActions(rows[j]);
249                                         }
250                                 }
251                                 commonClassDao.save(attribute);
252                         }
253                 }
254                 if(dictionaryName.startsWith("VarbindDictionary")){
255                         for(int i = 1; i< dictSheet.size(); i++){
256                                 VarbindDictionary attribute = new VarbindDictionary("",  userId);
257                                 UserInfo userinfo = new UserInfo();
258                                 userinfo.setUserLoginId(userId);
259                                 attribute.setUserCreatedBy(userinfo);
260                                 attribute.setUserModifiedBy(userinfo);
261                                 String[] rows = dictSheet.get(i);
262                                 for (int j=0 ; j<rows.length; j++ ){
263                                         if(dictSheet.get(0)[j].equalsIgnoreCase("varbind_Name") || dictSheet.get(0)[j].equalsIgnoreCase("Varbind Name")){
264                                                 attribute.setVarbindName(rows[j]);
265                                         }
266                                         if(dictSheet.get(0)[j].equalsIgnoreCase("varbind_Description") || dictSheet.get(0)[j].equalsIgnoreCase("Varbind Description")){
267                                                 attribute.setVarbindDescription(rows[j]);
268                                         }
269                                         if(dictSheet.get(0)[j].equalsIgnoreCase("varbind_oid") || dictSheet.get(0)[j].equalsIgnoreCase("Varbind OID")){
270                                                 attribute.setVarbindOID(rows[j]);
271                                         }
272                                 }
273                                 commonClassDao.save(attribute);
274                         }
275                 }
276                 if(dictionaryName.startsWith("BRMSParamDictionary")){
277                         for(int i = 1; i< dictSheet.size(); i++){
278                                 BRMSParamTemplate attribute = new BRMSParamTemplate();
279                                 UserInfo userinfo = new UserInfo();
280                                 userinfo.setUserLoginId(userId);
281                                 attribute.setUserCreatedBy(userinfo);
282                                 String[] rows = dictSheet.get(i);
283                                 for (int j=0 ; j<rows.length; j++ ){
284                                         if(dictSheet.get(0)[j].equalsIgnoreCase("param_template_name") || dictSheet.get(0)[j].equalsIgnoreCase("Rule Name")){
285                                                 attribute.setRuleName(rows[j]);
286                                         }
287                                         if(dictSheet.get(0)[j].equalsIgnoreCase("DESCRIPTION") || dictSheet.get(0)[j].equalsIgnoreCase("Description")){
288                                                 attribute.setDescription(rows[j]);
289                                         }
290                                         if(dictSheet.get(0)[j].equalsIgnoreCase("rule")){
291                                                 attribute.setRule(rows[j]);
292                                         }
293                                 }
294                                 commonClassDao.save(attribute);
295                         }
296                 }
297                 if(dictionaryName.startsWith("Settings")){
298                         for(int i = 1; i< dictSheet.size(); i++){
299                                 DecisionSettings attribute = new DecisionSettings("",  userId);
300                                 UserInfo userinfo = new UserInfo();
301                                 userinfo.setUserLoginId(userId);
302                                 attribute.setUserCreatedBy(userinfo);
303                                 attribute.setUserModifiedBy(userinfo);
304                                 String[] rows = dictSheet.get(i);
305                                 for (int j=0 ; j<rows.length; j++ ){
306                                         if(dictSheet.get(0)[j].equalsIgnoreCase("xacml_id") || dictSheet.get(0)[j].equalsIgnoreCase("Settings ID")){
307                                                 attribute.setXacmlId(rows[j]);
308                                         }
309                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
310                                                 attribute.setDescription(rows[j]);
311                                         }
312                                         if(dictSheet.get(0)[j].equalsIgnoreCase("priority")){
313                                                 attribute.setPriority(rows[j]);
314                                         }
315                                         if(dictSheet.get(0)[j].equalsIgnoreCase("datatype") || dictSheet.get(0)[j].equalsIgnoreCase("Data Type")){
316                                                 Datatype dataType = new Datatype();
317                                                 if(rows[j].equalsIgnoreCase("string")){
318                                                         dataType.setId(26);
319                                                 }else if(rows[j].equalsIgnoreCase("integer")){
320                                                         dataType.setId(12);
321                                                 }else if(rows[j].equalsIgnoreCase("double")){
322                                                         dataType.setId(25);
323                                                 }else if(rows[j].equalsIgnoreCase("boolean")){
324                                                         dataType.setId(18);
325                                                 }else if(rows[j].equalsIgnoreCase("user")){
326                                                         dataType.setId(29);
327                                                 }
328                                                 attribute.setDatatypeBean(dataType);
329                                         }
330                                 }
331                                 commonClassDao.save(attribute);
332                         }
333                 }
334                 if(dictionaryName.startsWith("PrefixList")){
335                         for(int i = 1; i< dictSheet.size(); i++){
336                                 PrefixList attribute = new PrefixList("",  userId);
337                                 String[] rows = dictSheet.get(i);
338                                 for (int j=0 ; j<rows.length; j++ ){
339                                         if(dictSheet.get(0)[j].equalsIgnoreCase("prefixListName") || dictSheet.get(0)[j].equalsIgnoreCase("PrefixList Name")){
340                                                 attribute.setPrefixListName(rows[j]);
341                                         }
342                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
343                                                 attribute.setPrefixListValue(rows[j]);
344                                         }
345                                         if(dictSheet.get(0)[j].equalsIgnoreCase("prefixListValue") || dictSheet.get(0)[j].equalsIgnoreCase("PrefixList Value")){
346                                                 attribute.setDescription(rows[j]);
347                                         }
348                                 }
349                                 commonClassDao.save(attribute);
350                         }
351                 }
352                 if(dictionaryName.startsWith("SecurityZone")){
353                         for(int i = 1; i< dictSheet.size(); i++){
354                                 SecurityZone attribute = new SecurityZone("",  userId);
355                                 String[] rows = dictSheet.get(i);
356                                 for (int j=0 ; j<rows.length; j++ ){
357                                         if(dictSheet.get(0)[j].equalsIgnoreCase("zoneName") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Name")){
358                                                 attribute.setZoneName(rows[j]);
359                                         }
360                                         if(dictSheet.get(0)[j].equalsIgnoreCase("zoneValue")  || dictSheet.get(0)[j].equalsIgnoreCase("Zone Value")){
361                                                 attribute.setZoneValue(rows[j]);
362                                         }
363                                 }
364                                 commonClassDao.save(attribute);
365                         }
366                 }
367                 if(dictionaryName.startsWith("Zone")){
368                         for(int i = 1; i< dictSheet.size(); i++){
369                                 Zone attribute = new Zone("",  userId);
370                                 String[] rows = dictSheet.get(i);
371                                 for (int j=0 ; j<rows.length; j++ ){
372                                         if(dictSheet.get(0)[j].equalsIgnoreCase("zoneName") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Name")){
373                                                 attribute.setZoneName(rows[j]);
374                                         }
375                                         if(dictSheet.get(0)[j].equalsIgnoreCase("zoneValue")  || dictSheet.get(0)[j].equalsIgnoreCase("Zone Value")){
376                                                 attribute.setZoneValue(rows[j]);
377                                         }
378                                 }
379                                 commonClassDao.save(attribute);
380                         }
381                 }
382                 if(dictionaryName.startsWith("ServiceList")){
383                         for(int i = 1; i< dictSheet.size(); i++){
384                                 ServiceList attribute = new ServiceList("",  userId);
385                                 String[] rows = dictSheet.get(i);
386                                 for (int j=0 ; j<rows.length; j++ ){
387                                         if(dictSheet.get(0)[j].equalsIgnoreCase("serviceName") || dictSheet.get(0)[j].equalsIgnoreCase("Service Name")){
388                                                 attribute.setServiceName(rows[j]);
389                                         }
390                                         if(dictSheet.get(0)[j].equalsIgnoreCase("serviceDesc")  || dictSheet.get(0)[j].equalsIgnoreCase("Description")){
391                                                 attribute.setServiceDescription(rows[j]);
392                                         }
393                                         if(dictSheet.get(0)[j].equalsIgnoreCase("serviceType")  || dictSheet.get(0)[j].equalsIgnoreCase("Service Type")){
394                                                 attribute.setServiceType(rows[j]);
395                                         }
396                                         if(dictSheet.get(0)[j].equalsIgnoreCase("serviceTrasProtocol")  || dictSheet.get(0)[j].equalsIgnoreCase("Transport Protocol")){
397                                                 attribute.setServiceTransProtocol(rows[j]);
398                                         }
399                                         if(dictSheet.get(0)[j].equalsIgnoreCase("serviceAppProtocol")  || dictSheet.get(0)[j].equalsIgnoreCase("APP Protocol")){
400                                                 attribute.setServiceAppProtocol(rows[j]);
401                                         }
402                                         if(dictSheet.get(0)[j].equalsIgnoreCase("servicePorts")  || dictSheet.get(0)[j].equalsIgnoreCase("Ports")){
403                                                 attribute.setServicePorts(rows[j]);
404                                         }
405                                 }
406                                 commonClassDao.save(attribute);
407                         }
408                 }
409                 if(dictionaryName.startsWith("ServiceGroup")){
410                         for(int i = 1; i< dictSheet.size(); i++){
411                                 GroupServiceList attribute = new GroupServiceList("",  userId);
412                                 String[] rows = dictSheet.get(i);
413                                 for (int j=0 ; j<rows.length; j++ ){
414                                         if(dictSheet.get(0)[j].equalsIgnoreCase("name") || dictSheet.get(0)[j].equalsIgnoreCase("Group Name")){
415                                                 attribute.setGroupName(rows[j]);
416                                         }
417                                         if(dictSheet.get(0)[j].equalsIgnoreCase("serviceList")  || dictSheet.get(0)[j].equalsIgnoreCase("Service List")){
418                                                 attribute.setServiceList(rows[j]);
419                                         }
420                                 }
421                                 commonClassDao.save(attribute);
422                         }
423                 }
424                 if(dictionaryName.startsWith("AddressGroup")){
425                         for(int i = 1; i< dictSheet.size(); i++){
426                                 AddressGroup attribute = new AddressGroup("",  userId);
427                                 String[] rows = dictSheet.get(i);
428                                 for (int j=0 ; j<rows.length; j++ ){
429                                         if(dictSheet.get(0)[j].equalsIgnoreCase("name") || dictSheet.get(0)[j].equalsIgnoreCase("Group Name")){
430                                                 attribute.setGroupName(rows[j]);
431                                         }
432                                         if(dictSheet.get(0)[j].equalsIgnoreCase("serviceList")  || dictSheet.get(0)[j].equalsIgnoreCase("Prefix List")){
433                                                 attribute.setServiceList(rows[j]);
434                                         }
435                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
436                                                 attribute.setDescription(rows[j]);
437                                         }
438                                 }
439                                 commonClassDao.save(attribute);
440                         }
441                 }
442                 if(dictionaryName.startsWith("ProtocolList")){
443                         for(int i = 1; i< dictSheet.size(); i++){
444                                 ProtocolList attribute = new ProtocolList("",  userId);
445                                 String[] rows = dictSheet.get(i);
446                                 for (int j=0 ; j<rows.length; j++ ){
447                                         if(dictSheet.get(0)[j].equalsIgnoreCase("protocolName") || dictSheet.get(0)[j].equalsIgnoreCase("Protocol Name")){
448                                                 attribute.setProtocolName(rows[j]);
449                                         }
450                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
451                                                 attribute.setDescription(rows[j]);
452                                         }
453                                 }
454                                 commonClassDao.save(attribute);
455                         }
456                 }
457                 if(dictionaryName.startsWith("ActionList")){
458                         for(int i = 1; i< dictSheet.size(); i++){
459                                 ActionList attribute = new ActionList("",  userId);
460                                 String[] rows = dictSheet.get(i);
461                                 for (int j=0 ; j<rows.length; j++ ){
462                                         if(dictSheet.get(0)[j].equalsIgnoreCase("actionName") || dictSheet.get(0)[j].equalsIgnoreCase("Action Name")){
463                                                 attribute.setActionName(rows[j]);
464                                         }
465                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
466                                                 attribute.setDescription(rows[j]);
467                                         }
468                                 }
469                                 commonClassDao.save(attribute);
470                         }
471                 }
472                 if(dictionaryName.startsWith("TermList")){
473                         for(int i = 1; i< dictSheet.size(); i++){
474                                 TermList attribute = new TermList("",  userId);
475                                 UserInfo userinfo = new UserInfo();
476                                 userinfo.setUserLoginId(userId);
477                                 attribute.setUserCreatedBy(userinfo);
478                                 attribute.setUserModifiedBy(userinfo);
479                                 String[] rows = dictSheet.get(i);
480                                 for (int j=0 ; j<rows.length; j++ ){
481                                         if(dictSheet.get(0)[j].equalsIgnoreCase("termName") || dictSheet.get(0)[j].equalsIgnoreCase("Term-Name")){
482                                                 attribute.setTermName(rows[j]);
483                                         }
484                                         if(dictSheet.get(0)[j].equalsIgnoreCase("Term-Description") || dictSheet.get(0)[j].equalsIgnoreCase("termDescription")){
485                                                 attribute.setDescription(rows[j]);
486                                         }
487                                         if(dictSheet.get(0)[j].equalsIgnoreCase("fromZone")  || dictSheet.get(0)[j].equalsIgnoreCase("From Zone")){
488                                                 attribute.setFromZones(rows[j]);
489                                         }
490                                         if(dictSheet.get(0)[j].equalsIgnoreCase("toZone") || dictSheet.get(0)[j].equalsIgnoreCase("To Zone")){
491                                                 attribute.setToZones(rows[j]);
492                                         }
493                                         if(dictSheet.get(0)[j].equalsIgnoreCase("srcIPList") || dictSheet.get(0)[j].equalsIgnoreCase("Source-IP-List")){
494                                                 attribute.setSrcIPList(rows[j]);
495                                         }
496                                         if(dictSheet.get(0)[j].equalsIgnoreCase("destIPList") || dictSheet.get(0)[j].equalsIgnoreCase("Destination-IP-List")){
497                                                 attribute.setDestIPList(rows[j]);
498                                         }
499                                         if(dictSheet.get(0)[j].equalsIgnoreCase("srcPortList") || dictSheet.get(0)[j].equalsIgnoreCase("Source-Port-List")){
500                                                 attribute.setSrcPortList(rows[j]);
501                                         }
502                                         if(dictSheet.get(0)[j].equalsIgnoreCase("destPortList") || dictSheet.get(0)[j].equalsIgnoreCase("Destination-Port-List")){
503                                                 attribute.setDestPortList(rows[j]);
504                                         }
505                                         if(dictSheet.get(0)[j].equalsIgnoreCase("action") || dictSheet.get(0)[j].equalsIgnoreCase("Action List")){
506                                                 attribute.setAction(rows[j]);
507                                         }
508                                 }
509                                 commonClassDao.save(attribute);
510                         }
511                 }
512                 if(dictionaryName.startsWith("SearchCriteria")){
513                         for(int i = 1; i< dictSheet.size(); i++){
514                                 DescriptiveScope attribute = new DescriptiveScope("",  userId);
515                                 UserInfo userinfo = new UserInfo();
516                                 userinfo.setUserLoginId(userId);
517                                 attribute.setUserCreatedBy(userinfo);
518                                 attribute.setUserModifiedBy(userinfo);
519                                 String[] rows = dictSheet.get(i);
520                                 for (int j=0 ; j<rows.length; j++ ){
521                                         if(dictSheet.get(0)[j].equalsIgnoreCase("descriptiveScopeName") || dictSheet.get(0)[j].equalsIgnoreCase("Descriptive ScopeName")){
522                                                 attribute.setScopeName(rows[j]);
523                                         }
524                                         if(dictSheet.get(0)[j].equalsIgnoreCase("description")){
525                                                 attribute.setDescription(rows[j]);
526                                         }
527                                         if(dictSheet.get(0)[j].equalsIgnoreCase("search") || dictSheet.get(0)[j].equalsIgnoreCase("Search Criteria")){
528                                                 attribute.setSearch(rows[j]);
529                                         }
530                                 }
531                                 commonClassDao.save(attribute);
532                         }
533                 }
534                 csvReader.close();
535                 if(file.exists()){
536                         file.delete();
537                 }
538         }
539 }