nexus site path corrected
[portal.git] / ecomp-portal-BE / src / main / java / org / openecomp / portalapp / portal / service / EPAuditServiceImpl.java
1 /*-
2  * ================================================================================
3  * eCOMP Portal
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
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  * ================================================================================
19  */
20 package org.openecomp.portalapp.portal.service;
21
22
23 import java.util.Date;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.context.annotation.EnableAspectJAutoProxy;
30 import org.springframework.stereotype.Service;
31 import org.springframework.transaction.annotation.Transactional;
32
33 import org.openecomp.portalsdk.core.service.DataAccessService;
34 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
35
36 @Service("epAuditService")
37 @Transactional
38 @org.springframework.context.annotation.Configuration
39 @EnableAspectJAutoProxy
40 @EPMetricsLog
41 public class EPAuditServiceImpl implements EPAuditService {
42
43         @Autowired
44         private DataAccessService  dataAccessService;
45
46         @Override
47         /* get the guest last login time with attuid as param.
48          * If record not found in table, return null.
49          *  
50          */
51         public Date getGuestLastLogin(String attuid) {
52                 Map<String, String> params = new HashMap<>();
53                 params.put("attuid", attuid);
54                 List<Date> list = getDataAccessService().executeNamedQuery("getGuestLastLogin", params, null);  
55                 Date date=null;
56                 if(list!=null){
57                         if(list.size()==1) /* if list only contains one item, meaning this is the first time user logs in or record not found in db*/
58                                 date = list.get(0); /*the guest's current log in time*/
59                         else if(list.size()==2)
60                                 date = list.get(1); /*most recent login date from db*/
61                 }
62                 return date;    
63         }
64
65         public DataAccessService getDataAccessService() {
66                 return dataAccessService;
67         }
68
69         public void setDataAccessService(DataAccessService dataAccessService) {
70                 this.dataAccessService = dataAccessService;
71         }
72
73
74 }